UnixOperatingSystem.st
author Claus Gittinger <cg@exept.de>
Sun, 03 Mar 2019 11:22:23 +0100
changeset 23816 1656c246ca09
parent 23781 8f474ae2c19b
child 23817 c713774adb32
permissions -rw-r--r--
#TUNING by cg class: UnixOperatingSystem::SocketHandle class changed: #getAddressInfo:serviceName:domain:type:protocol:flags:
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
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
     3
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    12
"{ Package: 'stx:libbasic' }"
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    13
17281
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
    14
"{ NameSpace: Smalltalk }"
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
    15
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
AbstractOperatingSystem subclass:#UnixOperatingSystem
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    17
	instanceVariableNames:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    18
	classVariableNames:'CacheMountPointsTimeStamp CachedMountPoints Codeset
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    19
		CodesetEncoder CurrentDirectory DomainName ForkFailed HostName
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    20
		Initialized LastTimeInfo LastTimeInfoIsLocal
22976
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
    21
		LastTimeInfoMilliseconds LastTimeInfoSeconds SlowFork
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
    22
		DefaultShell'
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    23
	poolDictionaries:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    24
	category:'OS-Unix'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    25
!
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    26
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    27
SharedPool subclass:#ELFConstants
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    28
	instanceVariableNames:''
22815
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    29
	classVariableNames:'EI_ABIVERSION EI_CLASS EI_DATA EI_MAG0 EI_MAG1 EI_MAG2 EI_MAG3
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    30
		EI_OSABI EI_PAD EI_VERSION ELFCLASS32 ELFCLASS64 ELFCLASSNONE
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    31
		ELFCLASSNUM ELFDATA2LSB ELFDATA2MSB ELFDATANONE ELFDATANUM
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    32
		ELFMAG0 ELFMAG1 ELFMAG2 ELFMAG3 ELFOSABI_AIX ELFOSABI_ARM
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    33
		ELFOSABI_ARM_AEABI ELFOSABI_FREEBSD ELFOSABI_GNU ELFOSABI_HPUX
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    34
		ELFOSABI_IRIX ELFOSABI_LINUX ELFOSABI_MODESTO ELFOSABI_NETBSD
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    35
		ELFOSABI_NONE ELFOSABI_OPENBSD ELFOSABI_SOLARIS
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    36
		ELFOSABI_STANDALONE ELFOSABI_SYSV ELFOSABI_TRU64 EM_386 EM_68HC05
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    37
		EM_68HC08 EM_68HC11 EM_68HC12 EM_68HC16 EM_68K EM_860 EM_88K
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    38
		EM_960 EM_AARCH64 EM_ALPHA EM_ARC EM_ARC_A5 EM_ARM EM_AVR
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    39
		EM_COLDFIRE EM_CRIS EM_D10V EM_D30V EM_FAKE_ALPHA EM_FIREPATH
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    40
		EM_FR20 EM_FR30 EM_FX66 EM_H8S EM_H8_300 EM_H8_300H EM_H8_500
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    41
		EM_HUANY EM_IA_64 EM_JAVELIN EM_M32 EM_M32R EM_ME16 EM_MICROBLAZE
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    42
		EM_MIPS EM_MIPS_RS3_LE EM_MIPS_X EM_MMA EM_MMIX EM_MN10200
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    43
		EM_MN10300 EM_NCPU EM_NDR1 EM_NONE EM_OPENRISC EM_PARISC EM_PCP
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    44
		EM_PDSP EM_PJ EM_PPC EM_PPC64 EM_PRISM EM_RCE EM_RH32 EM_S370
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    45
		EM_S390 EM_SH EM_SPARC EM_SPARC32PLUS EM_SPARCV9 EM_ST100 EM_ST19
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    46
		EM_ST7 EM_ST9PLUS EM_STARCORE EM_SVX EM_TILEGX EM_TILEPRO
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    47
		EM_TINYJ EM_TRICORE EM_V800 EM_V850 EM_VAX EM_VPP500 EM_X86_64
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    48
		EM_XTENSA EM_ZSP ET_CORE ET_DYN ET_EXEC ET_HIOS ET_HIPROC ET_LOOS
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    49
		ET_LOPROC ET_NONE ET_REL EV_CURRENT EV_NONE'
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    50
	poolDictionaries:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    51
	privateIn:UnixOperatingSystem
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    52
!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    53
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    54
Object subclass:#ELFFileHeader
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    55
	instanceVariableNames:'file data msb'
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    56
	classVariableNames:''
22815
e5aaabfb9a75 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22720
diff changeset
    57
	poolDictionaries:'ELFConstants'
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    58
	privateIn:UnixOperatingSystem
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    59
!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    60
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    61
Object subclass:#FileDescriptorHandle
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    62
	instanceVariableNames:'fd'
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    63
	classVariableNames:'OpenFiles'
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    64
	poolDictionaries:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    65
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    66
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    67
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    68
OSFileHandle subclass:#FilePointerHandle
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    69
	instanceVariableNames:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    70
	classVariableNames:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    71
	poolDictionaries:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    72
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    73
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    74
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    75
Object subclass:#FileStatusInfo
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    76
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    77
		sourcePath targetPath numLinks'
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    78
	classVariableNames:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    79
	poolDictionaries:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    80
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    83
Object subclass:#MountInfo
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    84
	instanceVariableNames:'mountPointPath deviceOrRemotePath fsType attributeString'
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    85
	classVariableNames:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    86
	poolDictionaries:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    87
	privateIn:UnixOperatingSystem
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    88
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    89
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    90
Object subclass:#OSProcessStatus
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    91
	instanceVariableNames:'pid status code core'
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    92
	classVariableNames:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    93
	poolDictionaries:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    94
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
16390
fb3ad2464cac class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16388
diff changeset
    97
UnixOperatingSystem::FilePointerHandle subclass:#SocketHandle
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    98
	instanceVariableNames:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
    99
	classVariableNames:'ProtocolCache'
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
   100
	poolDictionaries:''
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
   101
	privateIn:UnixOperatingSystem
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   102
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   103
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
!UnixOperatingSystem primitiveDefinitions!
22617
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   105
%{
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   106
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   107
#include "stxOSDefs.h"
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   108
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   109
#if defined(_AIX)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   110
# ifndef WANT_REALPATH
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   111
#  define WANT_REALPATH
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   112
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   113
# ifndef WANT_SYSTEM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   114
#  define WANT_SYSTEM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   115
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   116
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   117
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   118
#ifdef LINUX
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   119
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   120
# define __xxUSE_GNU      /* new */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   121
# undef HAS_UTS_DOMAINNAME
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   122
# define NET_IF_SUPPORT
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   123
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   124
# ifndef _STDIO_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   125
#  include <stdio.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   126
#  define _STDIO_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   127
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   128
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   129
# ifndef _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   130
#  include <sys/types.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   131
#  define _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   132
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   133
  /* use inline string macros */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   134
# define __STRINGDEFS__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   135
# include "linuxIntern.h"
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   136
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   137
# ifndef WANT_SYSTEM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   138
#  define WANT_SYSTEM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   139
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   140
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   141
# define WANT_SHM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   142
# define HAS_SETENV
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   143
# define HAS_UNSETENV
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   144
# include <time.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   145
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   146
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   147
#if defined(IRIX5) || defined(ultrix) || defined(hpux) || defined(solaris)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   148
# define WANT_SYSTEM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   149
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   150
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   151
#if defined(SYSV4) && defined(__i386__) /* e.g. unixware */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   152
# define WANT_SYSTEM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   153
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   154
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   155
#if defined (__osx__)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   156
# define NET_IF_SUPPORT
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   157
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   158
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   159
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   160
 * notice: although many systems' include files
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   161
 * already block against multiple inclusion, some
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   162
 * do not. Therefore, this is done here again.
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   163
 * (it does not hurt)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   164
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   165
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   166
#ifdef WANT_REALPATH
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   167
# ifndef NO_SYS_PARAM_H
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   168
#  include <sys/param.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   169
#  define _SYS_PARAM_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   170
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   171
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   172
# include <errno.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   173
# define _ERRNO_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   174
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   175
# include <sys/stat.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   176
# define _SYS_STAT_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   177
#endif /* WANT_REALPATH */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   178
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   179
# ifdef HAS_OPENDIR
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   180
#  include <sys/types.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   181
#  ifdef __NEXT__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   182
#   include <sys/dir.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   183
#   define DIRENT_STRUCT        struct direct
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   184
#  else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   185
#   include <dirent.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   186
#   define DIRENT_STRUCT        struct dirent
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   187
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   188
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   189
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   190
#ifdef WANT_SHM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   191
# ifndef _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   192
#  include <sys/types.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   193
#  define _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   194
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   195
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   196
# include <sys/ipc.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   197
# define _SYS_IPC_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   198
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   199
# include <sys/shm.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   200
# define _SYS_SHM_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   201
#endif /* WANT_SHM */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   202
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   203
#ifdef IRIX5
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   204
# include <sys/syssgi.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   205
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   206
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   207
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   208
#ifdef transputer
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   209
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   210
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   211
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   212
#else /* not transputer */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   213
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   214
# ifdef __arm__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   215
#  ifndef _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   216
#   include <sys/types.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   217
#   define _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   218
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   219
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   220
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   221
# ifndef _SIGNAL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   222
#  include <signal.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   223
#  define _SIGNAL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   224
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   225
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   226
# ifdef SYSV
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   227
#  ifndef _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   228
#   include <sys/types.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   229
#   define _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   230
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   231
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   232
#  ifndef _SYS_PARAM_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   233
#   ifndef NO_SYS_PARAM_H
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   234
#    include <sys/param.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   235
#    define _SYS_PARAM_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   236
#   endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   237
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   238
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   239
#  ifndef _SYS_TIMES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   240
#   include <sys/times.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   241
#   define _SYS_TIMES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   242
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   243
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   244
#  ifndef _SYS_FILE_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   245
#   include <sys/file.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   246
#   define _SYS_FILE_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   247
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   248
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   249
#  ifndef _UNISTD_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   250
#   include <unistd.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   251
#   define _UNISTD_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   252
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   253
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   254
#  ifndef _TIME_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   255
#   include <time.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   256
#   define _TIME_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   257
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   258
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   259
# else /* not SYSV */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   260
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   261
#  ifndef _SYS_TIME_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   262
#   include <sys/time.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   263
#   define _SYS_TIME_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   264
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   265
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   266
#  ifndef _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   267
#   include <sys/types.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   268
#   define _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   269
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   270
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   271
# endif /* not SYSV */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   272
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   273
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   274
# ifdef aix
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   275
#  ifndef _TIME_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   276
#   include <time.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   277
#   define _TIME_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   278
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   279
#  ifndef _SYS_SELECT_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   280
#   include <sys/select.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   281
#   define _SYS_SELECT_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   282
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   283
# endif /* aix */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   284
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   285
# ifdef __osx__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   286
#  ifndef _STRING_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   287
#   include <string.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   288
#   define _STRING_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   289
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   290
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   291
#  ifndef _STDLIB_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   292
#   include <stdlib.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   293
#   define _STDLIB_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   294
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   295
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   296
#  include <time.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   297
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   298
#  ifndef _TIME_H_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   299
   /* hack if __osx__ has been configured with case-ignoring filenames,
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   300
    * my own time.h was included above
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   301
    */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   302
#   include "/usr/include/time.h"
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   303
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   304
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   305
#  include <sys/time.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   306
#  define HAS_TIMEGM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   307
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   308
#  ifdef NO_LONGER_NEEDED
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   309
#   ifndef _TIME_H_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   310
// old hack
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   311
struct tm {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   312
	int     tm_sec;         /* seconds after the minute [0-60] */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   313
	int     tm_min;         /* minutes after the hour [0-59] */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   314
	int     tm_hour;        /* hours since midnight [0-23] */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   315
	int     tm_mday;        /* day of the month [1-31] */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   316
	int     tm_mon;         /* months since January [0-11] */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   317
	int     tm_year;        /* years since 1900 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   318
	int     tm_wday;        /* days since Sunday [0-6] */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   319
	int     tm_yday;        /* days since January 1 [0-365] */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   320
	int     tm_isdst;       /* Daylight Savings Time flag */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   321
	long    tm_gmtoff;      /* offset from CUT in seconds */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   322
	char    *tm_zone;       /* timezone abbreviation */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   323
};
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   324
#   endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   325
#  endif /* NO_LONGER */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   326
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   327
#  include <crt_externs.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   328
#  include <net/if_dl.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   329
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   330
# endif /* __osx__ */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   331
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   332
# ifndef _STDIO_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   333
#  include <stdio.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   334
#  define _STDIO_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   335
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   336
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   337
# ifndef _PWD_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   338
#  include <pwd.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   339
#  define _PWD_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   340
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   341
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   342
# ifndef NO_GRP_H
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   343
#  ifndef _GRP_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   344
#   include <grp.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   345
#   define _GRP_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   346
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   347
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   348
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   349
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   350
# ifndef _SYS_STAT_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   351
#  include <sys/stat.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   352
#  define _SYS_STAT_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   353
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   354
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   355
# ifndef _SYS_FILE_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   356
#  include <sys/file.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   357
#  define _SYS_FILE_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   358
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   359
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   360
# ifndef _ERRNO_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   361
#  include <errno.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   362
#  define _ERRNO_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   363
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   364
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   365
# ifndef _FCNTL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   366
#  include <fcntl.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   367
#  define _FCNTL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   368
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   369
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   370
# ifndef _SYS_IOCTL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   371
#  include <sys/ioctl.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   372
#  define _SYS_IOCTL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   373
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   374
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   375
# if defined(LINUX)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   376
#  define HAS_LOCALECONV
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   377
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   378
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   379
# if defined (HAS_LOCALECONV)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   380
#  ifndef _LOCALE_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   381
#   include <locale.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   382
#   define _LOCALE_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   383
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   384
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   385
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   386
# if defined (HAS_FTIME)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   387
#  include <sys/timeb.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   388
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   389
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   390
// #include <signal.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   391
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   392
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   393
 * posix systems should define these ...
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   394
 * but on some (older) systems, they are not.
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   395
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   396
# ifndef S_IXUSR
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   397
#  ifdef S_IEXEC
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   398
#   define S_IXUSR S_IEXEC
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   399
#   define S_IXGRP (S_IEXEC>>3)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   400
#   define S_IXOTH (S_IEXEC>>6)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   401
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   402
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   403
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   404
# ifndef S_IXUSR
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   405
#  define S_IXUSR 0100
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   406
#  define S_IXGRP 0010
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   407
#  define S_IXOTH 0001
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   408
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   409
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   410
# ifndef S_IRUSR
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   411
#  define S_IRUSR 0400
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   412
#  define S_IRGRP 0040
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   413
#  define S_IROTH 0004
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   414
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   415
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   416
# ifndef S_IWUSR
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   417
#  define S_IWUSR 0200
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   418
#  define S_IWGRP 0020
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   419
#  define S_IWOTH 0002
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   420
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   421
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   422
# ifndef MAXPATHLEN
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   423
#  ifndef NO_SYS_PARAM_H
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   424
#   include <sys/param.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   425
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   426
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   427
#  ifndef MAXPATHLEN
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   428
#   ifdef PATH_MAX
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   429
#    define MAXPATHLEN PATH_MAX
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   430
#   else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   431
#    define MAXPATHLEN 1024
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   432
#   endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   433
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   434
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   435
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   436
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   437
# if defined(HAS_UNAME)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   438
#  include <sys/utsname.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   439
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   440
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   441
# if defined(SYSV4)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   442
#  include <stropts.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   443
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   444
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   445
# ifndef aix
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   446
#  include <sys/termios.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   447
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   448
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   449
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   450
 * NeXT has no pid_t
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   451
 * and no sigemptyset
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   452
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   453
# ifdef __NEXT__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   454
#  define NO_WAITPID
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   455
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   456
# ifdef __NEXT3__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   457
   typedef int pid_t;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   458
#  define sigemptyset(set)      ((*(set) = 0L), 0)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   459
#  define HAS_GETDOMAINNAME
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   460
#  define NO_WAITPID
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   461
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   462
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   463
# ifdef sunos
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   464
#  undef NO_WAITPID
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   465
#  undef HAS_WAITPID
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   466
#  define HAS_WAIT3
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   467
#  define HAS_SIGACTION
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   468
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   469
//# ifdef sunos
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   470
//#  define NO_WAITPID
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   471
//# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   472
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   473
# ifdef __osx__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   474
#  undef NO_WAITPID
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   475
#  undef xxHAS_WAITPID
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   476
#  define HAS_WAITPID
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   477
#  define HAS_WAIT3
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   478
#  define HAS_SIGACTION
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   479
#  include <unistd.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   480
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   481
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   482
# ifdef HAS_WAIT3
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   483
#  ifdef __osx__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   484
#   define WAIT_STATUS int
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   485
#  else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   486
#   define WAIT_STATUS union wait
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   487
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   488
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   489
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   490
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   491
 * some (BSD ?) have no timezone global,
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   492
 * but provide the info in struct timezone.
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   493
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   494
# if defined(ultrix) || defined(sunos) || defined(__NEXT__)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   495
#  define HAS_NO_TIMEZONE
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   496
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   497
# if defined(__osx__)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   498
#  define HAS_NO_TIMEZONE
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   499
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   500
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   501
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   502
 * sigaction dummies (you won't believe these call themself ``POSIX'' systems ...)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   503
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   504
# ifndef SA_RESTART
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   505
#  define SA_RESTART    0
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   506
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   507
# ifndef SA_SIGINFO
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   508
#  define SA_SIGINFO    0
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   509
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   510
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   511
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   512
#  include <sys/wait.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   513
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   514
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   515
# if defined(HAS_SYSINFO)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   516
#  include <sys/sysinfo.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   517
#  include <sys/systeminfo.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   518
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   519
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   520
# ifdef LINUX
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   521
#  include <linux/kernel.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   522
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   523
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   524
# if defined(HAS_GETSYSINFO)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   525
#  include <sys/sysinfo.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   526
#  include <machine/hal_sysinfo.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   527
#  include <machine/hal/cpuconf.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   528
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   529
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   530
# if defined(HAS_SYSCONF)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   531
#  ifndef _UNISTD_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   532
#   include <unistd.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   533
#   define _UNISTD_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   534
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   535
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   536
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   537
# if defined(HAS_SYSCTL)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   538
#  include <sys/types.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   539
#  include <sys/sysctl.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   540
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   541
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   542
#endif /* not transputer */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   543
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   544
#ifndef NO_SOCKET
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   545
# define __USE_GNU      // For AI_IDN in netdb.h
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   546
# include <netdb.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   547
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   548
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   549
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   550
 * on some systems errno is a macro ... check for it here
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   551
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   552
#ifndef errno
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   553
 extern int errno;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   554
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   555
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   556
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   557
 * some (old ?) systems do not define this ...
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   558
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   559
#if !defined(R_OK) && !defined(_AIX)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   560
# define R_OK    4       /* Test for Read permission */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   561
# define W_OK    2       /* Test for Write permission */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   562
# define X_OK    1       /* Test for eXecute permission */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   563
# define F_OK    0       /* Test for existence of File */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   564
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   565
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   566
#define SIGHANDLER_ARG
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   567
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   568
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   569
 * where is the timezone info ?
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   570
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   571
#ifdef HAS_TM_GMTOFF
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   572
# define TIMEZONE(tmPtr)       (-((tmPtr)->tm_gmtoff))
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   573
#else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   574
# if defined(HAS_NO_TIMEZONE)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   575
#  if defined(HAS_NO_TM_GMTOFF)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   576
#   define TIMEZONE(tmPtr)       0
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   577
#  else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   578
#   define TIMEZONE(tmPtr)       (-((tmPtr)->tm_gmtoff))
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   579
#  endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   580
# else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   581
#  if defined(HAS_ALTZONE)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   582
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : altzone)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   583
#  else  /*!HAS_ALTZONE*/
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   584
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : timezone-3600)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   585
#  endif /*!HAS_ALTZONE*/
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   586
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   587
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   588
#ifndef CONST
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   589
# ifdef __GNUC__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   590
#  define CONST const
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   591
# else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   592
#  define CONST /* nothing */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   593
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   594
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   595
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   596
#ifndef        FORK
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   597
# if defined(HAS_VFORK)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   598
#  define     FORK            vfork
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   599
# else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   600
#  define     FORK            fork
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   601
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   602
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   603
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   604
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   605
 * Socket defines
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   606
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   607
#include "stxOSDefs.h"
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   608
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   609
#ifdef NET_IF_SUPPORT  /* for mac address of interfaces */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   610
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   611
# ifndef _NET_IF_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   612
#  include <net/if.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   613
#  define _NET_IF_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   614
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   615
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   616
# ifndef _SYS_IOCTL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   617
#  include <sys/ioctl.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   618
#  define _SYS_IOCTL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   619
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   620
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   621
#endif /* NET_IF_SUPPORT */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   622
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   623
#if defined(TRY_AGAIN) || defined(HOST_NOT_FOUND)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   624
# define USE_H_ERRNO
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   625
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   626
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   627
#ifdef USE_H_ERRNO
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   628
# ifndef h_errno
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   629
 extern h_errno;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   630
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   631
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   632
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   633
#if (defined(__ELD__) || defined (ELF))
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   634
# ifndef ELFMAG1
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   635
#  include <elf.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   636
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   637
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   638
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   639
%}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   640
! !
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
!UnixOperatingSystem primitiveFunctions!
22617
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   643
%{
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   644
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   645
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   646
 * some systems' system() is broken in that it does not correctly
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   647
 * handle EINTR and returns failure even though it actually succeeded.
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   648
 * (LINUX is one of them)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   649
 * Here is a fixed version. If you encounter EINTR returns from
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   650
 * UnixOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   651
 * in the xxxIntern.h file to get this fixed version.
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   652
 *
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   653
 * As an added BONUS, this system() enables interrupts while waiting
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   654
 * for the child which enables other threads to continue.
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   655
 * (i.e. it is RT safe)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   656
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   657
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   658
#if defined(WANT_SYSTEM)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   659
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   660
/* # define DPRINTF(x)     printf x */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   661
# define DPRINTF(x)     /* nothing */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   662
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   663
# ifndef _STDDEF_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   664
#  include <stddef.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   665
#  define _STDDEF_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   666
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   667
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   668
# ifndef _STDLIB_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   669
#  include <stdlib.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   670
#  define _STDLIB_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   671
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   672
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   673
# ifndef _UNISTD_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   674
#  include <unistd.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   675
#  define _UNISTD_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   676
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   677
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   678
# ifndef _SYS_WAIT_H_INCLUDED
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   679
#  include <sys/wait.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   680
#  define _SYS_WAIT_H_INCLUDED
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   681
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   682
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   683
# ifndef _SIGNAL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   684
#  include <signal.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   685
#  define _SIGNAL_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   686
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   687
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   688
# ifndef _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   689
#  include <sys/types.h>
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   690
#  define _SYS_TYPES_H_INCLUDED_
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   691
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   692
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   693
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   694
#  define       __environ       environ
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   695
    extern char **environ;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   696
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   697
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   698
# if !defined (__sigemptyset)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   699
#  define      __sigemptyset   sigemptyset
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   700
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   701
# if !defined (__sigaction)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   702
#  define      __sigaction     sigaction
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   703
#  define      __sigaddset     sigaddset
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   704
#  define      __sigprocmask   sigprocmask
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   705
#  define      __execve        execve
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   706
#  define      __wait          wait
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   707
#  define      __waitpid       waitpid
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   708
# endif /* ! LINUX */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   709
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   710
# define      __sigprocmask   sigprocmask
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   711
# define      __execve        execve
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   712
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   713
# define        SHELL_PATH      "/bin/sh"       /* Path of the shell.  */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   714
# define        SHELL_NAME      "sh"            /* Name to give it.  */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   715
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   716
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   717
static int
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   718
mySystem(const char *line)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   719
{
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   720
    int status, save;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   721
    pid_t pid;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   722
    struct sigaction sa, intr, quit;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   723
    sigset_t block, omask;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   724
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   725
    if (line == NULL)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   726
	return -1;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   727
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   728
    sa.sa_handler = SIG_IGN;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   729
    sa.sa_flags = 0;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   730
    __sigemptyset (&sa.sa_mask);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   731
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   732
    if (__sigaction (SIGINT, &sa, &intr) < 0) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   733
	DPRINTF(("1: errno=%d\n", errno));
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   734
	return -1;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   735
    }
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   736
    if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   737
	save = errno;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   738
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   739
	errno = save;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   740
	DPRINTF(("2: errno=%d\n", errno));
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   741
	return -1;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   742
    }
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   743
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   744
    __sigemptyset (&block);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   745
    __sigaddset (&block, SIGCHLD);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   746
    save = errno;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   747
    if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   748
	if (errno == ENOSYS)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   749
	    errno = save;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   750
	else {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   751
	    save = errno;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   752
	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   753
	    (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   754
	    errno = save;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   755
	    DPRINTF(("3: errno=%d\n", errno));
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   756
	    return -1;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   757
	}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   758
    }
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   759
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
   760
    pid = FORK();
22617
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   761
    if (pid == (pid_t) 0) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   762
	/* Child side.  */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   763
	CONST char *new_argv[4];
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   764
	new_argv[0] = SHELL_NAME;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   765
	new_argv[1] = "-c";
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   766
	new_argv[2] = line;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   767
	new_argv[3] = NULL;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   768
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   769
	/* Restore the signals.  */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   770
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   771
	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   772
	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   773
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   774
	/* Exec the shell.  */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   775
	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   776
	_exit (127);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   777
    } else {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   778
	if (pid < (pid_t) 0) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   779
	    /* The fork failed.  */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   780
	    DPRINTF(("4: errno=%d\n", errno));
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   781
	    status = -1;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   782
	} else {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   783
	    /* Parent side.  */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   784
#ifdef  NO_WAITPID
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   785
	    pid_t child;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   786
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   787
	    do {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   788
		__BEGIN_INTERRUPTABLE__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   789
		child = __wait (&status);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   790
		__END_INTERRUPTABLE__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   791
		if (child < 0 && errno != EINTR) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   792
		    DPRINTF(("5: errno=%d\n", errno));
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   793
		    status = -1;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   794
		    break;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   795
		}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   796
	    } while (child != pid);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   797
#else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   798
	    pid_t child;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   799
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   800
	    /* claus: the original did not care for EINTR here ... */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   801
	    do {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   802
		__BEGIN_INTERRUPTABLE__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   803
		child = __waitpid (pid, &status, 0);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   804
		__END_INTERRUPTABLE__
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   805
	    } while ((child != pid) && (errno == EINTR));
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   806
	    if (child != pid) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   807
		DPRINTF(("6: errno=%d\n", errno));
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   808
		status = -1;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   809
	    }
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   810
#endif /* NO_WAITPID */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   811
	}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   812
    }
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   813
    save = errno;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   814
    if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   815
     | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   816
     | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   817
	if (errno == ENOSYS) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   818
	    errno = save;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   819
	} else {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   820
	    status = -1;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   821
	    DPRINTF(("7: errno=%d\n", errno));
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   822
	}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   823
    }
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   824
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   825
    return status;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   826
}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   827
#else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   828
# define __wait wait
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   829
#endif /* WANT_SYSTEM */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   830
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   831
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   832
/*
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   833
 * some systems do not have realpath();
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   834
 * the alternative of reading from a 'pwd'-pipe
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   835
 * is way too slow. Here is a realpath for the rest of us.
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   836
 * define WANT_REALPATH in the xxxIntern-file to get it.
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   837
 */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   838
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   839
#if defined(HAS_REALPATH)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   840
# undef WANT_REALPATH
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   841
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   842
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   843
# undef WANT_REALPATH
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   844
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   845
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   846
#if defined(WANT_REALPATH)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   847
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   848
# ifndef NULL
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   849
#  define NULL (char *)0
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   850
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   851
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   852
# define MAX_READLINKS 32
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   853
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   854
# ifndef MAXPATHLEN
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   855
#  define MAXPATHLEN     1024
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   856
# endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   857
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   858
static char *
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   859
realpath(const char *path, char *resolved_path)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   860
{
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   861
	char copy_path[MAXPATHLEN];
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   862
	char link_path[MAXPATHLEN];
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   863
	char *new_path, *max_path, *mallocedPath;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   864
	int readlinks = 0;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   865
	int n;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   866
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   867
	if (resolved_path == NULL) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   868
	    mallocedPath = resolved_path = malloc(MAXPATHLEN+1);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   869
	}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   870
	new_path = resolved_path;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   871
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   872
	/* Make a copy of the source path since we may need to modify it. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   873
	strcpy(copy_path, path);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   874
	path = copy_path;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   875
	max_path = copy_path + MAXPATHLEN - 2;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   876
	/* If it's a relative pathname use getwd for starters. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   877
	if (*path != '/') {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   878
#ifdef HAS_GETCWD
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   879
		new_path = getcwd(new_path, MAXPATHLEN - 1);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   880
#else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   881
		new_path = getwd(new_path);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   882
#endif
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   883
		if (new_path == NULL) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   884
		    if (mallocedPath) free(mallocedPath);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   885
		    return(NULL);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   886
		}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   887
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   888
		new_path += strlen(new_path);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   889
		if (new_path[-1] != '/')
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   890
			*new_path++ = '/';
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   891
	}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   892
	else {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   893
		*new_path++ = '/';
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   894
		path++;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   895
	}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   896
	/* Expand each slash-separated pathname component. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   897
	while (*path != '\0') {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   898
		/* Ignore stray "/". */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   899
		if (*path == '/') {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   900
			path++;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   901
			continue;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   902
		}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   903
		if (*path == '.') {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   904
			/* Ignore ".". */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   905
			if (path[1] == '\0' || path[1] == '/') {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   906
				path++;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   907
				continue;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   908
			}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   909
			if (path[1] == '.') {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   910
				if (path[2] == '\0' || path[2] == '/') {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   911
					path += 2;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   912
					/* Ignore ".." at root. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   913
					if (new_path == resolved_path + 1)
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   914
						continue;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   915
					/* Handle ".." by backing up. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   916
					while ((--new_path)[-1] != '/')
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   917
						;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   918
					continue;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   919
				}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   920
			}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   921
		}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   922
		/* Safely copy the next pathname component. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   923
		while (*path != '\0' && *path != '/') {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   924
			if (path > max_path) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   925
			    if (mallocedPath) free(mallocedPath);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   926
			    errno = ENAMETOOLONG;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   927
			    return NULL;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   928
			}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   929
			*new_path++ = *path++;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   930
		}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   931
#ifdef S_IFLNK
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   932
		/* Protect against infinite loops. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   933
		if (readlinks++ > MAX_READLINKS) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   934
		    if (mallocedPath) free(mallocedPath);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   935
		    errno = ELOOP;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   936
		    return NULL;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   937
		}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   938
		/* See if latest pathname component is a symlink. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   939
		*new_path = '\0';
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   940
		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   941
		if (n < 0) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   942
			/* EINVAL means the file exists but isn't a symlink. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   943
			if (errno != EINVAL) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   944
			    if (mallocedPath) free(mallocedPath);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   945
			    return NULL;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   946
			}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   947
		}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   948
		else {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   949
			/* Note: readlink doesn't add the null byte. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   950
			link_path[n] = '\0';
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   951
			if (*link_path == '/')
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   952
				/* Start over for an absolute symlink. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   953
				new_path = resolved_path;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   954
			else
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   955
				/* Otherwise back up over this component. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   956
				while (*(--new_path) != '/')
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   957
					;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   958
			/* Safe sex check. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   959
			if (strlen(path) + n >= MAXPATHLEN) {
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   960
			    if (mallocedPath) free(mallocedPath);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   961
			    errno = ENAMETOOLONG;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   962
			    return NULL;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   963
			}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   964
			/* Insert symlink contents into path. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   965
			strcat(link_path, path);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   966
			strcpy(copy_path, link_path);
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   967
			path = copy_path;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   968
		}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   969
#endif /* S_IFLNK */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   970
		*new_path++ = '/';
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   971
	}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   972
	/* Delete trailing slash but don't whomp a lone slash. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   973
	if (new_path != resolved_path + 1 && new_path[-1] == '/')
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   974
		new_path--;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   975
	/* Make sure it's null terminated. */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   976
	*new_path = '\0';
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   977
	return resolved_path;
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   978
}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   979
# define HAS_REALPATH
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   980
#endif /* WANT_REALPATH && not HAS_REALPATH */
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   981
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   982
%}
Claus Gittinger <cg@exept.de>
parents: 22616
diff changeset
   983
! !
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
copyright
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
 COPYRIGHT (c) 1988 by Claus Gittinger
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   990
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
 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
   993
 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
   994
 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
   995
 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
   996
 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
   997
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
"
20707
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1003
    This class realizes access to most (all?) required operating system services.
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1004
    At startup, the global 'OperatingSystem' will be bound to either me, or one of
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1005
    my sibling classes, Win32OperatingSystem, VMSOperatinSystem or OSXOperatingSystem.
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1006
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1007
    Never access UnixOperatingSystem directly. Always only refer to OperatingSystem,
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1008
    if at all. Most functionality is actually used indirectly, via the Filename, PipeStream
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1009
    or Socket classes.
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  1010
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  1011
    Some of the functions are specific for unix, some may not be found in other OS's
20707
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1012
    or behave slightly different, returning different data.
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  1013
20707
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1014
    For portable programs, only rely on protocol which is found in my abstract
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1015
    superclass, and will therefore also be found in my correspnding sibling os-classes
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1016
    (i.e. Win32OperatingSystem).
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1017
    If you need os-specific functionality, surround it by a condition, such as
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1018
    OperatingSystem isUNIXlike or OperatingSystem isMSWINDOWSlike.
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  1019
20707
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1020
    On the other hand: I do not want to hide all features
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1021
    from you - in some situations it MAY be interesting to be
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1022
    able to get down to a select or fork system call easily (at least on Unix systems).
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1023
    You decide - portability vs. functionality.
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1024
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1025
    Notice, that on Unix systems, the Win32OperatingSystem class is not even loaded,
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1026
    and vice versa. So you may have to open a changes browser on the other class, to check
10b8fe574ce8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20665
diff changeset
  1027
    how the corresponding function operates in the other os.
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  1028
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
    [Class variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1031
	HostName        <String>        remembered hostname
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1032
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1033
	DomainName      <String>        remembered domainname
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1034
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1035
	SlowFork        <Boolean>       if set, fork and popen are avoided;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1036
					(more or less obsolete now)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1037
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1038
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1039
	CurrentDirectory <String>       remembered currentDirectories path
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
    [author:]
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1042
	Claus Gittinger
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
    [see also:]
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1045
	OSProcessStatus
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1046
	Filename Date Time
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1047
	ExternalStream FileStream PipeStream Socket
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
examples
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
  various queries
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1054
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1055
    Transcript
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1056
	showCR:'hello ' , (OperatingSystem getLoginName)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1057
								[exEnd]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1058
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1059
								[exBegin]
3793
aff27e755ffd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  1060
    OperatingSystem isUNIXlike ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1061
	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
  1062
    ] ifFalse:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1063
	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
  1064
    ]
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1065
								[exEnd]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1066
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1067
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1068
    Transcript
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1069
	showCR:'this machine is called ' , OperatingSystem getHostName
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1070
								[exEnd]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1071
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1072
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1073
    Transcript
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1074
	showCR:('this machine is in the '
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1075
	       , OperatingSystem getDomainName
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1076
	       , ' domain')
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1077
								[exEnd]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1078
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1079
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1080
    Transcript
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1081
	showCR:('this machine''s CPU is a '
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1082
	       , OperatingSystem getCPUType
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1083
	       )
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1084
								[exEnd]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1085
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1086
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
    Transcript showCR:'executing ls command ...'.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  1088
    OperatingSystem executeCommand:'ls'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
    Transcript showCR:'... done.'.
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1090
								[exEnd]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1092
  locking a file
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
  (should be executed on two running smalltalks - not in two threads):
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1094
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
    |f|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
    f := 'testFile' asFilename readWriteStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
    10 timesRepeat:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1100
	'about to lock ...' printCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1101
	[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1102
	  OperatingSystem
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1103
	    lockFD:(f fileDescriptor)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1104
	    shared:false
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1105
	    blocking:false
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1106
	] whileFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1107
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1108
	    Delay waitForSeconds:1
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1109
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1110
	'LOCKED ...' printCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1111
	Delay waitForSeconds:10.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1112
	'unlock ...' printCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1113
	(OperatingSystem
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1114
	    unlockFD:(f fileDescriptor)) printCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1115
	Delay waitForSeconds:3.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
    ]
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1117
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
!UnixOperatingSystem class methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
initialize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
    "initialize the class"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
17530
267a6722ddfb class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17519
diff changeset
  1126
    "/ protect against double initialization
267a6722ddfb class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17519
diff changeset
  1127
    Initialized isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1128
	ObjectMemory addDependent:self.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1129
	self initializeCachedData.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1130
	Initialized := true.
17530
267a6722ddfb class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17519
diff changeset
  1131
    ].
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1132
!
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1133
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1134
initializeCachedData
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    HostName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
    DomainName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
    LastErrorNumber := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
    PipeFailed := false.
4395
53122eb3ce70 clear ForkFailed flag; made it a classVar
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1139
    ForkFailed := false.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
    SlowFork := false.
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1141
    CurrentDirectory := nil.
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  1142
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1143
    self initializeCodeset.
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  1144
    CharacterEncoder initialize.
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  1145
    CodesetEncoder := CharacterEncoder encoderFor:Codeset.
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  1146
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  1147
    "Modified: / 27-02-2017 / 15:41:37 / stefan"
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1148
!
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1149
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1150
initializeCodeset
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1151
    "initialize the codeset, we are running under.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1152
     The codeset is determined from the environment.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1153
     The LC_CTYPE locale is set from the environment as a side effect."
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  1154
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1155
    |codeset|
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  1156
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1157
%{
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1158
#include <langinfo.h>
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1159
    char *__codeset;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1160
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1161
    setlocale(LC_CTYPE, "");
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1162
    __codeset = nl_langinfo(CODESET);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1163
    if (strlen(__codeset) > 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1164
	codeset = __MKSTRING(__codeset);
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1165
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1166
%}.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1167
    codeset notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1168
	codeset := codeset asLowercase.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1169
	codeset = 'utf-8' ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1170
	    codeset := #utf8.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1171
	] ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1172
	    codeset := codeset asSymbol.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1173
	].
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1174
    ].
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1175
    Codeset := codeset.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1176
    ^ codeset.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1177
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1178
    "
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1179
     OperatingSystem initializeCodeset
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1180
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
update:something with:aParameter from:changedObject
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1184
    "catch image restart and flush some cached data"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
    something == #earlyRestart ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1187
	self initializeCachedData
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
    ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1190
    "Created: / 15.6.1996 / 15:22:37 / cg"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1191
    "Modified: / 7.1.1997 / 19:36:11 / stefan"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1192
    "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
  1193
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
!UnixOperatingSystem class methodsFor:'OS signal constants'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
sigABRT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
    "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
  1199
     (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
  1200
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1201
    ^ self signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1202
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1203
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1204
     OperatingSystem sigABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1205
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1208
sigALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
    "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
  1210
     (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
  1211
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1212
    ^ self signalNamed:#SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1213
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1214
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1215
     OperatingSystem sigALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1216
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
sigBREAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1220
    "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
  1221
     This is an MSDOS specific signal"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1223
    ^ self signalNamed:#SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1224
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1225
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1226
     OperatingSystem sigBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1227
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1229
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1230
sigBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1231
    "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
  1232
     (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
  1233
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1234
    ^ self signalNamed:#SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1235
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1236
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1237
     OperatingSystem sigBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1238
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
!
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
sigCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
    "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
  1243
     (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
  1244
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1245
    ^ self signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1246
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1247
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1248
     OperatingSystem sigCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1249
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
!
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
sigCONT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1253
    "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
  1254
     (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
  1255
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1256
    ^ self signalNamed:#SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1257
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1258
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1259
     OperatingSystem sigCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1260
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
sigDANGER
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
    "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
  1265
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1266
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1267
    ^ self signalNamed:#SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1268
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1269
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1270
     OperatingSystem sigDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1271
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
!
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
sigEMT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1275
    "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
  1276
     (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
  1277
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1278
    ^ self signalNamed:#SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1279
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1280
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1281
     OperatingSystem sigEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1282
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
sigFP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1286
    "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
  1287
     (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
  1288
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1289
    ^ self signalNamed:#SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1290
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1291
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1292
     OperatingSystem sigFP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1293
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1294
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1296
sigGRANT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1297
    "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
  1298
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1299
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1300
    ^ self signalNamed:#SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1301
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1302
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1303
     OperatingSystem sigGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1304
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1307
sigHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1308
    "return the signal number for SIGHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1309
     (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
  1310
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1311
    ^ self signalNamed:#SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1312
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1313
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1314
     OperatingSystem sigHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1315
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1316
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1319
sigILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1320
    "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
  1321
     (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
  1322
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1323
    ^ self signalNamed:#SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1324
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1325
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1326
     OperatingSystem sigILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1327
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1328
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1330
sigINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
    "return the signal number for SIGINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1332
     (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
  1333
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1334
    ^ self signalNamed:#SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1335
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1336
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1337
     OperatingSystem sigINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1338
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
sigIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
    "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
  1343
     (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
  1344
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1345
    ^ self signalNamed:#SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1346
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1347
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1348
     OperatingSystem sigIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1349
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
sigIOT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
    "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
  1354
     (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
  1355
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1356
    ^ self signalNamed:#SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1357
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1358
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1359
     OperatingSystem sigIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1360
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1363
sigKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1364
    "return the signal number for SIGKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1365
     (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
  1366
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1367
    ^ self signalNamed:#SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1368
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1369
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1370
     OperatingSystem sigKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1371
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
sigLOST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1375
    "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
  1376
     (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
  1377
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1378
    ^ self signalNamed:#SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1379
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1380
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1381
     OperatingSystem sigLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1382
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
sigMIGRATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
    "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
  1387
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1389
    ^ self signalNamed:#SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1390
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1391
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1392
     OperatingSystem sigMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1393
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
sigMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1397
    "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
  1398
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1400
    ^ self signalNamed:#SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1401
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1402
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1403
     OperatingSystem sigMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1404
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1405
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
sigPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1408
    "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
  1409
     (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
  1410
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1411
    ^ self signalNamed:#SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1412
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1413
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1414
     OperatingSystem sigPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1415
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1416
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1417
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
sigPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
    "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
  1421
     (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
  1422
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1423
    ^ self signalNamed:#SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1424
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1425
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1426
     OperatingSystem sigPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1427
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
sigPRE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1431
    "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
  1432
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1433
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1434
    ^ self signalNamed:#SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1435
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1436
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1437
     OperatingSystem sigPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1438
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
sigPROF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
    "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
  1443
     (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
  1444
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1445
    ^ self signalNamed:#SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1446
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1447
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1448
     OperatingSystem sigPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1449
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
sigPWR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
    "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
  1454
     (not available on all systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1456
    ^ self signalNamed:#SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1457
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1458
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1459
     OperatingSystem sigPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1460
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1462
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
sigQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
    "return the signal number for SIGQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
     (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
  1466
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1467
    ^ self signalNamed:#SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1468
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1469
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1470
     OperatingSystem sigQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1471
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1473
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1474
sigRETRACT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1475
    "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
  1476
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1477
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1478
    ^ self signalNamed:#SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1479
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1480
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1481
     OperatingSystem sigRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1482
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1483
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
sigSAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
    "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
  1488
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1489
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1490
    ^ self signalNamed:#SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1491
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1492
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1493
     OperatingSystem sigSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1494
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1495
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1498
sigSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
    "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
  1500
     (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
  1501
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1502
    ^ self signalNamed:#SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1503
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1504
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1505
     OperatingSystem sigSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1506
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1507
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1508
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1510
sigSOUND
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
    "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
  1512
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1513
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1514
    ^ self signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1515
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1516
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1517
     OperatingSystem sigSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1518
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1519
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1520
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
sigSTOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1523
    "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
  1524
     (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
  1525
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1526
    ^ self signalNamed:#SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1527
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1528
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1529
     OperatingSystem sigSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1530
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1531
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1532
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1533
sigSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1534
    "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
  1535
     (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
  1536
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1537
    ^ self signalNamed:#SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1538
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1539
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1540
     OperatingSystem sigSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1541
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1542
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1543
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1544
sigTERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1545
    "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
  1546
     (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
  1547
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1548
    ^ self signalNamed:#SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1549
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1550
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1551
     OperatingSystem sigTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1552
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1553
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1554
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1555
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1556
sigTRAP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
    "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
  1558
     (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
  1559
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1560
    ^ self signalNamed:#SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1561
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1562
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1563
     OperatingSystem sigTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1564
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1565
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1566
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1567
sigTSTP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1568
    "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
  1569
     (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
  1570
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1571
    ^ self signalNamed:#SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1572
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1573
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1574
     OperatingSystem sigTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1575
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1576
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1577
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1578
sigTTIN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1579
    "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
  1580
     (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
  1581
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1582
    ^ self signalNamed:#SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1583
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1584
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1585
     OperatingSystem sigTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1586
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1588
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1589
sigTTOU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1590
    "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
  1591
     (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
  1592
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1593
    ^ self signalNamed:#SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1594
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1595
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1596
     OperatingSystem sigTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1597
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
sigURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
    "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
  1602
     (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
  1603
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1604
    ^ self signalNamed:#SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1605
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1606
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1607
     OperatingSystem sigURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1608
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1611
sigUSR1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1612
    "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
  1613
     (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
  1614
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1615
    ^ self signalNamed:#SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1616
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1617
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1618
     OperatingSystem sigUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1619
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1621
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1622
sigUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1623
    "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
  1624
     (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
  1625
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1626
    ^ self signalNamed:#SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1627
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1628
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1629
     OperatingSystem sigUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1630
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1631
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1632
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1633
sigVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1634
    "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
  1635
     (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
  1636
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1637
    ^ self signalNamed:#SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1638
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1639
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1640
     OperatingSystem sigVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1641
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1642
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1643
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1644
sigWINCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1645
    "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
  1646
     (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
  1647
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1648
    ^ self signalNamed:#SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1649
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1650
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1651
     OperatingSystem sigWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1652
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1653
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1654
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1655
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1656
sigXCPU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1657
    "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
  1658
     (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
  1659
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1660
    ^ self signalNamed:#SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1661
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1662
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1663
     OperatingSystem sigXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1664
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1665
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1666
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1667
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1668
sigXFSZ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1669
    "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
  1670
     (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
  1671
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1672
    ^ self signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1673
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1674
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1675
     OperatingSystem sigXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1676
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1677
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1678
!
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1679
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1680
signalNamed:signalName
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1681
    "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
  1682
     Return 0 if that signal is not supported by the OS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1683
     (NOTICE: the numeric value is not the same across unix-systems,
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1684
      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
  1685
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1686
%{  /* NOCONTEXT */
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1687
#ifdef SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1688
    if (signalName == @symbol(SIGABRT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1689
	RETURN ( __mkSmallInteger(SIGABRT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1690
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1691
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1692
#ifdef SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1693
    if (signalName == @symbol(SIGALRM)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1694
	RETURN ( __mkSmallInteger(SIGALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1695
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1696
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1697
#ifdef SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1698
    if (signalName == @symbol(SIGBREAK)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1699
	RETURN ( __mkSmallInteger(SIGBREAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1700
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1701
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1702
#ifdef SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1703
    if (signalName == @symbol(SIGBUS)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1704
	RETURN ( __mkSmallInteger(SIGBUS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1705
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1706
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1707
#ifdef SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1708
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1709
     || (signalName == @symbol(SIGCLD)) ) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1710
	RETURN ( __mkSmallInteger(SIGCHLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1711
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1712
#else
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1713
# if defined(SIGCLD)
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1714
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1715
     || (signalName == @symbol(SIGCLD)) ) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1716
	RETURN ( __mkSmallInteger(SIGCLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1717
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1718
# endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1719
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1720
#ifdef SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1721
    if (signalName == @symbol(SIGCONT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1722
	RETURN ( __mkSmallInteger(SIGCONT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1723
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1724
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1725
#ifdef SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1726
    if (signalName == @symbol(SIGDANGER)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1727
	RETURN ( __mkSmallInteger(SIGDANGER) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1728
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1729
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1730
#ifdef SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1731
    if (signalName == @symbol(SIGEMT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1732
	RETURN ( __mkSmallInteger(SIGEMT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1733
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1734
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1735
#ifdef SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1736
    if (signalName == @symbol(SIGFPE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1737
	RETURN ( __mkSmallInteger(SIGFPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1738
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1739
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1740
#ifdef SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1741
    if (signalName == @symbol(SIGGRANT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1742
	RETURN ( __mkSmallInteger(SIGGRANT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1743
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1744
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1745
#ifdef SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1746
    if (signalName == @symbol(SIGHUP)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1747
	RETURN ( __mkSmallInteger(SIGHUP) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1750
#ifdef SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1751
    if (signalName == @symbol(SIGILL)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1752
	RETURN ( __mkSmallInteger(SIGILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1753
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1754
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1755
#ifdef SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1756
    if (signalName == @symbol(SIGINT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1757
	RETURN ( __mkSmallInteger(SIGINT) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1760
#ifdef SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1761
    if (signalName == @symbol(SIGIO)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1762
	RETURN ( __mkSmallInteger(SIGIO) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1763
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1764
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1765
#ifdef SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1766
    if (signalName == @symbol(SIGIOT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1767
	RETURN ( __mkSmallInteger(SIGIOT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1768
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1769
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1770
#ifdef SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1771
    if (signalName == @symbol(SIGKILL)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1772
	RETURN ( __mkSmallInteger(SIGKILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1773
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1774
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1775
#ifdef SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1776
    if (signalName == @symbol(SIGLOST)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1777
	RETURN ( __mkSmallInteger(SIGLOST) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1778
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1779
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1780
#ifdef SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1781
    if (signalName == @symbol(SIGMIGRATE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1782
	RETURN ( __mkSmallInteger(SIGMIGRATE) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1785
#ifdef SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1786
    if (signalName == @symbol(SIGMSG)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1787
	RETURN ( __mkSmallInteger(SIGMSG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1788
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1789
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1790
#ifdef SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1791
    if (signalName == @symbol(SIGPIPE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1792
	RETURN ( __mkSmallInteger(SIGPIPE) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1795
#ifdef SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1796
    if (signalName == @symbol(SIGPOLL)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1797
	RETURN ( __mkSmallInteger(SIGPOLL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1798
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1799
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1800
#ifdef SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1801
    if (signalName == @symbol(SIGPRE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1802
	RETURN ( __mkSmallInteger(SIGPRE) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1805
#ifdef SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1806
    if (signalName == @symbol(SIGPROF)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1807
	RETURN ( __mkSmallInteger(SIGPROF) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1808
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1809
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1810
#ifdef SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1811
    if (signalName == @symbol(SIGPWR)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1812
	RETURN ( __mkSmallInteger(SIGPWR) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1813
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1814
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1815
#ifdef SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1816
    if (signalName == @symbol(SIGQUIT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1817
	RETURN ( __mkSmallInteger(SIGQUIT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1818
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1819
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1820
#ifdef SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1821
    if (signalName == @symbol(SIGRETRACT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1822
	RETURN ( __mkSmallInteger(SIGRETRACT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1823
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1824
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1825
#ifdef SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1826
    if (signalName == @symbol(SIGSAK)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1827
	RETURN ( __mkSmallInteger(SIGSAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1828
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1829
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1830
#ifdef SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1831
    if (signalName == @symbol(SIGSEGV)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1832
	RETURN ( __mkSmallInteger(SIGSEGV) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1833
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1834
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1835
#ifdef SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1836
    if (signalName == @symbol(SIGSOUND)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1837
	RETURN ( __mkSmallInteger(SIGSOUND) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1838
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1839
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1840
#ifdef SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1841
    if (signalName == @symbol(SIGSTOP)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1842
	RETURN ( __mkSmallInteger(SIGSTOP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1843
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1844
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1845
#ifdef SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1846
    if (signalName == @symbol(SIGSYS)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1847
	RETURN ( __mkSmallInteger(SIGSYS) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1850
#ifdef SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1851
    if (signalName == @symbol(SIGTERM)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1852
	RETURN ( __mkSmallInteger(SIGTERM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1853
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1854
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1855
#ifdef SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1856
    if (signalName == @symbol(SIGTRAP)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1857
	RETURN ( __mkSmallInteger(SIGTRAP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1858
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1859
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1860
#ifdef SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1861
    if (signalName == @symbol(SIGTSTP)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1862
	RETURN ( __mkSmallInteger(SIGTSTP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1863
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1864
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1865
#ifdef SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1866
    if (signalName == @symbol(SIGTTIN)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1867
	RETURN ( __mkSmallInteger(SIGTTIN) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1868
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1869
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1870
#ifdef SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1871
    if (signalName == @symbol(SIGTTOU)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1872
	RETURN ( __mkSmallInteger(SIGTTOU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1873
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1874
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1875
#ifdef SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1876
    if (signalName == @symbol(SIGURG)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1877
	RETURN ( __mkSmallInteger(SIGURG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1878
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1879
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1880
#ifdef SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1881
    if (signalName == @symbol(SIGUSR1)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1882
	RETURN ( __mkSmallInteger(SIGUSR1) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1885
#ifdef SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1886
    if (signalName == @symbol(SIGUSR2)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1887
	RETURN ( __mkSmallInteger(SIGUSR2) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1888
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1889
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1890
#ifdef SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1891
    if (signalName == @symbol(SIGVTALRM)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1892
	RETURN ( __mkSmallInteger(SIGVTALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1893
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1894
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1895
#ifdef SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1896
    if (signalName == @symbol(SIGWINCH)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1897
	RETURN ( __mkSmallInteger(SIGWINCH) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1898
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1899
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1900
#ifdef SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1901
    if (signalName == @symbol(SIGXCPU)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1902
	RETURN ( __mkSmallInteger(SIGXCPU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1903
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1904
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1905
#ifdef SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1906
    if (signalName == @symbol(SIGXFSZ)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1907
	RETURN ( __mkSmallInteger(SIGXFSZ) );
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1908
    }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1909
#endif
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1910
#ifdef SIGINFO
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1911
    if (signalName == @symbol(SIGINFO)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1912
	RETURN ( __mkSmallInteger(SIGINFO) );
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1913
    }
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1914
#endif
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  1915
%}.
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  1916
    ^ 0
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  1917
5404
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 signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1920
     OperatingSystem signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1921
     OperatingSystem signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1922
     OperatingSystem signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1923
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1924
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1925
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1926
!UnixOperatingSystem class methodsFor:'directory access'!
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1927
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1928
closeDirectory:dirPointer
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1929
    "low level close of a directoryStream"
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1930
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1931
%{
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1932
#ifdef HAS_OPENDIR
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1933
    if (__isExternalAddressLike(dirPointer)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1934
	closedir( (DIR *)(__FILEVal(dirPointer)) );
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1935
    }
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1936
#endif
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  1937
%}.
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  1938
    self primitiveFailed
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1939
!
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1940
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1941
nextLinkInfoFrom:aDirectoryStream dirPointer:dirPointer
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1942
    "return a FileStatusInfo entry for the next entry, when reading from a directory.
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1943
     Under UNIX, the returned fileStatuInfo ONLY contains the name of the file,
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1944
     whereas under Windows, it contains the full info (incl. fileSize, access rights etc.).
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1945
     The reason is that under windows, the ReadNextEntry system call does this, whereas the
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1946
     the corresponding unix read from a readdir only returns the name."
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1947
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1948
    |entry error|
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1949
%{
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1950
#ifdef HAS_OPENDIR
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1951
    DIR *d;
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1952
    DIRENT_STRUCT *dp;
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1953
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1954
    if ((dirPointer != nil)
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1955
     && __isExternalAddressLike(dirPointer)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1956
	d = (DIR *)__FILEVal(dirPointer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1957
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1958
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1959
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1960
	    do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1961
		__threadErrno = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1962
		dp = readdir(d);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1963
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1964
		 * for compatibility with ST-80,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1965
		 * skip entries for '.' and '..'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1966
		 * If wanted, these must be added synthetically.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1967
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1968
	    } while (dp && ((strcmp(dp->d_name, ".")==0) || (strcmp(dp->d_name, "..")==0)));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1969
	} while ((dp == NULL) && (__threadErrno == EINTR));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1970
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1971
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1972
	if (dp != NULL) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1973
	    entry = __MKSTRING((char *)(dp->d_name));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1974
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1975
	    if (__threadErrno) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1976
		error = __mkSmallInteger(__threadErrno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1977
	    }
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1978
       }
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1979
    }
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1980
#endif /* HAS_OPENDIR */
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1981
%}.
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1982
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1983
	^ StreamIOError newException
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1984
	    errorCode:error;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1985
	    osErrorHolder:(OperatingSystem errorHolderForNumber:error);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1986
	    parameter:aDirectoryStream;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1987
	    raiseRequest
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1988
    ].
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1989
    entry notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  1990
	^ FileStatusInfo new sourcePath:(self decodePath:entry).
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1991
    ].
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1992
    ^ aDirectoryStream pastEndRead
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1993
! !
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1994
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1995
!UnixOperatingSystem class methodsFor:'dummy shell operations'!
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1996
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1997
openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1998
    "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1999
     This is typically used to present help-files, html documents, pdf documents etc.
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2000
     operationSymbol is one of:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2001
	open
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2002
	edit
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2003
	explore
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2004
     mimeTypeStringArgOrNil is e.g. 'text/html' or: 'application/pdf';
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2005
     if nil is passed in, the file's suffix is used to guess it.
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2006
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2007
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2008
    | cmd |
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2009
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2010
    cmd := self openApplicationHelperCommand.
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2011
    cmd notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2012
	(cmd includesSubString:'%1') ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2013
	    cmd := cmd bindWith:aFilenameOrString asString.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2014
	] ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2015
	    cmd := cmd, ' "', aFilenameOrString asString, '"'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2016
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2017
	(self
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2018
	    startProcess:cmd
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2019
	    inputFrom:nil outputTo:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2020
	    errorTo:nil auxFrom:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2021
	    environment: self getEnvironment inDirectory:nil) notNil ifTrue:[ ^ self ]
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2022
    ].
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2023
    ^ super openApplicationForDocument:aFilenameOrString operation:operationSymbol mimeType:mimeTypeStringArgOrNil ifNone:exceptionBlock
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2024
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2025
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2026
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2027
     self openApplicationForDocument: 'https://www.exept.de' operation: #open.
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2028
     self openApplicationForDocument: Filename currentDirectory operation:#open
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2029
     self openApplicationForDocument: '..\..\doc\books\ArtOfSmalltalk\artMissing186187Fix1.pdf' asFilename operation:#open
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2030
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2031
     self openApplicationForDocument: 'C:\WINDOWS\Help\clipbrd.chm' asFilename operation:#open
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2032
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2033
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2034
    "Created: / 13-01-2015 / 08:30:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2035
!
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2036
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2037
openApplicationHelperCommand
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2038
    "Return a command line helper to open a default application for file or URL"
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2039
18923
fc32a7567437 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18758
diff changeset
  2040
    | xdgCurrentDesktop usersPref |
fc32a7567437 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18758
diff changeset
  2041
fc32a7567437 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18758
diff changeset
  2042
    ((usersPref := UserPreferences current osFileExplorerCommand) notEmptyOrNil
fc32a7567437 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18758
diff changeset
  2043
    and:[ self canExecuteCommand:(usersPref subStrings first) ]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2044
	^ usersPref
19044
318352c827d7 option to use stat64 instead f stat (-DUSE_STAT64)
Claus Gittinger <cg@exept.de>
parents: 18923
diff changeset
  2045
    ].
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2046
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2047
    xdgCurrentDesktop := self getEnvironment: 'XDG_CURRENT_DESKTOP'.
17299
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  2048
    ((xdgCurrentDesktop = 'GNOME') and:[self canExecuteCommand: 'gnome-open']) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2049
	^ 'gnome-open'
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2050
    ].
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2051
    "/ Guess...
17299
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  2052
    ((xdgCurrentDesktop = 'KDE') and:[self canExecuteCommand: 'kde-open']) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2053
	^ 'kde-open'
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2054
    ].
17299
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  2055
    (self canExecuteCommand: 'xdg-open') ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2056
	^ 'xdg-open'
18923
fc32a7567437 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18758
diff changeset
  2057
    ].
fc32a7567437 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 18758
diff changeset
  2058
    (self canExecuteCommand: 'nautilus') ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2059
	^ 'nautilus'
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2060
    ].
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2061
    ^ nil
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2062
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2063
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2064
     self openApplicationHelperCommand
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2065
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2066
     self openApplicationForDocument: 'https://www.exept.de' operation: #open.
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2067
     self openApplicationForDocument: Filename currentDirectory operation:#open
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2068
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2069
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2070
    "Created: / 13-01-2015 / 09:02:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
20382
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2071
!
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2072
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2073
openTerminalWithCommand:shellCommand inBackground:inBackground
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2074
    "open a new terminal, which executes a command"
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2075
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2076
    |cmd|
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2077
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2078
    cmd := 'xterm -e "%1"' bindWith:shellCommand.
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2079
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2080
    inBackground ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2081
	^ self
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2082
	    startProcess:cmd
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2083
	    inputFrom:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2084
	    outputTo:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2085
	    errorTo:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2086
	    auxFrom:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2087
	    environment:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2088
	    inDirectory:nil
20382
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2089
    ] ifFalse:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2090
	^ self executeCommand:cmd
20382
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2091
    ].
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2092
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2093
    "
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2094
     OSXOperatingSystem openTerminalWithCommand:'ls -l' inBackground:true
870f6e63c6aa #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20328
diff changeset
  2095
    "
17299
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  2096
! !
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  2097
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2098
!UnixOperatingSystem class methodsFor:'error messages'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2099
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2100
currentErrorNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2101
    "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
  2102
     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
  2103
     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
  2104
     request to the OS.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2105
     Use lastErrorNumber - currentErrorNumber is invalidated by
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2106
     many, many internal calls."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2107
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2108
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2109
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2110
     RETURN ( __mkSmallInteger(errno) );
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  2111
%}.
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  2112
    ^ 0
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  2113
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2114
     "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  2115
      OperatingSystem currentErrorNumber
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2116
     "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2117
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2118
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2119
errorHolderForNumber:errNr
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2120
    "return an osErrorHolder for the given error number (as returned by a system call)."
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2121
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2122
    |sym typ holder|
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2123
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2124
%{
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2125
    /* claus:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2126
     * I made this primitive code, since errnos are not
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2127
     * standard across unixes
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2128
     */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2129
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2130
    if (__isSmallInteger(errNr)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2131
	switch ( __intVal(errNr)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2132
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2133
	     * POSIX errnos - these should be defined
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2134
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2135
#ifdef EPERM
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2136
	    case EPERM:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2137
		sym = @symbol(EPERM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2138
		typ = @symbol(noPermissionsSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2139
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2140
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2141
#ifdef ENOENT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2142
	    case ENOENT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2143
		sym = @symbol(ENOENT);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2144
		typ = @symbol(nonexistentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2145
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2146
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2147
#ifdef ESRCH
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2148
	    case ESRCH:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2149
		sym = @symbol(ESRCH);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2150
		typ = @symbol(unavailableReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2151
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2152
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2153
#ifdef EINTR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2154
	    case EINTR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2155
		sym = @symbol(EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2156
		typ = @symbol(transientErrorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2157
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2158
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2159
#ifdef EIO
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2160
	    case EIO:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2161
		sym = @symbol(EIO);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2162
		typ = @symbol(transferFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2163
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2164
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2165
#ifdef ENXIO
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2166
	    case ENXIO:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2167
		sym = @symbol(ENXIO);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2168
		typ = @symbol(unavailableReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2169
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2170
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2171
#ifdef E2BIG
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2172
	    case E2BIG:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2173
		sym = @symbol(E2BIG);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2174
		typ = @symbol(invalidArgumentsSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2175
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2176
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2177
#ifdef ENOEXEC
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2178
	    case ENOEXEC:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2179
		sym = @symbol(ENOEXEC);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2180
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2181
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2182
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2183
#ifdef EBADF
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2184
	    case EBADF:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2185
		sym = @symbol(EBADF);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2186
		typ = @symbol(badAccessorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2187
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2188
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2189
#ifdef ECHILD
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2190
	    case ECHILD:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2191
		sym = @symbol(ECHILD);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2192
		typ = @symbol(informationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2193
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2194
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2195
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2196
	    case EAGAIN:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2197
		sym = @symbol(EAGAIN);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2198
		typ = @symbol(notReadySignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2199
		break;
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2200
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2201
#ifdef EOVERFLOW
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2202
	    case EOVERFLOW:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2203
		sym = @symbol(EOVERFLOW);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2204
		typ = @symbol(rangeErrorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2205
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2206
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2207
#ifdef ENOMEM
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2208
	    case ENOMEM:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2209
		sym = @symbol(ENOMEM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2210
		typ = @symbol(noMemorySignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2211
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2212
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2213
#ifdef EACCES
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2214
	    case EACCES:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2215
		sym = @symbol(EACCES);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2216
		typ = @symbol(noPermissionsSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2217
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2218
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2219
#ifdef EFAULT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2220
	    case EFAULT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2221
		sym = @symbol(EFAULT);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2222
		typ = @symbol(invalidArgumentsSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2223
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2224
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2225
#ifdef EBUSY
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2226
	    case EBUSY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2227
		sym = @symbol(EBUSY);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2228
		typ = @symbol(unavailableReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2229
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2230
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2231
#ifdef EEXIST
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2232
	    case EEXIST:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2233
		sym = @symbol(EEXIST);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2234
		typ = @symbol(existingReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2235
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2236
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2237
#ifdef EXDEV
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2238
	    case EXDEV:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2239
		sym = @symbol(EXDEV);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2240
		typ = @symbol(inappropriateReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2241
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2242
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2243
#ifdef ENODEV
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2244
	    case ENODEV:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2245
		sym = @symbol(ENODEV);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2246
		typ = @symbol(inaccessibleSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2247
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2248
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2249
#ifdef ENOTDIR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2250
	    case ENOTDIR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2251
		sym = @symbol(ENOTDIR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2252
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2253
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2254
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2255
#ifdef EISDIR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2256
	    case EISDIR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2257
		sym = @symbol(EISDIR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2258
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2259
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2260
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2261
#ifdef EINVAL
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2262
	    case EINVAL:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2263
		sym = @symbol(EINVAL);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2264
		typ = @symbol(invalidArgumentsSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2265
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2266
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2267
#ifdef ENFILE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2268
	    case ENFILE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2269
		sym = @symbol(ENFILE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2270
		typ = @symbol(noResourcesSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2271
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2272
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2273
#ifdef EMFILE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2274
	    case EMFILE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2275
		sym = @symbol(EMFILE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2276
		typ = @symbol(noResourcesSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2277
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2278
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2279
#ifdef ENOTTY
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2280
	    case ENOTTY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2281
		sym = @symbol(ENOTTY);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2282
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2283
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2284
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2285
#ifdef EFBIG
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2286
	    case EFBIG:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2287
		sym = @symbol(EFBIG);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2288
		typ = @symbol(noResourcesSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2289
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2290
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2291
#ifdef ENOSPC
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2292
	    case ENOSPC:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2293
		sym = @symbol(ENOSPC);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2294
		typ = @symbol(noResourcesSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2295
		break;
18198
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2296
#endif
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2297
#ifdef ENOTSUP
18205
182612a550dd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18198
diff changeset
  2298
# if !defined(EOPNOTSUPP) || (ENOTSUP != EOPNOTSUPP)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2299
	    case ENOTSUP:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2300
		sym = @symbol(ENOTSUP);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2301
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2302
		break;
18205
182612a550dd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18198
diff changeset
  2303
# endif
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2304
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2305
#ifdef ESPIPE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2306
	    case ESPIPE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2307
		sym = @symbol(ESPIPE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2308
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2309
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2310
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2311
#ifdef EROFS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2312
	    case EROFS:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2313
		sym = @symbol(EROFS);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2314
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2315
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2316
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2317
#ifdef EMLINK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2318
	    case EMLINK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2319
		sym = @symbol(EMLINK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2320
		typ = @symbol(rangeErrorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2321
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2322
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2323
#ifdef EPIPE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2324
	    case EPIPE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2325
		sym = @symbol(EPIPE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2326
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2327
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2328
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2329
#ifdef EDOM
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2330
	    case EDOM:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2331
		sym = @symbol(EDOM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2332
		typ = @symbol(rangeErrorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2333
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2334
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2335
#ifdef ERANGE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2336
	    case ERANGE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2337
		sym = @symbol(ERANGE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2338
		typ = @symbol(rangeErrorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2339
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2340
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2341
#ifdef EDEADLK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2342
# if EDEADLK != EWOULDBLOCK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2343
	    case EDEADLK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2344
		sym = @symbol(EDEADLK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2345
		typ = @symbol(noResourcesSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2346
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2347
# endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2348
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2349
#ifdef ENAMETOOLONG
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2350
	    case ENAMETOOLONG:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2351
		sym = @symbol(ENAMETOOLONG);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2352
		typ = @symbol(rangeErrorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2353
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2354
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2355
#ifdef ENOLCK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2356
	    case ENOLCK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2357
		sym = @symbol(ENOLCK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2358
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2359
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2360
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2361
#ifdef ENOSYS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2362
	    case ENOSYS:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2363
		sym = @symbol(ENOSYS);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2364
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2365
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2366
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2367
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2368
	    case ENOTEMPTY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2369
		sym = @symbol(ENOTEMPTY);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2370
		typ = @symbol(inappropriateReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2371
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2372
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2373
#ifdef EILSEQ
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2374
	    case EILSEQ:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2375
		sym = @symbol(EILSEQ);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2376
		typ = @symbol(transferFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2377
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2378
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2379
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2380
	     * XPG3 errnos - defined on most systems
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2381
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2382
#ifdef ENOTBLK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2383
	    case ENOTBLK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2384
		sym = @symbol(ENOTBLK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2385
		typ = @symbol(inappropriateReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2386
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2387
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2388
#ifdef ETXTBSY
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2389
	    case ETXTBSY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2390
		sym = @symbol(ETXTBSY);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2391
		typ = @symbol(inaccessibleSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2392
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2393
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2394
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2395
	     * some others
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2396
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2397
#ifdef EWOULDBLOCK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2398
	    case EWOULDBLOCK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2399
		sym = @symbol(EWOULDBLOCK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2400
		typ = @symbol(notReadySignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2401
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2402
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2403
#ifdef ENOMSG
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2404
	    case ENOMSG:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2405
		sym = @symbol(ENOMSG);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2406
		typ = @symbol(noDataSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2407
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2408
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2409
#ifdef ELOOP
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2410
	    case ELOOP:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2411
		sym = @symbol(ELOOP);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2412
		typ = @symbol(rangeErrorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2413
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2414
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2415
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2416
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2417
	     * some stream errors
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2418
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2419
#ifdef ETIME
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2420
	    case ETIME:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2421
		sym = @symbol(ETIME);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2422
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2423
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2424
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2425
#ifdef ENOSR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2426
	    case ENOSR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2427
		sym = @symbol(ENOSR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2428
		typ = @symbol(noResourcesSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2429
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2430
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2431
#ifdef ENOSTR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2432
	    case ENOSTR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2433
		sym = @symbol(ENOSTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2434
		typ = @symbol(inappropriateReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2435
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2436
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2437
#ifdef ECOMM
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2438
	    case ECOMM:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2439
		sym = @symbol(ECOMM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2440
		typ = @symbol(transferFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2441
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2442
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2443
#ifdef EPROTO
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2444
	    case EPROTO:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2445
		sym = @symbol(EPROTO);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2446
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2447
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2448
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2449
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2450
	     * nfs errors
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2451
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2452
#ifdef ESTALE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2453
	    case ESTALE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2454
		sym = @symbol(ESTALE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2455
		typ = @symbol(unavailableReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2456
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2457
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2458
#ifdef EREMOTE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2459
	    case EREMOTE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2460
		sym = @symbol(EREMOTE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2461
		typ = @symbol(rangeErrorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2462
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2463
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2464
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2465
	     * some networking errors
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2466
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2467
#ifdef EINPROGRESS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2468
	    case EINPROGRESS:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2469
		sym = @symbol(EINPROGRESS);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2470
		typ = @symbol(operationStartedSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2471
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2472
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2473
#ifdef EALREADY
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2474
	    case EALREADY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2475
		sym = @symbol(EALREADY);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2476
		typ = @symbol(operationStartedSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2477
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2478
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2479
#ifdef ENOTSOCK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2480
	    case ENOTSOCK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2481
		sym = @symbol(ENOTSOCK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2482
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2483
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2484
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2485
#ifdef EDESTADDRREQ
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2486
	    case EDESTADDRREQ:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2487
		sym = @symbol(EDESTADDRREQ);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2488
		typ = @symbol(underspecifiedSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2489
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2490
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2491
#ifdef EMSGSIZE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2492
	    case EMSGSIZE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2493
		sym = @symbol(EMSGSIZE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2494
		typ = @symbol(rangeErrorSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2495
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2496
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2497
#ifdef EPROTOTYPE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2498
	    case EPROTOTYPE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2499
		sym = @symbol(EPROTOTYPE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2500
		typ = @symbol(wrongSubtypeForOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2501
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2502
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2503
#ifdef ENOPROTOOPT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2504
	    case ENOPROTOOPT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2505
		sym = @symbol(ENOPROTOOPT);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2506
		typ = @symbol(unsupportedOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2507
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2508
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2509
#ifdef EPROTONOSUPPORT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2510
	    case EPROTONOSUPPORT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2511
		sym = @symbol(EPROTONOSUPPORT);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2512
		typ = @symbol(unsupportedOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2513
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2514
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2515
#ifdef ESOCKTNOSUPPORT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2516
	    case ESOCKTNOSUPPORT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2517
		sym = @symbol(ESOCKTNOSUPPORT);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2518
		typ = @symbol(unsupportedOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2519
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2520
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2521
#ifdef EOPNOTSUPP
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2522
	    case EOPNOTSUPP:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2523
		sym = @symbol(EOPNOTSUPP);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2524
		typ = @symbol(inappropriateOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2525
		break;
6287
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 EPFNOSUPPORT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2528
	    case EPFNOSUPPORT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2529
		sym = @symbol(EPFNOSUPPORT);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2530
		typ = @symbol(unsupportedOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
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 EAFNOSUPPORT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2534
	    case EAFNOSUPPORT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2535
		sym = @symbol(EAFNOSUPPORT);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2536
		typ = @symbol(unsupportedOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
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 EADDRINUSE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2540
	    case EADDRINUSE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2541
		sym = @symbol(EADDRINUSE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2542
		typ = @symbol(existingReferentSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
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
#ifdef EADDRNOTAVAIL
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2546
	    case EADDRNOTAVAIL:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2547
		sym = @symbol(EADDRNOTAVAIL);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2548
		typ = @symbol(noPermissionsSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
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 ETIMEDOUT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2552
	    case ETIMEDOUT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2553
		sym = @symbol(ETIMEDOUT);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2554
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2555
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2556
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2557
#ifdef ECONNREFUSED
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2558
	    case ECONNREFUSED:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2559
		sym = @symbol(ECONNREFUSED);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2560
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2561
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2562
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2563
#ifdef ENETDOWN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2564
	    case ENETDOWN:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2565
		sym = @symbol(ENETDOWN);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2566
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2567
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2568
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2569
#ifdef ENETUNREACH
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2570
	    case ENETUNREACH:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2571
		sym = @symbol(ENETUNREACH);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2572
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2573
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2574
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2575
#ifdef ENETRESET
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2576
	    case ENETRESET:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2577
		sym = @symbol(ENETRESET);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2578
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
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 ECONNABORTED
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2582
	    case ECONNABORTED:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2583
		sym = @symbol(ECONNABORTED);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2584
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
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 ECONNRESET
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2588
	    case ECONNRESET:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2589
		sym = @symbol(ECONNRESET);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2590
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2591
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2592
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2593
#ifdef EISCONN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2594
	    case EISCONN:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2595
		sym = @symbol(EISCONN);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2596
		typ = @symbol(unpreparedOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2597
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2598
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2599
#ifdef ENOTCONN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2600
	    case ENOTCONN:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2601
		sym = @symbol(ENOTCONN);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2602
		typ = @symbol(unpreparedOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2603
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2604
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2605
#ifdef ESHUTDOWN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2606
	    case ESHUTDOWN:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2607
		sym = @symbol(ESHUTDOWN);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2608
		typ = @symbol(unpreparedOperationSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2609
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2610
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2611
#ifdef EHOSTDOWN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2612
	    case EHOSTDOWN:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2613
		sym = @symbol(EHOSTDOWN);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2614
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2615
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2616
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2617
#ifdef EHOSTUNREACH
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2618
	    case EHOSTUNREACH:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2619
		sym = @symbol(EHOSTUNREACH);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2620
		typ = @symbol(peerFaultSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2621
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2622
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2623
#ifdef EDQUOT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2624
	    case EDQUOT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2625
		sym = @symbol(EDQUOT);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2626
		typ = @symbol(noResourcesSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2627
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2628
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2629
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2630
#ifdef ENOMEDIUM
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2631
	    case ENOMEDIUM:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2632
		sym = @symbol(ENOMEDIUM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2633
		typ = @symbol(noResourcesSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2634
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2635
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2636
#ifdef EMEDIUMTYPE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2637
	    case EMEDIUMTYPE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2638
		sym = @symbol(EMEDIUMTYPE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2639
		typ = @symbol(noResourcesSignal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2640
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2641
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2642
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2643
	    default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2644
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2645
	}
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2646
    }
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2647
%}.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2648
    holder := OSErrorHolder new.
16301
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2649
    sym isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2650
	sym := #ERROR_OTHER.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2651
	errNr notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2652
	    "keep symbols as symbols"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2653
	    holder parameter:(errNr isString ifTrue:[errNr] ifFalse:[errNr asString]).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2654
	].
16301
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2655
    ].
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2656
    holder errorSymbol:sym errorCategory:(typ ? #defaultOsErrorSignal).
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2657
    ^ holder
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2658
16301
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2659
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2660
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2661
     OperatingSystem errorHolderForNumber:4
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2662
     OperatingSystem errorHolderForNumber:45
16301
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2663
     OperatingSystem errorHolderForNumber:#badArgument
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2664
     self errorHolderForNumber:(self errorNumberFor:#EPERM)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2665
     self errorHolderForNumber:(self errorNumberFor:#EIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2666
     self errorHolderForNumber:(self errorNumberFor:#ENXIO)
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2667
     self errorHolderForNumber:(self errorNumberFor:#EOVERFLOW)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2668
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2669
!
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2670
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2671
errorNumberFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2672
    "given a symbolic error, return the numeric;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2673
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2674
     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
  2675
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2676
%{   /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2677
    OBJ sym = aSymbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2679
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2680
     * POSIX errnos - these should be defined
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2681
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2682
#ifdef EPERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2683
    if (sym == @symbol(EPERM)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2684
	RETURN ( __mkSmallInteger(EPERM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2685
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2686
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2687
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2688
#ifdef ENOENT
14435
fc486e748569 changed: #errorNumberFor:
Stefan Vogel <sv@exept.de>
parents: 14377
diff changeset
  2689
    /* ERROR_FILE_NOT_FOUND is originally windows, but referd to in ExternalStream>>#openError: */
fc486e748569 changed: #errorNumberFor:
Stefan Vogel <sv@exept.de>
parents: 14377
diff changeset
  2690
    if (sym == @symbol(ENOENT) || sym == @symbol(ERROR_FILE_NOT_FOUND)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2691
	RETURN ( __mkSmallInteger(ENOENT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2692
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2693
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2694
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2695
#ifdef ESRCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2696
    if (sym == @symbol(ESRCH)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2697
	RETURN ( __mkSmallInteger(ESRCH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2698
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2699
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2700
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2701
#ifdef EINTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2702
    if (sym == @symbol(EINTR)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2703
	RETURN ( __mkSmallInteger(EINTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2704
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2705
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2706
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2707
#ifdef EIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2708
    if (sym == @symbol(EIO)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2709
	RETURN ( __mkSmallInteger(EIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2710
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2711
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2712
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2713
#ifdef ENXIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2714
    if (sym == @symbol(ENXIO)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2715
	RETURN ( __mkSmallInteger(ENXIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2716
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2717
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2718
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2719
#ifdef E2BIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2720
    if (sym == @symbol(E2BIG)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2721
	RETURN ( __mkSmallInteger(E2BIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2722
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2723
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2725
#ifdef ENOEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2726
    if (sym == @symbol(ENOEXEC)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2727
	RETURN ( __mkSmallInteger(ENOEXEC) );
18198
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2728
    }
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2729
#endif
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2730
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2731
#ifdef ENOTSUP
18205
182612a550dd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18198
diff changeset
  2732
# if !defined(EOPNOTSUPP) || (ENOTSUP != EOPNOTSUPP)
18198
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2733
    if (sym == @symbol(ENOTSUP)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2734
	RETURN ( __mkSmallInteger(ENOTSUP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2735
    }
18205
182612a550dd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18198
diff changeset
  2736
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2737
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2738
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2739
#ifdef EBADF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2740
    if (sym == @symbol(EBADF)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2741
	RETURN ( __mkSmallInteger(EBADF) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2742
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2743
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2744
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2745
#ifdef ECHILD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2746
    if (sym == @symbol(ECHILD)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2747
	RETURN ( __mkSmallInteger(ECHILD) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2748
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2749
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2751
#if defined(EAGAIN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2752
    if (sym == @symbol(EAGAIN)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2753
	RETURN ( __mkSmallInteger(EAGAIN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2754
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2755
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2757
#ifdef ENOMEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2758
    if (sym == @symbol(ENOMEM)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2759
	RETURN ( __mkSmallInteger(ENOMEM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2760
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2761
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2762
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2763
#ifdef EACCES
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2764
    if (sym == @symbol(EACCES)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2765
	RETURN ( __mkSmallInteger(EACCES) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2766
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2767
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2768
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2769
#ifdef EFAULT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2770
    if (sym == @symbol(EFAULT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2771
	RETURN ( __mkSmallInteger(EFAULT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2772
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2773
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2774
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2775
#ifdef EBUSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2776
    if (sym == @symbol(EBUSY)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2777
	RETURN ( __mkSmallInteger(EBUSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2778
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2779
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2780
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2781
#ifdef EXDEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2782
    if (sym == @symbol(EXDEV)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2783
	RETURN ( __mkSmallInteger(EXDEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2784
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2785
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2786
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2787
#ifdef ENODEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2788
    if (sym == @symbol(ENODEV)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2789
	RETURN ( __mkSmallInteger(ENODEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2790
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2791
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2792
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2793
#ifdef ENOTDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2794
    if (sym == @symbol(ENOTDIR)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2795
	RETURN ( __mkSmallInteger(ENOTDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2796
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2797
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2798
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2799
#ifdef EISDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2800
    if (sym == @symbol(EISDIR)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2801
	RETURN ( __mkSmallInteger(EISDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2802
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2803
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2804
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2805
#ifdef EINVAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2806
    if (sym == @symbol(EINVAL)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2807
	RETURN ( __mkSmallInteger(EINVAL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2808
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2809
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2810
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2811
#ifdef ENFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2812
    if (sym == @symbol(ENFILE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2813
	RETURN ( __mkSmallInteger(ENFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2814
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2815
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2816
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2817
#ifdef EMFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2818
    if (sym == @symbol(EMFILE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2819
	RETURN ( __mkSmallInteger(EMFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2820
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2821
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2823
#ifdef ENOTTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
    if (sym == @symbol(ENOTTY)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2825
	RETURN ( __mkSmallInteger(ENOTTY) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2828
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2829
#ifdef EFBIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2830
    if (sym == @symbol(EFBIG)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2831
	RETURN ( __mkSmallInteger(EFBIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2832
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2833
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2834
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2835
#ifdef ENOSPC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2836
    if (sym == @symbol(ENOSPC)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2837
	RETURN ( __mkSmallInteger(ENOSPC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2838
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2839
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2840
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2841
#ifdef ESPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2842
    if (sym == @symbol(ESPIPE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2843
	RETURN ( __mkSmallInteger(ESPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2844
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2845
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2846
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2847
#ifdef EROFS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2848
    if (sym == @symbol(EROFS)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2849
	RETURN ( __mkSmallInteger(EROFS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2850
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2851
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2852
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2853
#ifdef EMLINK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2854
    if (sym == @symbol(EMLINK)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2855
	RETURN ( __mkSmallInteger(EMLINK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2856
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2858
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2859
#ifdef EPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2860
    if (sym == @symbol(EPIPE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2861
	RETURN ( __mkSmallInteger(EPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2862
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2863
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2864
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2865
#ifdef EDOM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2866
    if (sym == @symbol(EDOM)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2867
	RETURN ( __mkSmallInteger(EDOM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2868
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2869
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2870
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2871
#ifdef ERANGE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2872
    if (sym == @symbol(ERANGE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2873
	RETURN ( __mkSmallInteger(ERANGE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2874
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2875
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2876
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2877
#ifdef EDEADLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2878
    if (sym == @symbol(EDEADLK)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2879
	RETURN ( __mkSmallInteger(EDEADLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2880
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2881
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2882
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2883
#ifdef ENAMETOOLONG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2884
    if (sym == @symbol(ENAMETOOLONG)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2885
	RETURN ( __mkSmallInteger(ENAMETOOLONG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2886
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2887
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2888
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2889
#ifdef ENOLCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2890
    if (sym == @symbol(ENOLCK)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2891
	RETURN ( __mkSmallInteger(ENOLCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2892
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2893
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2894
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2895
#ifdef ENOSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2896
    if (sym == @symbol(ENOSYS)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2897
	RETURN ( __mkSmallInteger(ENOSYS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2898
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2899
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2900
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2901
#ifdef ENOTEMPTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2902
    if (sym == @symbol(ENOTEMPTY)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2903
	RETURN ( __mkSmallInteger(ENOTEMPTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2904
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2905
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2906
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2907
#ifdef EEXIST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2908
    if (sym == @symbol(EEXIST)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2909
	RETURN ( __mkSmallInteger(EEXIST) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2910
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2911
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2912
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2913
#ifdef EILSEQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2914
    if (sym == @symbol(EILSEQ)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2915
	RETURN ( __mkSmallInteger(EILSEQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2916
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2917
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2918
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
     * XPG3 errnos - defined on most systems
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2921
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2922
#ifdef ENOTBLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2923
    if (sym == @symbol(ENOTBLK)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2924
	RETURN ( __mkSmallInteger(ENOTBLK) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2927
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2928
#ifdef ETXTBSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2929
    if (sym == @symbol(ETXTBSY)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2930
	RETURN ( __mkSmallInteger(ETXTBSY) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2933
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2934
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2935
     * some others
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2936
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2937
#ifdef EWOULDBLOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2938
    if (sym == @symbol(EWOULDBLOCK)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2939
	RETURN ( __mkSmallInteger(EWOULDBLOCK) );
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2940
    }
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2941
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2942
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2943
#ifdef EOVERFLOW
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2944
    if (sym == @symbol(EOVERFLOW)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2945
	RETURN ( __mkSmallInteger(EOVERFLOW) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2946
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2947
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2948
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2949
#ifdef ENOMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2950
    if (sym == @symbol(ENOMSG)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2951
	RETURN ( __mkSmallInteger(ENOMSG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2952
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2953
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2954
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2955
#ifdef ELOOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2956
    if (sym == @symbol(ELOOP)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2957
	RETURN ( __mkSmallInteger(ELOOP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2958
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2959
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2960
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
     * some stream errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2963
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2964
#ifdef ETIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2965
    if (sym == @symbol(ETIME)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2966
	RETURN ( __mkSmallInteger(ETIME) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2969
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2970
#ifdef ENOSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2971
    if (sym == @symbol(ENOSR)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2972
	RETURN ( __mkSmallInteger(ENOSR) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2975
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2976
#ifdef ENOSTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2977
    if (sym == @symbol(ENOSTR)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2978
	RETURN ( __mkSmallInteger(ENOSTR) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2981
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2982
#ifdef ECOMM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2983
    if (sym == @symbol(ECOMM)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2984
	RETURN ( __mkSmallInteger(ECOMM) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2987
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2988
#ifdef EPROTO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2989
    if (sym == @symbol(EPROTO)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2990
	RETURN ( __mkSmallInteger(EPROTO) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2993
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2994
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2995
     * nfs errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2996
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2997
#ifdef ESTALE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2998
    if (sym == @symbol(ESTALE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  2999
	RETURN ( __mkSmallInteger(ESTALE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3000
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3001
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3003
#ifdef EREMOTE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3004
    if (sym == @symbol(EREMOTE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3005
	RETURN ( __mkSmallInteger(EREMOTE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3006
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3007
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3008
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
     * some networking errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3011
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3012
#ifdef EINPROGRESS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3013
    if (sym == @symbol(EINPROGRESS)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3014
	RETURN ( __mkSmallInteger(EINPROGRESS) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3017
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3018
#ifdef EALREADY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3019
    if (sym == @symbol(EALREADY)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3020
	RETURN ( __mkSmallInteger(EALREADY) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3023
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3024
#ifdef ENOTSOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3025
    if (sym == @symbol(ENOTSOCK)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3026
	RETURN ( __mkSmallInteger(ENOTSOCK) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3029
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3030
#ifdef EDESTADDRREQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3031
    if (sym == @symbol(EDESTADDRREQ)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3032
	RETURN ( __mkSmallInteger(EDESTADDRREQ) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3035
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3036
#ifdef EMSGSIZE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3037
    if (sym == @symbol(EMSGSIZE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3038
	RETURN ( __mkSmallInteger(EMSGSIZE) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3041
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3042
#ifdef EPROTOTYPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3043
    if (sym == @symbol(EPROTOTYPE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3044
	RETURN ( __mkSmallInteger(EPROTOTYPE) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3047
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3048
#ifdef ENOPROTOOPT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3049
    if (sym == @symbol(ENOPROTOOPT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3050
	RETURN ( __mkSmallInteger(ENOPROTOOPT) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3053
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3054
#ifdef EPROTONOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3055
    if (sym == @symbol(EPROTONOSUPPORT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3056
	RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3059
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3060
#ifdef ESOCKTNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3061
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3062
	RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3063
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3064
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3065
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3066
#ifdef EOPNOTSUPP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3067
    if (sym == @symbol(EOPNOTSUPP)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3068
	RETURN ( __mkSmallInteger(EOPNOTSUPP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3069
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3070
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3071
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3072
#ifdef EPFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3073
    if (sym == @symbol(EPFNOSUPPORT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3074
	RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3075
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3076
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3077
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3078
#ifdef EAFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3079
    if (sym == @symbol(EAFNOSUPPORT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3080
	RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3083
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3084
#ifdef EADDRINUSE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3085
    if (sym == @symbol(EADDRINUSE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3086
	RETURN ( __mkSmallInteger(EADDRINUSE) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3089
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3090
#ifdef EADDRNOTAVAIL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3091
    if (sym == @symbol(EADDRNOTAVAIL)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3092
	RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3093
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3094
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3095
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3096
#ifdef ETIMEDOUT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3097
    if (sym == @symbol(ETIMEDOUT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3098
	RETURN ( __mkSmallInteger(ETIMEDOUT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3099
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3100
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3101
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3102
#ifdef ECONNREFUSED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3103
    if (sym == @symbol(ECONNREFUSED)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3104
	RETURN ( __mkSmallInteger(ECONNREFUSED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3105
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3106
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3107
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3108
#ifdef ENETDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3109
    if (sym == @symbol(ENETDOWN)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3110
	RETURN ( __mkSmallInteger(ENETDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3111
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3112
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3113
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3114
#ifdef ENETUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3115
    if (sym == @symbol(ENETUNREACH)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3116
	RETURN ( __mkSmallInteger(ENETUNREACH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3117
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3118
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3119
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3120
#ifdef ENETRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3121
    if (sym == @symbol(ENETRESET)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3122
	RETURN ( __mkSmallInteger(ENETRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3123
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3124
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3125
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3126
#ifdef ECONNABORTED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3127
    if (sym == @symbol(ECONNABORTED)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3128
	RETURN ( __mkSmallInteger(ECONNABORTED) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3131
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3132
#ifdef ECONNRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3133
    if (sym == @symbol(ECONNRESET)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3134
	RETURN ( __mkSmallInteger(ECONNRESET) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3137
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3138
#ifdef EISCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3139
    if (sym == @symbol(EISCONN)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3140
	RETURN ( __mkSmallInteger(EISCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3144
#ifdef ENOTCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3145
    if (sym == @symbol(ENOTCONN)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3146
	RETURN ( __mkSmallInteger(ENOTCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3147
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
#ifdef ESHUTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3151
    if (sym == @symbol(ESHUTDOWN)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3152
	RETURN ( __mkSmallInteger(ESHUTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3153
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3155
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3156
#ifdef EHOSTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3157
    if (sym == @symbol(EHOSTDOWN)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3158
	RETURN ( __mkSmallInteger(EHOSTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3159
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3160
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3161
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3162
#ifdef EHOSTUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3163
    if (sym == @symbol(EHOSTUNREACH)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3164
	RETURN ( __mkSmallInteger(EHOSTUNREACH) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3165
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3166
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3167
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3168
#ifdef EREMOTEIO
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3169
    if (sym == @symbol(EREMOTEIO)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3170
	RETURN ( __mkSmallInteger(EREMOTEIO) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3171
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3172
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3173
#ifdef EDQUOT
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3174
    if (sym == @symbol(EDQUOT)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3175
	RETURN ( __mkSmallInteger(EDQUOT) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3176
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3177
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3178
#ifdef ENOMEDIUM
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3179
    if (sym == @symbol(ENOMEDIUM)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3180
	RETURN ( __mkSmallInteger(ENOMEDIUM) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3181
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3182
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3183
#ifdef EMEDIUMTYPE
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3184
    if (sym == @symbol(EMEDIUMTYPE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3185
	RETURN ( __mkSmallInteger(EMEDIUMTYPE) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3186
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3187
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3188
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3189
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3190
    ^ -1
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  3191
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  3192
    "
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  3193
     self errorNumberFor:#EOVERFLOW
18198
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  3194
     self errorNumberFor:#ENOTSUP
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  3195
    "
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
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3198
!UnixOperatingSystem class methodsFor:'executing OS commands-implementation'!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3199
14576
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  3200
exec:aCommandPathArg withArguments:argColl environment:environmentDictionary
20327
e70f8895a3cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20296
diff changeset
  3201
    fileDescriptors:fdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory showWindow:ignoredHere
e70f8895a3cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20296
diff changeset
  3202
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3203
    "Internal lowLevel entry for combined fork & exec;
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3204
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3205
     If fork is false (chain a command):
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3206
	 execute the OS command specified by the argument, aCommandPath, with
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3207
	 arguments in argArray (no arguments, if nil).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3208
	 If successful, this method does not return and smalltalk is gone.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3209
	 If not successful, it does return.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3210
	 Normal use is with forkForCommand.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3211
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3212
     If fork is true (subprocess command execution):
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3213
	fork a child to do the above.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3214
	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
  3215
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7072
diff changeset
  3216
     fdColl contains the filedescriptors, to be used for the child (if fork is true).
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3217
	fdArray[1] = 15 -> use fd 15 as stdin.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3218
	If an element of the array is set to nil, the corresponding filedescriptor
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3219
	will be closed for the child.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3220
	fdArray[1] == StdIn for child
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3221
	fdArray[2] == StdOut for child
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3222
	fdArray[3] == StdErr for child
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3223
	on VMS, these must be channels as returned by createMailBox.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3224
	All filedescriptors not present in fdColl will be closed for the child.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3225
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3226
     If newPgrp is not false, the subprocess will be established in a new process group.
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3227
	The processgroup will be equal to id.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3228
	newPgrp is not used on WIN32 and VMS systems.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3229
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  3230
     environmentDictionary specifies environment variables which are passed differently from
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3231
     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
  3232
     key-value pairs for changed/added environment variables.
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3233
     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
  3234
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3235
     Notice: this used to be two separate ST-methods; however, in order to use
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3236
	    vfork on some machines, it had to be merged into one, to avoid write
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3237
	    accesses to ST/X memory from the vforked-child.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3238
	    The code below only does read accesses."
14576
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  3239
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  3240
    |envArray argArray fdArray dirName cnt aCommandPath|
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  3241
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  3242
    environmentDictionary notEmptyOrNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3243
	envArray := Array new:environmentDictionary size.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3244
	cnt := 1.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3245
	environmentDictionary keysAndValuesDo:[:key :val |
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3246
	    val isNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3247
		envArray at:cnt put:((self encodePath:key), '=')
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3248
	    ] ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3249
		envArray at:cnt put:((self encodePath:key), '=', (self encodePath:val asString))
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3250
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3251
	    cnt := cnt + 1.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3252
	].
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3253
    ].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3254
    argColl notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3255
	argArray := argColl asArray collect:[:eachArg| self encodePath:eachArg].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3256
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3257
    fdColl notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3258
	fdArray := fdColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3259
    ].
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3260
    aDirectory notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3261
	dirName := aDirectory asFilename osNameForFile.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3262
	dirName := self encodePath:dirName.
14576
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  3263
    ].
14582
24adef09db30 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14576
diff changeset
  3264
    aCommandPath := self encodePath:aCommandPathArg.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3265
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3266
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3267
    char **argv;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3268
    int nargs, i, id;
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  3269
    OBJ arg;
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  3270
#ifdef __osx__
16282
a9cd85c4d2f2 getEnvironment fix for __osx__
Claus Gittinger <cg@exept.de>
parents: 16149
diff changeset
  3271
    char **environ = *_NSGetEnviron();
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  3272
#else
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3273
    extern char **environ;
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  3274
#endif
3571
9090dc66a427 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
  3275
    char **_env, **_nEnv;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3276
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3277
    if (__isStringLike(aCommandPath) &&
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3278
	((argArray == nil) || __isArrayLike(argArray)) &&
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3279
	((fdArray == nil) || __isArrayLike(fdArray))
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3280
    ) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3281
	nargs = argArray == nil ? 0 : __arraySize(argArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3282
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3283
	if (argv) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3284
	    int nOldEnv, nNewEnv;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3285
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3286
	    for (i=0; i < nargs; i++) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3287
		arg = __ArrayInstPtr(argArray)->a_element[i];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3288
		if (__isStringLike(arg)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3289
		    argv[i] = (char *) __stringVal(arg);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3290
		} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3291
		    argv[i] = "";
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3292
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3293
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3294
	    argv[i] = NULL;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3295
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3296
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3297
	     * number of new items in environment ..
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3298
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3299
	    nNewEnv = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3300
	    if ((envArray != nil) && __isArrayLike(envArray)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3301
		nNewEnv = __arraySize(envArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3302
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3303
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3304
	    if (nNewEnv == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3305
		_nEnv = environ;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3306
	    } else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3307
		_env = environ;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3308
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3309
		 * get size of environment
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3310
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3311
		nOldEnv = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3312
		if (_env) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3313
		    while (*_env) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3314
			nOldEnv++;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3315
			_env++;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3316
		    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3317
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3318
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3319
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3320
		 * generate a new environment
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3321
		 * I have not found a spec which defines if
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3322
		 * items at the end overwrite previous definitions,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3323
		 * or if the first encountered definition is valid.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3324
		 * To be prepared for any case, simply add the new definitions
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3325
		 * at both ends - that should do it in any case.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3326
		 * Someone with more know-how may want to fix this.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3327
		 * getenv() searches for the first entry.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3328
		 * But maybe someone creates a Dictionary from the environment.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3329
		 * In this case the last entry would overwrite previous entries.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3330
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3331
		_nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3332
		if (_nEnv) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3333
		    char **eO, **eN;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3334
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3335
		    eN = _nEnv;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3336
		    if (nNewEnv) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3337
			/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3338
			 * add new items at the front ...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3339
			 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3340
			int i;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3341
			OBJ *t;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3342
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3343
			for (i=0, t = __arrayVal(envArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3344
			     i < __arraySize(envArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3345
			     i++, t++) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3346
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3347
			    if (__isStringLike(*t)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3348
				*eN++ = (char *)__stringVal(*t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3349
			    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3350
			}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3351
		    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3352
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3353
		    if (nOldEnv) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3354
			/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3355
			 * append old environment
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3356
			 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3357
			for (eO = environ; *eO; *eN++ = *eO++)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3358
			    continue;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3359
		    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3360
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3361
		    if (nNewEnv) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3362
			/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3363
			 * append new items again at the end
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3364
			 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3365
			for (eO = _nEnv, i=0; i<nNewEnv; i++) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3366
			    *eN++ = *eO++;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3367
			}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3368
		    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3369
		    *eN = NULL;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3370
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3371
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3372
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3373
	    if (doFork == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3374
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3375
		 * fork a subprocess.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3376
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3377
		int nfd;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3378
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3379
		nfd = fdArray == nil ? 0 : __arraySize(fdArray);
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3380
#ifdef __osx__
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3381
		// on OSX, job control does not work with vfork
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3382
		id = fork();
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3383
#else
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3384
		id = FORK();
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3385
#endif
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3386
		if (id == 0) {
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3387
		    int ptyFd = -1;
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3388
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3389
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3390
#ifdef __osx__
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3391
		    {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3392
			int fd = __intVal(__arrayVal(fdArray)[0]);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3393
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3394
			if (setsid() < 0) {
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3395
# ifdef __VERBOSE__
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3396
			    fprintf(stderr, "setpgid failed: %s", strerror(errno));
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3397
# endif
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3398
			}
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3399
			if (ioctl(fd, TIOCSCTTY, NULL) < 0) {
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3400
# ifdef __VERBOSE__
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3401
			    fprintf(stderr, "TIOCSCTTY failed: %s", strerror(errno));
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3402
# endif
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3403
			}
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3404
		    }
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3405
#endif
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3406
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3407
		    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3408
		    ** In child.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3409
		    ** first: dup filedescriptors.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3410
		    */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3411
		    for (i = 0; i < nfd; i++) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3412
			OBJ fd;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3413
			int rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3414
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3415
			if (i != ptyFd) {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3416
			    fd = __arrayVal(fdArray)[i];
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3417
			    if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3418
				do {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3419
				    rslt = dup2(__intVal(fd), i);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3420
				} while ((rslt < 0) && (errno == EINTR));
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3421
			    }
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3422
			}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3423
		    }
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3424
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3425
		    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3426
		    ** Second: close descriptors
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3427
		    **         marked as unwanted
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3428
		    ** (extra loop to allow duping of low filedescriptor numbers to
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3429
		    **  higher fd numbers)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3430
		    */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3431
		    for (i = 0; i < nfd; i++) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3432
			if (__arrayVal(fdArray)[i] == nil) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3433
			    close(i);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3434
			}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3435
		    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3436
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3437
		    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3438
		    ** third: close all filedescriptors larger
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3439
		    ** then the explicitely closed or duped
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3440
		    ** filedescriptors
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3441
		    */
7072
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3442
#ifndef OPEN_MAX
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3443
# define OPEN_MAX       256
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3444
#endif
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3445
		    for ( ;i < OPEN_MAX; i++) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3446
			close(i);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3447
		    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3448
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3449
		    if (newPgrp != false) {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3450
#if !defined(__osx__)
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3451
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3452
#ifndef __NEXT__
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3453
			if (setsid() < 0) {
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3454
# ifdef __VERBOSE__
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3455
			    printf("setsid() -> %s\n", strerror(errno));
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3456
# endif
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3457
			}
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3458
#endif
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3459
#if defined(TIOCSCTTY)
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3460
			if (ioctl(0, TIOCSCTTY, 0) < 0) {
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3461
# ifdef __VERBOSE__
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3462
			    printf("TIOCSCTTY -> %s\n", strerror(errno));
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3463
# endif
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3464
			}
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3465
#endif
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3466
#if defined(TIOCSPGRP)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3467
			{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3468
			    int pgrp = getpid();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3469
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3470
			    if (ioctl(0, TIOCSPGRP, (char *)&pgrp) < 0) {
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3471
# ifdef __VERBOSE__
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3472
				printf("TIOCSPGRP -> %s\n", strerror(errno));
23781
8f474ae2c19b debug print
Claus Gittinger <cg@exept.de>
parents: 23780
diff changeset
  3473
# endif
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3474
			    }
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3475
			}
18672
175c59a9356b waitpid fix for osx
Claus Gittinger <cg@exept.de>
parents: 18626
diff changeset
  3476
#endif
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3477
#if defined(_POSIX_JOB_CONTROL)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3478
			(void) setpgid(0, 0);
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3479
# else
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3480
# if defined(BSD) || defined(LINUX)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3481
			(void) setpgrp(0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3482
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3483
#endif
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3484
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3485
#endif // ! osx
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3486
		    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3487
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3488
		    if (dirName == nil || chdir((char *)__stringVal(dirName)) == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3489
			execve((char *)__stringVal(aCommandPath), argv, _nEnv);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3490
		    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3491
		    /* reached if chdir failed or aCommandPath cannot be executed */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3492
		    _exit(127);                 /* POSIX 2 compatible exit value */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3493
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3494
	    } else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3495
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3496
		 * no subprocess (i.e. transfer to another program)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3497
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3498
		if (dirName == nil || chdir((char *)__stringVal(dirName)) == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3499
		    execve((char *)__stringVal(aCommandPath), argv, _nEnv);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3500
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3501
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3502
		 * reached if chdir failed or command-path cannot be executed
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3503
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3504
		id = -1;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3505
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3506
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3507
	    if (nNewEnv && (_nEnv != NULL)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3508
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3509
		 * free new environment stuff
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3510
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3511
		free(_nEnv);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3512
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3513
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3514
	    free(argv);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3515
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3516
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3517
	     * In parent: succes or failure
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3518
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3519
	    if (id == -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3520
		RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3521
	    } else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3522
		RETURN (__mkSmallInteger(id));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3523
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3524
	}
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3525
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3526
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3527
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3528
     path-argument not string
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3529
     or argArray not an array/nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3530
     or malloc failed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3531
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3532
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3533
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3534
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3535
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3536
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3537
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3538
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3539
     id == 0 ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3540
	'I am the child'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3541
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3542
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3543
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3544
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3545
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3546
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3547
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3548
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3549
     id == 0 ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3550
	'I am the child'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3551
	OperatingSystem
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3552
	   exec:'/bin/sh'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3553
	   withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3554
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3555
     ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3556
     id printNL.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3557
     (Delay forSeconds:3.5) wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3558
     'killing ...' printNL.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3559
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3560
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3561
    "
21769
99e8c78bf219 #DOCUMENTATION by mawalch
mawalch
parents: 21620
diff changeset
  3562
99e8c78bf219 #DOCUMENTATION by mawalch
mawalch
parents: 21620
diff changeset
  3563
    "Modified: / 23-05-2017 / 16:14:26 / mawalch"
22182
5b33d3644aef #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22173
diff changeset
  3564
    "Modified: / 09-08-2017 / 23:15:33 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3565
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3566
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3567
fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3568
    "fork a new (HEAVY-weight) unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3569
     Not supported with MSDOS & VMS systems.
20814
035cfc0c970b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20710
diff changeset
  3570
     Don't confuse this with Block>>fork, which creates
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  3571
     lightweight smalltalk processes.
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  3572
     This method will return 0 to the child process,
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  3573
     and a non-zero number (which is the childs unix-process-id)
20850
a71cca60518e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20814
diff changeset
  3574
     to the parent (original) process.
a71cca60518e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20814
diff changeset
  3575
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  3576
     In normal situations, you don't need to use this low level entry;
20850
a71cca60518e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20814
diff changeset
  3577
     see #startProcess: and #executeCommand: for higher level interfaces."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3578
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3579
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3580
    int pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3581
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3582
    pid = fork();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3583
    RETURN ( __MKUINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3584
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3585
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3586
    "/ not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3587
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3588
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3589
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3590
    "
20851
0c3beab2ee41 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20850
diff changeset
  3591
     |id t1 t2 t3|
0c3beab2ee41 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20850
diff changeset
  3592
0c3beab2ee41 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20850
diff changeset
  3593
     t1 := Timestamp now.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3594
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3595
     id == 0 ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3596
	 'Child t=' print. (Timestamp now - t1) printCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3597
	 'I am the child process' printCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3598
	 OperatingSystem exit
20851
0c3beab2ee41 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20850
diff changeset
  3599
     ].
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  3600
     'Parent t=' print. (Timestamp now - t1) printCR.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3601
    "
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3602
! !
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3603
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3604
!UnixOperatingSystem class methodsFor:'executing OS commands-queries'!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3605
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3606
commandAndArgsForOSCommand:aCommandStringOrArray
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3607
    "get a shell and shell arguments for command execution.
21201
427801203eb7 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21199
diff changeset
  3608
     If aCommandStringOrArray is a String, the commandString is passed to a shell for execution
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3609
     - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
21201
427801203eb7 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21199
diff changeset
  3610
     If aCommandStringOrArray is an Array, the first element is the command to be executed,
21199
ea098c7c7ac2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21187
diff changeset
  3611
     and the other elements are the arguments to the command. No shell is invoked in this case.
ea098c7c7ac2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21187
diff changeset
  3612
     The third element is nil - here for windows compatibility (showWindow in windows)"
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3613
22976
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3614
    |sh|
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3615
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3616
    aCommandStringOrArray isNonByteCollection ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3617
	"if an array is passed, the command string has already been parsed an no shell is invoked"
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3618
	^ Array with:aCommandStringOrArray first with:aCommandStringOrArray with:nil "dummy showWindow".
22976
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3619
    ].
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3620
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3621
    sh := self defaultShell.
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3622
21513
d4ae772134ba #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21498
diff changeset
  3623
    aCommandStringOrArray isEmptyOrNil ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3624
	"start a shell reading commands from stdin"
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3625
	^ Array with:sh with:#() with:nil "dummy showWindow".
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3626
    ].
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3627
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3628
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3629
    "/ '/bin/sh -c <command>'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3630
    "/
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3631
    ^ Array with:sh
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3632
	    with:(Array with:sh
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3633
			with:'-c'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3634
			with:aCommandStringOrArray)
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3635
	    with:nil "dummy showWindow".
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3636
21513
d4ae772134ba #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21498
diff changeset
  3637
    "Modified: / 20-01-1998 / 16:57:19 / md"
d4ae772134ba #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21498
diff changeset
  3638
    "Modified: / 05-06-1998 / 17:40:48 / cg"
d4ae772134ba #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21498
diff changeset
  3639
    "Modified: / 21-02-2017 / 18:40:07 / stefan"
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3640
!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3641
22976
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3642
defaultShell
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3643
    "the default shell to use for OS commands.
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3644
     If the DefaultShell variable is set, that one is used;
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3645
     otherwise, the SHELL environment variable;
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3646
     if that is not set, /bin/sh is used as fallback"
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3647
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3648
    DefaultShell isNil ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3649
	DefaultShell := self getEnvironment:'SHELL'.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  3650
    ].
22976
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3651
    ^ DefaultShell ? '/bin/sh'
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3652
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3653
    "
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3654
     self defaultShell
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3655
    "
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3656
!
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3657
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3658
defaultShell:aPathStringOrNil
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3659
    "the default shell to use for OS commands.
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3660
     If the DefaultShell variable is non-nil, that one is used;
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3661
     otherwise, the SHELL environment variable;
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3662
     if that is not set, /bin/sh is used as fallback"
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3663
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3664
    DefaultShell := aPathStringOrNil
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3665
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3666
    "
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3667
     self defaultShell:nil.
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3668
     self defaultShell.
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3669
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3670
     self defaultShell:'/bin/sh'.
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3671
     self defaultShell.
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3672
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3673
    "
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3674
!
ff8f2476519a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22968
diff changeset
  3675
11046
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3676
nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3677
    "return the name of the running ST/X executable program.
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3678
     Usually, 'stx' is returned -
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3679
     but may be different for standAlone apps (or winstx.exe)."
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3680
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3681
    |info path|
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3682
15206
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3683
    "shortcut - use the /proc filesystem (if present).
20456
b87283a19b7f #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20455
diff changeset
  3684
     Here we get an absolute path to the running executable.
b87283a19b7f #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20455
diff changeset
  3685
     Notice: we cannot depend on /proc to be present (actually only is on linux)"
14376
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  3686
    info := '/proc/self/exe' asFilename linkInfo.
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  3687
    info notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3688
	path := info path.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3689
	path notEmptyOrNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3690
	    ^ path
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3691
	].
14376
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  3692
     ].
11046
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3693
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3694
    "Fall back - do it the hard way"
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3695
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3696
    ^ super nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3697
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3698
    "
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3699
     OperatingSystem nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3700
    "
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3701
!
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3702
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3703
pathOfCommand:aCommand
20456
b87283a19b7f #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20455
diff changeset
  3704
    "find where aCommand's executable file would be searched for if executed by a shell.
b87283a19b7f #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20455
diff changeset
  3705
     Return nil if aCommand is either absolute, or relative and not executable,
b87283a19b7f #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20455
diff changeset
  3706
     or not executable is found along the PATH."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3707
9078
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3708
    |path f fExt commandFilename|
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3709
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3710
    commandFilename := aCommand asFilename.
9078
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3711
    commandFilename isAbsolute ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3712
	"/ something like "/foo/...", tried path is it
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3713
	commandFilename isExecutable ifFalse:[^ nil].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3714
	^ commandFilename pathName
9078
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3715
    ].
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3716
    commandFilename isExplicitRelative ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3717
	"/ something like "../foo/...", tried path resolved relative to the current directory
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3718
	commandFilename isExecutable ifFalse:[^ nil].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3719
	 ^ commandFilename pathName
17681
8894d153e26a class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17637
diff changeset
  3720
    ].
8894d153e26a class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17637
diff changeset
  3721
    (aCommand includes:$/) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3722
	"/ something like "smalltalk/stx", tried path is relative to the current directory
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3723
	(f := ('./',aCommand) asFilename) isExecutable ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3724
	    ^ f pathName
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3725
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3726
	^ nil
3496
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
20455
893fe6053faf #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20454
diff changeset
  3729
    "/ command is a single word, not relative and not absolute.
20710
0d1ee9d4446c #DOCUMENTATION by mawalch
mawalch
parents: 20707
diff changeset
  3730
    "/ search along PATH environment variable to see what a shell would do.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3731
    path := self getEnvironment:'PATH'.
14370
66a4b9c492b9 Fixed: bad definition of MAXPATHLEN from PATH_MAX
Stefan Vogel <sv@exept.de>
parents: 13801
diff changeset
  3732
    path notEmptyOrNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3733
	(path asCollectionOfSubstringsSeparatedBy:self pathSeparator) do:[:eachPathComponent |
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3734
	    eachPathComponent isEmpty ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3735
		f := commandFilename
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3736
	    ] ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3737
		f := eachPathComponent asFilename construct:aCommand.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3738
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3739
	    self executableFileExtensions do:[:eachExtension |
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3740
		eachExtension notEmpty ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3741
		    fExt := f addSuffix:eachExtension.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3742
		] ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3743
		    fExt := f.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3744
		].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3745
		fExt isExecutable ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3746
		    ^ fExt pathName
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3747
		].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3748
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3749
	].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3750
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3751
    ^ nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3752
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3753
    "unix:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3754
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3755
     OperatingSystem pathOfCommand:'fooBar'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3756
     OperatingSystem pathOfCommand:'ls'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3757
     OperatingSystem pathOfCommand:'cvs'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3758
     OperatingSystem pathOfCommand:'stx'
9078
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3759
     OperatingSystem pathOfCommand:'./stx'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3760
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3761
    "windows:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3762
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3763
     OperatingSystem pathOfCommand:'windbg'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3764
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3765
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3766
    "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
  3767
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3768
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3769
!UnixOperatingSystem class methodsFor:'file access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3770
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3771
closeFd:anInteger
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3772
    "low level close of a filedescriptor"
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
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3775
     if (__isSmallInteger(anInteger)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3776
	if (@global(ExternalStream:FileOpenTrace) == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3777
	    fprintf(stderr, "close [UnixOp] fd=%d\n", (int)__intVal(anInteger));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3778
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3779
	close(__intVal(anInteger));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3780
	RETURN(self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3781
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3782
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3783
     ^ self primitiveFailed.
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3784
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3785
    "
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3786
     10 to:400 do:[:fd | OperatingSystem closeFd:fd]
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3787
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3788
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3789
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3790
copyFromFd:inFd toFd:outFd startIndex:startIdx count:count
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3791
    "directly copy from one Fd to another (if supported by the OS)"
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3792
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3793
%{
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3794
#if defined(HAS_SENDFILE)
21044
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  3795
# include <sys/sendfile.h>
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  3796
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3797
     if (__isSmallInteger(inFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3798
      && __isSmallInteger(outFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3799
      && __isSmallInteger(startIdx)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3800
      && __isSmallInteger(count)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3801
	off_t startOffset = __intVal(startIdx);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3802
	ssize_t nWritten;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3803
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3804
	nWritten = sendfile(__intVal(outFd), __intVal(inFd), &startOffset, __intVal(count));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3805
	if (nWritten < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3806
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3807
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3808
	RETURN (__mkSmallInteger(nWritten));
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3809
     }
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3810
#endif
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3811
%}.
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3812
    ^ 0 "/ not supported
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3813
!
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3814
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3815
createDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3816
    "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
  3817
     path, or relative to the current directory.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3818
     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
  3819
     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
  3820
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3821
    ^ self createDirectory:aPathName withAccess:((self getEnvironment:'UMASK') ? 8r0755)
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3822
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3823
    "
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3824
     OperatingSystem createDirectory:'foo'
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3825
    "
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3826
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3827
    "Modified: 20.12.1995 / 11:24:13 / stefan"
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3828
    "Modified: 29.6.1996 / 14:06:54 / cg"
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3829
!
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3830
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3831
createDirectory:aPathName withAccess:umask
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3832
    "create a new directory with name 'aPathName', which may be an absolute
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3833
     path, or relative to the current directory.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3834
     Return nil if successful (or the directory existed already), an OsErrorHolder otherwise.
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3835
     This is a low-level entry - use Filename protocol for compatibility."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3836
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3837
    |encodedPathName error|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3838
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3839
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3840
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3841
%{
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3842
    if (__isStringLike(encodedPathName) && __isSmallInteger(umask)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3843
	if (mkdir(__stringVal(encodedPathName), __smallIntegerVal(umask)) >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3844
	    RETURN(nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3845
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3846
	error = __mkSmallInteger(errno);
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3847
    }
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3848
%}.
11547
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3849
    "/ could not create - if it already existed this is ok
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3850
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3851
    (self isDirectory:aPathName) ifTrue:[^ nil].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3852
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3853
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3854
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3855
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3856
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3857
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3858
    ^ self primitiveFailed
11547
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3859
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3860
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3861
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3862
     OperatingSystem createDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3863
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3864
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3865
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3866
createFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3867
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3868
    ^ self open:pathName attributes:#(O_RDWR O_CREAT O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3869
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3870
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3871
createFileForReadWrite:pathName
19675
fdf7f3ecf889 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19669
diff changeset
  3872
    "open a file for reading and writing, return an os specific fileHandle."
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3873
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3874
    ^ 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
  3875
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3876
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3877
createFileForWrite:pathName
19675
fdf7f3ecf889 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19669
diff changeset
  3878
    "create a file for writing, return an os specific fileHandle."
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3879
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3880
    ^ self open:pathName attributes:#(O_WRONLY O_CREAT O_TRUNC) mode:nil
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3881
!
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3882
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3883
createHardLinkFrom:oldPath to:newPath
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3884
    "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
  3885
     Return true if successful, false if not."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3886
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3887
    |encodedOldPathName encodedNewPathName error|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3888
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3889
    encodedOldPathName := self encodePath:oldPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3890
    encodedNewPathName := self encodePath:newPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3891
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3892
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3893
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3894
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3895
    if (__isStringLike(encodedOldPathName) && __isStringLike(encodedNewPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3896
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3897
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3898
	    ret = link((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3899
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3900
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3901
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3902
	    RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3903
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3904
	error = __mkSmallInteger(errno);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3905
    }
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3906
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3907
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3908
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3909
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3910
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3911
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3912
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3913
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3914
    "/ bad argument(s) given
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3915
    "/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3916
    ^ self primitiveFailed
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3917
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3918
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3919
     OperatingSystem linkFile:'foo' to:'bar'
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3920
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3921
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3922
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3923
createSymbolicLinkFrom:oldPath to:newPath
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3924
    "make a symbolic link for 'newPath' to the file 'oldPath'.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3925
     The link will be a soft (symbolic) link.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3926
     Answer nil on success and an OSErrorHolder on error."
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3927
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3928
    |encodedOldPathName encodedNewPathName error|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3929
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3930
    encodedOldPathName := self encodePath:oldPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3931
    encodedNewPathName := self encodePath:newPath.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3932
%{
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3933
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3934
    int ret;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3935
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3936
    if (__isStringLike(encodedOldPathName) && __isStringLike(encodedNewPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3937
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3938
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3939
	    ret = symlink((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3940
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3941
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3942
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3943
	    RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3944
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3945
	error = __mkSmallInteger(errno);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3946
    }
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3947
#endif
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3948
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3949
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3950
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3951
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3952
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3953
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3954
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3955
    (encodedOldPathName isString not or:[encodedNewPathName isString not]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3956
	"/
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3957
	"/ bad argument(s) given
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3958
	"/
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3959
	^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3960
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3961
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3962
    "/
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3963
    "/ 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
  3964
    "/
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  3965
    ^ OSErrorHolder unsupportedOperation
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3966
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3967
    "
17146
e28137456d48 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17116
diff changeset
  3968
     OperatingSystem createSymbolicLinkFrom:'foo' to:'/tmp/bar'
e28137456d48 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17116
diff changeset
  3969
     OperatingSystem createSymbolicLinkFrom:'foo' to:'/bla/bar'
3496
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
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3973
open:path attributes:attributes mode:modeInteger
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3974
    "open a file, return an os specific fileHandle.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3975
     openmode is a symbol defining the way to open
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3976
     valid modes are:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3977
	#O_RDONLY
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3978
	#O_RDWR
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3979
	#O_WRONLY
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3980
	#O_CREAT
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3981
	#O_APPEND
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3982
	#O_SYNC
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  3983
	#O_LARGEFILE
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3984
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3985
     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
  3986
     which is proprietrary to the operatingSystem."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3987
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3988
    |error fileDescriptor encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3989
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3990
    encodedPathName := self encodePath:path.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3991
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3992
%{
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3993
    OBJ *ap;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3994
    int nAttributes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3995
    int fd;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3996
    int mode, openFlags = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3997
    int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3998
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3999
    if (!__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4000
	error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4001
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4002
    }
8934
32a063645991 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  4003
    if (!__isArrayLike(attributes)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4004
	error = @symbol(badArgument2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4005
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4006
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4007
    if (modeInteger == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4008
	mode = 0644;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4009
    } else if (__isSmallInteger(modeInteger)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4010
	mode = __intVal(modeInteger);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4011
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4012
	error = @symbol(badArgument3);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4013
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4014
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4015
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4016
    nAttributes = __arraySize(attributes);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4017
    for (n = 0, ap = __arrayVal(attributes); n < nAttributes; n++) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4018
	OBJ attribute = ap[n];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4019
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4020
	if (attribute == @symbol(O_RDONLY)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4021
	    openFlags |= O_RDONLY;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4022
	} else if (attribute == @symbol(O_RDWR)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4023
	    openFlags |= O_RDWR;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4024
	} else if (attribute == @symbol(O_WRONLY)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4025
	    openFlags |= O_WRONLY;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4026
	} else if (attribute == @symbol(O_CREAT)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4027
	    openFlags |= O_CREAT;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4028
	} else if (attribute == @symbol(O_APPEND)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4029
	    openFlags |= O_APPEND;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4030
	} else if (attribute == @symbol(O_EXCL)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4031
	    openFlags |= O_EXCL;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4032
	} else if (attribute == @symbol(O_TRUNC)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4033
	    openFlags |= O_TRUNC;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4034
	} else if (attribute == @symbol(O_LARGEFILE)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4035
#ifdef O_LARGEFILE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4036
	    openFlags |= O_LARGEFILE;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4037
#else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4038
	    error = @symbol(badArgument2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4039
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4040
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4041
	} else if (attribute == @symbol(O_SYNC)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4042
#ifdef O_SYNC
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4043
	    openFlags |= O_SYNC;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4044
#else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4045
	    error = @symbol(badArgument2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4046
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4047
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4048
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4049
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4050
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4051
#if defined(O_NONBLOCK)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4052
    openFlags |= O_NONBLOCK;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  4053
#elif defined(O_NDELAY)
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4054
    openFlags |= O_NDELAY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4055
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4056
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4057
again:
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4058
    fd = open((char *) __stringVal(encodedPathName), openFlags, mode);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4059
    if (fd < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4060
	if (errno == EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4061
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4062
	    goto again;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4063
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4064
	    error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4065
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4066
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4067
    }
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  4068
    fileDescriptor = __mkSmallInteger(fd);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4069
err:;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4070
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4071
    ^ fileDescriptor notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4072
	FileDescriptorHandle for:fileDescriptor.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4073
    ] ifFalse:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4074
	(self errorHolderForNumber:error) reportError
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4075
    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4076
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4077
    "
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4078
	self open:'/etc/hosts' attributes:#(O_RDONLY) mode:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4079
	self open:'/tmp/xxzz' attributes:#(O_RDWR O_CREAT) mode:8r611
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4080
	self open:'/etc/passwd' attributes:#(O_RDWR) mode:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4081
	self open:'/no one knows this file' attributes:#(O_RDONLY) mode:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4082
	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
  4083
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4084
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4085
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4086
openFileForAppend:pathName
19675
fdf7f3ecf889 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19669
diff changeset
  4087
    "open a file for appending, return an os specific fileHandle."
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4088
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4089
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4090
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4091
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4092
openFileForRead:pathName
19675
fdf7f3ecf889 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19669
diff changeset
  4093
    "open a file for reading, return an os specific fileHandle."
20296
3a064b47bacf compiler warning eliminated
Claus Gittinger <cg@exept.de>
parents: 20257
diff changeset
  4094
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4095
    ^ self open:pathName attributes:#(O_RDONLY) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4096
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4097
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4098
openFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4099
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4100
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4101
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4102
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4103
openFileForReadWrite:pathName
19675
fdf7f3ecf889 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19669
diff changeset
  4104
    "open a file for reading and writing, return an os specific fileHandle."
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4105
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4106
    ^ self open:pathName attributes:#(O_RDWR)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4107
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4108
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4109
openFileForWrite:pathName
19675
fdf7f3ecf889 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19669
diff changeset
  4110
    "open a file for writing, return an os specific fileHandle."
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4111
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4112
    ^ self open:pathName attributes:#(O_WRONLY)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4113
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4114
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4115
recursiveCopyDirectory:sourcePathName to:destination
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4116
    "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
  4117
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4118
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  4119
    ^ self executeCommand:(Array with:'/bin/cp' with:'-af' with:sourcePathName with:destination)
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  4120
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  4121
    "
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4122
	self recursiveCopyDirectory:'packages' to:'foo'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4123
	self recursiveRemoveDirectory:'foo'.
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  4124
    "
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4125
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4126
    "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
  4127
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4128
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4129
recursiveRemoveDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4130
    "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
  4131
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4132
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  4133
    ^ self executeCommand:(Array with:'/bin/rm' with:'-rf' with:fullPathName)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4134
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4135
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4136
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4137
     OperatingSystem recursiveRemoveDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4138
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4139
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4140
    "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
  4141
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4142
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4143
removeDirectory:fullPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4144
    "remove the directory named 'fullPathName'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4145
     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
  4146
     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
  4147
     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
  4148
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4149
    |encodedPathName error|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4150
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4151
    encodedPathName := self encodePath:fullPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4152
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4153
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4154
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4155
    if (__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4156
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4157
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4158
	    ret = rmdir((char *) __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4159
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4160
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4161
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4162
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4163
	    RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4164
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4165
	error = __mkSmallInteger(errno);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4166
    }
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4167
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4168
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4169
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4170
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4171
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4172
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4173
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4174
    "/
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4175
    "/ either not a string argument
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4176
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4177
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4179
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4180
     OperatingSystem createDirectory:'foo'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4181
     OperatingSystem removeDirectory:'foo'
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4185
removeFile:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4186
    "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
  4187
     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
  4188
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4189
    |encodedPathName error|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4190
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4191
    encodedPathName := self encodePath:fullPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4192
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4193
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4194
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4195
    if (__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4196
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4197
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4198
	    ret = unlink((char *) __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4199
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4200
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4201
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4202
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4203
	    RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4204
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4205
	error = __mkSmallInteger(errno);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4206
    }
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4207
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4208
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4209
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4210
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4211
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4212
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4213
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4214
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4215
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4216
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4217
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4218
renameFile:oldPath to:newPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4219
    "rename the file 'oldPath' to 'newPath'.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4220
     Someone else has to care for the names to be correct and
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4221
     correct for the OS used - therefore, this should not be called
11798
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  4222
     directly. Instead, use Filename protocol to rename; this cares for
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4223
     any invalid names.
21044
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  4224
     Returns nil if successful, an OsErrorHolder if not"
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  4225
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  4226
    |encodedOldPathName encodedNewPathName error|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4227
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4228
    encodedOldPathName := self encodePath:oldPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4229
    encodedNewPathName := self encodePath:newPath.
3496
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
    int ret, eno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4232
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4233
    if (__isStringLike(encodedOldPathName) && __isStringLike(encodedNewPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4234
#if defined(HAS_RENAME)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4235
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4236
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4237
	    ret = rename((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4238
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4239
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4240
#else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4241
	ret = link((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4242
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4243
	    ret = unlink((char *) __stringVal(encodedOldPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4244
	    if (ret < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4245
		eno = errno;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4246
		unlink((char *) __stringVal(encodedNewPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4247
		errno = eno;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4248
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4249
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4250
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4251
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4252
	    RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4253
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4254
	error = __mkSmallInteger(errno);
21044
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  4255
    }
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  4256
%}.
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  4257
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  4258
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4259
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4260
	^ self errorHolderForNumber:error.
21044
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  4261
    ].
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  4262
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4263
    ^ self primitiveFailed
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4266
     OperatingSystem renameFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4267
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4268
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4269
17148
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4270
sync
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4271
    "sync all the filesystems"
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4272
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4273
%{
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4274
    sync();
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4275
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4276
    ^ nil
17148
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4277
!
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4278
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4279
syncFileSystem:handle
18494
41f8a86105f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18415
diff changeset
  4280
    <resource: #glibc (#'2.14')>
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4281
    "sync the filesystem where the file represented by handle resides"
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4282
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4283
%{
18494
41f8a86105f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18415
diff changeset
  4284
// macosx does not support syncfs
41f8a86105f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18415
diff changeset
  4285
// ... and we need to be compatible with GLIBC 2.12 (RedHat 6)
41f8a86105f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18415
diff changeset
  4286
// so disable it for now.
18495
c123b1d33222 mac osx compilability - again (sigh)
Claus Gittinger <cg@exept.de>
parents: 18494
diff changeset
  4287
#if 0
c123b1d33222 mac osx compilability - again (sigh)
Claus Gittinger <cg@exept.de>
parents: 18494
diff changeset
  4288
# if defined(LINUX)
c123b1d33222 mac osx compilability - again (sigh)
Claus Gittinger <cg@exept.de>
parents: 18494
diff changeset
  4289
#  if __GLIBC_PREREQ(2, 14)
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4290
    if (__isSmallInteger(handle)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4291
	if (syncfs(__intVal(handle)) == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4292
	    RETURN(self);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4293
	}
18494
41f8a86105f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18415
diff changeset
  4294
    }
18495
c123b1d33222 mac osx compilability - again (sigh)
Claus Gittinger <cg@exept.de>
parents: 18494
diff changeset
  4295
#  endif
c123b1d33222 mac osx compilability - again (sigh)
Claus Gittinger <cg@exept.de>
parents: 18494
diff changeset
  4296
# endif
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4297
#endif
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4298
%}.
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4299
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4300
    "fallback is to do a global sync"
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4301
    self sync.
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4302
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4303
    "
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  4304
     '/etc/passwd' asFilename readStream syncFileSystem
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4305
    "
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4306
!
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4307
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4308
truncateFile:aPathName to:newSize
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4309
    "change a files size return nil on success, an OSErrorHolder on failure.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4310
     This may not be supported on all architectures.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4311
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4312
     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
  4313
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4314
    |encodedPathName error|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4315
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4316
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4317
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4318
%{
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4319
#if defined(HAS_TRUNCATE) || defined(HAS_FTRUNCATE)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4320
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4321
    off_t truncateSize;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4322
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4323
    if (!__isStringLike(encodedPathName))
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4324
	goto getOutOfHere;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4325
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4326
    if (__isSmallInteger(newSize)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4327
	truncateSize = __intVal(newSize);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4328
	if (truncateSize < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4329
	    goto getOutOfHere;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4330
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4331
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4332
	truncateSize = __signedLongIntVal(newSize);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4333
	if (truncateSize < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4334
	    goto getOutOfHere;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4335
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4336
	if (truncateSize == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4337
	    if (sizeof(truncateSize) == 8) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4338
		if (__signedLong64IntVal(newSize, &truncateSize) == 0 || truncateSize < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4339
		    goto getOutOfHere;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4340
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4341
	    } else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4342
		goto getOutOfHere;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4343
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4344
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4345
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4346
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4347
#if defined(HAS_TRUNCATE)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4348
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4349
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4350
	    ret = truncate((char *) __stringVal(encodedPathName), truncateSize);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4351
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4352
	__END_INTERRUPTABLE__
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4353
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4354
#elif defined(HAS_FTRUNCATE)
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4355
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4356
	int fd;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4357
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4358
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4359
	    fd = ret = open((char *) __stringVal(encodedPathName), 2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4360
	} while (fd < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4361
	if (fd >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4362
	    ret = ftruncate(fd, truncateSize);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4363
	    close(fd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4364
	}
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4365
    }
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4366
#endif /* HAS_FTRUNCATE */
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4367
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4368
	    RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4369
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4370
	error = __mkSmallInteger(errno);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4371
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4372
getOutOfHere:;
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4373
#else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4374
	error = __mkSmallInteger(ENOTSUP);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4375
#endif
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4376
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4377
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4378
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4379
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4380
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4381
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4382
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4383
    ^ self primitiveFailed
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4384
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4385
    "
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4386
	self truncateFile:'foo' to:2222222
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4387
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4388
! !
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
!UnixOperatingSystem class methodsFor:'file access rights'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4391
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4392
accessMaskFor:aSymbol
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4393
    "return the access bits mask for numbers as returned by
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4394
     OperatingSystem>>accessModeOf:
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4395
     and expected by OperatingSystem>>changeAccessModeOf:to:.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4396
     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
  4397
     (never hardcode 8rxxx into your code)."
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4400
#   ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4401
    /* posix systems should define these ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4402
#    define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4403
#    define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4404
#    define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4405
#    define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4406
#    define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4407
#    define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4408
#    define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4409
#    define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4410
#    define S_IXOTH 0001
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4411
#    define S_ISUID 04000
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4412
#    define S_ISGID 02000
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4413
#    define S_ISVTX 01000
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4414
#   endif
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
    if (aSymbol == @symbol(readUser)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4417
	RETURN ( __mkSmallInteger(S_IRUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4418
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4419
    if (aSymbol == @symbol(writeUser)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4420
	RETURN ( __mkSmallInteger(S_IWUSR) );
3496
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
    if (aSymbol == @symbol(executeUser)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4423
	RETURN ( __mkSmallInteger(S_IXUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4424
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4425
    if (aSymbol == @symbol(readGroup)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4426
	RETURN ( __mkSmallInteger(S_IRGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4427
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4428
    if (aSymbol == @symbol(writeGroup)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4429
	RETURN ( __mkSmallInteger(S_IWGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4430
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4431
    if (aSymbol == @symbol(executeGroup)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4432
	RETURN ( __mkSmallInteger(S_IXGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4433
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4434
    if (aSymbol == @symbol(readOthers)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4435
	RETURN ( __mkSmallInteger(S_IROTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4436
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4437
    if (aSymbol == @symbol(writeOthers)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4438
	RETURN ( __mkSmallInteger(S_IWOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4439
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4440
    if (aSymbol == @symbol(executeOthers)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4441
	RETURN ( __mkSmallInteger(S_IXOTH) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4442
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4443
    if (aSymbol == @symbol(setUid)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4444
	RETURN ( __mkSmallInteger(S_ISUID) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4445
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4446
    if (aSymbol == @symbol(setGid)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4447
	RETURN ( __mkSmallInteger(S_ISGID) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4448
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4449
    if (aSymbol == @symbol(removeOnlyByOwner)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4450
	RETURN ( __mkSmallInteger(S_ISVTX) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4451
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4452
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4453
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4454
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4455
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4456
     OperatingSystem accessMaskFor:#readUser
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4457
     OperatingSystem accessMaskFor:#removeOnlyByOwner
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4458
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4459
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4460
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4461
accessModeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4462
    "return a number representing access rights rwxrwxrwx for owner,
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4463
     group and others. Return an OSErrorHolder if such a file does not exist.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4464
     Notice that the returned number is OS dependent - use the
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4465
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4466
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4467
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4468
     this could have been implemented as:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4469
	(self infoOf:aPathName) at:#mode
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4470
     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
  4471
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4472
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4473
    |encodedPathName error|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4474
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4475
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4476
%{
19045
179b8a549b5b e_largeFile64
Claus Gittinger <cg@exept.de>
parents: 19044
diff changeset
  4477
    struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4478
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4479
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4480
    if (__isStringLike(encodedPathName)) {
19044
318352c827d7 option to use stat64 instead f stat (-DUSE_STAT64)
Claus Gittinger <cg@exept.de>
parents: 18923
diff changeset
  4481
#ifdef TRACE_STAT_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4482
	printf("stat on '%s' for accessMode\n", __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4483
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4484
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4485
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4486
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4487
	} while ((ret < 0) && (errno == EINTR));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4488
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4489
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4490
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4491
	    RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4492
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4493
	error = __mkSmallInteger(errno);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4494
    }
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4495
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4496
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4497
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4498
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4499
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4500
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4501
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4502
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4503
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4504
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4505
    (OperatingSystem accessModeOf:'/') printStringRadix:8
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4506
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4507
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4508
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4509
accessModeOfFd:aFileDescriptor
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4510
    "return a number representing access rights rwxrwxrwx for owner,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4511
     group and others. Return nil if such a file does not exist.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4512
     Notice that the returned number is OS dependent - use the
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4513
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4514
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4515
    |error|
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4516
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4517
%{
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4518
    struct stat buf;
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4519
    int ret;
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4520
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4521
    if (__isSmallInteger(aFileDescriptor)) {
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4522
# ifdef TRACE_STAT_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4523
	printf("fstat on '%d' for accessMode\n", __smallIntegerVal(aFileDescriptor));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4524
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4525
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4526
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4527
	    ret = fstat(__smallIntegerVal(aFileDescriptor), &buf);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4528
	} while ((ret < 0) && (errno == EINTR));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4529
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4530
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4531
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4532
	    RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4533
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4534
	error = __mkSmallInteger(errno);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4535
    }
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4536
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4537
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4538
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4539
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4540
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4541
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4542
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4543
    ^ self primitiveFailed
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4544
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4545
   "
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4546
    '/' asFilename readingFileDo:[:s|
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4547
	(OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4548
    ].
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4549
   "
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4550
!
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4551
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4552
changeAccessModeOf:aPathName to:modeBits
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4553
    "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
  4554
     You should construct this mask using accessMaskFor, to be OS
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4555
     independent. Return nil if changed,
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4556
     anOSErrorHolder if such a file does not exist or change was not allowd."
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4557
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4558
    |encodedPathName error|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4559
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4560
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4561
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4562
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4563
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4564
    if (__isStringLike(encodedPathName) && __isSmallInteger(modeBits)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4565
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4566
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4567
	    ret = chmod((char *)__stringVal(encodedPathName), __intVal(modeBits));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4568
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4569
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4570
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4571
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4572
	    RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4573
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4574
	error = __mkSmallInteger(errno);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4575
    }
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4576
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4577
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4578
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4579
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4580
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4581
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4582
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4583
    ^ self primitiveFailed
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4584
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4585
    "
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4586
	self changeAccessModeOf:'foo' to:8r666
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4587
    "
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4588
!
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4589
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4590
changeAccessModeOfFd:aFileDescriptor to:modeBits
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4591
    "change the access rights of the file referenced by aFileDescriptor
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4592
     to the OS dependent modeBits.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4593
     You should construct this mask using accessMaskFor, to be OS
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4594
     independent. Return nil if changed,
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4595
     an OSErrorHolder if such a file does not exist or change was not allowed."
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4596
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4597
    |error|
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4598
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4599
%{
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4600
    int ret;
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4601
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4602
    if (__isSmallInteger(aFileDescriptor) && __isSmallInteger(modeBits)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4603
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4604
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4605
	    ret = fchmod(__smallIntegerVal(aFileDescriptor), __intVal(modeBits));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4606
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4607
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4608
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4609
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4610
	    RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4611
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4612
	error = __mkSmallInteger(errno);
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4613
    }
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4614
%}.
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4615
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4616
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4617
	LastErrorNumber := error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4618
	^ self errorHolderForNumber:error.
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4619
    ].
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4620
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4621
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4622
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4623
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4624
!UnixOperatingSystem class methodsFor:'file locking'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4625
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4626
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4627
   "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
  4628
    (such as returned by ExternalStream>>fileDescriptor).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4629
    On some systems, only advisory locks are available -
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4630
    these depends on other accessors to also perform the locking operation.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4631
    If they do not, they may still access the file
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4632
    (on some systems, locks are mandatory, on others, they are advisory).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4633
    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
  4634
    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
  4635
    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
  4636
20125
ae67288913e3 #OTHER by mawalch
mawalch
parents: 20103
diff changeset
  4637
    Returns true, if the lock was acquired, false otherwise.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4638
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4639
    Notice, that not all OS's support these locks;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4640
    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
  4641
    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
  4642
    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
  4643
    argument."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4644
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4645
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4646
    if (__isSmallInteger(aFileDescriptor)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4647
	int fd = __intVal(aFileDescriptor);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4648
	int lockArg;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4649
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4650
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4651
	 * claus: sigh - each one has a different interface ...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4652
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4653
#if defined(F_SETLK)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4654
	{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4655
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4656
	     * new fcntl(SETLK) interface;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4657
	     * available on SYSV4 and Linux
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4658
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4659
	    struct flock flock;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4660
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4661
	    if (isSharedReadLock == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4662
		flock.l_type = F_RDLCK;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4663
	    } else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4664
		flock.l_type = F_WRLCK;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4665
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4666
	    flock.l_whence = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4667
	    flock.l_start = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4668
	    flock.l_len = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4669
	    lockArg = F_SETLK;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4670
# if defined(F_SETLKW)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4671
	    if (blockIfLocked == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4672
		lockArg = F_SETLKW;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4673
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4674
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4675
	    if (fcntl(fd, lockArg, &flock) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4676
		RETURN (true);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4677
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4678
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4679
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4680
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4681
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4682
# if defined(LOCK_EX) && defined(LOCK_UN)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4683
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4684
	 * BSD 4.3 advisory locks
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4685
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4686
	lockArg = LOCK_EX;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4687
#  if defined(LOCK_SH)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4688
	if (isSharedReadLock == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4689
	    lockArg = LOCK_SH
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4690
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4691
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4692
#  if defined(LOCK_NB)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4693
	if (blockIfLocked == false) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4694
	    lockArg |= LOCK_NB;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4695
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4696
#  endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4697
	if (flock(fd, lockArg) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4698
	    RETURN (true);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4699
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4700
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4701
# else /* no flock available */
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
#  if defined(F_LOCK) && defined(F_UNLOCK)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4704
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4705
	 * SYSV3 advisory locks
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4706
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4707
	if (lockf(fd, F_LOCK, 0) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4708
	    RETURN (true);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4709
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4710
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4711
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4712
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4713
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4714
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4715
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4716
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4717
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4718
supportsFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4719
    "return true, if the OS supports file locking"
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
%{ /* NOCONTEXT */
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4722
#if defined(F_SETLK) || (defined(LOCK_EX) && defined(LOCK_UN)) || defined(F_LOCK) && defined(F_UNLOCK)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4723
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4724
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4725
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4726
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4728
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4729
     OperatingSystem supportsFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4730
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4731
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4732
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4733
supportsNonBlockingFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4734
    "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
  4735
     (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
  4736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4737
%{ /* NOCONTEXT */
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  4738
#if (defined(F_SETLK) && defined(F_SETLKW)) || (defined(LOCK_EX) && defined(LOCK_UN) && defined(LOCK_NB))
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4739
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4740
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4741
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4742
    ^ false
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4745
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4746
    "
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4749
supportsSharedLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4750
    "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
  4751
     file locking."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4752
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4753
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4754
#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
  4755
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4756
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4757
# 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
  4758
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4759
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4760
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4761
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4762
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4763
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4764
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4765
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4766
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4767
!
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
unlockFD:aFileDescriptor
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4770
    "clear a file lock on the file represented by aFileDescriptor,
20125
ae67288913e3 #OTHER by mawalch
mawalch
parents: 20103
diff changeset
  4771
     which was previously acquired by #lockFD:.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4772
     Return false, if the unlock failed
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4773
     (which may happens when a wrong fd is passed,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4774
      no lock was set previously, or the systsem does not support locks).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4775
     Notice, that not all OS's support file locks;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4776
     on some, this may simply be a no-op."
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4777
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4778
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4779
    if (__isSmallInteger(aFileDescriptor)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4780
	int fd = __intVal(aFileDescriptor);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4781
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4782
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4783
	 * claus: sigh - each one has a different interface ...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4784
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4785
#if defined(F_SETLK)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4786
	{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4787
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4788
	     * new fcntl(SETLK) interface;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4789
	     * available on SYSV4 and Linux
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4790
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4791
	    struct flock flock;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4792
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4793
	    flock.l_type = F_UNLCK;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4794
	    flock.l_whence = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4795
	    flock.l_start = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4796
	    flock.l_len = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4797
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4798
		RETURN (true);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4799
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4800
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4801
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4802
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4803
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4804
# if defined(LOCK_EX) && defined(LOCK_UN)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4805
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4806
	 * BSD 4.3 advisory locks
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4807
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4808
	if (flock(fd, LOCK_UN) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4809
	    RETURN (true);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4810
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4811
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4812
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4813
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4814
#  if defined(F_LOCK) && defined(F_UNLOCK)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4815
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4816
	 * SYSV3 advisory locks
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4817
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4818
	if (lockf(fd, F_UNLOCK, 0) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4819
	    RETURN (true);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4820
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4821
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4822
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4823
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4824
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4825
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4826
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4827
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4828
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4829
!UnixOperatingSystem class methodsFor:'file queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4830
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4831
caseSensitiveFilenames
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4832
    "return true, if the OS has caseSensitive file naming.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4833
     On MSDOS, this will return false;
19816
3f33539e9113 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19765
diff changeset
  4834
     on a real OS, we return true.
3f33539e9113 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19765
diff changeset
  4835
     Be aware, that some OSs can be configured to be either.
3f33539e9113 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19765
diff changeset
  4836
     Also, that it actually depends on the mounted volume"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4837
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  4838
    "/ actually, this is wrong and may depend on the mounted volume;
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  4839
    "/ so we need a query for a particular directory (and/or volume).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4840
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4841
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4842
    "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
  4843
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4844
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4845
compressPath:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4846
    "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
  4847
     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
  4848
     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
  4849
     if realPath and popen failed."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4850
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4851
    |names n "{ Class: SmallInteger }" |
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4852
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4853
    names := pathName
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4854
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4855
    names := names asOrderedCollection.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4856
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4857
     cut off initial double-slashes
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4858
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4859
    [names startsWith:#('' '')] whileTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4860
	names removeFirst.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4861
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4862
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4863
     cut off double-slashes at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4864
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4865
    [names endsWith:#('')] whileTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4866
	names removeLast.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4867
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4868
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4869
     cut off current-dir at beginning
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4870
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4871
    n := names size.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4872
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4873
	names removeFirst.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4874
	n := n - 1.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4875
    ].
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4878
     cut off parent-dirs at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4879
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4880
    [(n > 2)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4881
     and:[(names endsWith:#('..'))
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4882
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4883
	names removeLast; removeLast.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4884
	n := n - 2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4885
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4886
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4887
    ^ names asStringWith:self fileSeparator
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4888
		    from:1
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4889
		    to:n
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4890
		    compressTabs:false final:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4891
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4892
    "
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4893
     OperatingSystem compressPath:'./..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4894
     OperatingSystem compressPath:'/foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4895
     OperatingSystem compressPath:'foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4896
     OperatingSystem compressPath:'foo/bar/baz/../'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4897
     OperatingSystem compressPath:'foo/bar/baz/..///'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4898
     OperatingSystem compressPath:'///foo/bar/baz/..///'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4899
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4900
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4901
    "Modified: 1.11.1996 / 20:13:48 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4902
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4903
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4904
fileSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4905
    "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
  4906
     This character differs for MSDOS and other systems,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4907
     (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
  4908
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4909
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4910
    ^ $/
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4911
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4912
    "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
  4913
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4914
13110
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4915
getCurrentDirectory
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4916
    "return the name of the current directory"
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4917
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  4918
    |ret path|
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  4919
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  4920
    ret := self primGetCurrentDirectory.
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  4921
    ret isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4922
	self primitiveFailed
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  4923
    ].
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  4924
    path := self decodePath:ret.    "/ possibly decode from UTF8 (depending on the OS)
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4925
    CurrentDirectory := path.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4926
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4927
    ^ path.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4928
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4929
    "
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  4930
	self getCurrentDirectory
13110
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4931
    "
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4932
!
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4933
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4934
getDiskInfoOf:aDirectoryPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4935
    "return some disk info.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4936
     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
  4937
     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
  4938
     On unix, the information returned is (at least):
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  4939
	freeBytes
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  4940
	totalBytes
16580
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4941
    "
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4942
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4943
    |outputText keys values n info
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4944
     fileSystemIdx sizeIdx usedIdx availIdx capacityIdx mountIdx|
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4945
23607
093a6127d215 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23599
diff changeset
  4946
    outputText := PipeStream outputFromCommand:('PATH=/bin:/usr/bin df -k ''', aDirectoryPath, '''').
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4947
    outputText isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4948
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4949
    outputText := outputText asCollectionOfLines.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4950
    outputText size < 2 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4951
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4952
    keys := (outputText at:1) asLowercase asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4953
    values := (outputText at:2) asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4954
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4955
    "/ 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
  4956
    "/ on some rude Unix versions ...
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4957
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4958
    fileSystemIdx := 1.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4959
    sizeIdx := 2.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4960
    usedIdx := 3.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4961
    availIdx := 4.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4962
    capacityIdx := 5.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4963
    mountIdx := 6.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4964
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4965
    values size < 6 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4966
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4967
    info := IdentityDictionary new.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4968
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4969
    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
  4970
    n notNil ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  4971
	info at:#percentUsed put:n
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4972
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4973
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4974
    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
  4975
    n notNil ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  4976
	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
  4977
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4978
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4979
    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
  4980
    n notNil ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  4981
	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
  4982
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4983
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4984
    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
  4985
    n notNil ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  4986
	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
  4987
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4988
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4989
    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
  4990
    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
  4991
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4992
    ^ info
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4993
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4994
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4995
     OperatingSystem getDiskInfoOf:'/'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4996
     OperatingSystem getDiskInfoOf:'.'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4997
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4998
22275
ba5cf8f80436 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22269
diff changeset
  4999
    "Modified: / 22-05-1999 / 00:32:13 / cg"
ba5cf8f80436 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22269
diff changeset
  5000
    "Modified: / 21-09-2017 / 11:09:15 / stefan"
23607
093a6127d215 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23599
diff changeset
  5001
    "Modified: / 16-01-2019 / 17:06:45 / Stefan Vogel"
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  5002
!
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  5003
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5004
getMountedVolumes
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5005
    "return info about mounted volumes.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5006
     The amount of information returned depends upon the OS, and is
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5007
     not guaranteed to be consistent across architectures.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5008
     On unix, the information returned is (at least):
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5009
	mountPoint - mount point
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5010
	fileSystem - device or NFS-remotePath
16580
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  5011
    "
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  5012
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  5013
    |outputText keys values info infoEntry|
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  5014
23607
093a6127d215 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23599
diff changeset
  5015
    outputText := PipeStream outputFromCommand:('PATH=/bin:/usr/bin df -k').
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5016
    outputText isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5017
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5018
    outputText := outputText asCollectionOfLines.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5019
    outputText size < 2 ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5020
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5021
    keys := (outputText at:1) asLowercase asCollectionOfWords.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5022
    "/ we may have to validate the following column indices
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5023
    "/ on some rude Unix versions ...
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5024
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5025
    info := OrderedCollection new.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5026
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5027
    outputText from:2 do:[:line |
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5028
	values := line asCollectionOfWords.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5029
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5030
	values size >= 2 ifTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5031
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5032
	    infoEntry := IdentityDictionary new.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5033
	    infoEntry at:#mountPoint put:(values last).
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5034
	    infoEntry at:#fileSystem put:(values first).
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5035
	    info add:infoEntry.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5036
	]
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5037
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5038
    ^ info
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5039
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5040
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5041
     OperatingSystem getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5042
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5043
22275
ba5cf8f80436 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22269
diff changeset
  5044
    "Modified: / 22-05-1999 / 00:32:13 / cg"
ba5cf8f80436 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22269
diff changeset
  5045
    "Modified: / 21-09-2017 / 11:09:25 / stefan"
23607
093a6127d215 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23599
diff changeset
  5046
    "Modified: / 16-01-2019 / 17:03:35 / Stefan Vogel"
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5047
!
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  5048
4201
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  5049
getNullDevice
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  5050
    "return the name of the OS's null device"
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  5051
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  5052
    ^ '/dev/null'
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  5053
!
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  5054
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5055
getObjectFileInfoFor:aStringOrFilename
20665
e9ecf9afbe0b #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20609
diff changeset
  5056
    "Return an info object for a given executable or shared object
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5057
     or throw an error if given file is not a valid an executable now
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5058
     shared object.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5059
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5060
     The info object returned is OS-specific, however it responds to at
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5061
     least
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5062
	#isFor32BitArchitecture
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5063
	#isFor64BitArchitecture ... returns true, if the given object is for
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5064
				     32bit, 64bit architecture respectively
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5065
    "
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5066
    ^ ELFFileHeader fromFile: aStringOrFilename
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5067
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5068
    "Created: / 17-03-2015 / 20:52:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5069
!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  5070
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5071
infoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5072
    "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
  5073
     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
  5074
     the returned object) is:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5075
	 type            - a symbol giving the files type
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5076
	 mode            - numeric access mode
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5077
	 uid             - owners user id
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5078
	 gid             - owners group id
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5079
	 size            - files size
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5080
	 id              - files number (i.e. inode number)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5081
	 accessed        - last access time (as Timestamp)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5082
	 modified        - last modification time (as Timestamp)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5083
	 statusChanged   - last status change time (as Timestamp)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5084
	 alternativeName     - (windows only:) the MSDOS name of the file
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5085
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5086
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5087
	 recordAttributes    - (VMS only:) recordAttributes
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5088
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5089
	 recordSize          - (VMS only:) record size.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5090
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5091
     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
  5092
     all of the information.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5093
     Return nil if such a file does not exist.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5094
     For symbolic links (if supported by the OS),
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5095
     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
  5096
     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
  5097
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5098
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5099
    |type mode uid gid size id nLink aOStime mOStime cOStime error encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5100
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5101
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5102
%{
19045
179b8a549b5b e_largeFile64
Claus Gittinger <cg@exept.de>
parents: 19044
diff changeset
  5103
    struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5104
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5105
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5106
    if (!__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5107
	error = @symbol(badArgument);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5108
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5109
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5110
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5111
# ifdef TRACE_STAT_CALLS
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5112
    printf("stat on '%s' for info\n", __stringVal(aPathName));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5113
# endif
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5114
    __BEGIN_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5115
    do {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5116
	ret = stat((char *) __stringVal(encodedPathName), &buf);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5117
    } while ((ret < 0) && (errno == EINTR));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5118
    __END_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5119
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5120
    if (ret < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5121
	error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5122
	@global(LastErrorNumber) = error;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5123
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5124
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5125
    switch (buf.st_mode & S_IFMT) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5126
	case S_IFDIR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5127
	    type = @symbol(directory);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5128
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5129
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5130
	case S_IFREG:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5131
	    type = @symbol(regular);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5132
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5133
# ifdef S_IFCHR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5134
	case S_IFCHR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5135
	    type = @symbol(characterSpecial);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5136
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5137
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5138
# ifdef S_IFBLK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5139
	case S_IFBLK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5140
	    type = @symbol(blockSpecial);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5141
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5142
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5143
# ifdef S_IFMPC
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5144
	case S_IFMPC:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5145
	    type = @symbol(multiplexedCharacterSpecial);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5146
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5147
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5148
# ifdef S_IFMPB
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5149
	case S_IFMPB:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5150
	    type = @symbol(multiplexedBlockSpecial);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5151
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5152
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5153
# ifdef S_IFLNK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5154
	case S_IFLNK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5155
	    type = @symbol(symbolicLink);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5156
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5157
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5158
# ifdef S_IFSOCK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5159
	case S_IFSOCK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5160
	    type = @symbol(socket);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5161
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5162
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5163
# ifdef S_IFIFO
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5164
	case S_IFIFO:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5165
	    type = @symbol(fifo);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5166
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5167
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5168
	default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5169
	    type = @symbol(unknown);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5170
	    break;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5171
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5172
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5173
    if (sizeof(buf.st_ino) == 8) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5174
	id = __MKUINT64(&buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5175
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5176
	id = __MKUINT(buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5177
    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5178
    mode = __mkSmallInteger(buf.st_mode & 0777);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5179
    uid = __mkSmallInteger(buf.st_uid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5180
    gid = __mkSmallInteger(buf.st_gid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5181
    nLink = __mkSmallInteger(buf.st_nlink);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5182
    if (sizeof(buf.st_size) == 8) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5183
	size = __MKINT64(&buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5184
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5185
	size = __MKINT(buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5186
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5187
    aOStime = __MKUINT(buf.st_atime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5188
    mOStime = __MKUINT(buf.st_mtime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5189
    cOStime = __MKUINT(buf.st_ctime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5190
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5191
    out:;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5192
%}.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5193
     mode notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5194
	"/ now done lazy in FileStatusInfo
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5195
	"/ atime := Timestamp fromOSTime:(aOStime * 1000).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5196
	"/ mtime := Timestamp fromOSTime:(mOStime * 1000).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5197
	"/ ctime := Timestamp fromOSTime:(cOStime * 1000).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5198
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5199
	^ FileStatusInfo
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5200
		    type:type
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5201
		    mode:mode
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5202
		    uid:uid
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5203
		    gid:gid
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5204
		    size:size
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5205
		    id:id
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5206
		    accessed:aOStime
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5207
		    modified:mOStime
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5208
		    statusChanged:cOStime
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5209
		    sourcePath:nil targetPath:nil
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5210
		    numLinks:nLink.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5211
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5212
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5213
	^ nil.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5214
    ].
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5215
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5216
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5217
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5218
   "
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5219
    OperatingSystem infoOf:'/ccccccc'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5220
    (OperatingSystem infoOf:'/') uid
7889
5e96f8cdf9aa Fix comment
Stefan Vogel <sv@exept.de>
parents: 7886
diff changeset
  5221
    (OperatingSystem infoOf:'/') accessTime
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5222
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5223
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5224
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5225
isDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5226
    "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
  5227
     (i.e. exists and is a directory).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5228
     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
  5229
     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
  5230
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5231
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5232
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5233
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5234
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5235
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5236
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5237
    if (encodedPathName.isStringLike()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5238
	java.io.File file = new java.io.File( encodedPathName.asString() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5239
	int _mode;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5240
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5241
	if (file.exists() && file.isDirectory()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5242
	    return __c__._RETURN_true();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5243
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5244
	return __c__._RETURN_false();
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5245
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5246
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5247
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5248
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5249
    if (__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5250
	struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5251
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5252
# ifdef TRACE_STAT_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5253
	printf("stat on '%s' for isDirectory\n", __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5254
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5255
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5256
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5257
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5258
	} while ((ret < 0) && (errno == EINTR));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5259
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5260
	if (ret < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5261
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5262
	    RETURN ( false );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5263
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5264
	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
  5265
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5266
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5267
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5268
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5269
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5270
    "an alternative implementation would be:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5271
	^ (self infoOf:aPathName) type == #directory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5272
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5273
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5274
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5275
isExecutable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5276
    "return true, if the given file is executable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5277
     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
  5278
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5279
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5280
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5281
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5282
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5283
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5284
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5285
    if (encodedPathName.isStringLike()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5286
	java.io.File file = new java.io.File( encodedPathName.asString() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5287
	int _mode;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5288
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5289
	if (file.exists() && file.canExecute()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5290
	    return __c__._RETURN_true();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5291
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5292
	return __c__._RETURN_false();
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5293
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5294
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5295
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5296
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5297
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5298
# ifdef TRACE_ACCESS_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5299
	printf("access on '%s' for executable\n", __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5300
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5301
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5302
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5303
	    ret = access(__stringVal(encodedPathName), X_OK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5304
	} while ((ret < 0) && (errno == EINTR));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5305
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5306
	if (ret < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5307
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5308
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5309
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5310
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5311
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5312
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5313
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5314
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5315
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5316
isReadable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5317
    "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
  5318
     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
  5319
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5320
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5321
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5322
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5323
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5324
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5325
    if (encodedPathName.isStringLike()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5326
	java.io.File file = new java.io.File( encodedPathName.asString() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5327
	int _mode;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5328
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5329
	if (file.exists() && file.canRead()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5330
	    return __c__._RETURN_true();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5331
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5332
	return __c__._RETURN_false();
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5333
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5334
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5335
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5336
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5337
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5338
# ifdef TRACE_ACCESS_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5339
	printf("access on '%s' for readable\n", __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5340
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5341
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5342
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5343
	    ret = access(__stringVal(encodedPathName), R_OK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5344
	} while ((ret < 0) && (errno == EINTR));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5345
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5346
	if (ret < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5347
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5348
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5349
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5350
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5351
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5352
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5353
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5354
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5355
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5356
isValidPath:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5357
    "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
  5358
     (i.e. the file or directory exists)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5359
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5360
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5361
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5362
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5363
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5364
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5365
    if (encodedPathName.isStringLike()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5366
	java.io.File file = new java.io.File( encodedPathName.asString() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5367
	int _mode;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5368
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5369
	if (file.exists()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5370
	    return __c__._RETURN_true();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5371
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5372
	return __c__._RETURN_false();
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5373
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5374
#else
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5375
    if (__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5376
	struct stat buf;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5377
	int ret;
19044
318352c827d7 option to use stat64 instead f stat (-DUSE_STAT64)
Claus Gittinger <cg@exept.de>
parents: 18923
diff changeset
  5378
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5379
# ifdef TRACE_STAT_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5380
	printf("stat on '%s' for isValidPath\n", __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5381
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5382
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5383
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5384
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5385
	} while ((ret < 0) && (errno == EINTR));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5386
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5387
	if (ret < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5388
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5389
	    RETURN (false);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5390
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5391
	RETURN ( ret ? false : true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5392
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5393
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5394
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5395
    ^ self primitiveFailed
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5396
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5397
"/ alternative:
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5398
"/        ^ (self infoOf:aPathName) notNil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5399
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5401
isWritable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5402
    "return true, if the given file is writable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5403
     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
  5404
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5405
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5406
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5407
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5408
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5409
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5410
    if (encodedPathName.isStringLike()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5411
	java.io.File file = new java.io.File( encodedPathName.asString() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5412
	int _mode;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5413
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5414
	if (file.exists() && file.canWrite()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5415
	    return __c__._RETURN_true();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5416
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5417
	return __c__._RETURN_false();
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5418
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5419
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5420
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5421
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5422
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5423
# ifdef TRACE_ACCESS_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5424
	printf("access on '%s' for writable\n", __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5425
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5426
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5427
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5428
	    ret = access(__stringVal(encodedPathName), W_OK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5429
	} while ((ret < 0) && (errno == EINTR));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5430
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5431
	if (ret < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5432
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5433
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5434
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5435
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5436
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5437
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5438
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5439
!
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
linkInfoOf:aPathName
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  5442
    "return some object filled with info for the file 'aPathName'.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5443
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5444
     The info (for which corresponding access methods are understood by
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5445
     the returned object) is:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5446
	 type            - a symbol giving the file's type
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5447
	 mode            - numeric access mode
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5448
	 uid             - owners user id
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5449
	 gid             - owners group id
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5450
	 size            - files size
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5451
	 id              - files number (i.e. inode number)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5452
	 accessed        - last access time (as Timestamp)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5453
	 modified        - last modification time (as Timestamp)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5454
	 statusChanged   - last status change time (as Timestamp)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5455
	 alternativeName     - (windows only:) the MSDOS name of the file
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5456
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5457
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5458
	 recordAttributes    - (VMS only:) recordAttributes
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5459
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5460
	 recordSize          - (VMS only:) record size.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5461
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5462
     Some of the fields may be returned as nil on systems which do not provide
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5463
     all of the information.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5464
15250
c73ad268f7f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15234
diff changeset
  5465
     If aPathName is invalid, nil is returned.
c73ad268f7f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15234
diff changeset
  5466
     If aPathName is NOT a symbolic link, the #infoOf: aPathname itself is returned.
c73ad268f7f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15234
diff changeset
  5467
     (which means, that systems like VMS or MSDOS always return the info here.)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5468
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5469
     Return the info about the link itself,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5470
     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
  5471
     in case of a symbolic link."
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5472
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5473
    |type mode uid gid size id nLink aOStime mOStime cOStime path encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5474
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5475
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5476
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5477
%{  /* STACK: 1200 */
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5478
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5479
    if (encodedPathName.isStringLike()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5480
	java.io.File file = new java.io.File( encodedPathName.asString() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5481
	int _mode;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5482
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5483
	if (file.isDirectory()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5484
	    type = STSymbol._new("directory");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5485
	} else if (file.isFile()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5486
	    type = STSymbol._new("regular");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5487
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5488
	    type = STSymbol._new("unknown");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5489
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5490
	_mode = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5491
	if (file.canRead()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5492
	    _mode |= 0444;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5493
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5494
	if (file.canWrite()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5495
	    _mode |= 0222;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5496
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5497
	if (file.canExecute()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5498
	    _mode |= 0111;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5499
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5500
	mode = STInteger._new( _mode );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5501
	uid = STInteger._0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5502
	gid = STInteger._0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5503
	nLink = STInteger._0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5504
	size = STInteger._new( file.length());
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5505
	aOStime = STInteger._new( file.lastModified() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5506
	mOStime = STInteger._new( file.lastModified() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5507
	cOStime = STInteger._new( file.lastModified() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5508
	path = new STString( file.getPath() );
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5509
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5510
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5511
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5512
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5513
    char pathBuffer[1024];
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5514
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5515
    if (__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5516
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5517
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5518
	    ret = lstat((char *) __stringVal(encodedPathName), &buf);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5519
	} while ((ret < 0) && (errno == EINTR));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5520
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5521
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5522
	if (ret < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5523
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5524
	    RETURN ( nil );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5525
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5526
	switch (buf.st_mode & S_IFMT) {
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5527
# ifdef S_IFLNK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5528
	    case S_IFLNK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5529
		type = @symbol(symbolicLink);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5530
		if ((ret = readlink((char *) __stringVal(encodedPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5531
		    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5532
		    RETURN ( nil );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5533
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5534
		pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5535
		path = __MKSTRING(pathBuffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5536
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5537
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5538
	    case S_IFDIR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5539
		type = @symbol(directory);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5540
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5541
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5542
	    case S_IFREG:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5543
		type = @symbol(regular);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5544
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5545
# ifdef S_IFCHR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5546
	    case S_IFCHR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5547
		type = @symbol(characterSpecial);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5548
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5549
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5550
# ifdef S_IFBLK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5551
	    case S_IFBLK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5552
		type = @symbol(blockSpecial);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5553
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5554
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5555
# ifdef S_IFMPC
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5556
	    case S_IFMPC:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5557
		type = @symbol(multiplexedCharacterSpecial);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5558
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5559
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5560
# ifdef S_IFMPB
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5561
	    case S_IFMPB:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5562
		type = @symbol(multiplexedBlockSpecial);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5563
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5564
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5565
# ifdef S_IFSOCK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5566
	    case S_IFSOCK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5567
		type = @symbol(socket);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5568
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5569
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5570
# ifdef S_IFIFO
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5571
	    case S_IFIFO:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5572
		type = @symbol(fifo);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5573
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5574
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5575
	    default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5576
		type = @symbol(unknown);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5577
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5578
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5579
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5580
	if (sizeof(buf.st_ino) == 8) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5581
	    id = __MKUINT64(&buf.st_ino);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5582
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5583
	    id = __MKUINT(buf.st_ino);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5584
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5585
	mode = __mkSmallInteger(buf.st_mode & 0777);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5586
	uid = __mkSmallInteger(buf.st_uid);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5587
	gid = __mkSmallInteger(buf.st_gid);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5588
	nLink = __mkSmallInteger(buf.st_nlink);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5589
	if (sizeof(buf.st_size) == 8) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5590
	    size = __MKINT64(&buf.st_size);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5591
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5592
	    size = __MKINT(buf.st_size);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5593
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5594
	aOStime = __MKUINT(buf.st_atime);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5595
	mOStime = __MKUINT(buf.st_mtime);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5596
	cOStime = __MKUINT(buf.st_ctime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5597
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5598
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5599
%}.
14563
466905625978 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14435
diff changeset
  5600
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5601
    mode notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5602
	^ FileStatusInfo
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5603
	    type:type
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5604
	    mode:mode
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5605
	    uid:uid
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5606
	    gid:gid
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5607
	    size:size
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5608
	    id:id
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5609
	    accessed:aOStime
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5610
	    modified:mOStime
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5611
	    statusChanged:cOStime
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5612
	    sourcePath:aPathName targetPath:(self decodePath:path)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5613
	    numLinks:nLink.
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
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5616
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5617
   "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5618
    OperatingSystem infoOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5619
    OperatingSystem linkInfoOf:'Make.proto'
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  5620
    OperatingSystem linkInfoOf:'/usr/tmp'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5621
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5622
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5623
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5624
mountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5625
    "return a collection of mountPoints (aka. topDirectories of mounted file systems).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5626
     As this might be expensive on some systems,
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5627
     the info is cached for some time (5 minutes)"
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5628
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5629
    CacheMountPointsTimeStamp notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5630
	Timestamp now < (CacheMountPointsTimeStamp addSeconds:5*60) ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5631
	    ^ CachedMountPoints
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5632
	].
8735
531252ebbbe3 Fix a race in #mountPoints
Stefan Vogel <sv@exept.de>
parents: 8705
diff changeset
  5633
    ].
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5634
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5635
    '/proc/mounts' asFilename exists ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5636
	CachedMountPoints := self mountPointsFromProcFS.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5637
	CacheMountPointsTimeStamp := Timestamp now.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5638
	^ CachedMountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5639
    ].
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5640
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5641
    "/ TODO: add fallback code for other OS's (i.e. reading /etc/mtab)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5642
    ^ #()
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5643
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5644
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5645
     OperatingSystem mountPoints
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5646
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5647
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5648
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5649
parentDirectoryName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5650
    "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
  5651
     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
  5652
     for other systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5653
     (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
  5654
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5655
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5656
    ^ '..'
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
16678
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5659
pathNameForDrive:driveName
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5660
    "given a drive name, return the pathname to open it as a directory.
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5661
     For Windows, this is the driveName itself.
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5662
     For OSX, '/Volumes' is prepended.
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5663
     Other OSs might prepent the pount point (i.e. /mnt/)"
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5664
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5665
    ^ driveName
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5666
!
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5667
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5668
pathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5669
    "return the pathName of the argument, aPathString,
20431
f41652a5b64a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20382
diff changeset
  5670
     - that's the full pathname of the directory, starting at '/'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5671
     This method needs the path to be valid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5672
     (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
  5673
     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
  5674
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5675
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5676
    |p path command|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5677
23206
e291c84f8f11 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22976
diff changeset
  5678
    pathName = '.' ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5679
	^ self getCurrentDirectory.
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5680
    ].
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5681
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5682
    "some systems have a convenient function for this ..."
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5683
    path := self primPathNameOf:(self encodePath:pathName).
14575
c696ca8d05bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14568
diff changeset
  5684
    path notNil ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5685
	path := self decodePath:path.
14575
c696ca8d05bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14568
diff changeset
  5686
    ] ifFalse:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5687
	(self isValidPath:pathName) ifFalse:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5688
	    p := pathName.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5689
	    [(p size > 1)
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5690
	     and:[p endsWith:(self fileSeparator)]
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5691
	    ] whileTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5692
		p := p copyButLast.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5693
	    ].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5694
	    ^ p
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5695
	].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5696
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5697
	(SlowFork==true or:[PipeFailed==true]) ifFalse:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5698
	    |directoryName fileBaseName|
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5699
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5700
	    (self isDirectory:pathName) ifTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5701
		directoryName := pathName.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5702
		fileBaseName := nil.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5703
	    ] ifFalse:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5704
		|pathFilename|
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5705
		pathFilename := pathName asFilename.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5706
		directoryName := pathFilename directoryName.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5707
		fileBaseName := pathFilename baseName.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5708
	    ].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5709
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5710
	    PipeStream openErrorSignal handle:[:ex |
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5711
		PipeFailed := true.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5712
		'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5713
		ex return.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5714
	    ] do:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5715
		"have to fall back ..."
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5716
		command := 'cd "' , directoryName , '"; pwd'.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5717
		p := PipeStream readingFrom:command.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5718
	    ].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5719
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5720
	    (p isNil or:[p atEnd]) ifTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5721
		('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5722
	    ] ifFalse:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5723
		path := p nextLine.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5724
		p close.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5725
	    ].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5726
	    fileBaseName notNil ifTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5727
		path := path, '/', fileBaseName.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5728
	    ].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5729
	].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5730
	path isNil ifTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5731
	    "/
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5732
	    "/ return the original - there is nothing else can we do
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5733
	    "/
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5734
	    path := pathName
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5735
	].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5736
	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5737
	    path := self compressPath:path
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5738
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5739
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5740
    ^ path.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5741
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5742
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5743
     OperatingSystem pathNameOf:'.'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5744
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5745
     OperatingSystem pathNameOf:'../../..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5746
     OperatingSystem pathNameOf:'..'
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5747
     OperatingSystem pathNameOf:'/tmp////'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5748
     OperatingSystem pathNameOf:'/foo/bar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5749
     OperatingSystem pathNameOf:'/foo/bar/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5750
     OperatingSystem pathNameOf:'/foo/bar//'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5751
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5752
23206
e291c84f8f11 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22976
diff changeset
  5753
    "Modified: / 29-11-1996 / 18:02:12 / stefan"
e291c84f8f11 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22976
diff changeset
  5754
    "Modified: / 05-06-1998 / 18:37:15 / cg"
e291c84f8f11 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22976
diff changeset
  5755
    "Modified: / 12-07-2018 / 18:48:57 / Claus Gittinger"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5756
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5757
14584
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5758
primGetCurrentDirectory
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5759
    "return the raw name of the current directory (nil if failed - can this ever happen?).
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5760
     Warning:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5761
	Don't call this from outside: we may have to decode UTF on some systems.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5762
	See getCurrentDirectory"
14584
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5763
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5764
%{  /* UNLIMITEDSTACK */
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5765
    char nameBuffer[MAXPATHLEN + 1];
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5766
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5767
    if (getcwd(nameBuffer, MAXPATHLEN)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5768
	OBJ path = __MKSTRING(nameBuffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5769
	RETURN(path);
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5770
    }
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5771
    RETURN(nil);
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5772
%}
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5773
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5774
    "
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  5775
     self primGetCurrentDirectory
14584
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5776
    "
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5777
!
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5778
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5779
primIdOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5780
    "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
  5781
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5782
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5783
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5784
    encodedPathName := self encodePath:aPathName.
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  5785
%{
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5786
    if (__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5787
	struct stat buf;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5788
	unsigned INT ino;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5789
	OBJ retVal;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5790
	int ret;
19044
318352c827d7 option to use stat64 instead f stat (-DUSE_STAT64)
Claus Gittinger <cg@exept.de>
parents: 18923
diff changeset
  5791
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5792
# ifdef TRACE_STAT_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5793
	printf("stat on '%s' for id\n", __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5794
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5795
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5796
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5797
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5798
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5799
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5800
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5801
	    ino = buf.st_ino;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5802
	    retVal = __MKUINT(ino);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5803
	    RETURN (retVal);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5804
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5805
	@global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5806
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5807
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5808
    RETURN (nil);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5809
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5810
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5811
5492
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5812
primInfoOf:aPathName
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5813
   "for rel5 only"
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5814
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5815
   ^ self primitiveFailed
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5816
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5817
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5818
!
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5819
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5820
primPathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5821
    "return the pathName of the argument, aPathString,
20431
f41652a5b64a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20382
diff changeset
  5822
     - that's the full pathname of the directory, starting at '/'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5823
     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
  5824
     realPath library function.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5825
     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
  5826
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5827
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5828
    |error|
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5829
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  5830
%{  /* UNLIMITEDSTACK */
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5831
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5832
    if (pathName.isStringLike()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5833
	java.io.File file = new java.io.File( pathName.asString() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5834
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5835
	if (file.exists()) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5836
	    return __c__._RETURN( new STString( file.getAbsolutePath() ));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5837
	}
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5838
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5839
#else
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5840
    if (__isStringLike(pathName)) {
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5841
# ifdef HAS_REALPATH
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5842
	extern char *realpath();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5843
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5844
	// POSIX-2008 says, that a NULL namebuffer causes realPath to malloc()
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5845
	// the required memory. But this does not work as of 2013-04
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5846
	char nameBuffer[MAXPATHLEN+1];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5847
	char *nameP = realpath(__stringVal(pathName), nameBuffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5848
	if (nameP) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5849
	    OBJ ret = __MKSTRING(nameP);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5850
	    // free(nameP);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5851
	    RETURN ( ret );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5852
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5853
	// fprintf(stderr, "stx[warning]: realpath(\"%s\") failed: %s\n", __stringVal(pathName), strerror(errno));
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5854
# endif /* ! HAS_REALPATH */
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5855
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5856
	error = @symbol(argument);     // argument is not a string
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5857
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5858
#endif
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5859
%}.
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5860
"/ Does not work as of 2013-04 (UNLIMITEDSTACK problem?)
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5861
"/    error notNil ifTrue:[
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5862
"/        ^ self primitiveFailed:error.
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5863
"/    ].
5451
2e21cd54b656 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5448
diff changeset
  5864
    ^ nil
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5865
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5866
    "
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5867
	self primPathNameOf:'.'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5868
	self primPathNameOf:'/murks/quatsch/bla/.'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5869
	self primPathNameOf:5555
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5870
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5871
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5872
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5873
timeOfLastAccess:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5874
    "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
  5875
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5876
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5877
    "could be implemented as:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5878
	(self infoOf:aPathName) accessed
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5879
    "
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5880
    |osSeconds i encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5881
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5882
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5883
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5884
%{
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5885
    if (__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5886
	struct stat buf;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5887
	time_t mtime;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5888
	int ret;
19044
318352c827d7 option to use stat64 instead f stat (-DUSE_STAT64)
Claus Gittinger <cg@exept.de>
parents: 18923
diff changeset
  5889
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5890
# ifdef TRACE_STAT_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5891
	printf("stat on '%s' for timeOfLastAccess\n", __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5892
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5893
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5894
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5895
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5896
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5897
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5898
	if (ret < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5899
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5900
	    RETURN (nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5901
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5902
	osSeconds = __MKUINT(buf.st_atime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5903
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5904
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5905
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
3496
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
    i := self infoOf:aPathName.
19573
661541c56e08 #REFACTORING by mawalch
mawalch
parents: 19434
diff changeset
  5908
    i notNil ifTrue:[^ i accessTime].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5909
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5910
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5911
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5912
     OperatingSystem timeOfLastAccess:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5913
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5914
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5915
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5916
timeOfLastChange:aPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5917
    "return the time, when the file was last changed.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5918
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5919
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5920
    "could be implemented as:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5921
	(self infoOf:aPathName) modified
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5922
    "
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5923
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5924
    |osSeconds i encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5925
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5926
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5927
%{
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5928
    if (__isStringLike(encodedPathName)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5929
	struct stat buf;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5930
	int ret;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5931
	time_t mtime;
19044
318352c827d7 option to use stat64 instead f stat (-DUSE_STAT64)
Claus Gittinger <cg@exept.de>
parents: 18923
diff changeset
  5932
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5933
# ifdef TRACE_STAT_CALLS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5934
	printf("stat on '%s' for timeOfLastChange\n", __stringVal(encodedPathName));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5935
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5936
	__BEGIN_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5937
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5938
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5939
	} while (ret < 0 && errno == EINTR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5940
	__END_INTERRUPTABLE__
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5941
	if (ret < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5942
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5943
	    RETURN ( nil );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5944
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  5945
	osSeconds = __MKUINT(buf.st_mtime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5946
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5947
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5948
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5949
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5950
    i := self infoOf:aPathName.
19573
661541c56e08 #REFACTORING by mawalch
mawalch
parents: 19434
diff changeset
  5951
    i notNil ifTrue:[^ i modificationTime].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5952
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5953
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5954
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5955
     OperatingSystem timeOfLastChange:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5956
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5957
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5958
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5959
typeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5960
    "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
  5961
     nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5962
     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
  5963
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5964
    |i osSeconds encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5965
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5966
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5967
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5968
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5969
     this could have been implemented as:
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5970
	(self infoOf:aPathName) type
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5971
     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
  5972
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5973
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5974
%{
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5975
    if (__isStringLike(encodedPathName)) {
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5976
	struct stat buf;
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5977
	int ret;
19044
318352c827d7 option to use stat64 instead f stat (-DUSE_STAT64)
Claus Gittinger <cg@exept.de>
parents: 18923
diff changeset
  5978
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5979
# ifdef TRACE_STAT_CALLS
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5980
	printf("stat on '%s' for type\n", __stringVal(encodedPathName));
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5981
# endif
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5982
	__BEGIN_INTERRUPTABLE__
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5983
	do {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5984
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5985
	} while (ret < 0 && errno == EINTR);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5986
	__END_INTERRUPTABLE__
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5987
	if (ret < 0) {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5988
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5989
	    RETURN ( nil );
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5990
	}
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5991
	switch (buf.st_mode & S_IFMT) {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5992
	    case S_IFDIR:
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5993
		RETURN ( @symbol(directory) );
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5994
	    case S_IFREG:
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5995
		RETURN ( @symbol(regular) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5996
# ifdef S_IFCHR
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5997
	    case S_IFCHR:
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  5998
		RETURN ( @symbol(characterSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5999
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6000
# ifdef S_IFBLK
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6001
	    case S_IFBLK:
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6002
		RETURN ( @symbol(blockSpecial) );
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 S_IFLNK
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6005
	    case S_IFLNK:
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6006
		// we get this only for symbolic links not pointing to a file
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6007
		RETURN ( @symbol(symbolicLink) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6008
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6009
# ifdef S_IFSOCK
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6010
	    case S_IFSOCK:
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6011
		RETURN ( @symbol(socket) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6012
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6013
# ifdef S_IFIFO
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6014
	    case S_IFIFO:
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6015
		RETURN ( @symbol(fifo) );
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6016
# endif
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6017
	    default:
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6018
		RETURN ( @symbol(unknown) );
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6019
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6020
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6021
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6022
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6023
    i notNil ifTrue:[^ i type].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6024
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6025
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6026
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6027
     OperatingSystem typeOf:'/'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6028
     OperatingSystem typeOf:'.'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6029
     OperatingSystem typeOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6030
     OperatingSystem typeOf:'resources/motif.style'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6031
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6032
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6033
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6034
volumeNameOf:aPathString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6035
    "return the volumeName of the argument, aPath
20431
f41652a5b64a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20382
diff changeset
  6036
     - that's the name of the volume where aPath is.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6037
     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
  6038
     this always returns an empty string."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6039
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6040
    ^ ''
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6041
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6042
    "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
  6043
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6044
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6045
!UnixOperatingSystem class methodsFor:'interrupts & signals'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6046
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6047
defaultSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6048
    "revert to the default action on arrival of a (Unix-)signal.
20814
035cfc0c970b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20710
diff changeset
  6049
     Don't confuse Unix signals with smalltalk signals.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6050
     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
  6051
     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
  6052
     default for SIGQUIT (^ \) is to dump core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6053
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6054
     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
  6055
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6056
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6057
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6058
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6059
    if (__isSmallInteger(signalNumber)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6060
#ifdef SIG_DFL
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6061
	signal(__intVal(signalNumber), SIG_DFL);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6062
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6063
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6064
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6065
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6066
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6067
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6068
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6069
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6070
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6071
    "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
  6072
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6073
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6074
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6075
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6076
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6077
     'normal ^C handling again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6078
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6079
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6080
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6081
disableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6082
    "turn off IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6083
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6084
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6085
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6086
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6087
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6088
#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
  6089
    if (__isSmallInteger(fd)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6090
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6091
# if defined(SYSV4)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6092
	ret = ioctl(f, I_SETSIG, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6093
# else /*! SYSV4*/
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6094
	flags = fcntl(f, F_GETFL, 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6095
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6096
	 * if already clear, there is no need for this syscall ...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6097
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6098
	if (flags & FASYNC) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6099
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6100
	    if (ret >= 0) ret = flags;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6101
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6102
	    ret = flags;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6103
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6104
# endif /* !SYSV4 */
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6105
	RETURN ( __mkSmallInteger(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6106
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6107
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6108
%}.
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
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6111
     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
  6112
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6113
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6114
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6115
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6116
disableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6117
    "disable (Unix-) signal processing for signalNumber.
20814
035cfc0c970b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20710
diff changeset
  6118
     Don't confuse Unix signals with smalltalk signals.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6119
     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
  6120
     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
  6121
     handling.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6122
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6123
     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
  6124
     a signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6125
     Use only for fully debugged stand alone applications."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6126
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6127
%{  /* NOCONTEXT */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6128
#ifdef __SCHTEAM__
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6129
    if (signalNumber.isSmallInteger()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6130
	int sigNo = signalNumber.intValue();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6131
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6132
	if (sigNo != 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6133
	    java.lang.System.err.println("ignored disable-signal: "+sigNo);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6134
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6135
	return context._RETURN(self);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6136
    }
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6137
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6138
    if (__isSmallInteger(signalNumber)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6139
	int sigNo = __intVal(signalNumber);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6140
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6141
	if (sigNo == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6142
	    RETURN (self);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6143
	}
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6144
# ifdef SIG_IGN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6145
	signal(sigNo, SIG_IGN);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6146
	RETURN (self);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6147
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6148
    }
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6149
#endif
3496
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
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6153
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6154
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6155
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6156
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6157
     'now, ^C is totally ignored ...' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6158
     OperatingSystem disableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6159
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6160
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6161
     '^C handled again.' printNewline
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
!
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
disableTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6166
    "disable timer interrupts.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6167
     WARNING:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6168
	the system will not operate correctly with timer interrupts
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6169
	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
  6170
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6171
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6172
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6173
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6174
    struct itimerval dt;
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
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6177
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6178
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6179
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6180
    setitimer(ITIMER_REAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6181
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6182
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6183
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6184
# if defined(USE_SLOW_ALARM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6185
#  if defined(SIGALRM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6186
    alarm(0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6187
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6188
#  endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6189
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6190
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6191
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6192
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6193
    ^ false
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6196
enableChildSignalInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6197
    "enable childSignal interrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6198
     (SIGCHLD, if the architecture supports it).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6199
     After enabling, these signals will send the message
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6200
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6201
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6202
    self enableSignal:(self sigCHLD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6203
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6204
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6205
enableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6206
    "turn on IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6207
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6208
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6209
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6210
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6211
#ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6212
    extern void __signalIoInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6213
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6214
    static int firstCall = 1;
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
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6217
    /*
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6218
     * SIGIO/SIGPOLL - data available for I/O
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6219
     * (used to wake up waiting processes)
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6220
     */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6221
# ifdef SIGIO
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6222
#  define THESIGNAL SIGIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6223
# else
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6224
#  ifdef SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6225
#   define THESIGNAL SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6226
#  else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6227
#   ifdef SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6228
#    define THESIGNAL SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6229
#   endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6230
#  endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6231
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6232
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6233
    if (__isSmallInteger(fd)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6234
	if (firstCall) {
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6235
# ifdef HAS_SIGACTION
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6236
	    struct sigaction act;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6237
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6238
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6239
	     * Do not add SA_RESTART here. A signal can cause a
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6240
	     * thread switch, another thread can do a garbage collect
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6241
	     * and restarted system calls may write into old
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6242
	     * (collected) addresses.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6243
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6244
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6245
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6246
	    sigemptyset(&act.sa_mask);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6247
	    act.sa_handler = __signalIoInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6248
	    sigaction(THESIGNAL, &act, 0);
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6249
# else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6250
#  ifdef HAS_SIGVEC
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6251
	    struct sigvec vec;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6252
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6253
	    vec.sv_flags = SV_INTERRUPT;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6254
	    sigemptyset(&vec.sv_mask);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6255
	    vec.sv_handler = __signalIoInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6256
	    sigvec(THESIGNAL, &vec, NULL);
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6257
#  else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6258
	    signal(THESIGNAL, __signalIoInterrupt);
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6259
#  endif /* SIGVEC */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6260
# endif /* SIGACTION */
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6261
	    firstCall = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6262
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6263
#undef THESIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6264
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6265
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6266
# if defined(SYSV4)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6267
	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
  6268
# else /*! SYSV4*/
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6269
	flags = fcntl(f, F_GETFL, 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6270
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6271
	 * if already set, there is no need for this syscall ...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6272
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6273
	if (flags & FASYNC) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6274
	    ret = flags;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6275
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6276
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6277
	    if (ret >= 0) ret = flags;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6278
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6279
# endif /*!SYSV4*/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6280
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6281
# if defined(F_SETOWN) || defined(FIOSETOWN)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6282
	{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6283
	    int pid;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6284
	    int ok;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6285
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6286
	    pid = getpid();
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6287
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6288
#  if defined(F_SETOWN)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6289
	    ok = fcntl(f, F_SETOWN, pid);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6290
	    /* printf("F_SETOWN returns %d (%d)\n", ret, errno); */
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6291
#  else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6292
	    ok = ioctl(f, FIOSETOWN, &pid);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6293
	    /* printf("FIOSETOWN returns %d (%d)\n", ret, errno); */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6294
#  endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6295
	    if (ok < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6296
		ret = ok;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6297
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6298
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6299
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6300
	RETURN ( __MKUINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6301
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6302
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6303
%}.
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
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6306
     or if the system does not support SIGIO
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6309
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6310
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6311
enableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6312
    "enable (Unix-)signal processing for signalNumber.
15234
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  6313
     Don't confuse Unix signals with smalltalk signals.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6314
     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
  6315
     (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
  6316
     sends #signalInterrupt:.
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
     NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6319
     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
  6320
     a signal."
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
%{  /* NOCONTEXT */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6323
#ifdef __SCHTEAM__
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6324
    if (signalNumber.isSmallInteger()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6325
	int sigNo = signalNumber.intValue();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6326
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6327
	if (sigNo != 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6328
	    java.lang.System.err.println("ignored enable-signal: "+sigNo);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6329
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6330
	return context._RETURN(self);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6331
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6332
#else
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6333
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6334
# ifdef NSIG
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6335
#  define SIG_LIMIT NSIG
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6336
# else
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6337
#  ifdef SIGUSR2
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6338
#   define SIG_LIMIT SIGUSR2
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6339
#  else
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6340
#   ifdef SIGUSR
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6341
#    define SIG_LIMIT SIGUSR
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6342
#   endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6343
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6344
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6345
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6346
# if defined(SIGPOLL) && !defined(SIGIO)
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6347
#  define SIGIO SIGPOLL
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6348
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6349
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6350
# ifdef SIGCHLD
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6351
#  define CHILD_SIGNAL   SIGCHLD
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6352
# else
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6353
#  ifdef SIGCLD
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6354
#   define CHILD_SIGNAL  SIGCLD
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6355
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6356
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6357
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6358
    int sigNr;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6359
# if defined(SIGINT) || defined(SIGQUIT)
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6360
#  ifndef __signalUserInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6361
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6362
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6363
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6364
# ifdef SIGFPE
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6365
#  ifndef __signalFpExceptionInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6366
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6367
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6368
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6369
# ifdef SIGIO
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6370
#  ifndef __signalIoInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6371
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6372
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6373
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6374
# ifdef CHILD_SIGNAL
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6375
#  ifndef __signalChildInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6376
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6377
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6378
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6379
# ifdef SIGPIPE
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6380
#  ifndef __signalPIPEInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6381
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6382
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6383
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6384
# ifdef SIGBUS
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6385
#  ifndef __signalBUSInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6386
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6387
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6388
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6389
# ifdef SIGSEGV
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6390
#  ifndef __signalSEGVInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6391
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6392
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6393
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6394
# if defined(SIGILL) || defined(SIGEMT)
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6395
#  ifndef __signalTrapInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6396
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6397
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6398
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6399
# ifdef SIGALRM
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6400
#  ifndef __signalTimerInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6401
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6402
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6403
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6404
# ifdef SIGABRT
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6405
#  ifndef __signalAbortInterrupt
15234
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  6406
    extern void __signalAbortInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6407
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6408
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6409
# ifndef __signalInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6410
    extern void __signalInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6411
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6412
    void (*handler)(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6413
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6414
    if (__isSmallInteger(signalNumber)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6415
     && ((sigNr = __intVal(signalNumber)) >= 0)
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6416
# ifdef SIG_LIMIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6417
     &&  (sigNr <= SIG_LIMIT)
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6418
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6419
    ) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6420
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6421
	 * standard signals are forced into standard handlers
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6422
	 * - all others go into general signalInterrupt
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6423
	 */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6424
# if defined(SIGPOLL) && defined(SIGIO)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6425
	if (sigNr == SIGPOLL)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6426
	    sigNr = SIGIO;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6427
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6428
	switch (sigNr) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6429
	    case 0:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6430
		/* enabling a non-supported signal */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6431
		RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6432
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6433
# ifdef SIGBREAK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6434
	    case SIGBREAK:
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6435
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6436
# ifdef SIGINT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6437
	    case SIGINT:
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6438
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6439
# ifdef SIGQUIT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6440
	    case SIGQUIT:
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6441
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6442
# if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6443
		handler = __signalUserInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6444
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6445
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6446
# ifdef SIGFPE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6447
	    case SIGFPE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6448
		handler = __signalFpExceptionInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6449
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6450
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6451
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6452
# ifdef SIGPIPE
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6453
	    case SIGPIPE:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6454
		handler = __signalPIPEInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6455
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6456
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6457
# ifdef SIGBUS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6458
	    case SIGBUS:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6459
		handler = __signalBUSInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6460
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6461
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6462
# ifdef SIGSEGV
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6463
	    case SIGSEGV:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6464
		handler = __signalSEGVInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6465
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6466
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6467
# ifdef SIGABRT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6468
	    case SIGABRT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6469
		handler = __signalAbortInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6470
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6471
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6472
# ifdef SIGILL
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6473
	    case SIGILL:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6474
		handler = __signalTrapInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6475
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6476
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6477
# ifdef SIGEMT
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6478
	    case SIGEMT:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6479
		handler = __signalTrapInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6480
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6481
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6482
# ifdef SIGIO
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6483
	    case SIGIO:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6484
		handler = __signalIoInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6485
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6486
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6487
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6488
# ifdef CHILD_SIGNAL
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6489
	    case CHILD_SIGNAL:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6490
		handler = __signalChildInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6491
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6492
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6493
# ifdef SIGALRM
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6494
	    case SIGALRM:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6495
		handler = __signalTimerInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6496
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6497
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6498
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6499
	    default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6500
		handler = __signalInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6501
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6502
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6503
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6504
	{
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6505
# ifdef HAS_SIGACTION
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6506
	    struct sigaction act;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6507
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6508
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6509
	     * Do not add SA_RESTART here. A signal can cause a
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6510
	     * thread switch, another thread can do a garbage collect
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6511
	     * and restarted system calls may write into old
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6512
	     * (collected) addresses.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6513
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6514
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6515
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6516
	    sigemptyset(&act.sa_mask);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6517
	    act.sa_handler = handler;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6518
	    sigaction(sigNr, &act, 0);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6519
# else
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6520
#  ifdef HAS_SIGVEC
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6521
	    struct sigvec vec;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6522
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6523
	    vec.sv_flags = SV_INTERRUPT;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6524
	    sigemptyset(&vec.sv_mask);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6525
	    vec.sv_handler = handler;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6526
	    sigvec(sigNr, &vec, NULL);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6527
#  else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6528
	    (void) signal(sigNr, handler);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6529
#  endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6530
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6531
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6532
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6533
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6534
	 * maybe, we should ret the old enable-status
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6535
	 * as boolean here ...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6536
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6537
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6538
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6539
#endif /* not SCHTEAM */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6540
%}.
3496
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
     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
  6543
     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
  6544
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6545
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6546
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6547
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6548
enableTimer:milliSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6549
    "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
  6550
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6551
%{  /* NOCONTEXT */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6552
#ifdef __SCHTEAM__
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6553
    if (milliSeconds.isSmallInteger()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6554
	long millis = milliSeconds.longValue();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6555
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6556
	java.lang.System.err.println("ignored enable-timer");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6557
	return context._RETURN(self);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6558
    }
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6559
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6560
    int millis;
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
    millis = __intVal(milliSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6563
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6564
# ifdef SIGALRM
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6565
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6566
	static int firstCall = 1;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6567
#  ifndef __signalTimerInterrupt
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6568
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6569
#  endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6570
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6571
	if (firstCall) {
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6572
#  ifdef HAS_SIGACTION
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6573
	    struct sigaction act;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6574
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6575
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6576
	    sigemptyset(&act.sa_mask);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6577
	    act.sa_handler = __signalTimerInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6578
	    sigaction(SIGALRM, &act, 0);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6579
#  else
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6580
#   ifdef HAS_SIGVEC
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6581
	    struct sigvec vec;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6582
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6583
	    vec.sv_flags = SV_INTERRUPT;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6584
	    sigemptyset(&vec.sv_mask);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6585
	    vec.sv_handler = __signalTimerInterrupt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6586
	    sigvec(SIGALRM, &vec, NULL);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6587
#   else /* neither SIGACTION nor SIGVEC */
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6588
	    signal(SIGALRM, __signalTimerInterrupt);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6589
#   endif /* stupid system  */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6590
#  endif
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6591
	    firstCall = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6592
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6593
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6594
# endif /* SIGALRM */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6595
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6596
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6597
# if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6598
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6599
	struct itimerval dt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6600
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6601
	dt.it_interval.tv_sec = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6602
	dt.it_interval.tv_usec = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6603
	dt.it_value.tv_sec = millis / 1000;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6604
	dt.it_value.tv_usec = (millis % 1000) * 1000;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6605
	setitimer(ITIMER_REAL, &dt, 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6606
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6607
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6608
# else /* no ITIMER_REAL */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6609
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6610
#  ifdef USE_SLOW_ALARM
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6611
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6612
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6613
	 * last fallback - use alarm (which only gives 1 second resolution).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6614
	 * If the system does not support any of the above, you have to life
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6615
	 * with this. The consequence is that pressing CTRL-C processing and
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6616
	 * thread switching will take place much delayed.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6617
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6618
	alarm(1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6619
	RETURN(true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6620
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6621
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6622
# endif /* ITIMER_REAL */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6623
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6624
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6625
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6626
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6627
19172
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6628
interruptProcess:processId
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6629
    "interrupt (SIGINT) a unix process."
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6630
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6631
    self sendSignal:(self sigINT) to:processId toGroup:false toAll:false.
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6632
!
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6633
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6634
interruptProcessGroup:processId
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6635
    "interrupt (SIGINT) a unix process group."
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6636
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6637
    self sendSignal:(self sigINT) to:processId toGroup:false toAll:true.
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6638
!
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6639
6536
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6640
isFatalSignal:aNumber
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6641
   "return true if a signal with number aNumber is a fatal signal,
20257
bf95d404e329 #OTHER by mawalch
mawalch
parents: 20125
diff changeset
  6642
    i.e. some severe internal error occurred"
6536
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6643
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6644
   ^ (aNumber == self sigSEGV)
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6645
     or:[aNumber == self sigILL
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6646
     or:[aNumber == self sigBUS]]
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6647
!
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6648
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6649
killProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6650
    "kill a unix process.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6651
     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
  6652
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6653
     WARNING: in order to avoid zombie processes (on unix),
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6654
	      you may have to fetch the processes exitstatus with
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6655
	      OperatingSystem>>getStatusOfProcess:aProcessId."
19172
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6656
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6657
    self sendSignal:(self sigKILL) to:processId toGroup:false toAll:false.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6658
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6659
    "Modified: / 10.6.1998 / 11:59:12 / cg"
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6660
!
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6661
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6662
killProcessGroup:processGroupId
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6663
    "kill a unix process group.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6664
     The process has a no chance to do some cleanup.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6665
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6666
     WARNING: in order to avoid zombie processes (on unix),
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6667
	      you may have to fetch the processes exitstatus with
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6668
	      OperatingSystem>>getStatusOfProcess:aProcessId."
19172
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6669
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6670
    self sendSignal:(self sigKILL) to:processGroupId toGroup:false toAll:true.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6671
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6672
    "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
  6673
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6674
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6675
sendSignal:signalNumber to:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6676
    "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
  6677
     Returns false if any error occurred, true otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6678
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6679
     Do not confuse UNIX signals with Smalltalk-Signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6680
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6681
     WARNING: in order to avoid zombie processes (on unix),
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6682
	      you may have to fetch the processes exitstatus with
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6683
	      OperatingSystem>>getStatusOfProcess:aProcessId
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6684
	      if the signal terminates that process."
19172
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6685
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6686
    ^ self sendSignal:signalNumber to:processId toGroup:false toAll:false
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6687
!
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6688
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6689
sendSignal:signalNumber to:processId toGroup:toGroupBoolean toAll:toAllBoolean
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6690
    "send a unix signal to some process (maybe myself).
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6691
     Returns false if any error occurred, true otherwise.
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6692
     toGroup: sends the signal with pid as zero
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6693
     toAll:   sends the signal with pid negated
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6694
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6695
     From Unix man page:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6696
	 If pid is greater than zero:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6697
	     Sig is sent to the process whose ID is equal to pid.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6698
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6699
	 If pid is zero:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6700
	     Sig is sent to all processes whose group ID is equal to the process group ID of the
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6701
	     sender, and for which the process has permission; this is a variant of killpg(2).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6702
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6703
	 If pid is -1:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6704
	     If the user has super-user privileges, the signal is sent to all processes excluding
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6705
	     system processes and the process sending the signal.  If the user is not the super user,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6706
	     the signal is sent to all processes with the same uid as the user, excluding the process
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6707
	     sending the signal.  No error is returned if any process could be signaled.
19172
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6708
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6709
     Do not confuse UNIX signals with Smalltalk-Signals.
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6710
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6711
     WARNING: in order to avoid zombie processes (on unix),
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6712
	      you may have to fetch the processes exitstatus with
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6713
	      OperatingSystem>>getStatusOfProcess:aProcessId
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6714
	      if the signal terminates that process."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6715
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6716
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6717
    if (__bothSmallInteger(signalNumber, processId)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6718
	int sigNo, pid;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6719
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6720
	sigNo = __intVal(signalNumber);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6721
	pid = __intVal(processId);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6722
	if (toAllBoolean == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6723
	    pid = -pid;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6724
	} else if (toGroupBoolean == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6725
	    pid = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6726
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6727
	if (kill(pid, sigNo) < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6728
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6729
	    RETURN ( false );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6730
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6731
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6732
    }
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
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6735
    "/ either invalid argument (non-integers)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6736
    "/ or not supported by OS
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
    ^ self primitiveFailed
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6741
startSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6742
    "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
  6743
     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
  6744
     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
  6745
     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
  6746
     (which is of course less correct).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6747
     OBSOLETE: the new messageTally runs as a high prio process, not using
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6748
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6749
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6750
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6751
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6752
#ifndef __spyInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6753
    extern void __spyInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6754
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6755
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6756
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6757
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6758
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6759
# ifdef SIGVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6760
    signal(SIGVTALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6761
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6762
#  ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6763
    signal(SIGALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6764
#  else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6765
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6766
     * mhmh - system has neither SIGBTALRM nor SIGALRM ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6767
     * what should we do here ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6768
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6769
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6770
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6771
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6772
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6773
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6774
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6775
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6776
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6777
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6778
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6779
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6780
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6781
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6782
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6783
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6784
stopSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6785
    "stop spy timing - disable spy timer.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6786
     OBSOLETE: the new messageTally runs as a high prio process, not using
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6787
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6788
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6789
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6790
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6791
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6792
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6793
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6794
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6795
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6796
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6797
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6798
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6799
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6800
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6801
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6802
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6803
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6804
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6805
terminateProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6806
    "terminate a unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6807
     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
  6808
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6809
     WARNING: in order to avoid zombie processes (on unix),
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6810
	      you may have to fetch the processes exitstatus with
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6811
	      OperatingSystem>>getStatusOfProcess:aProcessId."
19172
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6812
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6813
    self sendSignal:(self sigTERM) to:processId toGroup:false toAll:false.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6814
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6815
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6816
    "Modified: / 27.1.1998 / 20:05:47 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6817
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6818
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6819
terminateProcessGroup:processGroupId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6820
    "terminate a unix process group.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6821
     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
  6822
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6823
     WARNING: in order to avoid zombie processes (on unix),
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6824
	      you may have to fetch the processes exitstatus with
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6825
	      OperatingSystem>>getStatusOfProcess:aProcessId."
19172
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6826
7aee5e9a31ba #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19045
diff changeset
  6827
    self sendSignal:(self sigTERM) to:processGroupId toGroup:false toAll:true.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6828
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6829
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6830
    "Created: / 23.4.1996 / 16:40:34 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6831
    "Modified: / 27.1.1998 / 20:05:59 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6832
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6833
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6834
!UnixOperatingSystem class methodsFor:'ipc support'!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6835
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6836
makeBidirectionalPipe
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6837
    "make a socketPair, return array with two filedescriptors on success,
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6838
     nil on failure.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6839
     This is a lowLevel entry, not for public use."
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6840
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6841
    |fd1 fd2|
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6842
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6843
%{
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6844
#ifndef NO_SOCKET
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6845
     int fds[2];
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6846
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6847
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6848
	@global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6849
	RETURN ( nil );
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6850
     }
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6851
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6852
     fd1 = __mkSmallInteger(fds[0]);
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6853
     fd2 = __mkSmallInteger(fds[1]);
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6854
#endif
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6855
%}.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6856
    fd1 notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6857
	^ Array with:fd1 with:fd2.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6858
    ].
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6859
    ^ nil
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6860
!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6861
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6862
makePTY
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6863
    "make a pty-pair, return a triple with two filedescriptors and the pty's name
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6864
     on success, nil on failure.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6865
     This is a lowLevel entry, not for public use.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6866
     See NonPositionableExternalStream>>makePTYPair for a more user-friendly,
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6867
     public interface."
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6868
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6869
    |fdS fdM ptyName|
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6870
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6871
%{
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6872
    /*
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6873
     * Find a pseudo tty to use and open both sides.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6874
     *  _fdM receives the master file descriptor while _fdS
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6875
     *  receives the slave.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6876
     */
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6877
#ifdef USE_OPENPTY
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6878
     {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6879
	int _fdM, _fdS;
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6880
	char slaveName[1024];
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6881
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6882
	if (openpty(&_fdM, &_fdS, slaveName,
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6883
		    NULL, /* struct termios *termp */
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6884
		    NULL  /* struct winsize *winp */ ) < 0) {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6885
	    fprintf(stderr, "openpty: %s\n", strerror(errno));
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6886
	}
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6887
	if ((_fdM >= 0) && (_fdS >= 0)) {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6888
	    fdM = __mkSmallInteger(_fdM);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6889
	    fdS = __mkSmallInteger(_fdS);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6890
	    ptyName = __MKSTRING(slaveName);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6891
	}
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6892
    }
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6893
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6894
#   define PTY_IS_IMPLEMENTED 1
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6895
#endif
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6896
3536
adad0d12c9a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3534
diff changeset
  6897
#ifdef IRIX5
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6898
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6899
    char *slaveName;
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6900
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6901
    slaveName = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6902
    if ((slaveName != 0) && (_fdM >= 0)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6903
	_fdS = open(slaveName, O_RDWR);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6904
	if (_fdS < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6905
	    (void)close(_fdM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6906
	    _fdS = _fdM = -1;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6907
	}
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6908
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6909
	_fdM -1;
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6910
    }
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6911
    if ((_fdM >= 0) && (_fdS >= 0)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6912
	fdM = __mkSmallInteger(_fdM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6913
	fdS = __mkSmallInteger(_fdS);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6914
	ptyName = __MKSTRING(slaveName);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6915
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6916
#   define PTY_IS_IMPLEMENTED 1
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6917
#endif /* IRIX5 */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6918
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6919
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6920
#if !defined(PTY_IS_IMPLEMENTED) && defined(HAS_UNIX98_PTY)
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6921
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6922
    char *slaveName;
21044
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  6923
    extern char *ptsname(int);     /* also in #include <stdlib.h> */
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  6924
    extern int grantpt(int);
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  6925
    extern int unlockpt(int);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6926
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6927
    _fdM = open("/dev/ptmx", O_RDWR | O_NOCTTY);
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6928
    // _fdM = posix_openpt(O_RDWR | O_NOCTTY);
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6929
    if (_fdM >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6930
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6931
	** grantpt() changes owner, group and mode of the pseudo-tty
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6932
	*/
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6933
	grantpt(_fdM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6934
	unlockpt(_fdM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6935
	slaveName = ptsname(_fdM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6936
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6937
	if (slaveName != NULL) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6938
	    /* printf("slave is: %s\n", slaveName); */
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6939
	    _fdS = open(slaveName, O_RDWR | O_NOCTTY);
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6940
	    if (_fdS < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6941
		(void)close(_fdM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6942
		_fdS = _fdM = -1;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6943
	    }
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6944
# if defined(UNIXWARE) || defined(solaris)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6945
	    else {
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6946
		/* SYS5 push terminal modules on stream */
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6947
		ioctl(_fdS, I_PUSH, "ptem");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6948
		ioctl(_fdS, I_PUSH, "ldterm");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6949
	    }
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  6950
# endif
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6951
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6952
	    (void)close(_fdM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6953
	    _fdS = _fdM = -1;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6954
	}
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6955
    }
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6956
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6957
    if ((_fdM >= 0) && (_fdS >= 0)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6958
	fdM = __mkSmallInteger(_fdM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6959
	fdS = __mkSmallInteger(_fdS);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  6960
	ptyName = __MKSTRING(slaveName);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6961
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6962
#   define PTY_IS_IMPLEMENTED 1
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6963
#endif /* HAS_UNIX98_PTY */
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6964
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6965
#if !defined(PTY_IS_IMPLEMENTED)
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6966
# ifdef LINUX
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6967
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6968
#   define PT_INDEX      5
3550
6c3824d07eac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  6969
#   define PTY_1_CHARS  "pqrstuabcdevwxyz"
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6970
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6971
# endif /* LINUX */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6972
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6973
# ifdef solaris
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6974
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6975
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6976
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6977
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6978
# endif /* solaris */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6979
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6980
# ifdef aix
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6981
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6982
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6983
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6984
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6985
# endif /* aix */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6986
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6987
# ifdef next3
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6988
#   define PTY_TEMPL    "/dev/ptyXX"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6989
#   define PT_INDEX      5
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6990
#   define PTY_1_CHARS  "pqr"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6991
#   define PTY_2_CHARS  "0123456789abcdef"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6992
# endif /* next3 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6993
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6994
# ifdef hpux
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6995
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6996
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6997
#   define PTY_1_CHARS  "pqrs"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6998
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6999
# endif /* hpux */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7000
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7001
# if defined(__osf__)
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  7002
#   define PTY_TEMPL    "/dev/ptyXX"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  7003
#   define PT_INDEX      5
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  7004
#   define PTY_1_CHARS  "pq"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  7005
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7006
# endif /* osf1 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7007
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7008
# if defined(BSD) && !defined(PTY_TEMPL)
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  7009
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  7010
#   define PT_INDEX      5
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  7011
#   define PTY_1_CHARS  "p"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  7012
#   define PTY_2_CHARS  "0123456789abcdefghijklmnopqrstuv"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7013
# endif /* BSD */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7014
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7015
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  7016
#   include <grp.h>
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  7017
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7018
    static int ttygid = -2;
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  7019
    char line[128];
3575
39723f691a0e hp-cc does not recognize const keyword
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
  7020
    register CONST char *cp1, *cp2;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7021
    int len, _fdM = -1, _fdS = -1;
15484
840d6cc94534 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 15483
diff changeset
  7022
    char *slaveName = NULL;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7023
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  7024
    len = sizeof(PTY_TEMPL) - 1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7025
    strncpy(line, PTY_TEMPL, sizeof(PTY_TEMPL));
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7026
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7027
    if (ttygid == -2) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7028
	struct group *gr;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7029
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7030
	if ((gr = getgrnam("tty")) != NULL)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7031
	    ttygid = gr->gr_gid;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7032
	else
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7033
	    ttygid = -1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7034
    }
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  7035
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  7036
    for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7037
	line[len-2] = * cp1;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7038
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7039
	for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7040
	    line[PT_INDEX] = 'p';
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7041
	    line[len-1] = *cp2;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7042
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7043
	    if ((_fdM = open(line, O_RDWR, 0)) < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7044
		if (errno == ENOENT) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7045
		    _fdM = _fdS = -1;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7046
		    goto getOutOfHere; /* out of ptys */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7047
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7048
	    } else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7049
		line[PT_INDEX] = 't';
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7050
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7051
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7052
		 * try to set owner and mode.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7053
		 * this works only if running under root
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7054
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7055
		(void) chown( line, getuid(), ttygid );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7056
		(void) chmod( line, S_IRUSR | S_IWUSR | S_IWGRP );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7057
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7058
		if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7059
		    slaveName = line;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7060
		    goto getOutOfHere; /* success */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7061
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7062
		(void) close(_fdM );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7063
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7064
	}
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  7065
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  7066
  getOutOfHere: ;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  7067
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  7068
    if ((_fdM >= 0) && (_fdS >= 0)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7069
	fdM = __mkSmallInteger(_fdM);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7070
	fdS = __mkSmallInteger(_fdS);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7071
	ptyName = __MKSTRING(slaveName);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7072
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  7073
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7074
#endif /* !defined(PTY_IS_IMPLEMENTED) */
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  7075
%}.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  7076
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  7077
    fdM notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7078
	^ Array with:fdM with:fdS with:ptyName.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  7079
    ].
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  7080
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  7081
    ^ nil
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  7082
!
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  7083
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7084
makePTYPair
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7085
    "make a pty-pair, return an array with two filedescriptors on success,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7086
     nil on failure.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7087
     This is a leftover compatibility lowLevel entry, not for public use.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7088
     See NonPositionableExternalStream>>makePTYPair for a more user-friendly,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7089
     public interface."
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7090
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7091
    |triple|
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7092
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7093
    triple := self makePTY.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7094
    triple isNil ifTrue:[^ nil].
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7095
    ^ Array with:(triple at:1) with:(triple at:2)
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7096
!
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  7097
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7098
makePipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7099
    "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
  7100
     nil on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7101
     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
  7102
     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
  7103
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7104
    |fd1 fd2|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7105
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7106
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7107
     int fds[2];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7108
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7109
     if (pipe(fds) < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7110
	@global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7111
	RETURN ( nil );
3496
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
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  7114
     fd1 = __mkSmallInteger(fds[0]);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  7115
     fd2 = __mkSmallInteger(fds[1]);
3496
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
    fd1 notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7118
	^ Array with:fd1 with:fd2.
3496
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
    ^ nil
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7121
!
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7122
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7123
resetTerminalInputOutputModes:fd
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7124
    "reset the terminal attributes"
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7125
%{
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7126
    struct termios switcher;
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7127
15176
aae943ef2519 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 15175
diff changeset
  7128
    printf("setMappingMaster fd:%d\n", (int)__intVal(fd));
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7129
    if (__isSmallInteger(fd)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7130
	if (tcgetattr( __intVal(fd), &switcher) < 0) RETURN (false);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7131
	switcher.c_iflag = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7132
	switcher.c_oflag = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7133
	if (tcsetattr( __intVal(fd), TCSANOW, &switcher) >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7134
	    RETURN (true);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7135
	}
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7136
    }
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7137
%}.
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7138
    ^ false
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7139
!
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  7140
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7141
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
  7142
    "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
  7143
%{
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7144
#ifdef TIOCSWINSZ
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7145
    struct winsize wsize;
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7146
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7147
    if (__isSmallInteger(fd)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7148
     && __isSmallInteger(w)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7149
     && __isSmallInteger(h)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7150
	wsize.ws_row = (unsigned short)__intVal(h);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7151
	wsize.ws_col = (unsigned short)__intVal(w);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7152
	if (ioctl(__intVal(fd), TIOCSWINSZ, (char *)&wsize) >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7153
	    RETURN (true);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7154
	}
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7155
    }
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7156
#endif
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7157
%}.
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  7158
    ^ false
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7159
!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7160
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7161
shutdownBidirectionalPipeOutput:fileDescriptor
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7162
    "inform the other end of the bidirectional pipe represented by fileDescriptor, that
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7163
     we will send no more data to the pipe, i.e. EOF is reached"
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7164
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7165
%{
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7166
#ifndef NO_SOCKET
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7167
    if (__isSmallInteger(fileDescriptor)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7168
	shutdown(__smallIntegerVal(fileDescriptor), 1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7169
	RETURN(self);
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7170
    }
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7171
#endif
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7172
%}.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  7173
    self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7174
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7175
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7176
!UnixOperatingSystem class methodsFor:'misc'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7177
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7178
closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7179
    "a bad bad kludge and workaround for a big bug in the linux
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7180
     getAddrInfo implementation:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7181
	if it gets interrupted (via a timer, for example), its domain-name
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7182
	socket remains open and is NEVER closed.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7183
	These open files collect up and lead to no-more-files eventually.
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7184
     Invoking this method helps in this situation."
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7185
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7186
    |p|
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7187
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7188
    p := PipeStream
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7189
	    readingFrom:('lsof -p ' , (OperatingSystem getProcessId printString)).
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7190
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7191
    p linesDo:[:line |
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7192
	|words fd|
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7193
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7194
	words := line asCollectionOfWords.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7195
	"/ COMMAND PID USER   FD   TYPE     DEVICE    SIZE    NODE NAME
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7196
	words first = 'stx' ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7197
	    words second = (OperatingSystem getProcessId printString) ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7198
		(words fourth endsWith:'u') ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7199
		    (words fifth = 'IPv4') ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7200
			(words seventh = 'UDP') ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7201
			    (words last endsWith:'domain') ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7202
				fd := Number readFrom:(words fourth copyButLast).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7203
Transcript showCR:line.
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7204
				OperatingSystem closeFd:fd.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7205
			    ]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7206
			]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7207
		    ]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7208
		]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7209
	    ]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7210
	]
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7211
    ].
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7212
    p close.
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7213
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7214
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7215
     self closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7216
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7217
!
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  7218
10983
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7219
dup:aFileDescriptor
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7220
    "duplicate a file descriptor.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7221
     Only use internally"
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7222
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7223
%{
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7224
    int dupFd;
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7225
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7226
    if (__isSmallInteger(aFileDescriptor)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7227
	dupFd = dup(__smallIntegerVal(aFileDescriptor));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7228
	if (dupFd >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7229
	    RETURN(__mkSmallInteger(dupFd));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7230
	}
10983
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7231
    }
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7232
%}.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7233
    ^ self primitiveFailed.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7234
!
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7235
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7236
slowFork:aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7237
    "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
  7238
     Only used internally on SYSV3 systems"
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
    SlowFork := aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7241
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7242
    "Modified: 22.4.1996 / 13:13:09 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7243
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7244
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7245
!UnixOperatingSystem class methodsFor:'os queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7246
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7247
executableFileExtensions
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7248
    "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
  7249
     Only req'd for msdos like systems ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7250
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7251
    ^ #('')
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7252
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7253
    "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
  7254
    "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
  7255
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7256
23599
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7257
expandEnvironmentStrings:aString
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7258
    "expand the environmentStrings (e.g. $JAVA_HOME or ${JAVA_HOME}) in aString.
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7259
     If the variable does not exist, keep the original text.
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7260
     Amswer the expanded string."
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7261
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7262
    |resultStream readStream|
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7263
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7264
    readStream := aString readStream.
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7265
    resultStream := WriteStream on:(String new:aString size + 256).
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7266
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7267
    [ "doUntil"
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7268
	|part varName varValue start|
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7269
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7270
	part := readStream upTo:$$.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7271
	resultStream nextPutAll:part.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7272
	readStream atEnd ifFalse:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7273
	    readStream peek = ${ ifTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7274
		readStream next.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7275
		varName := readStream nextUpTo:$}.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7276
		start := '${'.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7277
	    ] ifFalse:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7278
		varName := readStream nextUpTo:$/.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7279
		start := '$'.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7280
	    ].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7281
	    varValue := OperatingSystem getEnvironment:varName.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7282
	    varValue notNil ifTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7283
		"/ variable found - eat trailing } - if present"
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7284
		readStream peek == $} ifTrue:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7285
		    readStream next.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7286
		].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7287
		resultStream nextPutAll:varValue.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7288
	    ] ifFalse:[
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7289
		"/ variable not found - keep original contents"
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7290
		resultStream nextPutAll:start; nextPutAll:varName.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7291
	    ].
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7292
	].
23599
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7293
    ] doUntil:[readStream atEnd].
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7294
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7295
    ^ resultStream contents.
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7296
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7297
    "
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7298
	OperatingSystem getEnvironment:'JAVA_HOME'.
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7299
	self expandEnvironmentStrings:'$JAVA_HOME'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7300
	self expandEnvironmentStrings:'${JAVA_HOME}'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7301
	self expandEnvironmentStrings:'$JAVA_HOME/bin'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7302
	self expandEnvironmentStrings:'${JAVA_HOME}/bin'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7303
	self expandEnvironmentStrings:'${JAVA_HOME'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7304
	self expandEnvironmentStrings:'${JAVA_HOME/bin'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7305
	self expandEnvironmentStrings:'${JAVA_HOME}/bin$JAVA_HOME'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7306
	self expandEnvironmentStrings:'$bla-bla/bin'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  7307
	self expandEnvironmentStrings:'${bla-bla}/bin'
23599
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7308
    "
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7309
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7310
    "Created: / 10-01-2019 / 17:36:03 / Stefan Vogel"
23625
034316f8e057 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23607
diff changeset
  7311
    "Modified: / 21-01-2019 / 16:45:38 / Stefan Vogel"
23599
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7312
!
0f7f4466f1af #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 23483
diff changeset
  7313
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  7314
getCodeset
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  7315
    "get the codeset the system is running under"
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  7316
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  7317
    ^ Codeset
14587
d32cbeb8ca41 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14584
diff changeset
  7318
!
d32cbeb8ca41 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14584
diff changeset
  7319
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7320
getCodesetEncoder
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7321
    "Initialize CodesetEncoder used to encode/decode strings passed to/from
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7322
     the operating system (like file names, command output, environment ect.).
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7323
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  7324
     NOTE: This should be called initializeCodesetEncoder but to make it consistent
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  7325
     with getCodeset it is getCodesetEncoder"
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  7326
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  7327
    ^ CodesetEncoder.
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7328
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7329
    "Created: / 23-01-2013 / 09:54:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  7330
    "Modified: / 27-02-2017 / 15:43:31 / stefan"
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7331
!
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7332
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7333
getDomainName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7334
    "return the domain this host is in.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7335
     Notice:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7336
	not all systems support this; on some, #unknown is returned."
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7337
16495
a9eecbf739db class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16494
diff changeset
  7338
    |domainName idx hostName primDomainName|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7339
16634
e1ebc91b27af class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16592
diff changeset
  7340
    "/ use cached value, if present
16756
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7341
    (DomainName notNil and:[DomainName ~~ #unknown]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7342
	^ DomainName
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7343
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7344
16495
a9eecbf739db class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16494
diff changeset
  7345
    primDomainName := domainName := self primGetDomainName.
16494
0a7c7ec1961a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16481
diff changeset
  7346
    domainName = '(none)' ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7347
	domainName := nil.
16494
0a7c7ec1961a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16481
diff changeset
  7348
    ].
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7349
    domainName isEmptyOrNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7350
	"sometimes, we can extract the domainName from the hostName ..."
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7351
	hostName := self primGetHostName.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7352
	hostName notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7353
	    idx := hostName indexOf:$..
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7354
	    idx ~~ 0 ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7355
		domainName := hostName copyFrom:idx+1.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7356
	    ]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7357
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7358
	domainName isEmptyOrNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7359
	    "/ fallBack
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7360
	    domainName := self getEnvironment:'DOMAIN'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7361
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7362
	    "if #primGetDomainName did work, /bin/domainname would return the same result"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7363
	    (domainName isNil and:[primDomainName isNil]) ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7364
		domainName := self getCommandOutputFrom:'/bin/domainname'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7365
		(domainName isEmptyOrNil or:[ domainName = '(none)' ]) ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7366
		    domainName := nil.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7367
		].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7368
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7369
	    domainName isNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7370
		DomainName ~~ #unknown ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7371
		    "/ only warn once - the warning can be ignored, if you do not use the domain name
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7372
		    ObjectMemory debugPrinting ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7373
			'UnixOperatingSystem [info]: cannot find out domainname' infoPrintCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7374
		    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7375
		].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7376
		domainName := #unknown.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7377
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7378
	].
16756
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7379
    ].
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7380
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7381
    "cache, because domainName fetching may be expensive;
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7382
     but if unknown, it will be tried again"
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7383
    DomainName := domainName.
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7384
    ^ domainName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7386
    "
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7387
     OperatingSystem getDomainName
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  7388
     OperatingSystem primGetDomainName
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7389
     OperatingSystem getHostName
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7390
     OperatingSystem primGetHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7391
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7392
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7393
    "Modified: 26.4.1996 / 10:04:54 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7394
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7395
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7396
getEnvironment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7397
    "answer the whole environment as a Dictionary"
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7398
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7399
    |resultArray error dict sz "{ Class: SmallInteger }"|
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7400
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  7401
%{
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  7402
#ifdef __osx__
16282
a9cd85c4d2f2 getEnvironment fix for __osx__
Claus Gittinger <cg@exept.de>
parents: 16149
diff changeset
  7403
    char **environ = *_NSGetEnviron();
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  7404
#else
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7405
    extern char **environ;
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  7406
#endif
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7407
    char **env;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7408
    int nEnv = 0;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7409
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7410
    /*
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7411
     * get the size of the environment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7412
     */
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7413
    if (environ) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7414
	for (env = environ; *env; env++) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7415
	    nEnv++;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7416
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7417
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7418
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7419
    /*
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7420
     * allcate an array for keys and values
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7421
     */
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  7422
    resultArray = __ARRAY_NEW_INT(nEnv * 2);
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7423
    if (resultArray == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7424
	error = @symbol(allocationFailure);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7425
	goto bad;
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7426
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7427
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7428
    if (environ) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7429
	int envIndex;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7430
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7431
	for (env = environ, envIndex = 0; *env; env++) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7432
	    OBJ t;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7433
	    char *separatorPtr;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7434
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7435
	    separatorPtr = strchr(*env, '=');
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7436
	    t = __MKSTRING_L(*env, separatorPtr-*env);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7437
	    __arrayVal(resultArray)[envIndex++] = t;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7438
	    __STORE(resultArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7439
	    if (separatorPtr == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7440
		t = nil;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7441
	    } else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7442
		t = __MKSTRING(separatorPtr+1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7443
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7444
	    __arrayVal(resultArray)[envIndex++] = t;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7445
	    __STORE(resultArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7446
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7447
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7448
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7449
bad:;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7450
%}.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7451
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7452
	^ self primitiveFailed:error.
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7453
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7454
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7455
    sz := resultArray size.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7456
    dict := Dictionary new:(sz // 2).
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7457
    1 to:sz by:2 do:[:i |
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7458
	|key|
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7459
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7460
	key := resultArray at:i.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7461
	key notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7462
	    "same behavior as getenv() - the first entry takes precedence"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7463
	    (dict includesKey:key) ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7464
		dict at:key put:(resultArray at:i+1)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7465
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7466
	].
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7467
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7468
    ^ dict
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7469
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7470
    "
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7471
     OperatingSystem getEnvironment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7472
    "
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7473
!
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7474
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7475
getEnvironment:aStringOrSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7476
    "get an environment string"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7477
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7478
%{  /* NOCONTEXT */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7479
#ifdef __SCHTEAM__
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7480
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7481
	java.lang.String val = java.lang.System.getenv( aStringOrSymbol.asString() );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7482
	STObject retVal;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7483
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7484
	if (val == null) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7485
	    retVal = STObject.Nil;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7486
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7487
	    retVal = new STString( val );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7488
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7489
	return context._RETURN( retVal );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7490
	/* NOTREACHED */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7491
    }
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7492
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7493
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7494
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7495
    if (__isStringLike(aStringOrSymbol)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7496
	char *env =  getenv(__stringVal(aStringOrSymbol));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7497
	if (env) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7498
	    RETURN ( __MKSTRING(env) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7499
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7500
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7501
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7502
#endif /* not SCHTEAM */
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7503
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  7504
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7505
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7506
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7507
     OperatingSystem getEnvironment:'LANG'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7508
     OperatingSystem getEnvironment:'LOGIN'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7509
     OperatingSystem getEnvironment:'HOME'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7510
     OperatingSystem getEnvironment:'NNTPSERVER'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7511
     OperatingSystem getEnvironment:'MAIL'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7512
     OperatingSystem getEnvironment:'PATH'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7513
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7514
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7515
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7516
getHostName
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7517
    "return the hostname we are running on.
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7518
     The host name returned is fully qualified - if returned so by the system."
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7519
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7520
    |hostName|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7521
16756
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7522
    (HostName notNil and:[HostName ~~ #unknown]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7523
	^ HostName
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7524
    ].
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7525
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7526
    hostName := self primGetHostName.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7527
    hostName isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7528
	"fallBack - in non-antique systes we never come here"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7529
	hostName := self getEnvironment:'HOST'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7530
	hostName isNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7531
	    hostName := self getCommandOutputFrom:'/bin/hostname'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7532
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7533
	hostName isNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7534
	    HostName ~~ #unknown ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7535
		'UnixOperatingSystem [info]: cannot find out hostname' infoPrintCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7536
		hostName := #unknown.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7537
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7538
	].
16756
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7539
    ].
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7540
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7541
    "cache, because hostname fetching may be expensive;
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7542
     but if unknown, it will be tried again"
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7543
    HostName := hostName.
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7544
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7545
    ^ hostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7546
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7547
    "
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7548
     OperatingSystem getHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7549
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7550
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7551
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7552
getLocaleInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7553
    "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
  7554
     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
  7555
     Possible fields are:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7556
	decimalPoint                    <String>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7557
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7558
	thousandsSep                    <String>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7559
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7560
	internationalCurrencySymbol     <String>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7561
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7562
	currencySymbol                  <String>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7563
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7564
	monetaryDecimalPoint            <String>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7565
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7566
	monetaryThousandsSeparator      <String>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7567
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7568
	positiveSign                    <String>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7569
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7570
	negativeSign                    <String>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7571
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7572
	internationalFractionalDigits   <Integer>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7573
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7574
	fractionalDigits                <Integer>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7575
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7576
	positiveSignPrecedesCurrencySymbol      <Boolean>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7577
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7578
	negativeSignPrecedesCurrencySymbol      <Boolean>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7579
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7580
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7581
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7582
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7583
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7584
	positiveSignPosition                            <Symbol>
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7585
							one of: #parenthesesAround,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7586
								#signPrecedes,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7587
								#signSuceeds,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7588
								#signPrecedesCurrencySymbol,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7589
								#signSuceedsCurrencySymbol
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7590
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7591
	negativeSignPosition                            <like above>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7592
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7593
     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
  7594
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7595
     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
  7596
     it should be used by applications as required.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7597
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7599
    |info val|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7600
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7601
    LocaleInfo notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7602
	"/ return the internal info; useful on systems which do not
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7603
	"/ support this.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7604
	^ LocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7605
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7606
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7607
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7608
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7609
    char *decimalPoint;         /* something like "." (US) or "," (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7610
    char *thousandsSep;         /* something like "," (US) or "." (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7611
    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
  7612
    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
  7613
    char *monDecimalPoint;      /* money: decimal point */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7614
    char *monThousandsSep;      /* money: thousands sep */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7615
    char *positiveSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7616
    char *negativeSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7617
    int   intFractDigits;       /* money: international digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7618
    int   fractDigits;          /* money: local digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7619
    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
  7620
    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
  7621
    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
  7622
    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
  7623
    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
  7624
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7625
				/*        2: sign succeeds the value & currency symbol */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7626
				/*        3: sign immediately precedes the currency symbol */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7627
				/*        4: sign immediately suceeds the currency symbol */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7628
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7629
#if defined(HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7630
    struct lconv *conf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7631
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7632
    conf = localeconv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7633
    if (conf) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7634
	decimalPoint = conf->decimal_point;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7635
	thousandsSep = conf->thousands_sep;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7636
	intCurrencySymbol = conf->int_curr_symbol;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7637
	currencySymbol = conf->currency_symbol;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7638
	monDecimalPoint = conf->mon_decimal_point;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7639
	monThousandsSep = conf->mon_thousands_sep;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7640
	positiveSign = conf->positive_sign;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7641
	negativeSign = conf->negative_sign;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7642
	intFractDigits = conf->int_frac_digits;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7643
	fractDigits = conf->frac_digits;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7644
	csPosPrecedes = conf->p_cs_precedes;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7645
	csNegPrecedes = conf->n_cs_precedes;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7646
	csPosSepBySpace = conf->p_sep_by_space;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7647
	csNegSepBySpace = conf->n_sep_by_space;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7648
	csPosSignPosition = conf->p_sign_posn;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7649
	csNegSignPosition = conf->n_sign_posn;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7650
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7651
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7652
    decimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7653
    thousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7654
    intCurrencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7655
    currencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7656
    monDecimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7657
    monThousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7658
    positiveSign =  (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7659
    negativeSign =(char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7660
    intFractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7661
    fractDigits = -1;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7662
    csPosPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7663
    csNegPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7664
    csPosSepBySpace = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7665
    csNegSepBySpace = -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7666
    csPosSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7667
    csNegSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7668
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7669
    if (decimalPoint) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7670
	val = __MKSTRING(decimalPoint);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7671
	__AT_PUT_(info, @symbol(decimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7672
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7673
    if (thousandsSep) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7674
	val = __MKSTRING(thousandsSep);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7675
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7676
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7677
    if (intCurrencySymbol) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7678
	val = __MKSTRING(intCurrencySymbol);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7679
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7680
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7681
    if (currencySymbol) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7682
	val = __MKSTRING(currencySymbol);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7683
	__AT_PUT_(info, @symbol(currencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7684
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7685
    if (monDecimalPoint) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7686
	val = __MKSTRING(monDecimalPoint);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7687
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7688
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7689
    if (monThousandsSep) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7690
	val = __MKSTRING(monThousandsSep);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7691
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7692
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7693
    if (positiveSign) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7694
	val = __MKSTRING(positiveSign);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7695
	__AT_PUT_(info, @symbol(positiveSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7696
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7697
    if (negativeSign) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7698
	val = __MKSTRING(negativeSign);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7699
	__AT_PUT_(info, @symbol(negativeSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7700
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7701
    if (intFractDigits >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7702
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __mkSmallInteger(intFractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7703
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7704
    if (fractDigits >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7705
	__AT_PUT_(info, @symbol(fractionalDigits),  __mkSmallInteger(fractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7706
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7707
    if (csPosPrecedes >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7708
	if (csPosPrecedes == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7709
	    val = false;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7710
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7711
	    val = true;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7712
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7713
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7714
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7715
    if (csNegPrecedes >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7716
	if (csNegPrecedes == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7717
	    val = false;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7718
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7719
	    val = true;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7720
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7721
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7722
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7723
    if (csPosSepBySpace >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7724
	if (csPosSepBySpace == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7725
	    val = false;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7726
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7727
	    val = true;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7728
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7729
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7730
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7731
    if (csNegSepBySpace >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7732
	if (csNegSepBySpace == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7733
	    val = false;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7734
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7735
	    val = true;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7736
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7737
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7738
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7739
    switch (csPosSignPosition) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7740
	case 0:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7741
	    val = @symbol(parenthesesAround);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7742
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7743
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7744
	case 1:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7745
	    val = @symbol(signPrecedes);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7746
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7747
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7748
	case 2:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7749
	    val = @symbol(signSuceeds);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7750
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7751
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7752
	case 3:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7753
	    val = @symbol(signPrecedesCurrencySymbol);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7754
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7755
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7756
	case 4:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7757
	    val = @symbol(signSuceedsCurrencySymbol);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7758
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7759
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7760
	default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7761
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7762
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7763
    if (val != nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7764
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7765
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7766
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7767
    switch (csNegSignPosition) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7768
	case 0:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7769
	    val = @symbol(parenthesesAround);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7770
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7771
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7772
	case 1:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7773
	    val = @symbol(signPrecedes);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7774
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7775
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7776
	case 2:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7777
	    val = @symbol(signSuceeds);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7778
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7779
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7780
	case 3:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7781
	    val = @symbol(signPrecedesCurrencySymbol);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7782
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7783
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7784
	case 4:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7785
	    val = @symbol(signSuceedsCurrencySymbol);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7786
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7787
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7788
	default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7789
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7790
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7791
    if (val != nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7792
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7793
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7794
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7795
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7796
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7797
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7798
     OperatingSystem getLocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7799
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7800
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7801
    "Created: 23.12.1995 / 14:19:20 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7802
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7803
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7804
getNetworkAddressInfo
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  7805
    "return a Dictionary of network interface information.
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7806
	key -> name of interface
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7807
	value -> a Set of network address
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7808
		information for the interface - dictionaries containing the
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7809
		information about the configuration of each interface in the system.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7810
		The dictionary keys are:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7811
		    #address
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7812
		    #netmask
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7813
		    #flags
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7814
		    #destAddress"
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7815
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7816
    |returnArray addressArray nameArray noOfIf retDictionary error retIndex|
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7817
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7818
    noOfIf := 0.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7819
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7820
%{
21220
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7821
#include <ifaddrs.h>
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7822
#if 0 && defined(linux)
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7823
# include <linux/if_packet.h>
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7824
# include <net/ethernet.h> /* the L2 protocols */
21220
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7825
#endif
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7826
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7827
    struct ifaddrs *ifap, *ifaLoop;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7828
    int n_ifa = 0;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7829
    int retI = 0;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7830
    OBJ t;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7831
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7832
    if (getifaddrs(&ifap) < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7833
	error = __MKSTRING("getifaddrs() failed");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7834
	goto out;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7835
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7836
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7837
    for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) n_ifa++;
18694
7927bd9d38b9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18672
diff changeset
  7838
    noOfIf = __mkSmallInteger(n_ifa);
7927bd9d38b9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18672
diff changeset
  7839
7927bd9d38b9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18672
diff changeset
  7840
    returnArray = __ARRAY_NEW_INT(n_ifa*6);
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7841
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7842
    if (returnArray == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7843
	/* Creating a string wouldn't work here */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7844
	error = @symbol(allocationFailure);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7845
	goto bad;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7846
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7847
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7848
    for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7849
	int family, len;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7850
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7851
	if (ifaLoop->ifa_addr == 0)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7852
	       continue;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7853
	family = ifaLoop->ifa_addr->sa_family;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7854
	switch (family) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7855
	    case AF_INET:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7856
		len = sizeof(struct sockaddr_in);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7857
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7858
	    case AF_INET6:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7859
		len = sizeof(struct sockaddr_in6);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7860
		break;
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  7861
# ifdef WANT__AF_PACKET
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7862
	    case AF_PACKET:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7863
		len = sizeof(struct sockaddr_ll);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7864
		break;
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  7865
#endif
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  7866
# ifdef WANT__AF_LINK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7867
	    case AF_LINK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7868
		len = sizeof(struct sockaddr_dl);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7869
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7870
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7871
	    default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7872
		/* skip */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7873
		continue;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7874
	};
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7875
	t = __MKSTRING(ifaLoop->ifa_name);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7876
	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7877
	t = __MKUINT(ifaLoop->ifa_flags);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7878
	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7879
	t = __MKBYTEARRAY((char *)ifaLoop->ifa_addr, len);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7880
	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7881
	if (ifaLoop->ifa_netmask != 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7882
	    t = __MKBYTEARRAY((char *)ifaLoop->ifa_netmask, len);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7883
	    __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7884
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7885
	retI++;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7886
	if ((ifaLoop->ifa_flags&IFF_POINTOPOINT) && ifaLoop->ifa_dstaddr != 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7887
	    t = __MKBYTEARRAY((char *)ifaLoop->ifa_dstaddr, len);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7888
	    __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7889
	} else if (retI++, ifaLoop->ifa_broadaddr != 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7890
	    t = __MKBYTEARRAY((char *)ifaLoop->ifa_broadaddr, len);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7891
	    __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7892
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7893
	retI++;
18694
7927bd9d38b9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18672
diff changeset
  7894
    }
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7895
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7896
bad:
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7897
    freeifaddrs(ifap);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7898
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7899
out:;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7900
%}.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7901
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7902
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7903
	self primitiveFailed:error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7904
	"return empty dictionary if proceeding from error"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7905
	^  Dictionary new.
21220
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7906
    ].
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7907
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7908
    retDictionary := OrderedDictionary new:noOfIf.
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7909
    retIndex := 1.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7910
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7911
    1 to:noOfIf do:[:cnt|
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7912
	|name addressBytes set dict|
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7913
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7914
	name := returnArray at:retIndex.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7915
	addressBytes := returnArray at:retIndex+2.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7916
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7917
	addressBytes notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7918
	    set := retDictionary at:name ifAbsentPut:[OrderedCollection new].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7919
	    dict := Dictionary new:4.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7920
	    dict at:#flags put:(returnArray at:retIndex+1).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7921
	    dict at:#address put:(SocketAddress fromBytes:addressBytes).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7922
	    addressBytes := returnArray at:retIndex+3.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7923
	    addressBytes notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7924
		dict at:#netMask put:(SocketAddress fromBytes:addressBytes).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7925
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7926
	    addressBytes := returnArray at:retIndex+4.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7927
	    addressBytes notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7928
		dict at:#destAddress put:(SocketAddress fromBytes:addressBytes).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7929
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7930
	    addressBytes := returnArray at:retIndex+5.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7931
	    addressBytes notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7932
		dict at:#broadcastAddress put:(SocketAddress fromBytes:addressBytes).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7933
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7934
	    set add:dict.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7935
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7936
	retIndex := retIndex + 6.
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7937
    ].
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7938
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7939
    ^ retDictionary
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7940
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7941
    "
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7942
      OperatingSystem getNetworkAddressInfo
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7943
    "
21900
ec3738295337 #DOCUMENTATION by mawalch
mawalch
parents: 21899
diff changeset
  7944
ec3738295337 #DOCUMENTATION by mawalch
mawalch
parents: 21899
diff changeset
  7945
    "Modified (comment): / 22-06-2017 / 11:03:09 / mawalch"
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7946
!
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7947
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7948
getNetworkAddresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7949
    "return a dictionary filled with
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7950
	key -> name of interface
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7951
	value -> the first socket address of the interface
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7952
     for each interface"
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7953
21220
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7954
    |addressInfo newDict|
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7955
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  7956
    addressInfo := self getNetworkAddressInfo.
21220
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7957
    newDict := OrderedDictionary new:addressInfo size.
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7958
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7959
    addressInfo keysAndValuesDo:[:ifName :infoColl|
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7960
	newDict at:ifName put:(infoColl first at:#address)
21220
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7961
    ].
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7962
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7963
    ^ newDict.
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7964
4e57abcb59bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21201
diff changeset
  7965
    "
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7966
	self getNetworkAddresses
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7967
    "
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7968
!
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7969
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7970
getNetworkMACAddresses
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7971
    "return a dictionary filled with
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7972
	key -> name of interface
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7973
	value -> the MAC address (as ByteArray)
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7974
     for each interface"
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7975
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7976
    |addressArray nameArray noOfIf retDictionary error|
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7977
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7978
    noOfIf := 0.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7979
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7980
%{  /* stack: 32000 */
16868
4afb8750ccbf compilable under linux
Claus Gittinger <cg@exept.de>
parents: 16867
diff changeset
  7981
#if defined(SIOCGIFCONF)
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7982
    int             afinet_socket = -1;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7983
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7984
    struct ifconf   ifc;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7985
    struct ifreq    *ifr;
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7986
    unsigned char   buf[4*1024];
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7987
    int             n_ifs, i, countOfIf;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7988
    OBJ             t;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7989
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7990
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7991
    ** Open an INET socket
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7992
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7993
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7994
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7995
    if (afinet_socket < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7996
	error = __MKSTRING("Cannot open socket");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  7997
	goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7998
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7999
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8000
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8001
    ** Get the list of network interfaces
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8002
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8003
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8004
    ifc.ifc_len = sizeof (buf);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8005
    ifc.ifc_buf = (caddr_t) buf;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8006
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8007
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8008
	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8009
	goto bad;
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8010
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8011
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8012
    // get the number of interfaces in the returned structure
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8013
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8014
    // cg: sigh
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8015
    // on linux, the records have constant size;
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8016
    // on osx, the max of the alen of each entry and the struct size needs to be taken to advance
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8017
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8018
    // I am not sure, which one is the correct way to do (maybe we should invert the test to say #ifdef linux ????
16868
4afb8750ccbf compilable under linux
Claus Gittinger <cg@exept.de>
parents: 16867
diff changeset
  8019
    // Please check on BSD, solaris, etc... (my feeling is, the the other would behave like __osx__ does, as they are all BSDish)
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8020
    // see also 2nd loop below
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8021
#ifndef __osx__
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8022
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8023
#else
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8024
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8025
	unsigned char *cp = buf;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8026
	unsigned char *limit = buf + ifc.ifc_len;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8027
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8028
	n_ifs = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8029
	while (cp < limit) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8030
	    int sz;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8031
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8032
	    ifr = (struct ifreq *)cp;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8033
	    sz = IFNAMSIZ + ifr->ifr_addr.sa_len;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8034
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8035
	    cp += sz;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8036
	    n_ifs++;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8037
	}
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8038
    }
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8039
#endif
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8040
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  8041
    nameArray    = __ARRAY_NEW_INT(n_ifs);
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  8042
    addressArray = __ARRAY_NEW_INT(n_ifs);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8043
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8044
    if (nameArray == nil || addressArray == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8045
	/* Creating a string wouldn/t work here */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8046
	error = @symbol(allocationFailure);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8047
	goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8048
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8049
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8050
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8051
    ** Iterate of the list of the system's netif. Find all
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8052
    ** active interfaces and their ethernet addresses
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8053
    */
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8054
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8055
    countOfIf = 0;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8056
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8057
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8058
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8059
	** Get Flags for this interface
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8060
	*/
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  8061
16868
4afb8750ccbf compilable under linux
Claus Gittinger <cg@exept.de>
parents: 16867
diff changeset
  8062
# ifndef __osx__ // SIOCGIFFLAGS fails on osx (Q@sv: what is this needed for anyway?)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8063
	{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8064
	    struct ifreq ifreq;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8065
	    memcpy(&ifreq, ifr, sizeof(ifreq));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8066
	    if (ioctl (afinet_socket, SIOCGIFFLAGS, &ifreq) < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8067
		if (@global(InfoPrinting) == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8068
		    fprintf(stderr, "OS [warning]: ioctl(SIOCGIFFLAGS) failed");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8069
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8070
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8071
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8072
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8073
	{
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8074
# ifdef SIOCGIFHWADDR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8075
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8076
	    ** Get Hardware address for this interface
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8077
	    */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8078
	    {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8079
		struct ifreq ifreq;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8080
		memcpy(&ifreq, ifr, sizeof(ifreq));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8081
		if (ioctl (afinet_socket, SIOCGIFHWADDR, &ifreq) >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8082
		    t = __MKBYTEARRAY(&ifreq.ifr_hwaddr.sa_data, IFHWADDRLEN);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8083
		    __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8084
		    t = __MKSTRING(&ifreq.ifr_name);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8085
		    __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8086
		    countOfIf += 1;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8087
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8088
	    }
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8089
16868
4afb8750ccbf compilable under linux
Claus Gittinger <cg@exept.de>
parents: 16867
diff changeset
  8090
#else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8091
	    // macosx has no SIOCGIFHWADDR
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8092
	    // printf("family: %d\n", ifr->ifr_addr.sa_family);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8093
	    // printf("name: %s\n", ifr->ifr_name);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8094
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8095
	    if (ifr->ifr_addr.sa_family == AF_LINK) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8096
		struct sockaddr_dl *sdl;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8097
		char *adr;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8098
		extern char *ether_ntoa();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8099
		unsigned char mac[6];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8100
		int a,b,c,d,e,f;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8101
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8102
		sdl = (struct sockaddr_dl *)&(ifr->ifr_addr);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8103
		adr = ether_ntoa(LLADDR(sdl));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8104
		// printf("name: %s adr: %s\n", ifr->ifr_name, adr);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8105
		sscanf(adr, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e, &f);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8106
		mac[0] = a;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8107
		mac[1] = b;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8108
		mac[2] = c;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8109
		mac[3] = d;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8110
		mac[4] = e;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8111
		mac[5] = f;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8112
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8113
		t = __MKBYTEARRAY(mac, 6);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8114
		__arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8115
		t = __MKSTRING(ifr->ifr_name);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8116
		__arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8117
		countOfIf += 1;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8118
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8119
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8120
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8121
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8122
	// see (sigh) comment above
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8123
#ifndef __osx__
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8124
	ifr++;
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8125
#else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8126
	{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8127
	    int sz = IFNAMSIZ + ifr->ifr_addr.sa_len;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8128
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8129
	    ifr = (struct ifreq *)( ((char *)ifr)+sz );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8130
	}
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8131
#endif
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8132
    }
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8133
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8134
    noOfIf = __mkSmallInteger(countOfIf);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8135
bad:
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8136
    if (afinet_socket >= 0)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8137
	close(afinet_socket);
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8138
#else
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8139
    error = @symbol(notSupported);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8140
#endif /* SIOCGIFHWADDR */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8141
%}.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8142
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8143
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8144
	self primitiveFailed:error.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8145
	"return an empty dictionary if proceed from error"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8146
	^  Dictionary new.
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  8147
    ].
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  8148
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  8149
    "we prefer OrderedDictionary here, because we want to keep the
15152
2252471df4ae class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15151
diff changeset
  8150
     order as defined in the OS."
15151
60e0fcf07b17 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15129
diff changeset
  8151
    retDictionary := OrderedDictionary new:noOfIf.
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8152
    1 to:noOfIf do:[:cnt|
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8153
	|macAddress|
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8154
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8155
	macAddress := addressArray at:cnt.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8156
	macAddress ~= #[0 0 0 0 0 0] ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8157
	    retDictionary at:(nameArray at:cnt) put:macAddress.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8158
	].
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8159
    ].
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8160
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8161
    ^ retDictionary
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8162
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8163
    "
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8164
      OperatingSystem getNetworkMACAddresses
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  8165
    "
6363
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  8166
!
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  8167
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8168
getNumberOfProcessors
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8169
    "answer the number of physical processors in the system"
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8170
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8171
%{ /* NOCONTEXT */
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8172
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8173
#ifdef _SC_NPROCESSORS_CONF
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8174
    RETURN(__mkSmallInteger(sysconf(_SC_NPROCESSORS_CONF)));
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8175
#endif
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8176
%}.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8177
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8178
    self shouldImplement.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8179
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8180
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8181
      self getNumberOfProcessors
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8182
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8183
!
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8184
18742
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8185
getNumberOfProcessorsOnline
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8186
    "answer the number of physical processors which are online in the system"
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8187
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8188
%{ /* NOCONTEXT */
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8189
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8190
#ifdef _SC_NPROCESSORS_ONLN
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8191
    RETURN(__mkSmallInteger(sysconf(_SC_NPROCESSORS_ONLN)));
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8192
#endif
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8193
%}.
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8194
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8195
    self shouldImplement.
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8196
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8197
    "
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8198
      self getNumberOfProcessorsOnline
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8199
    "
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8200
!
12d1703e876d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18736
diff changeset
  8201
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8202
getProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8203
    "return the (unix-)processId"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8204
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8205
%{  /* NOCONTEXT */
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8206
    RETURN ( __mkSmallInteger(getpid()) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8207
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8208
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8209
     OperatingSystem getProcessId
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8210
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8211
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8212
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8213
getSystemID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8214
    "if supported by the OS, return the systemID;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8215
     a unique per machine identification.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8216
     WARNING:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8217
	not all systems support this; on some, #unknown is returned."
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8218
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8219
%{  /* NOCONTEXT */
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8220
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8221
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8222
	char buffer[128];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8223
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8224
	buffer[0] = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8225
	if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8226
	    buffer[127] = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8227
	    if (strlen(buffer) > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8228
		RETURN(__MKSTRING(buffer));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8229
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8230
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8231
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8232
#elif defined(HAS_GETHOSTID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8233
    int runningId;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8234
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8235
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8236
    runningId = gethostid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8237
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8238
    *(int *)(__byteArrayVal(arr)) = runningId;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8239
    RETURN (arr);
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8240
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8241
#elif defined(IRIX5)
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8242
    char idBuffer[MAXSYSIDSIZE];
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8243
    int retVal;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8244
    OBJ arr;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8245
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8246
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8247
	arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8248
	bcopy(idBuffer, __byteArrayVal(arr), MAXSYSIDSIZE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8249
	RETURN (arr);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8250
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8251
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8252
%}.
13726
73a69112be21 comment/format in: #getSystemType
Stefan Vogel <sv@exept.de>
parents: 13365
diff changeset
  8253
    ^ #unknown
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8254
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8255
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8256
     OperatingSystem getSystemID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8257
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8258
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8259
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8260
getSystemInfo
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8261
    "return info on the system we are running on.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8262
     If the system supports uname and sysinfo-like system calls, that info is returned;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8263
     otherwise, some simulated info is returned.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8264
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8265
     WARNING:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8266
       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
  8267
       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
  8268
       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
  8269
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8270
       This method is mainly provided to augment error reports with some system
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8271
       information.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8272
       (in case of system/version specific OS errors, conditional workarounds and patches
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8273
	may be based upon this info).
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8274
       Also, applications could enable/disable buffering or otherwise reduce
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8275
       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
  8276
       Your application may make use of available information for tuning,
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8277
       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
  8278
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8279
     The returned info may (or may not) contain:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8280
	#system -> some operating system identification (irix, Linux, nt, win32s ...)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8281
	#version -> OS version (some os version identification)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8282
	#release -> OS release (3.5, 1.2.1 ...)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8283
	#node   -> some host identification (hostname)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8284
	#domain  -> domain name (hosts domain)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8285
	#machine -> type of CPU (i586, mips ...)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8286
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8287
     those are currently returned on some machines (no warranty)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8288
     linux:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8289
	#totalRam         -> total amount of memory available
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8290
	#sharedRam        -> amount of memory which is shared among processes
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8291
			     (i.e. shared code)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8292
	#bufferRam        -> amount used for buffers
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8293
	#swapSize         -> total size of swap space
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8294
	#freeSwap         -> free amount in swapSpace
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8295
	#numberOfCPUs     -> number of cpus in box
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8296
	#extendedInstructions -> extended instruction set info
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8297
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8298
     osf:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8299
	#physicalRam      -> total amount of physical memory
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8300
	#cpuType          -> type of cpu (more detailed than machine)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8301
	#numberOfCPUs     -> number of cpus in box
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8302
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8303
     osx:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8304
	#physicalRam      -> total amount of physical memory
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8305
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8306
     solaris:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8307
	#physicalRam      -> total amount of physical memory
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8308
	#availableRam     -> total available amount of physical memory (i.e. unused ram)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8309
	#freeRam          -> amount of free memory
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8310
	#numberOfCPUs     -> number of cpus in box (online CPUS)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8311
	[#dCacheSize]     -> bytes in data cache (only available on some solaris versions)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8312
	[#iCacheSize]     -> bytes in data cache (only available on some solaris versions)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8313
	[#instructionSets]-> instruction sets available (only available on some solaris versions)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8314
	[#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
  8315
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8316
     hpux:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8317
	#physicalRam      -> total amount of physical memory in box
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8318
	#activeRealMemory -> ? - read pstat documentation
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8319
	#activeVirtualRam -> ? - read pstat documentation
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8320
	#freeMemory       -> ? - read pstat documentation
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8321
	#realMemory       -> ? (amount of memory left to user programs)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8322
	#virtualRam       -> ? - read pstat documentation
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8323
    "
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8324
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8325
    |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
  8326
     physicalRam availableRam totalRam sharedRam bufferRam swapSize freeSwap
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8327
     numberOfCPUs numberOfPhysicalCPUs pageSize physicalPages availablePages dCacheSize iCacheSize
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8328
     virtualRam activeVirtualRam realMemory activeRealMemory freeMemory
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8329
     instructionSets extendedInstructions platform|
3496
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
%{  /* STACK: 4096 */
21044
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  8332
#if defined(linux) && defined(ELF)  /* old a.out unixes do not have this ... */
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
  8333
# include <sys/sysinfo.h>
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8334
    /*
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8335
     * additional info available ...
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8336
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8337
    struct sysinfo infoBuffer;
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8338
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8339
    if (sysinfo(&infoBuffer) >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8340
	totalRam   = __MKUINT(infoBuffer.totalram);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8341
	sharedRam = __MKUINT(infoBuffer.sharedram);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8342
	bufferRam = __MKUINT(infoBuffer.bufferram);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8343
	swapSize  = __MKUINT(infoBuffer.totalswap);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8344
	freeSwap  = __MKUINT(infoBuffer.freeswap);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8345
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8346
#endif /* LINUX */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8347
4088
622551d3c0d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  8348
#if defined(hpux) && !defined(__GNUC__)
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8349
# include <sys/pstat.h>
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8350
    struct pst_static stat_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8351
    struct pst_dynamic dynam_buf;
11285
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8352
    union pstun pstun_static;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8353
    union pstun pstun_dynamic;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8354
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8355
    pstun_static.pst_static = &stat_buf;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8356
    pstun_dynamic.pst_dynamic = &dynam_buf;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8357
    pstat(PSTAT_STATIC, pstun_static, (size_t)(sizeof(stat_buf)), (size_t)0, 0);
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8358
    pstat(PSTAT_DYNAMIC, pstun_dynamic, (size_t)(sizeof(dynam_buf)), (size_t)0, 0);
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8359
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8360
    physicalRam        = __MKUINT(stat_buf.physical_memory/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8361
    virtualRam         = __MKUINT(dynam_buf.psd_vm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8362
    activeVirtualRam   = __MKUINT(dynam_buf.psd_avm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8363
    realMemory         = __MKUINT(dynam_buf.psd_rm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8364
    activeRealMemory   = __MKUINT(dynam_buf.psd_arm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8365
    freeMemory         = __MKUINT(dynam_buf.psd_free/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8366
#endif
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8367
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8368
#if defined(HAS_UNAME)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8369
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8370
	struct utsname ubuff;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8371
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8372
	if (uname(&ubuff) >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8373
	    sys  = __MKSTRING(ubuff.sysname);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8374
	    node = __MKSTRING(ubuff.nodename);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8375
	    rel  = __MKSTRING(ubuff.release);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8376
	    ver  = __MKSTRING(ubuff.version);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8377
	    mach = __MKSTRING(ubuff.machine);
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8378
# if defined(HAS_UTS_DOMAINNAME) || defined(_GNU_SOURCE)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8379
	    dom  = __MKSTRING(ubuff.domainname);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8380
# endif /* no HAS_UTS_DOMAINNAME */
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8381
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8382
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8383
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8384
#else /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8385
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8386
    /*
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8387
     * use fallBack code below
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8388
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8389
#endif /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8390
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8391
#if defined(HAS_SYSINFO)
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8392
# if defined(SI_ARCHITECTURE)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8393
    if (arch == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8394
	char buffer[128];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8395
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8396
	if (sysinfo(SI_ARCHITECTURE, buffer, sizeof(buffer))) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8397
	    arch = __MKSTRING(buffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8398
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8399
    }
4923
1cacdcfc82c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4922
diff changeset
  8400
# endif /* SI_ARCHITECTURE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8401
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8402
# if defined(SI_ISALIST)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8403
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8404
	char buffer[128];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8405
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8406
	if (sysinfo(SI_ISALIST, buffer, sizeof(buffer))) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8407
	    instructionSets = __MKSTRING(buffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8408
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8409
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8410
# endif /* SI_ISALIST */
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8411
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8412
# if defined(SI_PLATFORM)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8413
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8414
	char buffer[128];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8415
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8416
	if (sysinfo(SI_PLATFORM, buffer, sizeof(buffer))) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8417
	    platform = __MKSTRING(buffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8418
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8419
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8420
# endif /* SI_PLATFORM */
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8421
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8422
# if defined(SI_RELEASE)
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8423
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8424
	char buffer[128];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8425
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8426
	if (sysinfo(SI_RELEASE, buffer, sizeof(buffer))) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8427
	    rel = __MKSTRING(buffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8428
	}
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8429
    }
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8430
# endif /* SI_RELEASE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8431
#endif /* HAS_SYSINFO */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8432
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8433
#if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8434
# ifdef _SC_NPROCESSORS_ONLN
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8435
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8436
	long val;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8437
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8438
	val = sysconf(_SC_NPROCESSORS_ONLN);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8439
	if (val > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8440
	    numberOfCPUs = __MKINT(val);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8441
	}
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8442
    }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8443
# endif
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8444
# ifdef _SC_NPROCESSORS_CONF
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8445
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8446
	long val;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8447
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8448
	val = sysconf(_SC_NPROCESSORS_CONF);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8449
	if (val > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8450
	    numberOfPhysicalCPUs = __MKINT(val);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8451
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8452
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8453
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8454
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8455
# if defined(_SC_PAGESIZE)
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8456
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8457
	long val;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8458
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8459
	val = sysconf(_SC_PAGESIZE);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8460
	if (val != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8461
	    pageSize = __MKUINT(val);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8462
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8463
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8464
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8465
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8466
# if defined(_SC_PHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8467
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8468
	long val;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8469
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8470
	val = sysconf(_SC_PHYS_PAGES);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8471
	if (val != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8472
	    physicalPages = __MKUINT(val);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8473
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8474
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8475
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8476
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8477
# if defined(_SC_AVPHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8478
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8479
	long val;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8480
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8481
	val = sysconf(_SC_AVPHYS_PAGES);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8482
	if (val != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8483
	    availablePages = __MKUINT(val);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8484
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8485
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8486
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8487
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8488
# if defined(_SC_ICACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8489
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8490
	long val;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8491
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8492
	val = sysconf(_SC_ICACHE_SZ);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8493
	if (val != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8494
	    iCacheSize = __MKUINT(val);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8495
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8496
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8497
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8498
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8499
# if defined(_SC_DCACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8500
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8501
	long val;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8502
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8503
	val = sysconf(_SC_DCACHE_SZ);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8504
	if (val != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8505
	    dCacheSize = __MKUINT(val);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8506
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8507
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8508
# endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8509
#endif /* HAS_SYSCONF */
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8510
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8511
#if defined(HAS_GETSYSINFO)
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8512
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8513
	INT index;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8514
	int retInt32 = 0;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8515
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8516
# if defined(GSI_CPU)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8517
	index = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8518
	if (getsysinfo(GSI_CPU, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8519
	    switch (retInt32) {
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8520
#  ifdef VAX_780
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8521
		case VAX_780:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8522
		    cpuType = __MKSTRING("VAX_780");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8523
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8524
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8525
#  ifdef VAX_750
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8526
		case VAX_750:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8527
		    cpuType = __MKSTRING("VAX_750");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8528
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8529
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8530
#  ifdef VAX_730
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8531
		case VAX_730:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8532
		    cpuType = __MKSTRING("VAX_730");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8533
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8534
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8535
#  ifdef VAX_8600
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8536
		case VAX_8600:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8537
		    cpuType = __MKSTRING("VAX_8600");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8538
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8539
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8540
#  ifdef VAX_8200
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8541
		case VAX_8200:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8542
		    cpuType = __MKSTRING("VAX_8200");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8543
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8544
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8545
#  ifdef VAX_8800
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8546
		case VAX_8800:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8547
		    cpuType = __MKSTRING("VAX_8800");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8548
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8549
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8550
#  ifdef MVAX_I
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8551
		case MVAX_I:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8552
		    cpuType = __MKSTRING("MVAX_I");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8553
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8554
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8555
#  ifdef MVAX_II
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8556
		case MVAX_II:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8557
		    cpuType = __MKSTRING("MVAX_II");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8558
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8559
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8560
#  ifdef V_VAX
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8561
		case V_VAX:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8562
		    cpuType = __MKSTRING("V_VAX");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8563
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8564
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8565
#  ifdef VAX_3600
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8566
		case VAX_3600:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8567
		    cpuType = __MKSTRING("VAX_3600");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8568
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8569
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8570
#  ifdef VAX_6200
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8571
		case VAX_6200:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8572
		    cpuType = __MKSTRING("VAX_6200");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8573
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8574
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8575
#  ifdef VAX_3400
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8576
		case VAX_3400:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8577
		    cpuType = __MKSTRING("VAX_3400");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8578
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8579
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8580
#  ifdef C_VAXSTAR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8581
		case C_VAXSTAR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8582
		    cpuType = __MKSTRING("C_VAXSTAR");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8583
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8584
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8585
#  ifdef VAX_60
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8586
		case VAX_60:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8587
		    cpuType = __MKSTRING("VAX_60");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8588
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8589
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8590
#  ifdef VAX_3900
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8591
		case VAX_3900:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8592
		    cpuType = __MKSTRING("VAX_3900");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8593
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8594
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8595
#  ifdef DS_3100
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8596
		case DS_3100:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8597
		    cpuType = __MKSTRING("DS_3100");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8598
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8599
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8600
#  ifdef VAX_8820
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8601
		case VAX_8820:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8602
		    cpuType = __MKSTRING("VAX_8820");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8603
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8604
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8605
#  ifdef DS_5400
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8606
		case DS_5400:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8607
		    cpuType = __MKSTRING("DS_5400");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8608
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8609
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8610
#  ifdef DS_5800
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8611
		case DS_5800:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8612
		    cpuType = __MKSTRING("DS_5800");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8613
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8614
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8615
#  ifdef DS_5000
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8616
		case DS_5000:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8617
		    cpuType = __MKSTRING("DS_5000");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8618
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8619
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8620
#  ifdef DS_CMAX
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8621
		case DS_CMAX:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8622
		    cpuType = __MKSTRING("DS_CMAX");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8623
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8624
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8625
#  ifdef VAX_6400
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8626
		case VAX_6400:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8627
		    cpuType = __MKSTRING("VAX_6400");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8628
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8629
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8630
#  ifdef VAXSTAR
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8631
		case VAXSTAR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8632
		    cpuType = __MKSTRING("VAXSTAR");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8633
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8634
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8635
#  ifdef DS_5500
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8636
		case DS_5500:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8637
		    cpuType = __MKSTRING("DS_5500");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8638
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8639
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8640
#  ifdef DS_5100
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8641
		case DS_5100:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8642
		    cpuType = __MKSTRING("DS_5100");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8643
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8644
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8645
#  ifdef VAX_9000
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8646
		case VAX_9000:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8647
		    cpuType = __MKSTRING("VAX_9000");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8648
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8649
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8650
#  ifdef DS_500_100
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8651
		case DS_500_100:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8652
		    cpuType = __MKSTRING("DS_500_100");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8653
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8654
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8655
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8656
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8657
#  ifdef ALPHA_ADU
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8658
		case ALPHA_ADU:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8659
		    cpuType = __MKSTRING("ALPHA_ADU");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8660
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8661
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8662
#  ifdef DEC_4000
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8663
		case DEC_4000:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8664
		    cpuType = __MKSTRING("DEC_4000");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8665
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8666
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8667
#  ifdef DEC_3000_500
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8668
		case DEC_3000_500:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8669
		    cpuType = __MKSTRING("DEC_3000_500");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8670
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8671
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8672
#  ifdef DEC_7000
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8673
		case DEC_7000:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8674
		    cpuType = __MKSTRING("DEC_7000");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8675
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8676
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8677
#  ifdef DS_5000_300
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8678
		case DS_5000_300:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8679
		    cpuType = __MKSTRING("DS_5000_300");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8680
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8681
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8682
#  ifdef DEC_3000_300
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8683
		case DEC_3000_300:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8684
		    cpuType = __MKSTRING("DEC_3000_300");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8685
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8686
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8687
#  ifdef DEC_2000_300
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8688
		case DEC_2000_300:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8689
		    cpuType = __MKSTRING("DEC_2000_300");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8690
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8691
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8692
#  ifdef DEC_2100_A500
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8693
		case DEC_2100_A500:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8694
		    cpuType = __MKSTRING("DEC_2100_A500");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8695
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8696
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8697
#  ifdef DEC_2100_A50
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8698
		case DEC_2100_A50:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8699
		    cpuType = __MKSTRING("DEC_2100_A50");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8700
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8701
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8702
#  ifdef ALPHA_KN20AA
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8703
		case ALPHA_KN20AA:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8704
		    cpuType = __MKSTRING("ALPHA_KN20AA");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8705
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8706
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8707
#  ifdef DEC_21000
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8708
		case DEC_21000:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8709
		    cpuType = __MKSTRING("DEC_21000");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8710
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8711
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8712
#  ifdef DEC_AXPVME_64
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8713
		case DEC_AXPVME_64:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8714
		    cpuType = __MKSTRING("DEC_AXPVME_64");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8715
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8716
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8717
#  ifdef DEC_2100_C500
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8718
		case DEC_2100_C500:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8719
		    cpuType = __MKSTRING("DEC_2100_C500");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8720
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8721
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8722
#  ifdef DEC_AXPPCI_33
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8723
		case DEC_AXPPCI_33:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8724
		    cpuType = __MKSTRING("DEC_AXPPCI_33");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8725
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8726
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8727
#  ifdef DEC_1000
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8728
		case DEC_1000:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8729
		    cpuType = __MKSTRING("DEC_1000");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8730
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8731
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8732
#  ifdef EB64_PLUS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8733
		case EB64_PLUS:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8734
		    cpuType = __MKSTRING("EB64_PLUS");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8735
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8736
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8737
#  ifdef LCA_EB66
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8738
		case LCA_EB66:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8739
		    cpuType = __MKSTRING("LCA_EB66");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8740
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8741
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8742
#  ifdef ALPHA_EB164
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8743
		case ALPHA_EB164:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8744
		    cpuType = __MKSTRING("ALPHA_EB164");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8745
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8746
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8747
#  ifdef DEC_EV45_PBP
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8748
		case DEC_EV45_PBP:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8749
		    cpuType = __MKSTRING("DEC_EV45_PBP");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8750
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8751
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8752
#  ifdef DEC_1000A
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8753
		case DEC_1000A:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8754
		    cpuType = __MKSTRING("DEC_1000A");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8755
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8756
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8757
#  ifdef DEC_4100
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8758
		case DEC_4100:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8759
		    cpuType = __MKSTRING("DEC_4100");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8760
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8761
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8762
#  ifdef DEC_ALPHAVME_224
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8763
		case DEC_ALPHAVME_224:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8764
		    cpuType = __MKSTRING("DEC_ALPHAVME_224");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8765
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8766
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8767
#  ifdef DEC_1000_5
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8768
		case DEC_1000_5:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8769
		    cpuType = __MKSTRING("DEC_1000_5");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8770
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8771
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8772
#  ifdef DEC_1000A_5
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8773
		case DEC_1000A_5:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8774
		    cpuType = __MKSTRING("DEC_1000A_5");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8775
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8776
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8777
#  ifdef DEC_EV56_PBP
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8778
		case DEC_EV56_PBP:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8779
		    cpuType = __MKSTRING("DEC_EV56_PBP");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8780
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8781
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8782
#  ifdef ALPHABOOK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8783
		case ALPHABOOK:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8784
		    cpuType = __MKSTRING("ALPHABOOK");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8785
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8786
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8787
#  ifdef DEC_ALPHAVME_320
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8788
		case DEC_ALPHAVME_320:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8789
		    cpuType = __MKSTRING("DEC_ALPHAVME_320");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8790
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8791
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8792
#  ifdef DEC_550
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8793
		case DEC_550:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8794
		    cpuType = __MKSTRING("DEC_550");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8795
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8796
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8797
#  ifdef DEC_6600
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8798
		case DEC_6600:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8799
		    cpuType = __MKSTRING("DEC_6600");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8800
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8801
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8802
#  ifdef UNKN_SYSTEM
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8803
		case UNKN_SYSTEM:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8804
		    cpuType = __MKSTRING("UNKN_SYSTEM");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8805
		    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8806
#  endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8807
		default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8808
		    cpuType = __MKSTRING("OTHER_DEC_SYSTEM");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8809
		    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8810
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8811
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8812
# endif /* GSI_CPU */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8813
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8814
# if defined(GSI_CPU_INFO)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8815
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8816
	 * stupid: OSF1 pre V4.0 has no mhz, but V4.0 has it.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8817
	 * use the GSI_PLATFORM_NAME as a hint - it is only defined in
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8818
	 * V4.0 and higher ... (sigh)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8819
	 */
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  8820
#  if defined(GSI_PLATFORM_NAME)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8821
	{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8822
	    struct cpu_info cpuInfo;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8823
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8824
	    index = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8825
	    if (getsysinfo(GSI_CPU_INFO, &cpuInfo, sizeof(cpuInfo), &index, NULL) > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8826
		cpuSpeed   = __MKUINT(cpuInfo.mhz);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8827
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8828
	}
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  8829
#  endif
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8830
# endif /* GSI_CPU_INFO */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8831
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8832
# if defined(GSI_CPUS_IN_BOX)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8833
	index = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8834
	if (getsysinfo(GSI_CPUS_IN_BOX, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8835
	    numberOfCPUs   = __MKUINT(retInt32);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8836
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8837
# endif /* GSI_CPUS_IN_BOX */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8838
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8839
# if defined(GSI_PHYSMEM)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8840
	index = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8841
	if (getsysinfo(GSI_PHYSMEM, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8842
	    INT bytes = retInt32 * 1024;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8843
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8844
	    physicalRam   = __MKUINT(bytes);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8845
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8846
# endif /* GSI_PHYSMEM */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8847
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8848
# if defined(GSI_PLATFORM_NAME) && (!defined(HAS_SYSINFO) || !defined(SI_PLATFORM))
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8849
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8850
	char buffer[128];
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8851
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8852
	index = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8853
	if (getsysinfo(GSI_PLATFORM_NAME, buffer, sizeof(buffer), &index, NULL) > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8854
	    platform = __MKSTRING(buffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8855
	}
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8856
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8857
# endif /* GSI_PLATFORM_NAME */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8858
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8859
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8860
#endif /* HAS_GETSYSINFO */
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8861
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8862
#if defined(HAS_SYSCTL) /* __osx__ */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8863
    int mib[3];
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8864
    long _physmem;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8865
    size_t _len;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8866
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8867
    mib[0] = CTL_HW;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8868
    mib[1] = HW_MEMSIZE;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8869
    _len = sizeof(_physmem);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8870
    sysctl(mib, 2, &_physmem, &_len, NULL, 0);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8871
    physicalRam   = __MKUINT(_physmem);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8872
#endif /* __osx__ */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8873
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8874
#if defined(__x86_64__)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8875
    cpuType = __MKSTRING("x86_64");
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8876
#endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8877
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8878
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8879
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8880
	extern OBJ __getInstructionSetInfo();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8881
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8882
	extendedInstructions = __getInstructionSetInfo();
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8883
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8884
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8885
    sys isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8886
	sys := self getSystemType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8887
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8888
    node isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8889
	node := self getHostName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8890
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8891
    dom isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8892
	dom := self getDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8893
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8894
    mach isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8895
	mach := self getCPUType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8896
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8897
    arch isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8898
	arch := sys.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8899
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8900
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8901
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8902
    info at:#system put:sys.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8903
    info at:#node put:node.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8904
    rel notNil ifTrue:[info at:#release put:rel].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8905
    ver notNil ifTrue:[info at:#version put:ver].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8906
    mach notNil ifTrue:[info at:#machine put:mach].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8907
    arch notNil ifTrue:[info at:#architecture put:arch].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8908
    dom notNil ifTrue:[info at:#domain put:dom].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8909
    (pageSize notNil and:[physicalPages notNil]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8910
	physicalRam := pageSize * physicalPages. "/ done here - could be largeInt.
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8911
    ].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8912
    physicalRam notNil ifTrue:[info at:#physicalRam put:physicalRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8913
    (pageSize notNil and:[availablePages notNil]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8914
	availableRam := pageSize * availablePages. "/ done here - could be largeInt.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8915
	availableRam notNil ifTrue:[info at:#availableRam put:availableRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8916
    ].
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8917
    totalRam notNil ifTrue:[info at:#totalRam put:totalRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8918
    sharedRam notNil ifTrue:[info at:#sharedRam put:sharedRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8919
    bufferRam notNil ifTrue:[info at:#bufferRam put:bufferRam].
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8920
    virtualRam notNil ifTrue:[info at:#virtualRam put:virtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8921
    activeVirtualRam notNil ifTrue:[info at:#activeVirtualRam put:activeVirtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8922
    realMemory notNil ifTrue:[info at:#realMemory put:realMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8923
    activeRealMemory notNil ifTrue:[info at:#activeRealMemory put:activeRealMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8924
    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
  8925
    swapSize notNil ifTrue:[info at:#swapSize put:swapSize].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8926
    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
  8927
    numberOfCPUs notNil ifTrue:[info at:#numberOfCPUs put:numberOfCPUs].
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8928
    numberOfPhysicalCPUs notNil ifTrue:[info at:#numberOfPhysicalCPUs put:numberOfPhysicalCPUs].
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8929
    cpuType notNil ifTrue:[info at:#cpuType put:cpuType].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8930
    cpuSpeed notNil ifTrue:[info at:#cpuSpeed put:cpuSpeed].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8931
    dCacheSize notNil ifTrue:[info at:#dCacheSize put:dCacheSize].
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8932
    iCacheSize notNil ifTrue:[info at:#iCacheSize put:iCacheSize].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8933
    instructionSets notNil ifTrue:[info at:#instructionSets put:instructionSets].
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8934
    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
  8935
    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
  8936
    info at:#osType put:(self getOSType).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8937
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8938
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8939
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8940
     OperatingSystem getSystemInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8941
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8942
!
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
getSystemType
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8945
    "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
  8946
     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
  8947
     is slightly different for some systems (i.e. iris vs. irix).
20814
035cfc0c970b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20710
diff changeset
  8948
     Don't depend on this - use getOSType. I don't really see a point
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8949
     here ...
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8950
     (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
  8951
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8952
    |sys|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8953
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8954
%{
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8955
#   ifdef __NEXT__
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8956
#    define SYS_SYMBOL @symbol(next)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8957
#   endif
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
#   ifdef IRIS
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8960
#    define SYS_SYMBOL @symbol(iris)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8961
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8962
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8963
#   ifdef SYS_SYMBOL
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8964
     sys = SYS_SYMBOL;
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8965
#    undef SYS_SYMBOL
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8966
#   endif
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
    sys isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  8970
	^ self getOSType
3496
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
    ^ sys
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8973
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8974
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8975
     OperatingSystem getSystemType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8976
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8977
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8978
19763
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8979
getThreadId
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8980
    "return the threadId of the currently executing thread,
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8981
     or nil on systems which use a single OS thread"
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8982
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8983
    ^ nil
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8984
    "
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8985
     OperatingSystem getThreadId
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8986
    "
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8987
!
d5eb80c594ea #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19675
diff changeset
  8988
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8989
isBSDlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8990
    "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
  8991
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8992
%{  /* NOCONTEXT */
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
#if defined(BSD) || defined(MACH) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8995
    RETURN ( true );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8996
#endif
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
    ^ false
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8999
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  9000
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  9001
     OperatingSystem isBSDlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  9002
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9003
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9004
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9005
isLinuxLike
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9006
    "return true, if the OS we're running on is a linux."
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9007
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9008
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9009
%{  /* NOCONTEXT */
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9010
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9011
#if defined(LINUX)
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9012
    RETURN ( true );
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9013
#endif
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9014
%}.
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9015
    ^ false
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9016
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9017
    "
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9018
     OperatingSystem isLinuxLike
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9019
    "
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9020
!
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  9021
14802
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9022
isOSXlike
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9023
    "return true, if the OS we're running on is a mac OSX unix (not A/UX or OS9)."
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9024
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9025
%{  /* NOCONTEXT */
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9026
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9027
#if defined(__osx__)
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9028
    RETURN ( true );
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9029
#endif
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9030
%}.
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9031
    ^ false
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9032
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9033
    "
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9034
     OperatingSystem isOSXlike
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9035
    "
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9036
!
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  9037
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9038
isProcessIdPresent:pid
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9039
    "answer true, if a process with process id pid is present, false if not"
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9040
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9041
%{
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9042
    if (__isSmallInteger(pid)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9043
	/* in UNIX, a kill(pid, 0) is a noop used to check if a pid exists */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9044
	if (kill(__smallIntegerVal(pid), 0) < 0 && errno != EPERM) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9045
	    RETURN ( false );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9046
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9047
	RETURN ( true );
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9048
    }
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9049
%}.
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9050
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9051
    ^ self primitiveFailed:#invalidParameter
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9052
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9053
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9054
    "
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9055
      self isProcessIdPresent:self getProcessId
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9056
      self isProcessIdPresent:1
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9057
      self isProcessIdPresent:4711
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9058
    "
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9059
!
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  9060
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9061
isUNIXlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9062
    "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
  9063
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9064
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9065
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  9066
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  9067
     OperatingSystem isUNIXlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  9068
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9069
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9070
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9071
maxFileNameLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9072
    "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
  9073
     CAVEAT:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9074
	 Actually, the following is somewhat wrong - some systems
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9075
	 support different sizes, depending on the volume.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9076
	 We return a somewhat conservative number here.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9077
	 Another entry, to query for volume specific max
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9078
	 will be added in the future."
3496
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
%{  /* NOCONTEXT */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9081
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9082
    /*
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9083
     * 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
  9084
     */
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9085
#   if defined(MAXFILENAMELEN)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9086
      RETURN ( __mkSmallInteger(MAXFILENAMELEN) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9087
#   else
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9088
#    if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9089
      RETURN ( __mkSmallInteger(255) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9090
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9091
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9092
#    ifdef realIX
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9093
       RETURN ( __mkSmallInteger(127) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9094
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9095
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9096
#    ifdef SYSV
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9097
       RETURN ( __mkSmallInteger(14) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9098
#    endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9099
#   endif
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
    "unix default"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9102
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9103
    ^ 14
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9104
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9105
    "
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9106
     OperatingSystem maxFileNameLength
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  9107
    "
3496
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
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9110
maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9111
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9112
%{
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9113
     long l;
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9114
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9115
     l = sysconf(_SC_OPEN_MAX);
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9116
     if (l >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9117
	 RETURN(__mkSmallInteger(l));
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9118
     }
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9119
%}.
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9120
     self primitiveFailed
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9121
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9122
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9123
      self maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9124
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9125
!
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9126
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9127
maxPathLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9128
    "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
  9129
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9130
%{  /* NOCONTEXT */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9131
    RETURN ( __mkSmallInteger(MAXPATHLEN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9132
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9133
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9134
     OperatingSystem maxPathLength
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9135
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9136
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9137
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9138
pathSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9139
    "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
  9140
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9141
    ^ $:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9142
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9143
    "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
  9144
    "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
  9145
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9146
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9147
primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9148
    "return the domain this host is in.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9149
     Notice:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9150
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9151
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9152
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9153
#if defined(HAS_GETDOMAINNAME)
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  9154
    char buffer[256];
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9155
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9156
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9157
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9158
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9159
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9160
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9161
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9162
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9163
    if (uname(&ubuff) >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9164
	RETURN (__MKSTRING(ubuff.domainname));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9165
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9166
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9167
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9168
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9169
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9170
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9171
    if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9172
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9173
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9174
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9175
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9176
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9177
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9178
    ^ nil
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9179
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9180
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9181
     OperatingSystem primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9182
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9183
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9184
    "Modified: 26.4.1996 / 10:04:54 / stefan"
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9185
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9186
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9187
primGetHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9188
    "return the hostname we are running on - if there is
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9189
     a HOST environment variable, we are much faster here ...
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9190
     Notice:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9191
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9192
6960
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9193
%{  /* STACK: 100000 */
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9194
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9195
    /* sigh - with libc.so.6, gethostname needs huge amounts of stack
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9196
     * actually this is linux specific, but should not hurt others
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9197
     */
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9198
#if defined(HAS_GETHOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9199
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9200
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9201
    if (gethostname(buffer, sizeof(buffer)) == 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9202
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9203
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9204
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9205
# if defined(HAS_UNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9206
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9207
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9208
    if (uname(&ubuff) >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9209
	RETURN (__MKSTRING(ubuff.nodename));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9210
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9211
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9212
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9213
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9214
    int ret;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9215
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9216
    if ((ret = sysinfo(SI_HOSTNAME, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9217
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9218
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9219
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9220
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9221
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9222
%}.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9223
    ^ nil
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9224
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9225
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9226
     OperatingSystem getHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9227
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9228
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9229
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9230
randomBytesInto:bufferOrInteger
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9231
    "If bufferOrInteger is a String or a ByteArray,
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9232
	fill a given buffer with random bytes from the RtlGenRandom function
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9233
	and answer the buffer.
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9234
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9235
     If bufferOrInteger is a SmallInteger,
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9236
	return this many bytes (max 4) as a SmallInteger.
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9237
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9238
     Return nil on error (may raise PrimitiveFailure, too).
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9239
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9240
     NOTE: This is a private interface, please use RandomGenerator!!"
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9241
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9242
%{
19361
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9243
#if defined(LINUX)
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9244
# include <sys/syscall.h>
20257
bf95d404e329 #OTHER by mawalch
mawalch
parents: 20125
diff changeset
  9245
# if defined(SYS_getrandom) // getrandom(2) is supported starting with linux 3.17 (2014-10-05)
19361
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9246
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9247
# if 1 || !(defined(__GLIBC__) && __GLIBC_PREREQ(2, 23))
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9248
    // getrandom() appears first in GLIBC 2.23
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9249
    // but we define it here until this GLIBC has been deployed on all linux distributions
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9250
    // used by our customers
19913
df79a7806174 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19909
diff changeset
  9251
#  if __POINTER_SIZE__ == 8
df79a7806174 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19909
diff changeset
  9252
#   define __flag32 0
df79a7806174 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19909
diff changeset
  9253
#  else
df79a7806174 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19909
diff changeset
  9254
#   define __flag32 __X32_SYSCALL_BIT
df79a7806174 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19909
diff changeset
  9255
#  endif
19361
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9256
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9257
    inline int getrandom(void *buf, size_t buflen, unsigned int flags) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9258
	return syscall(SYS_getrandom|__flag32, buf, buflen, flags);
19361
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9259
    }
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9260
# endif
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9261
19669
d8a7300a2382 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19574
diff changeset
  9262
    size_t wanted, gotSoFar = 0;
d8a7300a2382 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 19574
diff changeset
  9263
    int cnt;
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9264
    char *buffer;
19434
fee1fbb3d8e5 change didn't work: bufffer vs. buffer
Stefan Vogel <sv@exept.de>
parents: 19432
diff changeset
  9265
    INT intBuffer = 0;
19432
c5d2a0141327 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19424
diff changeset
  9266
    int wantInteger = 0;
19972
bb8be0722679 #BUGFIX by mawalch
mawalch
parents: 19914
diff changeset
  9267
19432
c5d2a0141327 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19424
diff changeset
  9268
    if (__isSmallInteger(bufferOrInteger)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9269
	wanted = __smallIntegerVal(bufferOrInteger);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9270
	if (wanted > sizeof(INT)) goto error;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9271
	buffer = (char *)&intBuffer;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9272
	wantInteger = 1;
18728
bc4a95bbdf25 Fix typos in random generation code
javogel
parents: 18697
diff changeset
  9273
    } else if (__isByteArray(bufferOrInteger)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9274
	wanted = __byteArraySize(bufferOrInteger);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9275
	buffer = __byteArrayVal(bufferOrInteger);
18728
bc4a95bbdf25 Fix typos in random generation code
javogel
parents: 18697
diff changeset
  9276
    } else if (__isString(bufferOrInteger)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9277
	wanted = __stringSize(bufferOrInteger);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9278
	buffer = __stringVal(bufferOrInteger);
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9279
    } else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9280
	goto error;
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9281
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9282
    do {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9283
	cnt = getrandom(buffer + gotSoFar, wanted - gotSoFar, 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9284
	if (cnt < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9285
	    if (errno != EINTR && errno != EAGAIN)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9286
		goto error;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9287
	    if (!wantInteger) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9288
		// re-fetch buffer in case a garbage collect occurred meanwhile
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9289
		buffer = __isByteArray(bufferOrInteger) ?
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9290
			    __byteArrayVal(bufferOrInteger) : __stringVal(bufferOrInteger);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9291
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9292
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9293
	    gotSoFar = gotSoFar + cnt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9294
	}
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9295
    } while (gotSoFar < wanted);
19432
c5d2a0141327 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19424
diff changeset
  9296
    if (wantInteger) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9297
	RETURN(__mkSmallInteger(intBuffer & _MAX_INT));
19432
c5d2a0141327 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 19424
diff changeset
  9298
    }
18728
bc4a95bbdf25 Fix typos in random generation code
javogel
parents: 18697
diff changeset
  9299
    RETURN(bufferOrInteger);
19361
650e52cb3ec8 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 19191
diff changeset
  9300
# endif // SYS_getrandom
18758
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
  9301
#endif
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9302
error: ;
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9303
%}.
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9304
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9305
    ^ self primitiveFailed.
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9306
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9307
    "
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9308
	self randomBytesInto:1.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9309
	self randomBytesInto:2.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9310
	self randomBytesInto:4.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9311
	self randomBytesInto:8.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9312
	self randomBytesInto:(ByteArray new:16).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9313
	self randomBytesInto:(String new:16).
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9314
    "
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9315
!
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9316
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9317
setEnvironment:aKeyStringOrSymbol to:aString
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9318
    "put a string to the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9319
     If aString isNil, the variable will be removed from the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9320
     Currently there is some malloced memory lost each time a variable is put to the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9321
     We could use ExternalBytes and keep the references in a Dictionary to free the
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9322
     memory on change or delete"
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9323
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9324
%{  /* NOCONTEXT */
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9325
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9326
    char *env;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9327
    int valueSize;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9328
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9329
    if (__isStringLike(aKeyStringOrSymbol)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9330
	if (aString == nil) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9331
	    /* env used only temporary for deregistration */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9332
	    valueSize = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9333
	    env = __stringVal(aKeyStringOrSymbol);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9334
	} else if (__isStringLike(aString)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9335
	    /* have to use stable memory for env */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9336
	    valueSize = __stringSize(aString);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9337
	    env = (char *)malloc(__stringSize(aKeyStringOrSymbol) + valueSize + 2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9338
	    if (env == 0)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9339
		goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9340
	    strcpy(env, __stringVal(aKeyStringOrSymbol));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9341
	    strcat(env, "=");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9342
	    strncat(env, __stringVal(aString), valueSize);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9343
	} else
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9344
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9345
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9346
	if (putenv(env) == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9347
	    RETURN(self);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9348
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9349
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9350
	if (valueSize > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9351
	    /* could not register, free */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9352
	    free(env);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9353
	}
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9354
err:;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9355
    }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9356
%}.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9357
    ^ self primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9358
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9359
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9360
     OperatingSystem setEnvironment:#TEST to:'abc'.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9361
     OperatingSystem getEnvironment:#TEST.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9362
     OperatingSystem executeCommand:'echo $TEST' outputTo:Transcript.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9363
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9364
     OperatingSystem setEnvironment:#TEST to:nil.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9365
     OperatingSystem setEnvironment:#TEST to:''.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9366
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9367
     OperatingSystem setEnvironment:#LD_LIBRARY_PATH to:'/opt/oracle/instantclient10_1'.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9368
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9369
!
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9370
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9371
setLocale:categorySymbol to:localeStringOrNil
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9372
    "set (and get) the locale for categorySymbol (e.g. #LC_ALL, #LC_CTYPE,....).
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9373
     If localeStringOrNil is nil, nothing is set.
21498
e3c6ea4a8eef #DOCUMENTATION by mawalch
mawalch
parents: 21329
diff changeset
  9374
     If localeStringOrNil is empty, the locale for categorySymbol is set from the environment.
e3c6ea4a8eef #DOCUMENTATION by mawalch
mawalch
parents: 21329
diff changeset
  9375
     If localeStringOrNil is 'C', the locale for categorySymbol is set to the default.
21899
2ce4352ca6ac #DOCUMENTATION by mawalch
mawalch
parents: 21772
diff changeset
  9376
     If localeStringOrNil is to a locale name, the locale for categorySymbol is set.
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9377
     The current locale setting is returned."
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9378
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9379
    |locale error|
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9380
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9381
%{
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9382
    int __category;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9383
    char *__locale, *ret;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9384
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9385
    if (categorySymbol == @symbol(LC_ALL)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9386
	__category = LC_ALL;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9387
    } else if (categorySymbol == @symbol(LC_COLLATE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9388
	__category = LC_COLLATE;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9389
    } else if (categorySymbol == @symbol(LC_CTYPE)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9390
	__category = LC_CTYPE;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9391
    } else if (categorySymbol == @symbol(LC_MESSAGES)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9392
	__category = LC_MESSAGES;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9393
    } else if (categorySymbol == @symbol(LC_MONETARY)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9394
	__category = LC_MONETARY;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9395
    } else if (categorySymbol == @symbol(LC_NUMERIC)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9396
	__category = LC_NUMERIC;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9397
    } else if (categorySymbol == @symbol(LC_TIME)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9398
	__category = LC_TIME;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9399
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9400
	error = @symbol(argument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9401
	goto out;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9402
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9403
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9404
    if (localeStringOrNil == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9405
	__locale = 0;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9406
    } else if (__isStringLike(localeStringOrNil)){
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9407
	__locale = __stringVal(localeStringOrNil);
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9408
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9409
	error = @symbol(argument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9410
	goto out;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9411
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9412
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9413
    ret = setlocale(__category, __locale);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9414
    if (ret) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9415
	locale = __MKSTRING(ret);
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9416
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9417
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9418
out:;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9419
%}.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9420
    locale notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9421
	^ locale.
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9422
    ].
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9423
    ^ self primitiveFailed:error.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9424
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9425
    "
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9426
     OperatingSystem setLocale:#LC_ALL to:nil
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9427
     OperatingSystem setLocale:#LC_CTYPE to:nil
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9428
     OperatingSystem setLocale:#LC_CTYPE to:'C'
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9429
     OperatingSystem setLocale:#LC_CTYPE to:''
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9430
    "
21498
e3c6ea4a8eef #DOCUMENTATION by mawalch
mawalch
parents: 21329
diff changeset
  9431
21899
2ce4352ca6ac #DOCUMENTATION by mawalch
mawalch
parents: 21772
diff changeset
  9432
    "Modified (comment): / 22-06-2017 / 10:27:03 / mawalch"
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9433
!
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9434
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9435
setLocaleInfo:anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9436
    "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
  9437
     (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
  9438
     See description of fields in #getLocaleInfo.
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
     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
  9441
     it should be used by applications as required."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9442
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9443
    LocaleInfo := anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9444
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
     |d|
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
     d := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9449
     d at:#decimalPoint                 put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9450
     d at:#thousandsSeparator           put:','         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9451
     d at:#currencySymbol               put:'USD'       .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9452
     d at:#monetaryDecimalPoint         put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9453
     d at:#monetaryThousandsSeparator   put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9454
     d at:#fractionalDigits             put:2           .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9455
     d at:#positiveSign                 put:'+'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9456
     d at:#negativeSign                 put:'-'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9457
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9458
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9459
     OperatingSystem setLocaleInfo:d
3496
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
!
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
supportsChildInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9464
    "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
  9465
     through interrupts (i.e. SIGCHILD)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9466
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9467
%{  /* NOCONTEXT */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9468
#if defined(SIGCHLD) || defined(SIGCLD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9469
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9470
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9471
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9472
    ^ false
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
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9475
     OperatingSystem supportsChildInterrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9476
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9477
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9478
21072
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  9479
supportsFileLinks
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  9480
    "return true, if the OS supports file links (hard links).
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  9481
     Typically, only unix returns true here."
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  9482
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  9483
    ^ true
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  9484
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  9485
    "Modified: / 5.6.1998 / 18:35:01 / cg"
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  9486
!
8c9b32a1d4a8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21050
diff changeset
  9487
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9488
supportsIOInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9489
    "return true, if the OS supports IO availability interrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9490
     (i.e. SIGPOLL/SIGIO).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9491
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9492
     Currently, this mechanism does not work on all
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9493
     systems ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9494
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9495
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9496
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9497
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9498
  /* positive defines here
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9499
   *  - irix5.2 does not work
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9500
   */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9501
#if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9502
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9503
# if defined(SIGIO) || defined(SIGPOLL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9504
#  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
  9505
#   if defined(F_SETOWN) || defined(FIOSETOWN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9506
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9507
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9508
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9509
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9510
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9511
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9512
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9513
#endif /* machines where it works */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9514
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9515
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9516
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9517
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9518
     OperatingSystem supportsIOInterrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9519
    "
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  9520
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9521
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9522
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9523
supportsNonBlockingIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9524
    "return true, if the OS supports nonblocking IO."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9525
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9526
%{  /* NOCONTEXT */
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9527
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9528
# if defined(O_NONBLOCK) || defined(O_NDELAY) || defined(FNDELAY)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9529
       RETURN (true);
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9530
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9531
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9532
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9533
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9534
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9535
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9536
     OperatingSystem supportsNonBlockingIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9537
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9538
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9539
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9540
supportsSymbolicLinks
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9541
    "return true, if the OS supports symbolic (soft) links;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9542
     most UNIX'es do; many other OS's do not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9543
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9544
%{  /* NOCONTEXT */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9545
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9546
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9547
    /*
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9548
     * assume yes - if that is defined.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9549
     */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9550
    RETURN(true);
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9551
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9552
%}.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9553
    ^ false
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9554
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9555
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9556
     OperatingSystem supportsSymbolicLinks
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9557
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9558
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9559
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9560
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9561
!UnixOperatingSystem class methodsFor:'path queries'!
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9562
16417
88b61e714dd0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16410
diff changeset
  9563
decodePathOrCommandOutput:encodedPathNameOrOutputLine
16396
4896e6f5ffda class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16391
diff changeset
  9564
    "decode the encodedPathNameOrOutputLine as returned by system calls or output by system commands.
20609
1b423e40ed09 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20460
diff changeset
  9565
     This takes care for any specific OS encodings or specific command encodings.
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
  9566
16396
4896e6f5ffda class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16391
diff changeset
  9567
     E.g. linux system calls return single byte strings only,
17499
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9568
     so pathNames and command output comes UTF-8 encoded.
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9569
     (actually, on a mac, it comes utf8-mac encoded)."
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9570
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9571
    (encodedPathNameOrOutputLine isNil or:[CodesetEncoder isNil]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9572
	^ encodedPathNameOrOutputLine.
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9573
    ].
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9574
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9575
    ^ [
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9576
	CodesetEncoder decodeString:encodedPathNameOrOutputLine.
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9577
    ] on:DecodingError do:[:ex|
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9578
	"maybe there are old filenames in ISO-8859-x,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9579
	 just keep them untranslated"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9580
	encodedPathNameOrOutputLine
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9581
    ].
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9582
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9583
    "Modified: / 23-01-2013 / 10:02:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
21620
f13226508305 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21613
diff changeset
  9584
    "Modified: / 01-03-2017 / 18:46:08 / stefan"
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  9585
!
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  9586
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9587
defaultSystemPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9588
    "add additional directories to the systemPath
5647
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  9589
     (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
  9590
16653
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9591
    |places sysPath majorVersionNr minorVersionNr releaseFile vsnDirName s v|
5647
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  9592
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  9593
    majorVersionNr := Smalltalk majorVersionNr.
16646
eb3524f545f4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16645
diff changeset
  9594
    minorVersionNr := Smalltalk minorVersionNr.
eb3524f545f4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16645
diff changeset
  9595
    vsnDirName := '%1.%2' bindWith:majorVersionNr with:minorVersionNr.
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9596
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9597
    sysPath := super defaultSystemPath.
16653
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9598
    places :=
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9599
	#(
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9600
	    '/usr/local/lib/stx'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9601
	    '/usr/local/lib/smalltalk'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9602
	    '/usr/local/lib/smalltalk-x'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9603
	    '/usr/lib/stx'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9604
	    '/usr/lib/smalltalk'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9605
	    '/usr/lib/smalltalk-x'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9606
	    '/lib/stx'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9607
	    '/lib/smalltalk'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9608
	    '/lib/smalltalk-x'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9609
	    '/opt/stx'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9610
	    '/opt/smalltalk'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9611
	    '/opt/smalltalk-x'
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9612
	).
16653
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9613
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9614
    self isOSXlike ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9615
	|pathOfSTX|
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9616
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9617
	 places :=
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9618
		{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9619
		    '/Library/Smalltalk' .
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9620
		    '/Library/Smalltalk-x' .
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9621
		    '~/Library/Smalltalk' .
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9622
		    '~/Library/Smalltalk-x' .
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9623
		} , places.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9624
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9625
	pathOfSTX := OperatingSystem pathOfSTXExecutable.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9626
	pathOfSTX notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9627
	    places :=
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9628
		{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9629
		    (pathOfSTX asFilename / '../Packages') name .
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9630
		    (pathOfSTX asFilename / '../../Packages') name .
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9631
		} , places.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9632
	]
16653
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9633
    ].
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9634
    places do:[:dirName |
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9635
	|dir vsnDir|
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9636
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9637
	dir := dirName asFilename.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9638
	(dir isDirectory) ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9639
	    "/ try to guess a gnu-smalltalk; skip it
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9640
	    (dir construct:'initialize.st') exists ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9641
		vsnDir := dir / vsnDirName.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9642
		vsnDir exists ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9643
		    "/ new style: look for a major.minor directory there
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9644
		    sysPath add:vsnDir.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9645
		] ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9646
		    "/ old style: look for a RELEASE file there and check if it matches
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9647
		    releaseFile := dir construct:'RELEASE'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9648
		    releaseFile exists ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9649
			s := releaseFile readStreamOrNil.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9650
			s notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9651
			    v := Integer readFrom:s onError:-1.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9652
			    s close.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9653
			    v == majorVersionNr ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9654
				sysPath add:dirName
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9655
			    ] ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9656
				('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE mismatch)') infoPrintCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9657
			    ]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9658
			] ifFalse:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9659
			    ('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE missing)') infoPrintCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9660
			]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9661
		    ]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9662
		]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9663
	    ]
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9664
	]
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9665
    ].
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9666
    ^ sysPath
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  9667
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  9668
    "
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  9669
     OperatingSystem defaultSystemPath
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  9670
    "
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  9671
!
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  9672
21612
39b7db8e759c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21601
diff changeset
  9673
encodePathOrCommandInput:pathNameOrCommandInput
39b7db8e759c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21601
diff changeset
  9674
    "encode the pathNameOrCommandInput for use with system calls or to be sent to stdin of a command.
14839
f79ff27d7e52 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14802
diff changeset
  9675
     E.g. linux system calls accept single byte strings only,
21612
39b7db8e759c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21601
diff changeset
  9676
     so the pathName has to be UTF-8 encoded, before using it in a system call
17499
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9677
     (actually, on a mac, it has to be utf8-mac encoded)."
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9678
21613
327dd2743f94 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21612
diff changeset
  9679
    (pathNameOrCommandInput isNil or:[CodesetEncoder isNil]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9680
	^ pathNameOrCommandInput.
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9681
    ].
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9682
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9683
    ^ [
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9684
	CodesetEncoder encodeString: pathNameOrCommandInput.
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9685
    ] on:EncodingError do:[:ex|
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9686
	"maybe there are old filenames in ISO-8859-x,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9687
	 just keep them untranslated"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9688
	pathNameOrCommandInput
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9689
    ].
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9690
17499
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9691
    "
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9692
     Codeset := #'utf8-mac'.
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9693
     CodesetEncoder := nil.
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9694
     OperatingSystem getCodesetEncoder
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
  9695
     OperatingSystem encodePath:'äöü'
17499
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9696
    "
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9697
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9698
    "Modified: / 23-01-2013 / 10:00:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
21601
c8d456f2e93e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21513
diff changeset
  9699
    "Modified: / 27-02-2017 / 15:49:32 / stefan"
22182
5b33d3644aef #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22173
diff changeset
  9700
    "Modified: / 09-08-2017 / 23:00:47 / cg"
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9701
! !
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9702
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9703
!UnixOperatingSystem class methodsFor:'private'!
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9704
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9705
mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9706
    "return a collection of mountPoints (aka. topDirectories of mounted file systems)"
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9707
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9708
    |entries|
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9709
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9710
    entries := OrderedCollection new.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9711
    ('/proc/mounts' asFilename) readingLinesDo:[:eachLine |
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9712
	|items mountInfo|
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9713
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9714
	items := eachLine asCollectionOfWords.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9715
	mountInfo := (MountInfo new
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9716
	    mountPointPath:(items at:2)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9717
	    deviceOrRemotePath:(items at:1)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9718
	    fsType:(items at:3)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9719
	    attributeString:(items at:4)).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9720
	entries add:mountInfo
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9721
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9722
    ^ entries
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9723
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9724
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9725
     OperatingSystem mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9726
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9727
!
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9728
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9729
osProcessStatusClass
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9730
    ^ OSProcessStatus
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9731
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9732
    "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
  9733
! !
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9734
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9735
!UnixOperatingSystem class methodsFor:'shared memory access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9737
shmAttach:id address:addr flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9738
    "low level entry to shmat()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9739
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9740
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9741
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9742
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9743
    void *address, *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9744
    int shmflg, shmid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9745
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9746
    if (__isSmallInteger(addr)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9747
     && __bothSmallInteger(flags, id)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9748
	shmaddr = (void *) __intVal(addr);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9749
	shmflg = __intVal(flags);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9750
	shmid = __intVal(id);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9751
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9752
	address = shmat(shmid, shmaddr, shmflg);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9753
	if (address != (void *)-1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9754
	    RETURN (__MKEXTERNALBYTES(addr));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9755
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9756
	@global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9757
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9758
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9759
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9760
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9761
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9762
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9763
    "Modified: 22.4.1996 / 13:15:12 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9764
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9765
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9766
shmDetach:addr
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9767
    "low level entry to shmdt()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9768
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9769
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9770
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9771
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9772
    void *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9773
    int rslt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9774
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9775
    if (__isSmallInteger(addr)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9776
	shmaddr = (void *) __intVal(addr);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9777
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9778
	rslt = shmdt(shmaddr);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9779
	if (rslt != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9780
	    RETURN (true);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9781
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9782
	@global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9783
	RETURN (false);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9784
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9785
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9786
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9787
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9788
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9789
    "Modified: 22.4.1996 / 13:15:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9790
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9791
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9792
shmGet:key size:size flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9793
    "low level entry to shmget()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9794
     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
  9795
     - use the provided wrapper class SharedExternalBytes instead."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9796
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9797
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9798
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9799
    if (__bothSmallInteger(key, size)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9800
     && __isSmallInteger(flags)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9801
	int rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9802
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9803
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9804
	if (rslt != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9805
	    RETURN (__mkSmallInteger(rslt));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9806
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9807
	@global(LastErrorNumber) = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9808
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9809
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9810
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9811
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9812
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9813
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9814
    "Modified: 22.4.1996 / 13:14:46 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9815
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9816
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9817
!UnixOperatingSystem class methodsFor:'socket creation'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9818
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  9819
socketAccessor
16390
fb3ad2464cac class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16388
diff changeset
  9820
    ^ SocketHandle
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  9821
!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  9822
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9823
socketWithDomain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9824
    "set up socket with domain, type and protocol number.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9825
     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
  9826
     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
  9827
     #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9828
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9829
    ^ SocketHandle new domain:domainArg type:typeArg protocol:protocolArg
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9830
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9831
22968
411d41553689 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22841
diff changeset
  9832
!UnixOperatingSystem class methodsFor:'sound & voice'!
411d41553689 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22841
diff changeset
  9833
411d41553689 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22841
diff changeset
  9834
voiceCommandSpec
411d41553689 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22841
diff changeset
  9835
    ^ #(
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9836
	"/ triples are:
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9837
	"/      -command
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9838
	"/      -commandline for default voice
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9839
	"/      -commandline for specific voice
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9840
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9841
	"/ cg: I dont know how to specify the voice in those;
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9842
	"/ please fix the commandLines for specific voice
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9843
	(
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9844
	    'say'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9845
		'say "%2"'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9846
		'say "%2"'      "/ 'say -v "%1" "%2"' ???
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9847
	)
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9848
	(
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9849
	    'espeak'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9850
		'espeak "%2"'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9851
		'espeak "%2"'   "/ 'espeak -v "%1" "%2"' ???
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9852
	)
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9853
	(
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9854
	    'festival'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9855
		'echo "%2" | festival --tts'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9856
		'echo "%2" | festival --tts'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9857
	)
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9858
	(
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9859
	    'spd-say'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9860
		'spd-say "%2" '
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9861
		'spd-say "%2"'
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9862
	)
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
  9863
    )
22968
411d41553689 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22841
diff changeset
  9864
! !
411d41553689 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22841
diff changeset
  9865
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9866
!UnixOperatingSystem class methodsFor:'time and date'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9867
16948
45832ec999e2 method name cleanup
Claus Gittinger <cg@exept.de>
parents: 16925
diff changeset
  9868
computeOSTimeFromYear:y month:m day:d hour:h minute:min second:s millisecond:millis utc:utcBoolean
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9869
    "return the OS-dependent time for the given time and day.
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  9870
     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
  9871
     otherwise, in localtime including any daylight saving adjustings."
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  9872
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9873
    |osSeconds|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9874
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9875
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9876
    struct tm tm;
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9877
#ifdef HAS_MKTIME64
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9878
#   define TIME_T time64_t
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9879
#else
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9880
#   define TIME_T time_t
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9881
#endif
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9882
    TIME_T t;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9883
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9884
    if (__bothSmallInteger(y, m)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9885
     && __bothSmallInteger(d, h)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9886
     && __bothSmallInteger(min, s)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9887
	tm.tm_hour = __intVal(h);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9888
	tm.tm_min = __intVal(min);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9889
	tm.tm_sec = __intVal(s);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9890
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9891
	tm.tm_year = __intVal(y) - 1900;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9892
	tm.tm_mon = __intVal(m) - 1;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9893
	tm.tm_mday = __intVal(d);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9894
	tm.tm_isdst = -1;
19765
2231b180f224 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19763
diff changeset
  9895
2231b180f224 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19763
diff changeset
  9896
#if __POINTER_SIZE__ < 8 && !defined(HAS_MKTIME64)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9897
	if (__intVal(y) > 2038) goto outOfRange;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9898
	if (__intVal(y) == 2038) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9899
	    if (__intVal(m) > 1) goto outOfRange;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9900
	    if (__intVal(d) > 19) goto outOfRange;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9901
	    if (__intVal(d) == 19) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9902
		if (__intVal(h) > 3) goto outOfRange;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9903
		if (__intVal(h) == 3) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9904
		    if (__intVal(min) > 14) goto outOfRange;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9905
		    if (__intVal(min) == 14) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9906
			if (__intVal(s) > 7) goto outOfRange;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9907
		    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9908
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9909
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9910
	}
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9911
#endif
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9912
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9913
#ifdef HAS_TIMEGM
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9914
	if (utcBoolean == true) {               /* convert to utc time */
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9915
# ifdef HAS_MKTIME64
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9916
	    t = timegm64(&tm);                  /* timegm() interprets tm as utc time */
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9917
# else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9918
	    t = timegm(&tm);                    /* timegm() interprets tm as utc time */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9919
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9920
	} else
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9921
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9922
	{
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9923
#ifdef HAS_MKTIME64
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9924
	    t = mktime64(&tm);                  /* mktime() interprets tm as localtime */
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9925
#else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9926
	    t = mktime(&tm);                    /* mktime() interprets tm as localtime */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9927
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9928
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9929
	if (t != (TIME_T)-1) {
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9930
#ifndef HAS_TIMEGM
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9931
	    if (utcBoolean == true) {           /* convert to utc time */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9932
		// printf("tz=%d\n", TIMEZONE(&tm));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9933
		t = t - TIMEZONE(&tm);          /* TIMZONE = seconds westward from 0 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9934
	    }
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9935
#endif
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9936
#ifdef HAS_MKTIME64
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9937
	    osSeconds = __MKLARGEINT64(1, (t & 0xFFFFFFFF), (t>>32)& 0xFFFFFFFF);
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9938
#else
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9939
	    /* be careful, t can be negative at the start of the epoch ! */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9940
	    osSeconds = __MKINT((INT)t);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9941
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9942
	}
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9943
    }
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9944
  outOfRange: ;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9945
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9946
    osSeconds notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9947
	^ osSeconds * 1000 + millis
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9948
    ].
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9949
    ^ TimeConversionError raiseRequest.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9950
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9951
    "
17082
94ba9563eaba class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17029
diff changeset
  9952
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 second:0 millisecond:0 utc:true
94ba9563eaba class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17029
diff changeset
  9953
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 second:0 millisecond:0 utc:false
19765
2231b180f224 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 19763
diff changeset
  9954
     OperatingSystem computeOSTimeFromYear:2080 month:1 day:1 hour:0 minute:0 second:0 millisecond:0 utc:false
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  9955
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9956
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9957
17029
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9958
epochStartOSTime
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9959
    "private interface for timestamp to ask the OS what the minimum time
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9960
     (in milliseconds since the Unix epoch, 1.1.1970) is.
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9961
     Unix systems will return 0 here; other OS's may return a negative number to indicate,
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9962
     that they can deal with timestamps before 1970 (especially: win32 will do so).
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9963
     Notice that timestamp is prepared to compensate for any OS limitation by computing the timeInfo
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9964
     components itself.
19424
7f6cdbefb9f5 #DOCUMENTATION
Stefan Vogel <sv@exept.de>
parents: 19361
diff changeset
  9965
     So it is usually (except for a little performance) no problem to return a range too small here."
17029
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9966
22269
eec8ee404507 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22182
diff changeset
  9967
    ^ 16r-80000000 * 1000
eec8ee404507 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22182
diff changeset
  9968
eec8ee404507 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22182
diff changeset
  9969
    "Modified (format): / 19-09-2017 / 16:31:55 / stefan"
17029
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9970
!
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9971
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9972
getMicrosecondTime
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9973
    "This returns the microsecond timers value - if available.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9974
     On some machines, times with this precision may not be available,
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9975
     on those, the returned value may be rounded towards some internal
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
  9976
     clock resolution value.
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
  9977
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
  9978
     If supported by the system, it uses a clock that cannot be set and represents
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
  9979
     monotonic time since some unspecified starting point.  This clock is not affected by
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9980
     discontinuous  jumps  in  the system time
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
  9981
     (e.g., if the system administrator manually changes the clock), but is affected by
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
  9982
     the incremental adjustments performed by adjtime(3) and NTP."
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9983
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9984
    |seconds micros error|
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9985
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9986
%{
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9987
#ifdef __SCHTEAM__
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9988
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9989
	long nanos = java.lang.System.nanoTime();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9990
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
  9991
	return context._RETURN( STInteger._new(nanos / 1000) );
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9992
    }
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9993
    /* NOTREACHED */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9994
#else
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9995
    unsigned long _secs, _micros;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9996
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
  9997
# if (_POSIX_C_SOURCE >= 199309L) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9998
    struct timespec ts;
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  9999
    static int has_clock_gettime = 1;
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
 10000
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
 10001
    if (has_clock_gettime) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10002
	if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10003
	    _secs = ts.tv_sec;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10004
	    _micros  = ts.tv_nsec / 1000;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10005
	    goto out;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10006
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10007
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10008
	     * clock_gettime is not implemented in the kernel
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10009
	     * fall through to alternative implementation
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10010
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10011
	    has_clock_gettime = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10012
	}
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
 10013
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10014
# endif
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10015
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10016
# if defined(HAS_GETTIMEOFDAY)
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10017
    struct timeval tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10018
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10019
    gettimeofday(&tb, NULL /* &tzb */);
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10020
    if (tb.tv_usec >= (1000000)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10021
	error = @symbol(bad);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10022
	goto err;
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10023
    }
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10024
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10025
    _secs = tb.tv_sec;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10026
    _micros  = tb.tv_usec;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10027
# endif
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10028
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10029
out:
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10030
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10031
# if __POINTER_SIZE__ == 8
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10032
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10033
	unsigned INT rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10034
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10035
	rslt = (unsigned INT)_secs * 1000000 + _micros;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10036
	RETURN (__MKUINT(rslt));
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10037
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10038
# else
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10039
#  ifdef HAS_LONGLONG
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10040
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10041
	unsigned long long rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10042
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10043
	rslt = (unsigned long long)_secs * 1000000 + _micros;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10044
	RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10045
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10046
#  else
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10047
    seconds = __MKUINT(_secs);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10048
    micros = __MKUINT(_micros);
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10049
#  endif /* long long */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10050
# endif /* __POINTER_SIZE__ == 8 */
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10051
err:;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10052
#endif /* not SCHTEAM */
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10053
%}.
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10054
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10055
    seconds notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10056
	^ (seconds * 1000000) + micros
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10057
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10058
    error isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10059
	^ self getMillisecondTime * 1000
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10060
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10061
    self primitiveFailed:error.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10062
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10063
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10064
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10065
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10066
    "
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10067
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10068
    "Modified (comment): / 07-08-2017 / 11:52:34 / stefan"
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10069
!
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
 10070
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10071
getMillisecondTime
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10072
    "Return the millisecond timers value.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10073
     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
 10074
     LargeInteger arithmetic when doing timeouts and delays.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10075
     Since this value is wrapping around in regular intervals, this can only be used for
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10076
     short relative time deltas.
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10077
     Use the XXXmillisecondTime:-methods to compare and add time deltas - these know about the wrap.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10078
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10079
     BAD DESIGN:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10080
	This should be changed to return some instance of RelativeTime,
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10081
	and these computations moved there.
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10082
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10083
     Don't use this method in application code since it is an internal (private)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10084
     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
 10085
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10086
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10087
%{  /* NOCONTEXT */
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10088
#ifdef __SCHTEAM__
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10089
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10090
	long millis = java.lang.System.currentTimeMillis();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10091
	return context._RETURN( STInteger._new(millis) );
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10092
    }
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10093
    /* NOTREACHED */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10094
#else
20103
f9b00623bef2 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 20086
diff changeset
 10095
    unsigned INT t = 0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10096
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10097
# if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
21044
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
 10098
    static int has_clock_gettime = 1;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
 10099
    struct timespec ts;
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
 10100
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
 10101
    if (has_clock_gettime) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10102
	if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10103
	    t = ts.tv_sec*1000 + ts.tv_nsec/1000000;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10104
	    goto out;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10105
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10106
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10107
	     * clock_gettime is not implemented in the kernel
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10108
	     * fall through to alternative implementation
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10109
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10110
	    has_clock_gettime = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10111
	}
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
 10112
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10113
# endif /*  _POSIX_MONOTONIC_CLOCK */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10114
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10115
# if defined(_SC_CLK_TCK)
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10116
/*
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
 10117
 * We prefer times here, since it is monotonic and immune to clock changes
8601
bf2b973a9a0e unimpl clock-syscall handling
Claus Gittinger <cg@exept.de>
parents: 8599
diff changeset
 10118
 * but: it has less precision!
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10119
 */
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10120
#  include <sys/times.h>
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10121
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10122
    static int millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10123
    clock_t ticks;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10124
    struct tms tb;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10125
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10126
    if (!millisecondsPerTick) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10127
	int ticksPerSecond = sysconf(_SC_CLK_TCK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10128
	if (ticksPerSecond <= 0)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10129
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10130
	if (ticksPerSecond > 1000)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10131
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10132
	millisecondsPerTick = 1000 / ticksPerSecond;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
 10133
/*
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
 10134
printf("milliSecondsPerTick: %d\n", millisecondsPerTick);
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
 10135
*/
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10136
    }
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10137
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10138
    ticks = times(&tb);
8672
f93733514fec Fix times() systemcall overflow into negative values (onl Solaris 9).
Stefan Vogel <sv@exept.de>
parents: 8618
diff changeset
 10139
    if (ticks == -1)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10140
	goto err;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10141
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10142
    t = ticks * millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10143
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10144
# else /* !times */
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10145
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10146
    /* assume HAS_GETTIMEOFDAY
13801
6e060254590d changed: #getMillisecondTime
Stefan Vogel <sv@exept.de>
parents: 13778
diff changeset
 10147
     * - will result in a linkage error if not fixed.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10148
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10149
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10150
    struct timeval tb;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10151
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10152
    gettimeofday(&tb, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10153
    t = tb.tv_sec*1000 + tb.tv_usec/1000;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10154
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10155
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
 10156
out:
20103
f9b00623bef2 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 20086
diff changeset
 10157
    RETURN ( __mkSmallInteger(t & (_MAX_INT >> 1)) );
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10158
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10159
err:;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10160
#endif /* not SCHTEAM */
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
 10161
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
 10162
    self primitiveFailed
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10163
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10164
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10165
    "
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10166
      self getMillisecondTime
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10167
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10168
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10169
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
 10170
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10171
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10172
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10173
getMonotonicNanosecondTime
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10174
    "This returns the nanosecond timers value - if available.
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10175
     On some machines, times with this precision may not be available,
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10176
     on those, the returned value may be rounded towards some internal
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10177
     clock resolution value.
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10178
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10179
     If supported by the system, it uses a clock that cannot be set and represents
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10180
     monotonic time since some unspecified starting point.  This clock is not affected by
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10181
     discontinuous  jumps  in  the system time
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10182
     (e.g., if the system administrator manually changes the clock), but is affected by
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10183
     the incremental adjustments performed by adjtime(3) and NTP."
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10184
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10185
    |seconds nanos error|
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10186
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10187
%{
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10188
#ifdef __SCHTEAM__
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10189
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10190
	long nanos = java.lang.System.nanoTime();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10191
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10192
	return context._RETURN( STInteger._new(nanos) );
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10193
    }
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10194
    /* NOTREACHED */
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10195
#else
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10196
    unsigned long _secs, _nanos;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10197
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10198
# if (_POSIX_C_SOURCE >= 199309L) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10199
    struct timespec ts;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10200
    static int has_clock_gettime = 1;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10201
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10202
    if (has_clock_gettime) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10203
	if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10204
	    _secs = ts.tv_sec;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10205
	    _nanos  = ts.tv_nsec;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10206
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10207
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10208
	     * clock_gettime is not implemented in the kernel
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10209
	     * fall through to alternative implementation
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10210
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10211
	    has_clock_gettime = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10212
	    goto notSupported;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10213
	}
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10214
    }
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10215
# if __POINTER_SIZE__ == 8
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10216
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10217
	unsigned INT rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10218
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10219
	rslt = (unsigned INT)_secs * 1000000000 + _nanos;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10220
	RETURN (__MKUINT(rslt));
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10221
    }
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10222
# else
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10223
#  ifdef HAS_LONGLONG
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10224
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10225
	unsigned long long rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10226
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10227
	rslt = (unsigned long long)_secs * 1000000000 + _nanos;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10228
	RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10229
    }
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10230
#  else
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10231
    seconds = __MKUINT(_secs);
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10232
    nanos = __MKUINT(_nanos);
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10233
#  endif /* long long */
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10234
# endif /* __POINTER_SIZE__ == 8 */
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10235
# endif
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10236
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10237
notSupported:;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10238
#endif /* not SCHTEAM */
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10239
%}.
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10240
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10241
    seconds notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10242
	^ (seconds * 1000000000) + nanos
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10243
    ].
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10244
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10245
    "fallback, if monotonic time is not supported"
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10246
    ^ self getRealNanosecondTime
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10247
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10248
    "
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10249
     Transcript showCR:(OperatingSystem getMonotonicNanosecondTime).
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10250
     Transcript showCR:(OperatingSystem getMonotonicNanosecondTime).
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10251
    "
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10252
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10253
    "Created: / 07-08-2017 / 11:49:55 / stefan"
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10254
!
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10255
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10256
getOSTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10257
    "This returns the OS time.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10258
     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
 10259
     different OS's - some return the number of millis since jan, 1st 1970;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10260
     others since 1900. The Time classes are prepared for this, and
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10261
     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
 10262
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10263
     Don't use this method in application code since it is an internal (private)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10264
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10265
     or use instances of Time, Date or Timestamp to work with."
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10266
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10267
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10268
    |seconds millis|
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10269
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10270
%{
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10271
#ifdef __SCHTEAM__
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10272
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10273
	long millisSince1970 = java.lang.System.currentTimeMillis();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10274
	return context._RETURN( STInteger._new(millisSince1970));
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10275
    }
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10276
    /* NOTREACHED */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10277
#else
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10278
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10279
    unsigned long _secs, _millis;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10280
# if !defined(HAS_GETTIMEOFDAY)
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10281
#  if defined(HAS_FTIME)
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10282
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10283
	struct timeb timebuffer;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10284
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10285
	ftime(&timebuffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10286
	_secs = timebuffer.time;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10287
	_millis = timebuffer.millitm;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10288
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10289
#    define HAVE_TIME
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10290
#  endif /* HAS_FTIME */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10291
# endif /* no HAS_GETTIMEOFDAY */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10292
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10293
# ifndef HAVE_TIME
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10294
    /*
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10295
     * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10296
     * 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
 10297
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10298
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10299
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10300
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10301
	 * bsd time
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10302
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10303
	struct timeval tb;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10304
	/* struct timezone tzb; */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10305
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10306
	gettimeofday(&tb, NULL /* &tzb */);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10307
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10308
	_secs = tb.tv_sec;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10309
	_millis = tb.tv_usec / 1000;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10310
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10311
# endif
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10312
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10313
# if __POINTER_SIZE__ == 8
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10314
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10315
	unsigned INT rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10316
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10317
	rslt = (unsigned INT)_secs * 1000 + _millis;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10318
	RETURN (__MKUINT(rslt));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10319
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10320
# else
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10321
#  ifdef HAS_LONGLONG
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10322
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10323
	unsigned long long rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10324
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10325
	rslt = (unsigned long long)_secs * 1000 + _millis;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10326
	RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10327
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10328
#  else
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10329
    seconds = __MKUINT(_secs);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10330
    millis = __MKUINT(_millis);
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10331
#  endif /* long long */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10332
# endif /* __POINTER_SIZE__ == 8 */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10333
#endif /* SCHTEAM */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10334
%}.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10335
    seconds notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10336
	^ (seconds * 1000) + millis
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10337
    ].
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10338
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10339
    self primitiveFailed.
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10340
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10341
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10342
    "
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10343
     OperatingSystem getOSTime printCR.
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10344
     Delay waitForSeconds:0.2.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10345
     OperatingSystem getOSTime printCR.
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10346
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10347
!
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10348
22623
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10349
getOSTimeWithMicros
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10350
    "This returns the OS time as a 2-element vector with milliseconds (as before)
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10351
     plus microseconds.
22615
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10352
     The base of the returned value is not consistent across
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10353
     different OS's - some return the number of microseconds since jan, 1st 1970;
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10354
     others since 1900. The Time classes are prepared for this, and
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10355
     converts as appropriate (by using my fromOSTime: conversion methods).
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10356
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10357
     Don't use this method in application code since it is an internal (private)
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10358
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10359
     or use instances of Time, Date or Timestamp to work with."
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10360
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10361
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10362
    |seconds millis micros|
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10363
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10364
%{
22623
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10365
#if defined(HAS_GETTIMEOFDAY)
22616
3c48b1deb9b3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22615
diff changeset
 10366
    unsigned long _secs, _millis, _micros;
22615
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10367
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10368
    struct timeval tb;
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10369
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10370
    gettimeofday(&tb, NULL /* &tzb */);
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10371
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10372
    _secs = tb.tv_sec;
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10373
    _millis = tb.tv_usec / 1000;
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10374
    _micros = tb.tv_usec % 1000;
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10375
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10376
    seconds = __MKUINT(_secs);
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10377
    millis = __MKUINT(_millis);
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10378
    micros = __MKUINT(_micros);
22623
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10379
#endif
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10380
%}.
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10381
    seconds notNil ifTrue:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10382
	^ { ((seconds * 1000) + millis) . micros }
22623
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10383
    ].
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10384
a4a3c7bfd522 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22617
diff changeset
 10385
    self primitiveFailed.
22615
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10386
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10387
    "
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10388
     OperatingSystem getOSTimeInMicros printCR.
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10389
     Delay waitForSeconds:0.1.
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10390
     OperatingSystem getOSTimeInMicros printCR.
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10391
    "
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10392
!
e862790ffdfd #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22578
diff changeset
 10393
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10394
getOSTimeWithNanos
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10395
    "This returns the OS time as a 2-element vector with milliseconds (as before)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10396
     plus nanoseconds.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10397
     The base of the returned value is not consistent across
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10398
     different OS's - some return the number of microseconds since jan, 1st 1970;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10399
     others since 1900. The Time classes are prepared for this, and
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10400
     converts as appropriate (by using my fromOSTime: conversion methods).
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10401
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10402
     Don't use this method in application code since it is an internal (private)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10403
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10404
     or use instances of Time, Date or Timestamp to work with."
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10405
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10406
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10407
    |seconds millis nanos|
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10408
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10409
%{
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10410
# if (_POSIX_C_SOURCE >= 199309L) && defined(CLOCK_REALTIME) && !defined(NO_CLOCK_GETTIME)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10411
    struct timespec ts;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10412
    static int has_clock_gettime = 1;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10413
    unsigned long _secs, _millis, _nanos;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10414
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10415
    if (has_clock_gettime) {
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10416
	if (clock_gettime(CLOCK_REALTIME, &ts) != -1) {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10417
	    _secs = ts.tv_sec;
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10418
	    _millis = ts.tv_nsec / 1000000;
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10419
	    _nanos = ts.tv_nsec % 1000000;
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10420
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10421
	    seconds = __MKUINT(_secs);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10422
	    millis = __MKUINT(_millis);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10423
	    nanos = __MKUINT(_nanos);
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10424
	} else {
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10425
	    /*
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10426
	     * clock_gettime is not implemented in the kernel
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10427
	     * fall through to alternative implementation
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10428
	     */
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10429
	    has_clock_gettime = 0;
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10430
	}
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10431
    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10432
# endif
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10433
%}.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10434
    seconds notNil ifTrue:[
23780
2aa13597950c fixed openpty / sessions / processgroup setting for osx
Claus Gittinger <cg@exept.de>
parents: 23625
diff changeset
 10435
	^ { ((seconds * 1000) + millis) . nanos }
22841
63cdbb2f19b2 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22829
diff changeset
 10436
    ].
63cdbb2f19b2 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22829
diff changeset
 10437
    ^ super getOSTimeWithNanos
63cdbb2f19b2 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22829
diff changeset
 10438
63cdbb2f19b2 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22829
diff changeset
 10439
    "
63cdbb2f19b2 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22829
diff changeset
 10440
     OperatingSystem getOSTimeWithNanos printCR.
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10441
     Delay waitForSeconds:0.1.
22841
63cdbb2f19b2 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22829
diff changeset
 10442
     OperatingSystem getOSTimeWithNanos printCR.
63cdbb2f19b2 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22829
diff changeset
 10443
    "
63cdbb2f19b2 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22829
diff changeset
 10444
63cdbb2f19b2 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22829
diff changeset
 10445
    "Modified: / 09-05-2018 / 17:25:31 / stefan"
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10446
!
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 10447
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10448
getRealNanosecondTime
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10449
    "This returns the microsecond timers value - if available.
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10450
     On some machines, times with this precision may not be available,
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10451
     on those, the returned value may be rounded towards some internal
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10452
     clock resolution value.
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10453
     Note, that the timers value is not monotonic,
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10454
     it may jump forward or backward if the sytsems time is changed by e.g. NTP
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10455
     or the system administrator!!"
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10456
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10457
    |seconds nanos error|
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10458
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10459
%{
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10460
#ifdef __SCHTEAM__
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10461
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10462
	long nanos = java.lang.System.nanoTime();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10463
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10464
	return context._RETURN( STInteger._new(nanos) );
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10465
    }
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10466
    /* NOTREACHED */
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10467
#else
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10468
    unsigned long _secs, _nanos;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10469
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10470
# if (_POSIX_C_SOURCE >= 199309L) && defined(CLOCK_REALTIME) && !defined(NO_CLOCK_GETTIME)
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10471
    struct timespec ts;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10472
    static int has_clock_gettime = 1;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10473
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10474
    if (has_clock_gettime) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10475
	if (clock_gettime(CLOCK_REALTIME, &ts) != -1) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10476
	    _secs = ts.tv_sec;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10477
	    _nanos  = ts.tv_nsec;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10478
	    goto out;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10479
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10480
	    /*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10481
	     * clock_gettime is not implemented in the kernel
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10482
	     * fall through to alternative implementation
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10483
	     */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10484
	    has_clock_gettime = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10485
	}
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10486
    }
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10487
# endif
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10488
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10489
# if defined(HAS_GETTIMEOFDAY)
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10490
    struct timeval tb;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10491
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10492
    gettimeofday(&tb, NULL /* &tzb */);
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10493
    if (tb.tv_usec >= 1000000) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10494
	error = @symbol(bad);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10495
	goto err;
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10496
    }
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10497
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10498
    _secs = tb.tv_sec;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10499
    _nanos  = tb.tv_usec * 1000;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10500
# endif
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10501
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10502
out:
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10503
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10504
# if __POINTER_SIZE__ == 8
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10505
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10506
	unsigned INT rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10507
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10508
	rslt = (unsigned INT)_secs * 1000000000 + _nanos;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10509
	RETURN (__MKUINT(rslt));
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10510
    }
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10511
# else
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10512
#  ifdef HAS_LONGLONG
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10513
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10514
	unsigned long long rslt;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10515
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10516
	rslt = (unsigned long long)_secs * 1000000000 + _nanos;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10517
	RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10518
    }
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10519
#  else
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10520
    seconds = __MKUINT(_secs);
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10521
    nanos = __MKUINT(_nanos);
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10522
#  endif /* long long */
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10523
# endif /* __POINTER_SIZE__ == 8 */
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10524
err:;
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10525
#endif /* not SCHTEAM */
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10526
%}.
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10527
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10528
    seconds notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10529
	^ (seconds * 1000000000) + nanos
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10530
    ].
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10531
    error isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10532
	^ self getMillisecondTime * 1000000
22165
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10533
    ].
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10534
    self primitiveFailed:error.
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10535
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10536
    "
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10537
     Transcript showCR:(OperatingSystem getRealNanosecondTime).
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10538
     Transcript showCR:(OperatingSystem getRealNanosecondTime).
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10539
    "
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10540
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10541
    "Created: / 07-08-2017 / 11:33:51 / stefan"
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10542
!
0505599d03e7 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 22136
diff changeset
 10543
18415
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10544
microsecondSleep:micros
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10545
    "cease ANY action for some time.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10546
     This suspends the whole smalltalk (unix/windows-) process for some time.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10547
     Not really useful since not even low-prio processes and interrupt
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10548
     handling will run during the sleep.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10549
     Use either OperatingSystem>>millisecondDelay: (which makes all
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10550
     threads sleep, but handles interrupts) or use a Delay
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10551
     (which makes only the calling thread sleep)."
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10552
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10553
    |uLow uHigh|
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10554
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10555
    uLow := micros // 1000000.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10556
    uHigh := micros \\ 1000000.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10557
%{
18758
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10558
#ifdef HAS_USLEEP
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10559
    INT secs, usecs;
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10560
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10561
    secs = __intVal(uLow);
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10562
    usecs = __intVal(uHigh);
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10563
    if (secs > 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10564
	sleep(secs);
18758
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10565
    }
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10566
    usleep(usecs);
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10567
    RETURN (true);
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10568
#else
18415
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10569
    struct timeval tv;
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10570
    fd_set dummy;
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10571
    int success;
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10572
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10573
    int s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10574
    FD_ZERO(&dummy);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10575
    FD_SET(s, &dummy);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10576
    tv.tv_sec = __intVal(uLow);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10577
    tv.tv_usec = __intVal(uHigh);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10578
    success = (0 == select(0, 0, 0, &dummy, &tv));
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10579
    close(s);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10580
    RETURN (success ? true : false);
18758
fd717520a5ef use usleep if avail.
Claus Gittinger <cg@exept.de>
parents: 18742
diff changeset
 10581
#endif
18415
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10582
%}
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10583
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10584
    "
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10585
     Timestamp now printCR.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10586
     OperatingSystem microsecondSleep:100.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10587
     Timestamp now printCR.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10588
    "
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10589
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10590
    "Created: / 28-05-2015 / 14:14:53 / gg"
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10591
!
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10592
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10593
sleep:numberOfSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10594
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10595
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10596
    "cease ANY action for some time. This suspends the whole smalltalk
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
 10597
     (unix-) process for some time if running threadless;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10598
     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
 10599
     only block until the next clock tick and return with the next
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
 10600
     timer interrupt.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10601
     Use either OperatingSystem>>millisecondDelay: (which makes all
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10602
     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
 10603
     only the calling thread sleep)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10604
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10605
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10606
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10607
    if (__isSmallInteger(numberOfSeconds)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10608
	sleep(__intVal(numberOfSeconds));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10609
	RETURN ( self );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10610
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10611
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10612
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10613
     argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10614
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10615
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10616
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10617
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10618
     OperatingSystem sleep:2
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10619
    "
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10620
!
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10621
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10622
timeInfoFromSeconds:osSeconds milliseconds:osMilliseconds localTime:isLocalTime
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10623
    "return a timeInfo structure containing values for the given
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10624
     OS-second value.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10625
     An internal helper"
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10626
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10627
    |year month day hours minutes seconds utcOffset dstOffset
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10628
     dst yDay wDay info|
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10629
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10630
%{
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10631
#ifdef __SCHTEAM__
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10632
    if (osSeconds.isSmallInteger()
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10633
     && osMilliseconds.isSmallInteger()) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10634
	long _seconds = osSeconds.longValue();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10635
	long _millis = osMilliseconds.longValue();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10636
	long _millisSinceEpoch = _seconds * 1000 + _millis;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10637
	java.util.TimeZone _tz;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10638
	java.util.Calendar _calendar;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10639
	int _wDay;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10640
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10641
	if (isLocalTime == STObject.True) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10642
	    _tz = java.util.TimeZone.getDefault();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10643
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10644
	    _tz = java.util.TimeZone.getTimeZone("UTC");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10645
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10646
	_calendar = java.util.Calendar.getInstance(_tz);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10647
	_calendar.setTimeInMillis(_millisSinceEpoch);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10648
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10649
	year = STInteger._new( _calendar.get(java.util.Calendar.YEAR) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10650
	month = STInteger._new( _calendar.get(java.util.Calendar.MONTH) + 1 );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10651
	day = STInteger._new( _calendar.get(java.util.Calendar.DAY_OF_MONTH) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10652
	hours = STInteger._new( _calendar.get(java.util.Calendar.HOUR_OF_DAY) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10653
	minutes = STInteger._new( _calendar.get(java.util.Calendar.MINUTE) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10654
	seconds = STInteger._new( _calendar.get(java.util.Calendar.SECOND) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10655
	yDay = STInteger._new( _calendar.get(java.util.Calendar.DAY_OF_YEAR) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10656
	_wDay = _calendar.get(java.util.Calendar.DAY_OF_WEEK);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10657
	// convert from 1=SUN, 2=MON,...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10658
	// to 1=MON, 2=TUE,...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10659
	_wDay = _wDay - 1; if (_wDay < 1) _wDay += 7;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10660
	wDay = STInteger._new( _wDay );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10661
	utcOffset = STInteger._new( (_calendar.get(java.util.Calendar.ZONE_OFFSET)) / 1000 );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10662
	dstOffset = STInteger._new( (_calendar.get(java.util.Calendar.DST_OFFSET)) / 1000 );
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10663
    }
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10664
#else
16924
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10665
    struct tm tmValue, *result;
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10666
    time_t tt = __signedLongIntVal(osSeconds);
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10667
16925
62b6c12ce2d0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16924
diff changeset
 10668
    if (tt == 0 && !__isSmallInteger(osSeconds))
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10669
	goto out;             // __singedLongIntVal() returns 0 on failure
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10670
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10671
    /* try cache */
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10672
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10673
	OBJ lastSeconds = @global(LastTimeInfoSeconds);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10674
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10675
	if (__isInteger(lastSeconds)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10676
	     && (__signedLongIntVal(lastSeconds) == tt)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10677
	     && (@global(LastTimeInfoIsLocal) == isLocalTime)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10678
	) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10679
	    OBJ lastTimeInfo = @global(LastTimeInfo);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10680
	    if (lastTimeInfo != nil) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10681
		info = lastTimeInfo;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10682
		goto out;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10683
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10684
	}
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10685
    }
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10686
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10687
    result = (isLocalTime == true) ? localtime_r(&tt, &tmValue) :  gmtime_r(&tt, &tmValue);
16924
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10688
    if (result != NULL) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10689
	hours = __mkSmallInteger(tmValue.tm_hour);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10690
	minutes = __mkSmallInteger(tmValue.tm_min);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10691
	seconds = __mkSmallInteger(tmValue.tm_sec);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10692
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10693
	year = __mkSmallInteger(tmValue.tm_year + 1900);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10694
	month = __mkSmallInteger(tmValue.tm_mon + 1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10695
	day = __mkSmallInteger(tmValue.tm_mday);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10696
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10697
	yDay = __mkSmallInteger(tmValue.tm_yday+1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10698
	wDay = __mkSmallInteger(tmValue.tm_wday == 0 ? 7 : tmValue.tm_wday);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10699
	utcOffset = __mkSmallInteger(TIMEZONE(&tmValue));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10700
	dst = (tmValue.tm_isdst == 0 ? false : true);
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10701
    }
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10702
out:;
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10703
#endif
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10704
%}.
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10705
    info notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10706
	"there is a matching cached value"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10707
	LastTimeInfoMilliseconds == osMilliseconds ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10708
	    ^ info.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10709
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10710
	info := info copy.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10711
	info milliseconds:osMilliseconds.
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10712
    ] ifFalse:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10713
	year isNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10714
	    TimeConversionError raiseErrorString:' - out of range'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10715
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10716
	dst isNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10717
	    dst := (dstOffset ~= 0)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10718
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10719
	info := self timeInfoClass new.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10720
	info
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10721
	    year:year
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10722
	    month:month
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10723
	    day:day
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10724
	    hours:hours
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10725
	    minutes:minutes
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10726
	    seconds:seconds
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10727
	    milliseconds:osMilliseconds
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10728
	    utcOffset:utcOffset
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10729
	    dst:dst
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10730
	    dayInYear:yDay
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10731
	    dayInWeek:wDay.
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10732
    ].
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10733
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10734
%{
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10735
    @global(LastTimeInfo) = info;                       __GSTORE(info);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10736
    @global(LastTimeInfoSeconds) = osSeconds;           __GSTORE(osSeconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10737
    @global(LastTimeInfoMilliseconds) = osMilliseconds; __GSTORE(osMilliseconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10738
    @global(LastTimeInfoIsLocal) = isLocalTime;         __GSTORE(isLocalTime);
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10739
%}.
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10740
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10741
    ^ info
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10742
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10743
    "
16924
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10744
     OperatingSystem timeInfoFromSeconds:3600 milliseconds:0 localTime:false
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10745
     OperatingSystem timeInfoFromSeconds:3600 milliseconds:0 localTime:true
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10746
     OperatingSystem timeInfoFromSeconds:7200 milliseconds:0 localTime:true
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10747
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10748
     OperatingSystem timeInfoFromSeconds:16r7FFFFFFF milliseconds:0 localTime:false
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10749
     OperatingSystem timeInfoFromSeconds:16r7FFFFFFF + 1 milliseconds:0 localTime:false
16925
62b6c12ce2d0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16924
diff changeset
 10750
     OperatingSystem timeInfoFromSeconds:16r7FFFFFFFFFFFFFFFFFFFFFF milliseconds:0 localTime:false
16924
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10751
     OperatingSystem timeInfoFromSeconds:0 milliseconds:0 localTime:true
17022
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10752
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10753
    DST in MEZ in 1994:
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10754
      self assert:(Timestamp year:1994 month:7 day:1 hour:0 minute:0 second:0) timeInfo dst
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10755
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10756
     no DST in MEZ in 1970:
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10757
      self assert:(Timestamp year:1970 month:7 day:1 hour:0 minute:0 second:0) timeInfo dst not
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10758
    "
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10761
!UnixOperatingSystem class methodsFor:'users & groups'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10762
15802
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10763
getDesktopDirectory
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10764
    "{ Pragma: +optSpace }"
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10765
    "return the name of the user's desktop directory."
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
 10766
15802
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10767
    |home desktop|
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10768
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10769
    home := self getHomeDirectory.
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10770
    desktop := home,'/Desktop'.
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10771
    desktop asFilename exists ifTrue:[^ desktop].
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10772
    ^ home.
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10773
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10774
    "
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10775
     OperatingSystem getDesktopDirectory
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10776
    "
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10777
!
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10778
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10779
getEffectiveGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10780
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10781
20431
f41652a5b64a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20382
diff changeset
 10782
    "return the current users (that's you) effective numeric group id.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10783
     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
 10784
     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
 10785
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10786
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10787
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10788
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10789
    uid = getegid();
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10790
    RETURN ( __mkSmallInteger(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10791
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10792
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10793
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10794
     OperatingSystem getEffectiveGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10795
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10796
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10797
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10798
getEffectiveUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10799
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10800
20431
f41652a5b64a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20382
diff changeset
 10801
    "return the current users (that's you) effective numeric user id.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10802
     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
 10803
     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
 10804
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10805
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10806
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10807
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10808
    uid = geteuid();
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10809
    RETURN ( __mkSmallInteger(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10810
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10811
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10812
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10813
     OperatingSystem getEffectiveUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10814
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10815
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10816
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10817
getFullUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10818
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10819
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10820
    "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
 10821
     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
 10822
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10823
    |info gecos|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10824
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10825
    info := self userInfoOf:userID.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10826
    (info notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10827
    and:[info includesKey:#gecos]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10828
	gecos := info at:#gecos.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10829
	(gecos includes:$,) ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10830
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10831
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10832
	^ gecos
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10833
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10834
    ^ self getUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10835
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10836
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10837
     OperatingSystem getFullUserNameFromID:0
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10838
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10839
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10840
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10841
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10842
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10843
    "Modified: 15.7.1996 / 12:44:21 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10844
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10845
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10846
getGroupID
20431
f41652a5b64a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20382
diff changeset
 10847
    "return the current users (that's you) numeric group id"
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10848
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10849
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10850
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10851
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10852
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10853
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10854
    RETURN ( __mkSmallInteger(getgid()) );
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10855
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10856
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10857
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10858
     OperatingSystem getGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10859
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10860
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10861
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10862
getGroupNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10863
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10864
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10865
    "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
 10866
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10867
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10868
    struct group *g;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10869
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10870
    if (__isSmallInteger(aNumber)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10871
	g = getgrgid(__intVal(aNumber));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10872
	if (g) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10873
	    RETURN ( __MKSTRING(g->gr_name) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10874
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10875
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10876
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10877
    ^ '???'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10878
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10879
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10880
     OperatingSystem getGroupNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10881
     OperatingSystem getGroupNameFromID:10
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10882
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10883
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10884
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10885
getHomeDirectory
15940
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10886
    "return the name of the user's home directory (i.e. yours)"
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10887
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10888
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10889
15940
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10890
    |homeDir|
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10891
15981
c31f0cec5db0 osx: nil keys in getEnvironment
Claus Gittinger <cg@exept.de>
parents: 15977
diff changeset
 10892
    homeDir := self getEnvironment:'HOME'.
15940
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10893
    homeDir isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10894
	"/ mhmh - can only happen if started via some uncorrectly
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10895
	"/ initialized subprocess...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10896
	'UnixOperatingSystem [warning]: cannot figure out home directory' errorPrintCR.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10897
	homeDir := '/tmp'.
15940
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10898
    ].
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10899
    ^ self decodePath:homeDir
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10900
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10901
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10902
     OperatingSystem getHomeDirectory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10903
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10904
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10905
    "Modified: 24.1.1997 / 11:32:13 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10906
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10907
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10908
getLoginName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10909
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10910
20431
f41652a5b64a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20382
diff changeset
 10911
    "return a string with the users login name (that's yours)"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10912
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10913
%{  /* NOCONTEXT */
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
 10914
    static char cachedName[128];
21044
732f18ee791b #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 20963
diff changeset
 10915
    static int firstCall = 1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10916
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10917
    extern char *getlogin();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10918
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10919
    char *name = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10920
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10921
    if (firstCall) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10922
	/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10923
	 * try a few common environment variables ...
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10924
	 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10925
	name = getenv("LOGNAME");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10926
	if (! name || (name[0] == 0)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10927
	    name = getlogin();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10928
	    if (! name || (name[0] == 0) ) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10929
		name = getenv("LOGIN");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10930
		if (! name || (name[0] == 0) ) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10931
		    name = getenv("USER");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10932
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10933
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10934
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10935
	if (name && (strlen(name) < sizeof(cachedName))) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10936
	    strcpy(cachedName, name);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10937
	    firstCall = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10938
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10939
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10940
	name = cachedName;
7767
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
 10941
    }
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
 10942
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10943
    /*
20814
035cfc0c970b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20710
diff changeset
 10944
     * nope - I really don't know who you are.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10945
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10946
    if (! name || (name[0] == 0) ) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10947
	name = "you";
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10948
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10949
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10950
    RETURN ( __MKSTRING(name) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10951
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10952
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10953
     OperatingSystem getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10954
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10955
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10956
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10957
getUserID
20431
f41652a5b64a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20382
diff changeset
 10958
    "return the current users (that's you) numeric user id"
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10959
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10960
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10961
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10962
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10963
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10964
    RETURN ( __mkSmallInteger(getuid()) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10965
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10966
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10967
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10968
     OperatingSystem getUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10969
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10970
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10971
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10972
getUserNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10973
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10974
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10975
    "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
 10976
     This is the login name, not the fullName."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10977
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10978
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10979
19909
77feb88ec876 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19901
diff changeset
 10980
#ifndef NO_PWD
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10981
    struct passwd *p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10982
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10983
    if (__isSmallInteger(aNumber)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10984
	p = getpwuid(__intVal(aNumber));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10985
	if (p && p->pw_name && (strlen(p->pw_name) > 0)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10986
	    RETURN ( __MKSTRING(p->pw_name) );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 10987
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10988
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10989
#endif /* unix-like */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10990
%}.
19909
77feb88ec876 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19901
diff changeset
 10991
    ^ super getUserNameFromID:aNumber
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10992
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10993
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10994
     OperatingSystem getUserNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10995
     OperatingSystem getUserNameFromID:100
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10996
     OperatingSystem getUserNameFromID:9991
19909
77feb88ec876 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19901
diff changeset
 10997
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10998
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10999
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11000
15875
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11001
isRunningWithElevatedRootOrAdminRights
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11002
    "return true, if a NORMAL user is running with elevated admin rights."
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11003
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11004
    ^ (self getEffectiveUserID == 0)
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11005
    and:[self getUserID ~~ 0 ]
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11006
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11007
    "
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
 11008
     self isRunningWithElevatedRootOrAdminRights
15875
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11009
    "
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11010
!
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11011
15832
8e5cb444d6bd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15802
diff changeset
 11012
isRunningWithRootOrAdminRights
15875
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11013
    "return true, if running with root rights (either an elevated normal user
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11014
     or super user right away)."
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 11015
15832
8e5cb444d6bd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15802
diff changeset
 11016
    ^ self getEffectiveUserID == 0
8e5cb444d6bd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15802
diff changeset
 11017
!
8e5cb444d6bd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15802
diff changeset
 11018
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11019
primUserInfoOf:aNameOrID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11020
    "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
 11021
     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
 11022
     Notice, that not all systems provide (all of) this info;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11023
     DOS systems return nothing;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11024
     non-SYSV4 systems have no age/comment.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11025
     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
 11026
     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
 11027
     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
 11028
     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
 11029
     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
 11030
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11031
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11032
%{ /* UNLIMITEDSTACK */  /* Don't know whether NIS, LDAP or whatever is consulted */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11033
#if !defined(NO_PWD)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11034
    struct passwd *result = 0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11035
    int ret;
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11036
    int idx = 0;
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
 11037
    OBJ returnArray;
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11038
    OBJ tmp;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11039
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11040
#if defined(_POSIX_SOURCE)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11041
    char buf[4096];
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11042
    struct passwd pwd;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11043
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
 11044
    if (__isStringLike(aNameOrID)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11045
	getpwnam_r(__stringVal(aNameOrID), &pwd, buf, sizeof(buf), &result);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11046
    } else if (__isSmallInteger(aNameOrID)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11047
	getpwuid_r(__intVal(aNameOrID), &pwd, buf, sizeof(buf), &result);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11048
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11049
#else
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11050
    if (__isStringLike(aNameOrID)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11051
	result = getpwnam(__stringVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11052
    } else if (__isSmallInteger(aNameOrID)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11053
	result = getpwuid(__intVal(aNameOrID));
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11054
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11055
#endif /* ! _POSIX_SOURCE */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11056
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11057
    if (result) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11058
	returnArray = __ARRAY_NEW_INT(20);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11059
	__PROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11060
	tmp = __MKSTRING(result->pw_name);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11061
	__UNPROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11062
	__arrayVal(returnArray)[idx++] = @symbol(name);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11063
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11064
#  ifndef NO_PWD_PASSWD
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11065
	__PROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11066
	tmp = __MKSTRING(result->pw_passwd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11067
	__UNPROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11068
	__arrayVal(returnArray)[idx++] = @symbol(passwd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11069
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11070
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11071
#  ifdef SYSV4
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11072
	__PROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11073
	tmp = __MKSTRING(result->pw_age);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11074
	__UNPROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11075
	__arrayVal(returnArray)[idx++] = @symbol(age);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11076
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11077
	__PROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11078
	tmp = __MKSTRING(result->pw_comment);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11079
	__UNPROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11080
	__arrayVal(returnArray)[idx++] = @symbol(comment);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11081
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11082
#  endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11083
	__PROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11084
	tmp = __MKSTRING(result->pw_dir);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11085
	__UNPROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11086
	__arrayVal(returnArray)[idx++] = @symbol(dir);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11087
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11088
#  ifndef NO_PWD_GECOS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11089
	__PROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11090
	tmp = __MKSTRING(result->pw_gecos);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11091
	__UNPROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11092
	__arrayVal(returnArray)[idx++] = @symbol(gecos);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11093
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11094
#  endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11095
	__PROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11096
	tmp = __MKSTRING(result->pw_shell);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11097
	 __UNPROTECT__(returnArray);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11098
	__arrayVal(returnArray)[idx++] = @symbol(shell);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11099
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11100
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11101
	__arrayVal(returnArray)[idx++] = @symbol(uid);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11102
	__arrayVal(returnArray)[idx++] = __mkSmallInteger(result->pw_uid);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11103
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11104
	__arrayVal(returnArray)[idx++] = @symbol(gid);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11105
	__arrayVal(returnArray)[idx++] = __mkSmallInteger(result->pw_gid);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11106
	RETURN(returnArray);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11107
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11108
# endif /* ! NO_PWD */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11109
%}.
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
 11110
    ^ nil
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11111
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11112
    "
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11113
     OperatingSystem primUserInfoOf:'root'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11114
     OperatingSystem primUserInfoOf:1
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11115
     OperatingSystem primUserInfoOf:'cg'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11116
     OperatingSystem primUserInfoOf:'fooBar'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11117
     OperatingSystem primUserInfoOf:(OperatingSystem getUserID)
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11118
    "
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11119
!
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11120
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11121
userInfoOf:aNameOrID
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11122
    "{ Pragma: +optSpace }"
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11123
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11124
    "return a dictionary filled with userinfo. The argument can be either
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11125
     a string with the users name or its numeric id.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11126
     Notice, that not all systems provide (all of) this info;
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11127
     DOS systems return nothing;
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11128
     non-SYSV4 systems have no age/comment.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11129
     Portable applications may want to check the systemType and NOT depend
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11130
     on all keys to be present in the returned dictionary.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11131
     Another notice: on some systems (SYSV4), the gecos field includes multiple
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11132
     entries (i.e. not just the name), separated by commas. You may want to
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11133
     extract any substring, up to the first comma to get the real life name."
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11134
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11135
    |infoArray info name dir|
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11136
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11137
    infoArray := self primUserInfoOf:aNameOrID.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11138
    info := IdentityDictionary new.
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11139
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11140
    infoArray notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11141
	infoArray pairWiseDo:[:key :value|
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11142
	    key notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11143
		info at:key put:value.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11144
		key == #name ifTrue:[name := value].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11145
		key == #dir  ifTrue:[dir := value].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11146
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11147
	].
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11148
    ].
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11149
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11150
    name isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11151
	info at:#name put:#unknown
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11152
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11153
    dir isNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11154
	aNameOrID == self getUserID ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11155
	    info at:#dir put:self getHomeDirectory
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11156
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11157
    ].
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11158
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11159
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11160
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11161
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 11162
     OperatingSystem userInfoOf:'root'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 11163
     OperatingSystem userInfoOf:1
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11164
     OperatingSystem userInfoOf:'cg'
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11165
     OperatingSystem userInfoOf:'fooBar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 11166
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11167
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11168
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11169
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11170
!UnixOperatingSystem class methodsFor:'waiting for events'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11171
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11172
blockingChildProcessWait
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11173
     "return true, if childProcessWait: blocks, if no children are ready.
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11174
      On those systems, we must be somewhat careful when looking out for
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11175
      a subprocesses status (to avoid blocking)."
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11176
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11177
    "/ blocking waits are no longer supported - see ProcessorScheduler>>#monitor:action:
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11178
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11179
%{ /*NOCONTEXT*/
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11180
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11181
    RETURN(false);
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11182
#endif
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11183
%}.
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11184
    ^ true.
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11185
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11186
    "Modified: / 29-03-2018 / 16:02:15 / stefan"
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11187
!
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11188
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11189
childProcessWait:blocking pid:pidToWaitForOrNil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11190
    "get status changes from child processes.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11191
     Return an OSProcessStatus or nil, if no process has terminated.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11192
     If blocking is true, we wait until a process changed state,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11193
     otherwise we return immediately.
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11194
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11195
     If implementations uses waitpid() and pidToWaitForOrNil is an integer,
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11196
     only wait for childProcesses with pid pidToWaitForOrNil.
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11197
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11198
     If implementation uses the obsolete wait3() or the very obsolete wait()
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11199
     or pidToWaitFor is nil, wait for any child process"
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11200
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11201
    "/ blocking waits are no longer supported - see ProcessorScheduler>>#monitor:action:
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11202
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11203
    "{ Pragma: +optSpace }"
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11204
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11205
    |pid status code core error|
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11206
%{
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11207
    pid_t _pid;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11208
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11209
#if defined(HAS_WAITPID)
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11210
    int waitStatus;
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11211
    pid_t _pidToWaitFor = -1;
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11212
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11213
    if (__isSmallInteger(pidToWaitForOrNil)) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11214
	_pidToWaitFor = __intVal(pidToWaitForOrNil);
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11215
    } else if (pidToWaitForOrNil != nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11216
	error = @symbol(badArgument2);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11217
	goto done;
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11218
    }
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11219
#   define __WAIT     waitpid(_pidToWaitFor, &waitStatus, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED)
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11220
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11221
#elif defined(HAS_WAIT3)
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11222
    WAIT_STATUS waitStatus;
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11223
#   define __WAIT      wait3(&waitStatus, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0)
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11224
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11225
#else /* neither waitpid, nor wait3; use wait, which is blocking */
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11226
    // blocking waits are no longer supported - see ProcessorScheduler>>#monitor:action:
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11227
    int waitStatus;
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11228
#   define __WAIT      wait(&waitStatus)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11229
#   define __BLOCKING_WAIT__ 1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11230
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11231
    if (blocking != true) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11232
	/*
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11233
	 * We do not support nonBlocking waits, so signal an error
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11234
	 * Sorry about the goto, but with all these ifdefs ...
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11235
	 */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11236
	goto done;
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11237
    }
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11238
#endif /* !HAS_WAIT3 */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11239
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11240
#if !defined(WIFEXITED)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11241
# define WIFEXITED(stat)      (((int)((stat)&0377))==0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11242
# 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
 11243
# 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
 11244
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11245
# define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11246
# define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11247
# define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11248
#endif /*!WIFEXITED*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11249
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11250
#if !defined(WCOREDUMP)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11251
   /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11252
    * 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
 11253
    */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11254
# if defined(HAS_WAIT3)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11255
#  define WCOREDUMP(status)    (((union __wait*)&(status))->__w_coredump)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11256
# else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11257
#  define WCOREDUMP(status)    ((int)(((status)>>8)&0200))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11258
# endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11259
#endif /*!WCOREDUMP*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11260
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11261
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11262
    __BEGIN_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11263
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11264
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11265
    do {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11266
	_pid = __WAIT;
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11267
    } while (_pid == -1 && errno == EINTR);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11268
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11269
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11270
    __END_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11271
#  undef __BLOCKING_WAIT__
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11272
#endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11273
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11274
#undef __WAIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11275
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11276
    if (_pid == 0)
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11277
	RETURN(nil)
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11278
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11279
    if (_pid == -1) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11280
	if (errno == ECHILD)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11281
	    RETURN(nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11282
    } else {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11283
	pid = __mkSmallInteger(_pid);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11284
	if (WIFEXITED(waitStatus)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11285
	    status = @symbol(exit);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11286
	    code = __mkSmallInteger(WEXITSTATUS(waitStatus));
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11287
	    core = WCOREDUMP(waitStatus) ? true : false;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11288
	} else if (WIFSIGNALED(waitStatus)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11289
	    status = @symbol(signal);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11290
	    code = __mkSmallInteger(WTERMSIG(waitStatus));
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11291
	} else if (WIFSTOPPED(waitStatus)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11292
	    status = @symbol(stop);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11293
	    code = __mkSmallInteger(WSTOPSIG(waitStatus));
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11294
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11295
#if defined(WIFCONTINUED)
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11296
	else if (WIFCONTINUED(waitStatus)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11297
	    status = @symbol(continue);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11298
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 11299
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11300
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11301
done: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11302
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11303
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11304
    (status isNil or:[pid isNil]) ifTrue:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11305
	^ self primitiveFailed:error
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11306
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11308
"/ 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
 11309
"/ show:' code: '; show:code; show:' core:'; showCR:core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11310
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11311
    ^ 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
 11312
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11313
    "
22663
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11314
     OperatingSystem childProcessWait:false pid:0
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11315
     OperatingSystem childProcessWait:false pid:nil
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11316
    "
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11317
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11318
    "Created: / 05-01-1996 / 16:39:14 / stefan"
0f063640f797 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 22644
diff changeset
 11319
    "Modified: / 29-03-2018 / 16:16:20 / stefan"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11320
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11321
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11322
isBlockingOn:fd
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11323
    "{ Pragma: +optSpace }"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11324
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11325
    "return the blocking attribute - if set (which is the default)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11326
     a read on the fileDescriptor will block until data is available.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11327
     If clear, a read operation will immediately return with a value nil.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11328
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11329
     blocking is off"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11330
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11331
%{  /* NOCONTEXT */
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11332
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11333
    int flags;
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11334
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11335
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11336
# undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11337
# if defined(O_NONBLOCK)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11338
#  define DELAY_FLAG O_NONBLOCK
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11339
# elif defined(O_NDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11340
#  define DELAY_FLAG O_NDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11341
# elif defined(FNDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11342
#  define DELAY_FLAG FNDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11343
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11344
# if defined(DELAY_FLAG)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11345
    if (__isSmallInteger(fd)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11346
	int f = __intVal(fd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11347
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11348
	flags = fcntl(f, F_GETFL, 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11349
	RETURN ((flags & DELAY_FLAG) ? false : true );
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11350
    }
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11351
#  undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11352
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11353
#endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11354
%}.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11355
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11356
     fd argument not integer or bad return code
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11357
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11358
    ^ self primitiveFailed
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11359
!
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11360
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11361
numAvailableForReadOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11362
    "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
 11363
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11364
%{
20103
f9b00623bef2 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 20086
diff changeset
 11365
#if defined(FIONREAD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11366
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11367
	int n = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11368
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11369
	if (__isSmallInteger(fd)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11370
	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11371
		RETURN (__MKINT(n));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11372
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11373
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11374
    }
20103
f9b00623bef2 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 20086
diff changeset
 11375
#endif /* FIONREAD */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11376
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11377
    ^ (self readCheck:fd) ifTrue:[1] ifFalse:[0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11378
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11379
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11380
readCheck:fd
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11381
    "return true, if data is available on a filedescriptor
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11382
     (i.e. read is possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11383
     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
 11384
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11385
%{
18399
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 11386
#ifdef __SCHTEAM__
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 11387
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11388
	int avail = fd.streamAvailable();
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11389
	return __c__._RETURN (avail > 0 ? STObject.True : STObject.False);
18399
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 11390
    }
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 11391
    /* NOTREACHED */
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 11392
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11393
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11394
     * 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
 11395
     */
18399
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 11396
# if 0 && defined(FIONREAD)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11397
    if (__isSmallInteger(fd)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11398
	int result = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11399
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11400
	if (ioctl(__smallIntegerVal(fd), FIONREAD, &result) >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11401
	    RETURN(result > 0 ? true : false);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11402
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11403
    }
18399
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 11404
# endif /* FIONREAD */
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 11405
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11406
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11407
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11408
    ^ super readCheck:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11409
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11410
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11411
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11412
	readableInto:readableResultFdArray writableInto:writableResultFdArray
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11413
	exceptionInto:exceptionResultFdArray
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11414
	withTimeOut:millis
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11415
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11416
    "wait for any fd in readFdArray (an Array of integers) to become ready for reading,
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11417
     writeFdArray to become ready for writing,
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11418
     or exceptFdArray to arrive exceptional data (i.e. out-of-band data).
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11419
     Timeout after t milliseconds or - if the timeout time is 0 - immediately.
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11420
     If the timeout is nil, not timeout will happen (but an interrupt may).
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11421
     Empty fd-sets will always wait. Zero time can be used to poll file-
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11422
     descriptors (i.e. to check if I/O possible without blocking).
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11423
     The corresponding filedescriptors which are ready are returned in readableResultFdArray,
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11424
     writableResultFdArray and exceptionResultFdArray respectively.
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11425
     The resultFdArrays can be the same arrays.
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11426
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11427
     Return the (overall) number of selected filedescriptors.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11428
     readableResultFdArray, writableResultFdArray and exceptionResultFdArray will
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11429
     get a nil-value stored into the slot after the last valid fileDescriptor;
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11430
     Thus, the caller can simply scan these arrays upTo the end or a nil value."
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11431
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11432
%{
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11433
    fd_set rset, wset, eset;
16314
3b069e0219c6 fix prev version
Stefan Vogel <sv@exept.de>
parents: 16313
diff changeset
 11434
    struct timeval wt, *wtp, et;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11435
    int maxF;
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11436
    INT __millis;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11437
    int ret;
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11438
    int cntR = 0, cntW = 0, cntE = 0, cntAll = 0;
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11439
    int *pcntR = &cntR, *pcntW = &cntW, *pcntE = &cntE;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11440
    int resultSizeReadable = 0, resultSizeWritable = 0, resultSizeException = 0;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11441
    int numFds = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11442
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11443
    if (readableResultFdArray != nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11444
	if (! __isArrayLike(readableResultFdArray)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11445
	    goto fail;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11446
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11447
	resultSizeReadable = __arraySize(readableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11448
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11449
    if (writableResultFdArray != nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11450
	if (! __isArrayLike(writableResultFdArray)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11451
	    goto fail;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11452
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11453
	resultSizeWritable = __arraySize(writableResultFdArray);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11454
	if (readableResultFdArray == writableResultFdArray) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11455
	    // allow common result set for read/write/except
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11456
	    pcntW = &cntR;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11457
	}
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11458
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11459
    if (exceptionResultFdArray != nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11460
	if (! __isArrayLike(exceptionResultFdArray)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11461
	    goto fail;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11462
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11463
	resultSizeException = __arraySize(exceptionResultFdArray);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11464
	if (exceptionResultFdArray == readableResultFdArray) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11465
	    // allow common result set for read/write/except
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11466
	    pcntE = &cntR;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11467
	} else if (exceptionResultFdArray == writableResultFdArray) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11468
	    pcntE = &cntW;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11469
	}
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 11470
    }
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11471
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11472
    FD_ZERO(&rset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11473
    FD_ZERO(&wset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11474
    FD_ZERO(&eset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11475
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11476
    maxF = -1;
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11477
    if (readFdArray != nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11478
	int i, count;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11479
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11480
	if (! __isArrayLike(readFdArray)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11481
	    goto fail;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11482
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11483
	count = __arraySize(readFdArray);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11484
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11485
	for (i=0; i<count;i++) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11486
	    OBJ fd = __arrayVal(readFdArray)[i];
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11487
	    if (fd != nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11488
		if (! __isSmallInteger(fd)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11489
		    if (@global(InfoPrinting) == true) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11490
			fprintf(stderr, "OS [warning]: funny read-fd (0x%lx) given to select\n", (unsigned long)fd);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11491
		    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11492
		} else {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11493
		    int f = __intVal(fd);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11494
		    if ((unsigned)f < FD_SETSIZE) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11495
			FD_SET(f, &rset);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11496
			if (f > maxF) maxF = f;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11497
			numFds++;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11498
		    } else {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11499
			if (@global(InfoPrinting) == true) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11500
			    fprintf(stderr, "OS [warning]: huge read-fd (0x%lx) given to select\n", (unsigned long)fd);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11501
			}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11502
		    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11503
		}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11504
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11505
	}
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11506
    }
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11507
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11508
    if (writeFdArray != nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11509
	int i, count;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11510
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11511
	if (! __isArrayLike(writeFdArray)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11512
	    goto fail;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11513
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11514
	count = __arraySize(writeFdArray);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11515
	for (i=0; i<count;i++) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11516
	    OBJ fd = __arrayVal(writeFdArray)[i];
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11517
	    if (fd != nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11518
		if (! __isSmallInteger(fd)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11519
		    if (@global(InfoPrinting) == true) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11520
			fprintf(stderr, "OS [warning]: funny write-fd (0x%lx) given to select\n", (unsigned long)fd);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11521
		    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11522
		} else {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11523
		    int f = __intVal(fd);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11524
		    if ((unsigned)f < FD_SETSIZE) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11525
			FD_SET(f, &wset);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11526
			if (f > maxF) maxF = f;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11527
			numFds++;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11528
		    } else {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11529
			if (@global(InfoPrinting) == true) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11530
			    fprintf(stderr, "OS [warning]: huge write-fd (0x%lx) given to select\n", (unsigned long)fd);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11531
			}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11532
		    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11533
		}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11534
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11535
	}
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11536
    }
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11537
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11538
    if (exceptFdArray != nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11539
	int i, count;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11540
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11541
	if (! __isArrayLike(exceptFdArray)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11542
	    goto fail;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11543
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11544
	count = __arraySize(exceptFdArray);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11545
	for (i=0; i<count;i++) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11546
	    OBJ fd = __arrayVal(exceptFdArray)[i];
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11547
	    if (fd != nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11548
		if (! __isSmallInteger(fd)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11549
		    if (@global(InfoPrinting) == true) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11550
			fprintf(stderr, "OS [warning]: funny except-fd (0x%lx) given to select\n", (unsigned long)fd);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11551
		    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11552
		} else {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11553
		    int f = __intVal(fd);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11554
		    if ((unsigned)f < FD_SETSIZE) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11555
			FD_SET(f, &eset);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11556
			if (f > maxF) maxF = f;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11557
			numFds++;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11558
		    } else {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11559
			if (@global(InfoPrinting) == true) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11560
			    fprintf(stderr, "OS [warning]: huge except-fd (0x%lx) given to select\n", (unsigned long)fd);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11561
			}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11562
		    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11563
		}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11564
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11565
	}
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11566
    }
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11567
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11568
    if (millis == nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11569
	wtp = NULL;         // wait forever
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11570
    } else if (__isSmallInteger(millis)) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11571
	__millis = __intVal(millis);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11572
	if (__millis > 0) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11573
	    wt.tv_sec = __millis / 1000;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11574
	    wt.tv_usec = (__millis % 1000) * 1000;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11575
	} else {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11576
	    wt.tv_sec = wt.tv_usec = 0;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11577
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11578
	wtp = &wt;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11579
    } else {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11580
	goto fail;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11581
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11582
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11583
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11584
     * make certain, that interrupt gets us out of the select
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11585
     * However, we must then care for moved objects.
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11586
     */
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 11587
    if (wtp == NULL) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11588
	/*
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11589
	 * wait forever - there is no timeout time, we can stay here interruptable.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11590
	 */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11591
	__BEGIN_INTERRUPTABLE__
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11592
	do {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11593
	    ret = select(maxF+1, &rset, &wset, &eset, NULL);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11594
	} while ((ret < 0) && (errno == EINTR));
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11595
	__END_INTERRUPTABLE__
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 11596
    } else if (__millis == 0) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11597
	/*
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11598
	 * just poll, no interrupt processing.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11599
	 */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11600
	do {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11601
	    ret = select(maxF+1, &rset, &wset, &eset, wtp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11602
	} while ((ret < 0) && (errno == EINTR));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11603
    } else {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11604
	__BEGIN_INTERRUPTABLE__
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11605
	do {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11606
	    ret = select(maxF+1, &rset, &wset, &eset, wtp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11607
	    /*
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11608
	     * for now: don't loop; if we did, we had to adjust the vt-timeval;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11609
	     * could otherwise stay in this loop forever ...
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11610
	     * Premature ret (before the time expired) must be handled by the caller.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11611
	     * A good solution is to update the wt-timeval and redo the select.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11612
	     */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11613
	} while (0 /* (ret < 0) && (errno == EINTR) */ );
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11614
	__END_INTERRUPTABLE__
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 11615
    }
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11616
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11617
    if (ret > 0) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11618
	OBJ *__resultR = (resultSizeReadable > 0) ? (__arrayVal(readableResultFdArray)) : 0;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11619
	OBJ *__resultW = (resultSizeWritable > 0) ? (__arrayVal(writableResultFdArray)) : 0;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11620
	OBJ *__resultE = (resultSizeException > 0) ? (__arrayVal(exceptionResultFdArray)) : 0;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11621
	int i;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11622
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11623
	for (i=0; i <= maxF; i++) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11624
	    if (FD_ISSET(i, &rset)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11625
		if (*pcntR < resultSizeReadable) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11626
		    __resultR[*pcntR] = __mkSmallInteger(i);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11627
		}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11628
		(*pcntR)++; cntAll++;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11629
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11630
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11631
	    if (FD_ISSET(i, &wset)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11632
		if (*pcntW < resultSizeWritable) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11633
		    __resultW[*pcntW] = __mkSmallInteger(i);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11634
		}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11635
		(*pcntW)++; cntAll++;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11636
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11637
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11638
	    if (FD_ISSET(i, &eset)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11639
		if (*pcntE < resultSizeException) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11640
		    __resultE[*pcntE] = __mkSmallInteger(i);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11641
		}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11642
		(*pcntE)++;  cntAll++;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11643
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11644
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11645
	/* add a delimiter */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11646
	if (*pcntR < resultSizeReadable) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11647
	    __resultR[*pcntR] = nil;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11648
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11649
	if (*pcntW < resultSizeWritable) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11650
	    __resultW[*pcntW] = nil;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11651
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11652
	if (*pcntE < resultSizeException) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11653
	    __resultE[*pcntE] = nil;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11654
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11655
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11656
	RETURN (__mkSmallInteger(cntAll));
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11657
    } else if (ret < 0 && errno != EINTR) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11658
	/*
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11659
	 * Error: Return -1
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11660
	 */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11661
	if (@global(InfoPrinting) == true) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11662
	    fprintf(stderr, "OS [info]: select errno = %d\n", errno);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11663
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11664
	@global(LastErrorNumber) = __mkSmallInteger(errno);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 11665
	RETURN (__mkSmallInteger(-1));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11666
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11667
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11668
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11669
     * Return 0 (no filedescriptor ready)
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11670
     */
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11671
    @global(LastErrorNumber) = nil;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 11672
    RETURN (__mkSmallInteger(0));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11673
fail: ;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11674
%}.
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11675
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11676
     timeout argument not integer,
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11677
     or any fd-array nonNil and not an array
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11678
     or not supported by OS
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11679
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11680
    ^ self primitiveFailed
22664
5dd13ece33ac #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 22663
diff changeset
 11681
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 11682
    "Modified: / 03-05-2018 / 14:48:44 / stefan"
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11683
!
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11684
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11685
setBlocking:aBoolean on:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11686
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11687
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11688
    "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
 11689
     a read on the fileDescriptor will block until data is available.
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 11690
     If cleared, a read operation will immediately return with a value of nil.
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11691
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11692
     blocking is off.
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 11693
     Return the previous blocking state."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11694
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11695
%{  /* NOCONTEXT */
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11696
#ifdef __SCHTEAM__
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11697
    // TODO
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11698
    return context._RETURN(0);
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11699
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11700
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 11701
    int ret = 0, flags;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11702
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11703
# if defined(F_GETFL) && defined(F_SETFL)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11704
#  undef DELAY_FLAG
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11705
#  if defined(O_NONBLOCK)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11706
#   define DELAY_FLAG O_NONBLOCK
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11707
#  elif defined(O_NDELAY)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11708
#   define DELAY_FLAG O_NDELAY
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11709
#  elif defined(FNDELAY)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11710
#   define DELAY_FLAG FNDELAY
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11711
#  endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11712
#  if defined(DELAY_FLAG)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11713
    if (__isSmallInteger(fd)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11714
	int f = __intVal(fd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11715
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11716
	flags = fcntl(f, F_GETFL, 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11717
	if (aBoolean == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11718
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11719
	} else if (aBoolean == false) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11720
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11721
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11722
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11723
	    RETURN ((flags & DELAY_FLAG) ? false : true );
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11724
	}
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 11725
    }
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11726
#   undef DELAY_FLAG
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11727
#  endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11728
# endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11729
#endif /* not SCHTEAM */
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 11730
%}.
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 11731
    "
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 11732
     fd argument not integer or bad return code
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11733
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11734
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11735
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11736
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11737
!UnixOperatingSystem::ELFConstants class methodsFor:'initialization'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11738
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11739
initialize
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11740
    "Invoked at system start or when the class is dynamically loaded."
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11741
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11742
%{
17637
e88d00519209 ELF and OSX defines
Claus Gittinger <cg@exept.de>
parents: 17635
diff changeset
 11743
#ifdef ELF
e88d00519209 ELF and OSX defines
Claus Gittinger <cg@exept.de>
parents: 17635
diff changeset
 11744
# define DEFCONST(c) __GLOBAL_SET(__MKSYMBOL("UnixOperatingSystem::ELFConstants:" #c, (OBJ *)0), __MKSMALLINT(c), (OBJ *)0);
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11745
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11746
    /* Fields in the e_ident array.  The EI_* macros are indices into the
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11747
       array.  The macros under each EI_* macro are the values the byte
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11748
       may have.  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11749
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11750
    DEFCONST(EI_MAG0)           /* File identification byte 0 index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11751
    DEFCONST(EI_MAG1)           /* File identification byte 1 index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11752
    DEFCONST(EI_MAG2)           /* File identification byte 2 index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11753
    DEFCONST(EI_MAG3)           /* File identification byte 3 index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11754
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11755
    DEFCONST(EI_CLASS)          /* File class byte index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11756
    DEFCONST(ELFCLASSNONE)      /* Invalid class */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11757
    DEFCONST(ELFCLASS32)        /* 32-bit objects */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11758
    DEFCONST(ELFCLASS64)        /* 64-bit objects */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11759
    DEFCONST(ELFCLASSNUM)
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11760
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11761
    DEFCONST(EI_DATA)           /* Data encoding byte index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11762
    DEFCONST(ELFDATANONE)       /* Invalid data encoding */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11763
    DEFCONST(ELFDATA2LSB)       /* 2's complement, little endian */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11764
    DEFCONST(ELFDATA2MSB)       /* 2's complement, big endian */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11765
    DEFCONST(ELFDATANUM)
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11766
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11767
    DEFCONST(EI_VERSION)        /* File version byte index */
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11768
				/* Value must be EV_CURRENT */
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11769
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11770
    DEFCONST(EI_OSABI)          /* OS ABI identification */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11771
    DEFCONST(ELFOSABI_NONE)     /* UNIX System V ABI */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11772
    DEFCONST(ELFOSABI_SYSV)     /* Alias.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11773
    DEFCONST(ELFOSABI_HPUX)     /* HP-UX */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11774
    DEFCONST(ELFOSABI_NETBSD)   /* NetBSD.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11775
#ifdef ELFOSABI_GNU
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11776
    DEFCONST(ELFOSABI_GNU)      /* Object uses GNU ELF extensions.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11777
#endif
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11778
    DEFCONST(ELFOSABI_LINUX)    /* Compatibility alias.  */
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11779
    DEFCONST(ELFOSABI_SOLARIS)  /* Sun Solaris.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11780
    DEFCONST(ELFOSABI_AIX)      /* IBM AIX.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11781
    DEFCONST(ELFOSABI_IRIX)     /* SGI Irix.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11782
    DEFCONST(ELFOSABI_FREEBSD)  /* FreeBSD.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11783
    DEFCONST(ELFOSABI_TRU64)    /* Compaq TRU64 UNIX.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11784
    DEFCONST(ELFOSABI_MODESTO)  /* Novell Modesto.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11785
    DEFCONST(ELFOSABI_OPENBSD)  /* OpenBSD.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11786
#ifdef ELFOSABI_ARM_AEABI
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11787
    DEFCONST(ELFOSABI_ARM_AEABI)/* ARM EABI */
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11788
#endif
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11789
    DEFCONST(ELFOSABI_ARM)      /* ARM */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11790
    DEFCONST(ELFOSABI_STANDALONE)/* Standalone (embedded) application */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11791
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11792
    DEFCONST(EI_ABIVERSION)     /* ABI version */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11793
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11794
    DEFCONST(EI_PAD)            /* Byte index of padding bytes */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11795
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11796
    /* Legal values for e_type (object file type).  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11797
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11798
    DEFCONST(ET_NONE)           /* No file type */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11799
    DEFCONST(ET_REL)            /* Relocatable file */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11800
    DEFCONST(ET_EXEC)           /* Executable file */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11801
    DEFCONST(ET_DYN)            /* Shared object file */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11802
    DEFCONST(ET_CORE)           /* Core file */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11803
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11804
    DEFCONST(ET_LOOS)           /* OS-specific range start */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11805
    DEFCONST(ET_HIOS)           /* OS-specific range end */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11806
    DEFCONST(ET_LOPROC)         /* Processor-specific range start */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11807
    DEFCONST(ET_HIPROC)         /* Processor-specific range end */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11808
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11809
    /* Legal values for e_machine (architecture).  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11810
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11811
    DEFCONST(EM_NONE)           /* No machine */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11812
    DEFCONST(EM_M32)            /* AT&T WE 32100 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11813
    DEFCONST(EM_SPARC)          /* SUN SPARC */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11814
    DEFCONST(EM_386)            /* Intel 80386 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11815
    DEFCONST(EM_68K)            /* Motorola m68k family */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11816
    DEFCONST(EM_88K)            /* Motorola m88k family */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11817
    DEFCONST(EM_860)            /* Intel 80860 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11818
    DEFCONST(EM_MIPS)           /* MIPS R3000 big-endian */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11819
    DEFCONST(EM_S370)           /* IBM System/370 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11820
    DEFCONST(EM_MIPS_RS3_LE)    /* MIPS R3000 little-endian */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11821
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11822
    DEFCONST(EM_PARISC)         /* HPPA */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11823
    DEFCONST(EM_VPP500)         /* Fujitsu VPP500 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11824
    DEFCONST(EM_SPARC32PLUS)    /* Sun's "v8plus" */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11825
    DEFCONST(EM_960)            /* Intel 80960 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11826
    DEFCONST(EM_PPC)            /* PowerPC */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11827
    DEFCONST(EM_PPC64)          /* PowerPC 64-bit */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11828
    DEFCONST(EM_S390)           /* IBM S390 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11829
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11830
    DEFCONST(EM_V800)           /* NEC V800 series */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11831
    DEFCONST(EM_FR20)           /* Fujitsu FR20 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11832
    DEFCONST(EM_RH32)           /* TRW RH-32 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11833
    DEFCONST(EM_RCE)            /* Motorola RCE */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11834
    DEFCONST(EM_ARM)            /* ARM */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11835
    DEFCONST(EM_FAKE_ALPHA)     /* Digital Alpha */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11836
    DEFCONST(EM_SH)             /* Hitachi SH */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11837
    DEFCONST(EM_SPARCV9)        /* SPARC v9 64-bit */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11838
    DEFCONST(EM_TRICORE)        /* Siemens Tricore */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11839
    DEFCONST(EM_ARC)            /* Argonaut RISC Core */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11840
    DEFCONST(EM_H8_300)         /* Hitachi H8/300 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11841
    DEFCONST(EM_H8_300H)        /* Hitachi H8/300H */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11842
    DEFCONST(EM_H8S)            /* Hitachi H8S */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11843
    DEFCONST(EM_H8_500)         /* Hitachi H8/500 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11844
    DEFCONST(EM_IA_64)          /* Intel Merced */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11845
    DEFCONST(EM_MIPS_X)         /* Stanford MIPS-X */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11846
    DEFCONST(EM_COLDFIRE)       /* Motorola Coldfire */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11847
    DEFCONST(EM_68HC12)         /* Motorola M68HC12 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11848
    DEFCONST(EM_MMA)            /* Fujitsu MMA Multimedia Accelerator*/
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11849
    DEFCONST(EM_PCP)            /* Siemens PCP */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11850
    DEFCONST(EM_NCPU)           /* Sony nCPU embeeded RISC */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11851
    DEFCONST(EM_NDR1)           /* Denso NDR1 microprocessor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11852
    DEFCONST(EM_STARCORE)       /* Motorola Start*Core processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11853
    DEFCONST(EM_ME16)           /* Toyota ME16 processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11854
    DEFCONST(EM_ST100)          /* STMicroelectronic ST100 processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11855
    DEFCONST(EM_TINYJ)          /* Advanced Logic Corp. Tinyj emb.fam*/
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11856
    DEFCONST(EM_X86_64)         /* AMD x86-64 architecture */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11857
    DEFCONST(EM_PDSP)           /* Sony DSP Processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11858
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11859
    DEFCONST(EM_FX66)           /* Siemens FX66 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11860
    DEFCONST(EM_ST9PLUS)        /* STMicroelectronics ST9+ 8/16 mc */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11861
    DEFCONST(EM_ST7)            /* STmicroelectronics ST7 8 bit mc */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11862
    DEFCONST(EM_68HC16)         /* Motorola MC68HC16 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11863
    DEFCONST(EM_68HC11)         /* Motorola MC68HC11 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11864
    DEFCONST(EM_68HC08)         /* Motorola MC68HC08 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11865
    DEFCONST(EM_68HC05)         /* Motorola MC68HC05 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11866
    DEFCONST(EM_SVX)            /* Silicon Graphics SVx */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11867
    DEFCONST(EM_ST19)           /* STMicroelectronics ST19 8 bit mc */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11868
    DEFCONST(EM_VAX)            /* Digital VAX */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11869
    DEFCONST(EM_CRIS)           /* Axis Communications 32-bit embedded processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11870
    DEFCONST(EM_JAVELIN)        /* Infineon Technologies 32-bit embedded processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11871
    DEFCONST(EM_FIREPATH)       /* Element 14 64-bit DSP Processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11872
    DEFCONST(EM_ZSP)            /* LSI Logic 16-bit DSP Processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11873
    DEFCONST(EM_MMIX)           /* Donald Knuth's educational 64-bit processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11874
    DEFCONST(EM_HUANY)          /* Harvard University machine-independent object files */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11875
    DEFCONST(EM_PRISM)          /* SiTera Prism */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11876
    DEFCONST(EM_AVR)            /* Atmel AVR 8-bit microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11877
    DEFCONST(EM_FR30)           /* Fujitsu FR30 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11878
    DEFCONST(EM_D10V)           /* Mitsubishi D10V */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11879
    DEFCONST(EM_D30V)           /* Mitsubishi D30V */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11880
    DEFCONST(EM_V850)           /* NEC v850 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11881
    DEFCONST(EM_M32R)           /* Mitsubishi M32R */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11882
    DEFCONST(EM_MN10300)        /* Matsushita MN10300 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11883
    DEFCONST(EM_MN10200)        /* Matsushita MN10200 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11884
    DEFCONST(EM_PJ)             /* picoJava */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11885
    DEFCONST(EM_OPENRISC)       /* OpenRISC 32-bit embedded processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11886
    DEFCONST(EM_ARC_A5)         /* ARC Cores Tangent-A5 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11887
    DEFCONST(EM_XTENSA)         /* Tensilica Xtensa Architecture */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11888
#ifdef EM_AARCH64
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11889
    DEFCONST(EM_AARCH64)        /* ARM AARCH64 */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11890
#endif
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11891
#ifdef EM_TILEPRO
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11892
    DEFCONST(EM_TILEPRO)        /* Tilera TILEPro */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11893
#endif
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11894
#ifdef EM_MICROBLAZE
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11895
    DEFCONST(EM_MICROBLAZE)     /* Xilinx MicroBlaze */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11896
#endif
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11897
#ifdef EM_TILEGX
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11898
    DEFCONST(EM_TILEGX)         /* Tilera TILE-Gx */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11899
#endif
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11900
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11901
   /* If it is necessary to assign new unofficial EM_* values, please
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11902
      pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11903
      chances of collision with official or non-GNU unofficial values.  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11904
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11905
    DEFCONST(EM_ALPHA)
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11906
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11907
    /* Legal values for e_version (version).  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11908
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11909
    DEFCONST(EV_NONE)           /* Invalid ELF version */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11910
    DEFCONST(EV_CURRENT)        /* Current version */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11911
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11912
#undef DEFCONST
17637
e88d00519209 ELF and OSX defines
Claus Gittinger <cg@exept.de>
parents: 17635
diff changeset
 11913
#endif /* ELF */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11914
%}.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11915
    ELFMAG0 := 16r7F.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11916
    ELFMAG1 := $E codePoint.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11917
    ELFMAG2 := $L codePoint.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11918
    ELFMAG3 := $F codePoint.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11919
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11920
    "Modified (comment): / 16-03-2015 / 15:15:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11921
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11922
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11923
!UnixOperatingSystem::ELFFileHeader class methodsFor:'instance creation'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11924
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11925
fromFile: aStringOrFilename
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11926
    ^ self new initializeOnFile: aStringOrFilename
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11927
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11928
    "Created: / 16-03-2015 / 16:12:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11929
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11930
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11931
!UnixOperatingSystem::ELFFileHeader methodsFor:'accessing'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11932
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11933
e_ident_class
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11934
    ^ data at: 1 + EI_CLASS
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11935
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11936
    "Created: / 17-03-2015 / 20:26:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11937
!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11938
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11939
e_machine
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11940
    ^ data unsignedShortAt: 1 + 16r12 bigEndian: msb
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11941
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11942
    "Created: / 16-03-2015 / 16:29:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11943
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11944
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11945
!UnixOperatingSystem::ELFFileHeader methodsFor:'initialization'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11946
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11947
initializeOnFile: aStringOrFilename
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11948
    file := aStringOrFilename asFilename.
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11949
    file exists ifFalse:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11950
	self error:'Given file does not exist'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11951
	^ nil
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11952
    ].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11953
    file isRegularFile ifFalse:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11954
	self error:'Given file is not a regular file'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11955
	^ nil
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11956
    ].
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11957
    file readingFileDo:[ :s |
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11958
	s binary.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11959
	data := s next: 16r18.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11960
	(data at: 1 + EI_MAG0) ~~ ELFMAG0 ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11961
	    self error:'Given file is not a valid ELF file (magic not found)'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11962
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11963
	(data at: 1 + EI_MAG1) ~~ ELFMAG1 ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11964
	    self error:'Given file is not a valid ELF file (magic not found)'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11965
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11966
	(data at: 1 + EI_MAG2) ~~ ELFMAG2 ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11967
	    self error:'Given file is not a valid ELF file (magic not found)'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11968
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11969
	(data at: 1 + EI_MAG3) ~~ ELFMAG3 ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11970
	    self error:'Given file is not a valid ELF file (magic not found)'.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11971
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11972
	msb := (data at: 1 + EI_DATA) == ELFDATA2MSB
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11973
    ].
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11974
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11975
    "Created: / 16-03-2015 / 16:13:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11976
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11977
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11978
!UnixOperatingSystem::ELFFileHeader methodsFor:'queries'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11979
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11980
isFor32BitArchitecture
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11981
    ^ self e_ident_class == ELFCLASS32
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11982
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11983
    "Created: / 17-03-2015 / 20:31:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11984
!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11985
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11986
isFor64BitArchitecture
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11987
    ^ self e_ident_class == ELFCLASS64
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11988
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11989
    "Created: / 17-03-2015 / 20:31:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11990
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11991
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11992
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11993
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11994
update:aspect with:argument from:anObject
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11995
    "one of our registered handles has been collected"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11996
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11997
    aspect == #ElementExpired ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11998
	OpenFiles keysAndValuesDo:[:fd :handle |
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 11999
	    handle class == SmallInteger ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12000
		"Have to close the file descriptor"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12001
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12002
		OperatingSystem closeFd:fd.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12003
		OpenFiles at:fd put:nil.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12004
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12005
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12006
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12007
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12008
    "Created: 30.9.1997 / 12:57:35 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12009
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12010
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12011
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12012
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12013
initialize
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12014
    OpenFiles := WeakArray new:10.
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12015
    OpenFiles addDependent:self.
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12016
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12017
    "
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12018
	self initialize
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12019
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12020
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12021
    "Created: 26.9.1997 / 17:15:50 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12022
    "Modified: 30.9.1997 / 12:40:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12023
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12024
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12025
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12026
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12027
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12028
    "create an instance of myself for a given fileDescriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12029
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12030
    ^ self new for:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12031
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12032
    "Created: 30.9.1997 / 14:00:00 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12033
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12034
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12035
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12036
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12037
error:anErrorSymbolOrErrno
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12038
    "got an error; arg is either a symbol specifying a primitive error
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12039
     or the error number as returned by the OperatingSystem"
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12040
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12041
    anErrorSymbolOrErrno isInteger ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12042
	(UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12043
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12044
    self primitiveFailed:anErrorSymbolOrErrno.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12045
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12046
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12047
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12048
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12049
close
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12050
    "close the descriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12051
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12052
    |desc|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12053
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12054
    desc := fd.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12055
    self invalidate.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12056
    ^ OperatingSystem closeFd:desc.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12057
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12058
    "Modified: 30.9.1997 / 13:06:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12059
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12060
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12061
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12062
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12063
for:aFileDescriptor
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12064
    "create a file for a handle"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12065
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12066
    |oldHandle|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12067
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12068
    fd := aFileDescriptor.
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12069
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12070
    "JV@2013-03-15: It may happen that OS returns a filedescriptor whose value
21772
04a96a4b3c45 #DOCUMENTATION by mawalch
mawalch
parents: 21769
diff changeset
 12071
     is larger than twice the length of the weakarray. Care for this.
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 12072
     Spotted by Martin Kobetic."
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12073
    oldHandle := OpenFiles at:aFileDescriptor ifAbsent: [nil].
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12074
    "/ the 0 is possible, if an fd was open when saving a snapshot image,
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12075
    "/ and we come up in the new image with no one referring to it.
18620
b4e9f25d6ce6 preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents: 18618
diff changeset
 12076
    (oldHandle notNil and:[oldHandle class ~~ SmallInteger and:[ oldHandle ~~ self]]) ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12077
	oldHandle invalidate.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12078
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12079
    self register.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12080
21772
04a96a4b3c45 #DOCUMENTATION by mawalch
mawalch
parents: 21769
diff changeset
 12081
    "Created: / 26-09-1997 / 17:14:40 / stefan"
04a96a4b3c45 #DOCUMENTATION by mawalch
mawalch
parents: 21769
diff changeset
 12082
    "Modified: / 30-09-1997 / 12:41:43 / stefan"
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12083
    "Modified (comment): / 16-03-2013 / 00:04:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
21772
04a96a4b3c45 #DOCUMENTATION by mawalch
mawalch
parents: 21769
diff changeset
 12084
    "Modified (comment): / 24-05-2017 / 22:02:34 / mawalch"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12085
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12086
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12087
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12088
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12089
readBytes:count into:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12090
    "read count bytes into a byte-buffer;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12091
     Return the number of bytes read.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12092
     The read is non-blocking. If the operation would block
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12093
     either an incomplete count or nil will be returned.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12094
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12095
     An exception is raised on any other error"
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12096
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12097
    |error|
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12098
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12099
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12100
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12101
    int nRead = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12102
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12103
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12104
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12105
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12106
    if (! __isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12107
	error = @symbol(errorNotOpen);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12108
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12109
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12110
    if (! __bothSmallInteger(count, firstIndex)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12111
	error = @symbol(badArgument);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12112
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12113
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12114
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12115
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12116
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12117
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12118
    if (fd < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12119
	error = @symbol(internalError);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12120
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 12121
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 12122
    if (__isExternalBytesLike(aByteBuffer)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12123
	OBJ sz;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12124
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12125
	nInstBytes = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12126
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12127
	if (extPtr == NULL) goto bad;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12128
	sz = __externalBytesSize(aByteBuffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12129
	if (__isSmallInteger(sz)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12130
	    objSize = __smallIntegerVal(sz);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12131
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12132
	    objSize = -1; /* unknown */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12133
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12134
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12135
	OBJ oClass = __Class(aByteBuffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12136
	int nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12137
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12138
	nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12139
	switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12140
	    case BYTEARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12141
	    case WORDARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12142
	    case LONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12143
	    case SWORDARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12144
	    case SLONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12145
	    case FLOATARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12146
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12147
	    case DOUBLEARRAY:
15991
84ded9e95455 class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 15982
diff changeset
 12148
#ifdef __NEED_DOUBLE_ALIGN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12149
		nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12150
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12151
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12152
	    case LONGLONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12153
	    case SLONGLONGARRAY:
15991
84ded9e95455 class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 15982
diff changeset
 12154
#ifdef __NEED_LONGLONG_ALIGN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12155
		nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12156
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12157
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12158
	    default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12159
		goto bad;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12160
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12161
	extPtr = (char *)0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12162
	objSize = __Size(aByteBuffer) - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12163
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12164
    if ((offs >= 0)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12165
	&& (cnt >= 0)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12166
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12167
	nRead = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12168
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12169
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12170
	    int n;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12171
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12172
	    if (extPtr) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12173
		n = read(fd, extPtr+offs, cnt);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12174
	    } else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12175
		char *bp;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12176
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12177
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12178
		 * on interrupt, anObject may be moved to another location.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12179
		 * So we recompute the byte-address here.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12180
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12181
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12182
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12183
		n = read(fd, bp + offs, cnt);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12184
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12185
	    if (n > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12186
		cnt -= n;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12187
		offs += n;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12188
		nRead += n;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12189
	    } else if (n == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12190
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12191
	    } else if (n < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12192
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12193
#ifdef EWOULDBLOCK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12194
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12195
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12196
#ifdef EAGAIN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12197
		    || errno == EAGAIN
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12198
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12199
		) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12200
		     RETURN(nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12201
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12202
		if (errno != EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12203
		     error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12204
		     goto bad;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12205
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12206
		__HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12207
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12208
	} while (cnt > 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12209
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12210
	RETURN (__mkSmallInteger(nRead));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12211
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12212
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12213
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12214
    ^ self error:error.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12215
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12216
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12217
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12218
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12219
     h := OperatingSystem openFileForRead:'/etc/hosts'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12220
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12221
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12222
     Transcript show:n; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12223
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12224
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12225
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12226
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12227
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12228
     h := OperatingSystem openFileForRead:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12229
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12230
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12231
     Transcript show:n printString; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12232
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12233
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12234
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12235
writeBytes:count from:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12236
    "write count bytes from a byte-buffer;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12237
     Return the number of bytes written (negative on error)"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12238
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12239
    |error|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12240
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12241
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12242
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12243
    int nWritten = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12244
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12245
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12246
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12247
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12248
    if (! __isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12249
	error = @symbol(errorNotOpen);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12250
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12251
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12252
    if (! __bothSmallInteger(count, firstIndex)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12253
	error = @symbol(badArgument);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12254
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12255
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12256
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12257
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12258
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12259
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12260
    if (fd < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12261
	error = @symbol(internalError);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12262
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 12263
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 12264
    if (__isExternalBytesLike(aByteBuffer)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12265
	OBJ sz;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12266
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12267
	nInstBytes = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12268
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12269
	if (extPtr == NULL) goto bad;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12270
	sz = __externalBytesSize(aByteBuffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12271
	if (__isSmallInteger(sz)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12272
	    objSize = __smallIntegerVal(sz);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12273
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12274
	    objSize = -1; /* unknown */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12275
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12276
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12277
	OBJ oClass = __Class(aByteBuffer);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12278
	int nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12279
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12280
	nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12281
	switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12282
	    case BYTEARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12283
	    case WORDARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12284
	    case LONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12285
	    case SWORDARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12286
	    case SLONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12287
	    case FLOATARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12288
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12289
	    case DOUBLEARRAY:
15991
84ded9e95455 class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 15982
diff changeset
 12290
#ifdef __NEED_DOUBLE_ALIGN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12291
		nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12292
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12293
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12294
	    case LONGLONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12295
	    case SLONGLONGARRAY:
15991
84ded9e95455 class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 15982
diff changeset
 12296
#ifdef __NEED_LONGLONG_ALIGN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12297
		nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12298
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12299
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12300
	    default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12301
		goto bad;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12302
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12303
	extPtr = (char *)0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12304
	objSize = __Size(aByteBuffer) - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12305
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12306
    if ((offs >= 0)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12307
	&& (cnt >= 0)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12308
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12309
	nWritten = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12310
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12311
	do {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12312
	    int n;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12313
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12314
	    if (extPtr) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12315
		n = write(fd, extPtr+offs, cnt);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12316
	    } else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12317
		char *bp;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12318
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12319
		/*
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12320
		 * on interrupt, anObject may be moved to another location.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12321
		 * So we recompute the byte-address here.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12322
		 */
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12323
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12324
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12325
		n = write(fd, bp + offs, cnt);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12326
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12327
	    if (n > 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12328
		cnt -= n;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12329
		offs += n;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12330
		nWritten += n;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12331
	    } else if (n == 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12332
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12333
	    } else if (n < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12334
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12335
#ifdef EWOULDBLOCK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12336
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12337
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12338
#ifdef EAGAIN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12339
		    || errno == EAGAIN
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12340
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12341
		) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12342
		     RETURN(nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12343
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12344
		if (errno != EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12345
		     error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12346
		     goto bad;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12347
		}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12348
		__HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12349
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12350
	} while (cnt > 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12351
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12352
	RETURN (__mkSmallInteger(nWritten));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12353
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12354
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12355
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12356
    ^ self error:error
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12357
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12358
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12359
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12360
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12361
     h := OperatingSystem createFileForReadWrite:'/tmp/xx'.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12362
     buff := '12345678901234567890'.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12363
     n := h writeBytes:10 from:buff startingAt:1.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12364
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12365
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12366
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12367
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12368
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12369
     h := OperatingSystem createFileForReadWrite:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12370
     buff := '12345678901234567890'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12371
     n := h writeBytes:10 from:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 12372
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12373
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12374
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12375
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12376
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12377
nextError
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12378
    "retrieve the pending error from the current fileDescriptor
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12379
     and raise an error exception.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12380
     This should be only called, when an error is pending.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12381
     Otherwise a byte may be lost"
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12382
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12383
    |dummyByte|
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12384
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12385
    dummyByte := ByteArray new:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12386
    ^ self readBytes:1 into:dummyByte startingAt:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12387
!
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12388
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12389
seekTo:newPosition from:whence
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12390
    "seek to newPosition
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12391
     whence is one of: #begin #current #end.
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12392
     Return the new position."
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12393
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12394
    |error|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12395
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12396
%{
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12397
    INT fd;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12398
    INT __whence;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12399
    off_t pos, ret;
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12400
    OBJ rslt;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12401
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12402
    if (! __isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12403
	error = @symbol(errorNotOpen);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12404
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12405
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12406
    if (__isSmallInteger(newPosition)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12407
	pos = __smallIntegerVal(newPosition);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12408
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12409
	pos = __signedLongIntVal(newPosition);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12410
	if (pos < 0 && (sizeof(pos) < 8 || __signedLong64IntVal(newPosition, &pos) == 0)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12411
	    error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12412
	    goto bad;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12413
	}
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12414
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12415
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12416
    fd = __smallIntegerVal(__INST(fd));
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12417
    if (fd < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12418
	error = @symbol(internalError);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12419
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12420
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12421
    if (whence == @symbol(begin)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12422
	__whence = SEEK_SET;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12423
    } else if (whence == @symbol(current)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12424
	__whence = SEEK_CUR;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12425
    } else if (whence == @symbol(end)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12426
	__whence = SEEK_END;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12427
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12428
	error = @symbol(badArgument2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12429
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12430
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12431
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12432
again:
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12433
    ret = lseek(fd, pos, __whence);
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12434
    if (ret < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12435
	if (errno == EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12436
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12437
	    goto again;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12438
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12439
	error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12440
	goto bad;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12441
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12442
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12443
    if (sizeof(ret) == 8) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12444
	rslt = __MKINT64 (&ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12445
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12446
	rslt = __MKINT(ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12447
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 12448
    RETURN (rslt);
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12449
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12450
bad: ;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12451
%}.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12452
    ^ self error:error.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12453
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12454
    "
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12455
     |h buff n|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12456
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12457
     h := OperatingSystem openFileForRead:'/etc/hosts'.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12458
     h seekTo:10 from:#begin.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12459
     buff := ByteArray new:1000. buff inspect.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12460
     n := h readBytes:1000 into:buff startingAt:1.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12461
     Transcript show:n; space; showCR:buff asString.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12462
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12463
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12464
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12465
selectWithTimeOut:millis
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12466
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12467
     Return true, if i/o ok, false if timed-out or interrupted.
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12468
     With 0 as timeout argument, this can be used to check for availability (poll)
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12469
     of read-data."
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12470
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12471
    ^ (OperatingSystem
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12472
	selectOnAnyReadable:(Array with:fd) writable:nil exception:nil
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12473
	readableInto:nil writableInto:nil exceptionInto:nil
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12474
	withTimeOut:millis) ~~ 0.
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12475
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12476
    "Created: / 01-10-1997 / 08:51:11 / stefan"
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12477
    "Modified (comment): / 03-05-2018 / 14:59:08 / stefan"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12478
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12479
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12480
setBlocking:aBoolean
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12481
    "{ Pragma: +optSpace }"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12482
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12483
    "set/clear the blocking attribute - if set (which is the default)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12484
     a read on the fileDescriptor will block until data is available.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12485
     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
 12486
     nil if no data is available."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12487
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12488
    |err|
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12489
%{
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12490
#ifdef __SCHTEAM__
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12491
    // TODO
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12492
    return context._RETURN(0);
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12493
#else
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12494
    int ret, flags;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12495
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12496
# if defined(F_GETFL) && defined(F_SETFL)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12497
#  if defined(O_NDELAY)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12498
#   define DELAY_FLAG O_NDELAY
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12499
#  else
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12500
#   if defined(FNDELAY)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12501
#    define DELAY_FLAG FNDELAY
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12502
#   endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12503
#  endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12504
#  if defined(DELAY_FLAG)
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12505
    if (__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12506
	int f = __intVal(__INST(fd));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12507
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12508
	flags = fcntl(f, F_GETFL, 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12509
	if (aBoolean == true) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12510
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12511
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12512
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12513
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12514
	if (ret >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12515
	    RETURN(__mkSmallInteger(flags));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12516
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12517
	    err = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12518
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12519
    }
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12520
#  undef DELAY_FLAG
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12521
#  endif /* DELAY_FLAG */
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12522
# endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12523
#endif /* not SCHTEAM */
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12524
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12525
    err notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12526
	self error:err
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12527
    ].
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12528
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12529
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12530
     fd argument not integer
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12531
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12532
    ^ self primitiveFailed
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12533
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12534
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12535
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12536
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 12537
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'private-accessing'!
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12538
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12539
fileDescriptor
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12540
    "return the (integer) fileDescriptor"
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12541
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12542
%{
7462
05b5202d988a Fix compiler warning
Stefan Vogel <sv@exept.de>
parents: 7461
diff changeset
 12543
    OBJ handle = __externalAddressVal(self);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12544
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12545
    if (__isSmallInteger(handle)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12546
	RETURN (handle);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12547
    }
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12548
%}.
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12549
    ^ nil
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12550
!
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12551
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12552
setFileDescriptor:anInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12553
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12554
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12555
    if (__isSmallInteger(anInteger)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12556
	__externalAddressVal(self) = (OBJ)(__smallIntegerVal(anInteger));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12557
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12558
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12559
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12560
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12561
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12562
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12563
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12564
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12565
canReadWithoutBlocking
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12566
    "return true, if data is available on a filedescriptor
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12567
     (i.e. read is possible without blocking).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12568
     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
 12569
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12570
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12571
    if (__isSmallInteger(__INST(fd))) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12572
	int fd = __smallIntegerVal(__INST(fd));
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12573
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12574
	/*
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12575
	 * if available, try FIONREAD first, which is usually done faster.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12576
	 */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12577
# ifdef FIONREAD
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12578
	{
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12579
	    int result = 0;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12580
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12581
	    if (ioctl(fd, FIONREAD, &result) >= 0) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12582
		RETURN(result > 0 ? true : false);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12583
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12584
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12585
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12586
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12587
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12588
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12589
    ^ (OperatingSystem
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12590
	selectOnAnyReadable:(Array with:fd) writable:nil exception:nil
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12591
	readableInto:nil writableInto:nil exceptionInto:nil
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12592
	withTimeOut:0) ~~ 0.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12593
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12594
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12595
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12596
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12597
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12598
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12599
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12600
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12601
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12602
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12603
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12604
     h := OperatingSystem openFileForRead:'/dev/ttyS0'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12605
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12606
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12607
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12608
    "
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12609
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12610
    "Modified: / 03-05-2018 / 14:54:59 / stefan"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12611
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12612
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12613
canWriteWithoutBlocking
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12614
    "return true, if filedescriptor can be written without blocking"
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12615
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12616
    ^ (OperatingSystem
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12617
	selectOnAnyReadable:nil writable:(Array with:fd) exception:nil
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12618
	readableInto:nil writableInto:nil exceptionInto:nil
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12619
	withTimeOut:0) ~~ 0.
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12620
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12621
    "Modified: / 03-05-2018 / 14:54:51 / stefan"
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12622
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12623
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12624
isValid
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12625
    "answer true, if the handle is valid, i.e. connected to
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12626
     a file or some other OS object"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12627
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12628
    ^ fd notNil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12629
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12630
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12631
numAvailableForRead
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12632
    "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
 12633
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12634
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12635
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12636
     * 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
 12637
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12638
# if defined(FIONREAD)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12639
    {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12640
	int n = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12641
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12642
	if (__isSmallInteger(__INST(fd))) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12643
	    if (ioctl(__smallIntegerVal(__INST(fd)), FIONREAD, &n) >= 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12644
		RETURN (__MKINT(n));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12645
	    }
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12646
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12647
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12648
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12649
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12650
    ^ self canReadWithoutBlocking ifTrue:[1] ifFalse:[0]
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12651
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12652
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12653
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12654
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12655
     n := h numAvailableForRead.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12656
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12657
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12658
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12659
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12660
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12661
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12662
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12663
register
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12664
    "register myself as an open file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12665
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12666
    |sz old|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12667
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12668
    sz := OpenFiles size.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12669
    fd > sz ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12670
	"grow for more descriptors"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12671
	old := OpenFiles.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12672
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12673
	"JV@2013-03-15: It may happen that OS returns a filedescriptor whose value
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12674
	 is larger than twice the length of the weakarray. Care for this.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12675
	 Spotted by Martin Kobetic."
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12676
	OpenFiles := WeakArray new:((sz * 2) max:fd).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12677
	old removeDependent:(self class).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12678
	OpenFiles addDependent:(self class).
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12679
	old keysAndValuesDo:[:index :elem|
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12680
	    "be careful to not overwrite new entries in OpenFiles"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12681
	    elem notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12682
		OpenFiles at:index put:elem.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12683
	    ].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12684
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12685
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12686
    OpenFiles at:fd put:self.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12687
21772
04a96a4b3c45 #DOCUMENTATION by mawalch
mawalch
parents: 21769
diff changeset
 12688
    "Created: / 30-09-1997 / 12:51:48 / stefan"
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12689
    "Modified (comment): / 16-03-2013 / 00:04:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
21772
04a96a4b3c45 #DOCUMENTATION by mawalch
mawalch
parents: 21769
diff changeset
 12690
    "Modified (comment): / 24-05-2017 / 22:03:02 / mawalch"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12691
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12692
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12693
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12694
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12695
invalidate
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12696
    "a file handle has become invalid"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12697
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12698
    OpenFiles at:fd put:nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12699
    fd := nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12700
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12701
    "Created: 30.9.1997 / 12:37:26 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12702
    "Modified: 30.9.1997 / 12:42:16 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12703
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12704
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12705
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'waiting'!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12706
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12707
readWaitWithTimeoutMs:timeout
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12708
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12709
     becomes ready for reading or a timeout (in milliseconds) expired.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12710
     If data is already available, return immediate.
20257
bf95d404e329 #OTHER by mawalch
mawalch
parents: 20125
diff changeset
 12711
     Return true if a timeout occurred (i.e. false, if data is available).
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12712
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12713
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12714
    |inputSema wasBlocked hasTimedout|
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12715
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12716
    fd isNil ifTrue:[^ self error:#errorNotOpen].
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12717
    self canReadWithoutBlocking ifTrue:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12718
	^ false.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12719
    ].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12720
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12721
    wasBlocked := OperatingSystem blockInterrupts.
22173
2b5ea01dc3e1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22165
diff changeset
 12722
    inputSema := Semaphore name:'readWait'.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12723
    [
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12724
	Processor signal:inputSema onInput:fd.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12725
	hasTimedout := (inputSema waitWithTimeoutMs:timeout state:#iowait) isNil.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12726
    ] ifCurtailed:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12727
	Processor disableSemaphore:inputSema.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12728
	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12729
    ].
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12730
    hasTimedout ifTrue:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12731
	Processor disableSemaphore:inputSema.
16481
cbecb6681a12 class: UnixOperatingSystem>>FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16464
diff changeset
 12732
    ].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12733
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12734
    ^ hasTimedout
22173
2b5ea01dc3e1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22165
diff changeset
 12735
2b5ea01dc3e1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22165
diff changeset
 12736
    "Modified: / 09-08-2017 / 12:00:05 / cg"
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12737
    "Modified: / 03-05-2018 / 15:03:42 / stefan"
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12738
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12739
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12740
writeWaitWithTimeoutMs:timeout
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12741
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12742
     becomes ready for writing or a timeout (in seconds) expired.
20257
bf95d404e329 #OTHER by mawalch
mawalch
parents: 20125
diff changeset
 12743
     Return true if a timeout occurred (i.e. false, if data is available).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12744
     Return immediate if the receiver is already ready.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12745
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12746
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12747
    |outputSema wasBlocked hasTimedOut|
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12748
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12749
    fd isNil ifTrue:[^ self error:#errorNotOpen].
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12750
    self canWriteWithoutBlocking ifTrue:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12751
	^ false.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12752
    ].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12753
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12754
    wasBlocked := OperatingSystem blockInterrupts.
22173
2b5ea01dc3e1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22165
diff changeset
 12755
    outputSema := Semaphore name:'writeWait'.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12756
    [
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12757
	Processor signal:outputSema onOutput:fd.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12758
	hasTimedOut := (outputSema waitWithTimeoutMs:timeout state:#iowait) isNil.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12759
    ] ifCurtailed:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12760
	Processor disableSemaphore:outputSema.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12761
	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12762
    ].
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12763
    hasTimedOut ifTrue:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 12764
	Processor disableSemaphore:outputSema.
16481
cbecb6681a12 class: UnixOperatingSystem>>FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16464
diff changeset
 12765
    ].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12766
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12767
    ^ hasTimedOut
22173
2b5ea01dc3e1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22165
diff changeset
 12768
2b5ea01dc3e1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22165
diff changeset
 12769
    "Modified: / 09-08-2017 / 12:00:10 / cg"
22720
af161a8324b8 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22666
diff changeset
 12770
    "Modified: / 03-05-2018 / 15:05:31 / stefan"
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12771
! !
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12772
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12773
!UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12774
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12775
closeFile
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12776
    "close the underlying file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12777
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12778
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12779
    FILE *f = (FILE *)(__externalAddressVal(self));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12780
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12781
    if (f) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12782
	__externalAddressVal(self) = NULL;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12783
	fclose(f);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12784
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12785
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12786
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12787
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12788
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12789
!UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12790
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12791
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
22136
b5a59ffdd8d8 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21900
diff changeset
 12792
    <resource: #obsolete>
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12793
    ^ self basicNew
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12794
	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
17314
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12795
!
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12796
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12797
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT sourcePath:sP targetPath:tP numLinks:nL
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12798
    ^ self basicNew
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12799
	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT sourcePath:sP targetPath:tP numLinks:nL
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12800
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12801
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12802
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12803
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12804
accessTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12805
    "return accessed"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12806
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12807
    accessed isInteger ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12808
	"/ lazy time conversion
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12809
	accessed := Timestamp fromOSTime:(accessed * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12810
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12811
    ^ accessed
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12812
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12813
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12814
alternativeName
16592
cb3cbc0f525c class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16580
diff changeset
 12815
    "return the file's other name (DOS name on Windows).
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12816
     Nil if there is no other name"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12817
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12818
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12819
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12820
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12821
creationTime
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12822
    ^ nil
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12823
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12824
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12825
fileSize
22402
65b1d7257fbd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22294
diff changeset
 12826
    "return the file's size"
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12827
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12828
    ^ size
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12829
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12830
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12831
gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12832
    "return gid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12833
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12834
    ^ gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12835
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12836
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12837
id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12838
    "return id"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12839
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12840
    ^ id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12841
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12842
17313
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12843
linkTargetPath
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12844
    "for symbolic links only: return the path where the symbolic link points to"
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12845
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12846
    ^ targetPath
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12847
!
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12848
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12849
mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12850
    "return mode"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12851
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12852
    ^ mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12853
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12854
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12855
modificationTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12856
    "return modified"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12857
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12858
    modified isInteger ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12859
	"/ lazy time conversion
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12860
	modified := Timestamp fromOSTime:(modified * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12861
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12862
    ^ modified
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12863
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12864
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12865
numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12866
    "return numLinks"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12867
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12868
    ^ numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12869
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12870
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12871
path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12872
    "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
 12873
17288
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12874
    ^ targetPath
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12875
!
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12876
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12877
sourcePath
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12878
    ^ sourcePath
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12879
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12880
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12881
statusChangeTime
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12882
    statusChanged isInteger ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12883
	"/ lazy time conversion
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 12884
	statusChanged := Timestamp fromOSTime:(statusChanged * 1000).
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12885
    ].
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12886
    ^ statusChanged
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12887
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12888
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12889
targetPath
23483
89533706d387 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23418
diff changeset
 12890
    <resource: #obsolete> "/ use linkTargetPath
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12891
    "for symbolic links only: return the path where the symbolic link points to"
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12892
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12893
    ^ targetPath
23483
89533706d387 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23418
diff changeset
 12894
89533706d387 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23418
diff changeset
 12895
    "Modified (comment): / 29-10-2018 / 12:30:27 / Claus Gittinger"
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12896
!
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12897
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12898
type
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12899
    "return type"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12900
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12901
    ^ type
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12902
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12903
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12904
uid
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12905
    "return uid"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12906
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12907
    ^ uid
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12908
! !
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12909
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12910
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing-vms'!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12911
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12912
fixedHeaderSize
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12913
    "return the fixedHeaderSize (VMS only; nil everywhere else)"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12914
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12915
    ^ nil
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12916
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12917
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12918
recordAttributes
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12919
    "return the recordAttributes (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12920
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12921
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12922
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12923
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12924
recordFormat
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12925
    "return the recordFormat (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12926
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12927
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12928
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12929
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12930
recordFormatNumeric
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12931
    "return the recordFormat as numeric (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12932
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12933
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12934
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12935
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12936
recordSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12937
    "return the recordSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12938
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12939
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12940
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12941
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12942
!UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12943
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12944
accessed
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 12945
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12946
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12947
    self obsoleteMethodWarning:'use #accessTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12948
    ^ self accessTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12949
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12950
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12951
at:key
22136
b5a59ffdd8d8 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21900
diff changeset
 12952
    <resource: #obsolete>
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12953
    "backward compatibility access: in previous releases, IdentityDictionaries
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12954
     were used to hold my information. Allow access via key messages.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12955
     This method will vanish - use the proper access protocol."
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12956
22136
b5a59ffdd8d8 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21900
diff changeset
 12957
    self obsoleteMethodWarning:'use ', key.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12958
    ^ self perform:key
22136
b5a59ffdd8d8 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21900
diff changeset
 12959
b5a59ffdd8d8 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21900
diff changeset
 12960
    "Modified: / 01-08-2017 / 10:08:07 / stefan"
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12961
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12962
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12963
modified
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 12964
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12965
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12966
    self obsoleteMethodWarning:'use #modificationTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12967
    ^ self modificationTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12968
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12969
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12970
statusChanged
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 12971
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12972
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12973
    self obsoleteMethodWarning:'use #statusChangeTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12974
    ^ self statusChangeTime
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12975
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12976
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 12977
!UnixOperatingSystem::FileStatusInfo methodsFor:'private-accessing'!
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12978
17288
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12979
sourcePath:lP
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12980
    sourcePath := lP.
17282
3e6b5f0df9e6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17281
diff changeset
 12981
!
3e6b5f0df9e6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17281
diff changeset
 12982
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12983
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
22136
b5a59ffdd8d8 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21900
diff changeset
 12984
    <resource: #obsolete>
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12985
    type := t.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12986
    mode := m.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12987
    uid := u.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12988
    gid := g.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12989
    size := s.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12990
    id := i.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12991
    accessed := aT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12992
    modified := mT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12993
    statusChanged := sT.
17288
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12994
    targetPath := lP.
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12995
    numLinks := nL.
17314
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12996
!
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12997
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12998
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT sourcePath:sP targetPath:tP numLinks:nL
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12999
    type := t.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13000
    mode := m.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13001
    uid := u.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13002
    gid := g.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13003
    size := s.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13004
    id := i.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13005
    accessed := aT.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13006
    modified := mT.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13007
    statusChanged := sT.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13008
    sourcePath := sP.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13009
    targetPath := tP.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 13010
    numLinks := nL.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 13011
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 13012
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13013
!UnixOperatingSystem::FileStatusInfo methodsFor:'queries-access'!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13014
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13015
isGroupExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13016
    ^ mode bitTest:8r10
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13017
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13018
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13019
      '/etc/passwd' asFilename info isGroupExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13020
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13021
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13022
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13023
isGroupReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13024
    ^ mode bitTest:8r40
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13025
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13026
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13027
      '/etc/passwd' asFilename info isGroupReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13028
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13029
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13030
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13031
isGroupWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13032
    ^ mode bitTest:8r20
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13033
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13034
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13035
      '/etc/passwd' asFilename info isGroupWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13036
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13037
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13038
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13039
isOwnerExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13040
    ^ mode bitTest:8r100
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13041
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13042
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13043
      '/etc/passwd' asFilename info isOwnerExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13044
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13045
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13046
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13047
isOwnerReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13048
    ^ mode bitTest:8r400
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13049
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13050
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13051
      '/etc/passwd' asFilename info isOwnerReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13052
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13053
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13054
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13055
isOwnerWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13056
    ^ mode bitTest:8r200
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13057
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13058
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13059
      '/etc/passwd' asFilename info isOwnerWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13060
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13061
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13062
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13063
isWorldExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13064
    ^ mode bitTest:8r1
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13065
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13066
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13067
      '/etc/passwd' asFilename info isWorldExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13068
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13069
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13070
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13071
isWorldReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13072
    ^ mode bitTest:8r4
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13073
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13074
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13075
      '/etc/passwd' asFilename info isWorldReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13076
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13077
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13078
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13079
isWorldWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13080
    ^ mode bitTest:8r2
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13081
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13082
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13083
      '/etc/passwd' asFilename info isWorldWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13084
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13085
! !
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13086
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 13087
!UnixOperatingSystem::FileStatusInfo methodsFor:'queries-type'!
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13088
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13089
isBlockSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13090
    ^ type == #blockSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13091
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13092
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13093
isCharacterSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13094
    ^ type == #characterSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13095
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13096
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13097
isDirectory
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13098
    ^ type == #directory
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13099
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13100
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13101
isFifo
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13102
    ^ type == #fifo
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13103
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13104
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13105
isRegular
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13106
    ^ type == #regular
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13107
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13108
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13109
isSocket
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13110
    ^ type == #socket
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13111
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13112
15301
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 13113
isSpecialFile
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 13114
    ^ (type ~~ #directory
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13115
	and:[type ~~ #remoteDirectory
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13116
	and:[type ~~ #regular
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13117
	and:[type ~~ #symbolicLink
15301
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 13118
    ]]])
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 13119
!
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 13120
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13121
isSymbolicLink
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13122
    ^ type == #symbolicLink
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13123
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13124
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13125
isUnknown
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13126
    ^ type == #unknown
17281
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13127
!
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13128
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13129
isValid
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13130
    "true if this info contains valid status info, or only the name.
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13131
     Under UNIX, the fileStatuInfo as returned from readDir ONLY contains the name of the file,
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13132
     whereas under Windows, it contains the full info (incl. fileSize, access rights etc.).
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13133
     The reason is that under windows, the ReadNextEntry system call does this, whereas the
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13134
     the corresponding unix readdir only returns the name."
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13135
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 13136
    ^ type notNil
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13137
! !
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 13138
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13139
!UnixOperatingSystem::MountInfo methodsFor:'accessing'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13140
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13141
mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13142
    "return the value of the instance variable 'mountPointPath' (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13143
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13144
    ^ mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13145
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13146
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13147
mountPointPath:mountPointArg deviceOrRemotePath:deviceOrRemotePathArg fsType:fsTypeArg attributeString:attributeStringArg
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13148
    "set instance variables (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13149
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13150
    mountPointPath := mountPointArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13151
    deviceOrRemotePath := deviceOrRemotePathArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13152
    fsType := fsTypeArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13153
    attributeString := attributeStringArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13154
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13155
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 13156
!UnixOperatingSystem::MountInfo methodsFor:'printing'!
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 13157
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 13158
printOn:aStream
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13159
    aStream
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13160
	nextPutAll:'MountInfo for ';
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13161
	nextPutAll:mountPointPath.
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 13162
! !
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 13163
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13164
!UnixOperatingSystem::MountInfo methodsFor:'queries'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13165
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13166
isRemote
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13167
    ^ fsType = 'nfs'
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13168
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 13169
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13170
!UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13171
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13172
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13173
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13174
    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
 13175
    operating system processes (these are no smalltalk processes!!).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13176
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13177
    [Instance variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13178
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13179
	pid     <Integer>       OS-Process identifier
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13180
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13181
	status  <Symbol>        either #exit #signal #stop #continue
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13182
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13183
	code    <Integer>       either exitcode or signalnumber
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13184
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13185
	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
 13186
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13187
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13188
    [author:]
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13189
	Stefan Vogel
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13190
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13191
    [see also:]
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13192
	OperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13193
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13194
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13195
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13196
!UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13197
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13198
pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13199
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13201
    ^ 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
 13202
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13203
    "Created: 28.12.1995 / 14:16:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13204
    "Modified: 30.4.1996 / 18:25:00 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13205
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13206
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13207
processCreationFailure
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13208
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13209
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13210
    ^ 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
 13211
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13212
    "Created: 28.12.1995 / 14:35:29 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13213
    "Modified: 30.4.1996 / 18:25:05 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13214
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13215
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13216
!UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13217
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13218
code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13219
    "return the exitcode / signalNumber"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13220
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13221
    ^ code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13222
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13223
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13224
    "Modified: 30.4.1996 / 18:26:23 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13225
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13226
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13227
core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13228
    "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
 13229
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13230
    ^ core == true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13231
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13232
    "Modified: 28.12.1995 / 14:14:38 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13233
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13234
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13235
pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13236
    "return the pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13237
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13238
    ^ pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13239
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13240
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13241
    "Modified: 30.4.1996 / 18:26:30 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13242
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13243
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13244
status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13245
    "return status as a Symbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13246
     one of #exit #signal #stop #continue"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13247
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13248
    ^ status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13249
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13250
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13251
    "Modified: 30.4.1996 / 18:26:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13252
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13253
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13254
!UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13255
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13256
pid:newPid status:newStatus code:newCode core:newCore
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13257
    pid := newPid.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13258
    status := newStatus.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13259
    code := newCode.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13260
    core := newCore.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13261
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13262
    "Created: 28.12.1995 / 14:18:22 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13263
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13264
7175
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13265
!UnixOperatingSystem::OSProcessStatus methodsFor:'printing & storing'!
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13266
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13267
printOn:aStream
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13268
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13269
    aStream nextPutAll:'ExitStatus ('.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13270
    status printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13271
    aStream nextPutAll:', code='.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13272
    code printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13273
    aStream nextPut:$).
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13274
! !
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 13275
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13276
!UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13277
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13278
code:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13279
    "set the exitCode"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13280
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13281
    code := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13282
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13283
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13284
    "Modified: 30.4.1996 / 18:25:18 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13285
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13286
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13287
core:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13288
    "set core"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13289
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13290
    core := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13291
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13292
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13293
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13294
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13295
pid:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13296
    "set pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13297
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13298
    pid := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13299
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13300
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13301
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13302
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13303
status:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13304
    "set status"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13305
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13306
    status := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13308
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13309
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13310
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13311
!UnixOperatingSystem::OSProcessStatus methodsFor:'queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13312
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13313
couldNotExecute
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13314
    "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
 13315
21187
fc18b7d78488 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21158
diff changeset
 13316
    ^ status == #failure or:[status == #exit and:[code = 127]].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13317
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13318
    "Created: 28.12.1995 / 15:43:17 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13319
    "Modified: 30.4.1996 / 18:27:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13320
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13321
16410
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 13322
isError
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 13323
    "true if process terminated with error"
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 13324
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 13325
    ^ status == #exit and:[code ~= 0]
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 13326
!
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 13327
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13328
stillAlive
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13329
    "true if process is still alive"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13330
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13331
    ^ status == #stop or:[status == #continue]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13332
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13333
    "Created: 28.12.1995 / 14:27:26 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13334
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13335
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13336
success
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13337
    "true if process terminated successfully"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13338
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13339
    ^ status == #exit and:[code = 0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13340
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13341
    "Created: 28.12.1995 / 14:13:05 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13342
    "Modified: 28.12.1995 / 14:13:41 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13343
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13344
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13345
!UnixOperatingSystem::SocketHandle class methodsFor:'constants'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13346
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13347
protocolCodeOf:aNameOrNumber
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13348
    "convert a symbol to a numeric protocol code"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13349
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13350
    |protocolCode protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13351
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13352
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13353
    if (__isSmallInteger(aNameOrNumber) || aNameOrNumber == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13354
	RETURN(aNameOrNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13355
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13356
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13357
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13358
    ProtocolCache notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13359
	protocolCode := ProtocolCache at:(aNameOrNumber asSymbol) ifAbsent:[].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13360
	protocolCode notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13361
	    ^ protocolCode.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13362
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13363
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13364
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13365
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13366
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13367
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13368
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 13369
    if (__isStringLike(aNameOrNumber)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13370
	protoent = getprotobyname((char *) __stringVal(aNameOrNumber));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13371
	if (protoent) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13372
	    protocolCode = __mkSmallInteger(protoent->p_proto);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13373
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13374
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13375
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13376
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13377
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13378
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13379
    protocolSymbol notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13380
	ProtocolCache isNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13381
	    ProtocolCache := IdentityDictionary new.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13382
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13383
	"beware of polluting the protocol cache with aliases"
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13384
	ProtocolCache at:protocolSymbol put:protocolCode.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13385
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13386
    ^ protocolCode
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13387
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13388
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13389
     self protocolCodeOf:#tcp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13390
     self protocolCodeOf:#udp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13391
     self protocolCodeOf:#raw
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13392
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13393
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13394
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13395
protocolSymbolOf:anInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13396
    "convert a numeric protocol code to a symbol"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13397
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13398
    |protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13399
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13400
    ProtocolCache notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13401
	protocolSymbol := ProtocolCache keyAtIdentityValue:anInteger ifAbsent:[].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13402
	protocolSymbol notNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13403
	    ^ protocolSymbol.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13404
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13405
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13406
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13407
%{
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13408
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13409
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13410
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13411
    if (__isSmallInteger(anInteger)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13412
	protoent = getprotobynumber(__intVal(anInteger));
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13413
	if (protoent) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13414
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13415
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13416
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13417
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13418
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13419
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13420
    protocolSymbol notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13421
	ProtocolCache isNil ifTrue:[
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13422
	    ProtocolCache := IdentityDictionary new.
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13423
	].
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 13424
	ProtocolCache at:protocolSymbol put:anInteger.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13425
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13426
    ^ protocolSymbol
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13427
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13428
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13429
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13430
     self protocolSymbolOf:(self protocolCodeOf:#tcp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13431
     self protocolSymbolOf:(self protocolCodeOf:#udp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13432
     self protocolSymbolOf:(self protocolCodeOf:#icmp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13433
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13434
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13435
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13436
!UnixOperatingSystem::SocketHandle class methodsFor:'initialization'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13437
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13438
reinitialize
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13439
    "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
 13440
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13441
    ProtocolCache := nil.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13442
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13443
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13444
!UnixOperatingSystem::SocketHandle class methodsFor:'queries'!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13445
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13446
getAddressInfo:hostName serviceName:serviceName domain:domainArg type:typeArg protocol:protoArg flags:flags
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13447
    "answer an Array of socket addresses for serviceName on hostName.
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13448
     A nil hostName will return the loopback address(es) e.g. localhost.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13449
     Domain, type, protocol may be nil or specify a hint for the socket
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13450
     addresses to be returned.
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13451
     The sorting function used within getaddrinfo() is defined in RFC 3484; in linux the order can be
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13452
     tweaked for a particular system by editing /etc/gai.conf"
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13453
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13454
    |result domain type proto encodedHostName os|
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13455
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13456
    os := OperatingSystem.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13457
    
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13458
    domainArg notNil ifTrue:[
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13459
        domain := os domainCodeOf:domainArg.
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13460
    ].
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13461
    typeArg notNil ifTrue:[
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13462
        type := os socketTypeCodeOf:typeArg.
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13463
    ].
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13464
    protoArg notNil ifTrue:[
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13465
        proto := self protocolCodeOf:protoArg.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13466
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13467
15795
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 13468
    hostName isNil ifTrue:[
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13469
        encodedHostName := nil.
15795
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 13470
    ] ifFalse:[
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13471
        encodedHostName := hostName utf8Encoded.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13472
    ].
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13473
    (encodedHostName ~~ hostName and:[os getCodeset ~~ #utf8]) ifTrue:[
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13474
        "hostName is not plain ASCII - so this is an IDN domain name. Have to ensure, that the locale is UTF-8.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13475
         Block interrupt to not affect other ST/X processes while the locale is changed."
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13476
        |interruptsBlocked oldLocale|
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13477
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13478
        interruptsBlocked := os blockInterrupts.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13479
        oldLocale := os setLocale:#'LC_CTYPE' to:nil.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13480
        os setLocale:#'LC_CTYPE' to:'en_US.UTF-8'.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13481
        result := self primGetAddressInfo:encodedHostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13482
        os setLocale:#'LC_CTYPE' to:oldLocale.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13483
        interruptsBlocked ifFalse:[
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13484
            os unblockInterrupts.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13485
        ].
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13486
    ] ifFalse:[
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13487
        result := self primGetAddressInfo:encodedHostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13488
    ].
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13489
    result isArray ifFalse:[
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13490
        |request|
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13491
        request := SocketAddressInfo new
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13492
            domain:domainArg;
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13493
            type:typeArg;
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13494
            protocol:protoArg;
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13495
            canonicalName:hostName;
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13496
            serviceName:serviceName.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13497
        ^ (HostNameLookupError new
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13498
                parameter:result;
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13499
                messageText:' - ', (result printString);
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13500
                request:request) raiseRequest.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13501
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13502
    1 to:result size do:[:i |
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13503
        |entry dom info|
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13504
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13505
        entry := result at:i.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13506
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13507
        info := SocketAddressInfo new.
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13508
        info
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13509
            flags:(entry at:1);
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13510
            domain:(dom := os domainSymbolOf:(entry at:2));
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13511
            type:(os socketTypeSymbolOf:(entry at:3));
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13512
            protocol:(self protocolSymbolOf:(entry at:4));
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13513
            socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5));
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13514
            canonicalName:(entry at:6).
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13515
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13516
        result at:i put:info.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13517
    ].
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13518
    ^ result.
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13519
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13520
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13521
    "
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13522
     self getAddressInfo:'localhost' serviceName:nil
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13523
            domain:nil type:nil protocol:nil flags:nil
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13524
     self getAddressInfo:nil serviceName:22
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13525
            domain:nil type:nil protocol:nil flags:nil
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13526
     self getAddressInfo:'' serviceName:22
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13527
            domain:nil type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13528
     self getAddressInfo:'localhost' serviceName:nil
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13529
            domain:nil type:#stream protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13530
     self getAddressInfo:'localhost' serviceName:nil
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13531
            domain:#inet type:#stream protocol:#tcp flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13532
     self getAddressInfo:'blurb.exept.de' serviceName:nil
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13533
            domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13534
     self getAddressInfo:'1.2.3.4' serviceName:'bla'
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13535
            domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13536
     self getAddressInfo:'localhost' serviceName:'echo'
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13537
            domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13538
     self getAddressInfo:nil serviceName:'echo'
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13539
            domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13540
     self getAddressInfo:nil serviceName:nil
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13541
            domain:#inet type:nil protocol:nil flags:nil
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13542
     self getAddressInfo:'www.google.de' serviceName:80
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13543
            domain:nil type:nil protocol:nil flags:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 13544
     self getAddressInfo:'www.exept.de' serviceName:nil
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13545
            domain:nil type:nil protocol:nil flags:nil
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13546
     self getAddressInfo:'www.exept.de' serviceName:'https'
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13547
            domain:#'AF_INET' type:nil protocol:nil flags:nil
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13548
     self getAddressInfo:'www.exept.de' serviceName:'https'
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13549
            domain:#'AF_UNSPEC' type:nil protocol:nil flags:nil
20963
68a1d022d6f4 #REFACTORING by mawalch
mawalch
parents: 20929
diff changeset
 13550
     self getAddressInfo:'www.exept.de' serviceName:nil
23816
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13551
            domain:#'AF_INET6' type:nil protocol:nil flags:nil
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13552
     self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13553
            domain:#'AF_INET' type:#stream protocol:nil flags:nil
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13554
     self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13555
            domain:#'AF_INET6' type:#stream protocol:nil flags:nil
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13556
    "
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13557
1656c246ca09 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23781
diff changeset
 13558
    "Modified: / 03-03-2019 / 11:21:21 / Claus Gittinger"
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13559
!
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13560
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13561
getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13562
    "answer an Array containing the hostName and serviceName
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13563
     in socketAddress.
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13564
     This is the generic version of getHostByAddr, however, if supported by the OS,
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13565
     this returns multiple hostnames (if appropriate)"
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13566
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13567
    |error errorString hostName serviceName|
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13568
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 13569
%{ /* STACK: 100000 */  /* Don't know whether DNS, NIS, LDAP or whatever is consulted */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13570
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13571
#undef xxNI_NUMERICHOST /* remove xx to test gethost...() path */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13572
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13573
#if !defined(NO_SOCKET)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13574
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13575
# ifndef NI_MAXHOST
8788
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 13576
#  define NI_MAXHOST 1025
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13577
#  define NI_MAXSERV 64
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13578
# endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13579
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13580
    char host[NI_MAXHOST];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13581
    char service[NI_MAXSERV];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13582
    char *hp = 0, *sp = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13583
    int hsz = 0, ssz = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13584
    int ret, __flags;
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13585
    int nInstBytes, sockAddrSize;
22643
ca656b9a9b79 ouch: passing the address of an ST-object to an interruptable
Claus Gittinger <cg@exept.de>
parents: 22623
diff changeset
 13586
    union {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13587
	struct sockaddr addr;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13588
	char enoughBytesForBigAddresses[1024];
22644
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13589
    } sav_sockaddr;
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13590
    struct sockaddr *sav_sockaddrp;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13591
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13592
    if (wantHostName == true) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13593
	hp = host;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13594
	hsz = sizeof(host);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13595
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13596
    if (wantServiceName == true) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13597
	sp = service;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13598
	ssz = sizeof(service);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13599
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13600
    if (hp == 0 && sp == 0) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13601
	error = @symbol(badArgument);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13602
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13603
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13604
    if (!__isBytes(socketAddress)) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13605
	error = @symbol(badArgument1);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13606
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13607
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13608
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13609
    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
22644
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13610
    sockAddrSize = __byteArraySize(socketAddress) - nInstBytes;
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13611
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13612
    if (!__isSmallInteger(flags)) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13613
	error = @symbol(badArgument5);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13614
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13615
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13616
    __flags = __intVal(flags);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13617
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13618
#if defined(NI_NUMERICHOST)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13619
    if (useDatagram == true) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13620
	__flags |= NI_DGRAM;
22644
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13621
    }
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13622
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13623
    if (sockAddrSize <= sizeof(sav_sockaddr)) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13624
	sav_sockaddrp = &sav_sockaddr.addr;
22644
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13625
    } else {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13626
	fprintf(stderr, "OS: sockAddr buffer size too small\n");
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13627
	sav_sockaddrp = (struct sockaddr *)malloc(sockAddrSize + 32);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13628
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13629
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13630
    {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13631
	// when we run this interruptable (or even in a separate thread),
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13632
	// we cannot pass ST/X objects to it
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13633
	// (some other ST/X thread might trigger a GC)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13634
	memcpy(sav_sockaddrp, __byteArrayVal(socketAddress)+nInstBytes, sockAddrSize);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13635
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13636
	__BEGIN_INTERRUPTABLE__
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13637
	ret = getnameinfo(sav_sockaddrp, sockAddrSize, hp, hsz, sp, ssz, __flags);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13638
	__END_INTERRUPTABLE__
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13639
    } while (ret == EAI_SYSTEM && errno == EINTR);
22643
ca656b9a9b79 ouch: passing the address of an ST-object to an interruptable
Claus Gittinger <cg@exept.de>
parents: 22623
diff changeset
 13640
22644
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13641
    if (sav_sockaddrp != &sav_sockaddr.addr) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13642
	free(sav_sockaddrp);
22644
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13643
    }
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13644
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13645
    if (ret != 0) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13646
	switch (ret) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13647
	case EAI_FAMILY:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13648
	    error = @symbol(badProtocol);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13649
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13650
	case EAI_SOCKTYPE:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13651
	    error = @symbol(badSocketType);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13652
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13653
	case EAI_BADFLAGS:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13654
	    error = @symbol(badFlags);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13655
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13656
	case EAI_NONAME:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13657
	    error = @symbol(unknownHost);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13658
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13659
	case EAI_SERVICE:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13660
	    error = @symbol(unknownService);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13661
	    break;
11626
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 13662
#ifdef EAI_ADDRFAMILY
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13663
	case EAI_ADDRFAMILY :
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13664
	    error = @symbol(unknownHostForProtocol);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13665
	    break;
11626
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 13666
#endif
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 13667
#ifdef EAI_NODATA
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13668
	case EAI_NODATA:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13669
	    error = @symbol(noAddress);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13670
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13671
#endif
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13672
	case EAI_MEMORY:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13673
	    error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13674
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13675
	case EAI_FAIL:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13676
	    error = @symbol(permanentFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13677
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13678
	case EAI_AGAIN:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13679
	    error = @symbol(tryAgain);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13680
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13681
	case EAI_SYSTEM:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13682
	    error = @symbol(systemError);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13683
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13684
	default:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13685
	    error = @symbol(unknownError);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13686
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13687
	errorString = __MKSTRING(gai_strerror(ret));
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13688
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13689
    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13690
# else /* ! NI_NUMERICHOST */
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13691
    {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13692
	/*
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13693
	 * Do it using gethostbyaddr()
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13694
	 */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13695
	struct sockaddr_in *sa;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13696
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13697
	if (sockAddrSize < sizeof(*sa)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13698
	    error = @symbol(badArgument1);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13699
	    goto err;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13700
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13701
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13702
	if (sp) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13703
	    char *__proto = (useDatagram == true ? "udp" : "tcp");
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13704
	    struct servent *servp = getservbyport(sa->sin_port, __proto);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13705
	    if (servp) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13706
		sp = servp->s_name;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13707
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13708
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13709
	if (hp) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13710
	    struct hostent *hostp;
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13711
#  ifdef USE_H_ERRNO
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13712
	    do {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13713
		sa = (struct sockaddr_in *)(__byteArrayVal(socketAddress) + nInstBytes);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13714
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13715
		/* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13716
							 and sa points to possible grabage collected memory
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13717
		 */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13718
		hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13719
		/* __END_INTERRUPTABLE__ */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13720
	    } while ((hostp == NULL)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13721
		      && ((h_errno == TRY_AGAIN)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13722
			  || errno == EINTR
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13723
#   ifdef IRIX5_3
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13724
			  || (errno == ECONNREFUSED)
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13725
#   endif
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13726
			 )
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13727
	    );
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13728
	    if (hostp == 0) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13729
		switch (h_errno) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13730
		case HOST_NOT_FOUND:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13731
		    errorString = @symbol(unknownHost);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13732
		    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13733
		case NO_ADDRESS:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13734
		    errorString = @symbol(noAddress);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13735
		    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13736
		case NO_RECOVERY:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13737
		    errorString = @symbol(permanentFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13738
		    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13739
		case TRY_AGAIN:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13740
		    errorString = @symbol(tryAgain);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13741
		    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13742
		default:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13743
		    errorString = @symbol(unknownError);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13744
		    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13745
		}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13746
		error = __mkSmallInteger(h_errno);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13747
		goto err;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13748
	    }
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13749
#  else /* !USE_H_ERRNO */
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13750
	    hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13751
	    if (hostp == 0) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13752
		errorString = @symbol(unknownHost);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13753
		error = __mkSmallInteger(-1);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13754
		goto err;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13755
	    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13756
#  endif /* !USE_H_ERRNO*/
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13757
	    hp = hostp->h_name;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13758
	}
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13759
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13760
# endif /* ! NI_NUMERICHOST */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13761
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13762
    if (hp)
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13763
	hostName = __MKSTRING(hp);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13764
    if (sp)
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13765
	serviceName = __MKSTRING(sp);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13766
err:;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13767
#else
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13768
    error = @symbol(notImplemented);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13769
#endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13770
%}.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13771
    error notNil ifTrue:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13772
	^ (HostAddressLookupError new
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13773
		parameter:error;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13774
		messageText:' - ', errorString;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13775
		request:thisContext message) raiseRequest.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13776
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13777
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13778
    ^ Array with:hostName with:serviceName
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13779
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13780
    "
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13781
     self getNameInfo:
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13782
	(self getAddressInfo:'localhost' serviceName:'echo'
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13783
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13784
	 wantHostName:true wantServiceName:true datagram:false flags:0
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13785
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13786
     self getNameInfo:
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13787
	(self getAddressInfo:'exept.de' serviceName:'echo'
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13788
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13789
	 wantHostName:true wantServiceName:true datagram:false flags:0
8788
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 13790
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 13791
     self getNameInfo:
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13792
	(self getAddressInfo:'217.172.183.25' serviceName:'22'
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13793
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13794
	 wantHostName:true wantServiceName:true datagram:false flags:0
8788
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 13795
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 13796
     self getNameInfo:
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13797
	(self getAddressInfo:'1.2.3.4' serviceName:'22'
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13798
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13799
	 wantHostName:true wantServiceName:true datagram:false flags:0
22644
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13800
    "
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13801
be8a36f6839d #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 22643
diff changeset
 13802
    "Modified: / 21-03-2018 / 10:03:30 / stefan"
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13803
!
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13804
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13805
primGetAddressInfo:hostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13806
    "answer an Array of socket addresses for serviceName on hostName
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13807
     Domain, type, protocol may be nil or specify a hint for the socket
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13808
     addresses to be returned.
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13809
     A nil hostName resolves to the loopback interface address (localhost).
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13810
     An empty hostname resolves to an address that may be used for a lisstening server."
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13811
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13812
    |error errorString result|
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13813
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13814
%{ /* UNLIMITEDSTACK */  /* Don't know whether DNS, NIS, LDAP or whatever is consulted */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13815
#undef xxAI_NUMERICHOST /* remove xx to test gethost...() path */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13816
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13817
#if !defined(NO_SOCKET)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13818
    char *__hostName, *__serviceName;
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13819
    char intServiceName[21];
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13820
    int ret, cnt = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13821
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13822
    if (hostName == nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13823
	__hostName = 0;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13824
    } else if (__isStringLike(hostName)) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13825
	__hostName = __stringVal(hostName);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13826
    } else {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13827
	error = @symbol(badArgument1);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13828
	goto out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13829
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13830
    if (serviceName == nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13831
	__serviceName = 0;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13832
    } else if (__isStringLike(serviceName)) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13833
	__serviceName = __stringVal(serviceName);
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13834
    } else if (__isSmallInteger(serviceName)) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13835
	__serviceName = intServiceName;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13836
	snprintf(intServiceName, sizeof(intServiceName), "%d", (int)(__intVal(serviceName)));
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13837
    } else {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13838
	error = @symbol(badArgument2);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13839
	goto out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13840
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13841
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13842
{
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13843
# if defined(AI_NUMERICHOST)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13844
    /*
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13845
     * Use getaddrinfo()
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13846
     */
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13847
    struct addrinfo hints = {0};
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13848
    struct addrinfo *info = NULL, *infop;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13849
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13850
    hints.ai_flags = AI_ADDRCONFIG      // only return IPv6 or IPv4 addresses if there is at least on interface where this address type is configured
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13851
		    | AI_V4MAPPED;
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
 13852
    if (__isSmallInteger(serviceName))
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13853
	hints.ai_flags |= AI_NUMERICSERV;
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13854
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13855
    if (__hostName && __stringSize(hostName) == 0) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13856
	// empty string, this is a listening host - bound to INADDR_ANY
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13857
	__hostName = 0;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13858
	hints.ai_flags |= AI_PASSIVE;
21329
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
 13859
    }
0305c8e8f35f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21220
diff changeset
 13860
15798
2f79f67ae7b7 has no A_IDN
Claus Gittinger <cg@exept.de>
parents: 15795
diff changeset
 13861
#if defined(AI_IDN)
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13862
    hints.ai_flags |= AI_IDN | AI_CANONIDN;     // map non-ascii domain names to IDN format
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13863
#endif
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13864
    if (__isSmallInteger(domain))
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13865
	hints.ai_family = __intVal(domain);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13866
    if (__isSmallInteger(type))
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13867
	hints.ai_socktype = __intVal(type);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13868
    if (__isSmallInteger(proto))
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13869
	hints.ai_protocol = __intVal(proto);
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13870
    if (__isSmallInteger(flags))
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13871
	hints.ai_flags |= __intVal(flags);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13872
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13873
    do {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13874
	/* reload */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13875
	if (__hostName) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13876
	    __hostName = __stringVal(hostName);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13877
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13878
	if (__isStringLike(serviceName)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13879
	    __serviceName = __stringVal(serviceName);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13880
	}
22666
4366ac264f07 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22664
diff changeset
 13881
4366ac264f07 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22664
diff changeset
 13882
// disabled, because sender blocks interrupts
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13883
//        __BEGIN_INTERRUPTABLE__
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13884
	ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13885
//        __END_INTERRUPTABLE__
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13886
    } while (ret == EAI_SYSTEM && errno == EINTR);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13887
    if (ret != 0) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13888
	switch (ret) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13889
	case EAI_FAMILY:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13890
	    error = @symbol(badProtocol);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13891
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13892
	case EAI_SOCKTYPE:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13893
	    error = @symbol(badSocketType);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13894
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13895
	case EAI_BADFLAGS:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13896
	    error = @symbol(badFlags);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13897
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13898
	case EAI_NONAME:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13899
	    error = @symbol(unknownHost);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13900
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13901
	case EAI_SERVICE:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13902
	    error = @symbol(unknownService);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13903
	    break;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13904
#ifdef EAI_ADDRFAMILY
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13905
	case EAI_ADDRFAMILY :
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13906
	    error = @symbol(unknownHostForProtocol);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13907
	    break;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13908
#endif
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13909
#ifdef EAI_NODATA
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13910
	case EAI_NODATA:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13911
	    error = @symbol(noAddress);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13912
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13913
#endif
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13914
	case EAI_MEMORY:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13915
	    error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13916
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13917
	case EAI_FAIL:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13918
	    error = @symbol(permanentFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13919
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13920
	case EAI_AGAIN:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13921
	    error = @symbol(tryAgain);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13922
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13923
	case EAI_SYSTEM:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13924
	    error = @symbol(systemError);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13925
	    break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13926
	default:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13927
	    error = @symbol(unknownError);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13928
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13929
	errorString = __MKSTRING(gai_strerror(ret));
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13930
	goto ai_out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13931
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13932
    for (cnt=0, infop=info; infop; infop=infop->ai_next)
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13933
	cnt++;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13934
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13935
    result = __ARRAY_NEW_INT(cnt);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13936
    if (result == nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13937
	error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13938
	goto ai_out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13939
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13940
    for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13941
	OBJ o, resp;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13942
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13943
	resp = __ARRAY_NEW_INT(6);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13944
	if (resp == nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13945
	    error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13946
	    goto ai_out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13947
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13948
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13949
	__ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13950
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13951
	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13952
	__ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13953
	__ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13954
	__ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13955
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13956
	__PROTECT__(resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13957
	o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13958
	__UNPROTECT__(resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13959
	if (o == nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13960
	    error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13961
	    goto ai_out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13962
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13963
	memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13964
       __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13965
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13966
	if (infop->ai_canonname) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13967
	    __PROTECT__(resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13968
	    o = __MKSTRING(infop->ai_canonname);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13969
	    __UNPROTECT__(resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13970
	    if (o == nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13971
		error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13972
		goto ai_out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13973
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13974
	    __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13975
	}
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13976
    }
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13977
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 13978
ai_out:
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13979
    if (info) freeaddrinfo(info);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13980
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13981
# else /* ! AI_NUMERICHOST =============================================================*/
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13982
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13983
    /*
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13984
     * Use getservbyname() / gethostByName()
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13985
     */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13986
    struct hostent *hp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13987
    char **addrpp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13988
    int port = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13989
    int i;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13990
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13991
    if (__serviceName) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13992
	struct servent *sp;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13993
	char *__proto = 0;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13994
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13995
	if (__isStringLike(protoArg))
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13996
	    __proto = __stringVal(protoArg);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13997
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13998
	sp = getservbyname(__serviceName, __proto);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 13999
	if (sp == NULL) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14000
	    errorString = @symbol(unknownService);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14001
	    error = __mkSmallInteger(-3);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14002
	    goto out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14003
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14004
	port = sp->s_port;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14005
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14006
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14007
    if (__hostName) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14008
#  ifdef USE_H_ERRNO
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14009
	do {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14010
	    if (hostName == nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14011
		__hostName = 0;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14012
	    } else if (__isStringLike(hostName)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14013
		__hostName = __stringVal(hostName);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14014
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14015
	    /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14016
	     * uses a static data area
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14017
	     */
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14018
	    __BEGIN_INTERRUPTABLE__
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14019
	    hp = gethostbyname(__hostName);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14020
	    __END_INTERRUPTABLE__
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14021
	} while ((hp == NULL)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14022
		  && (
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14023
			(h_errno == TRY_AGAIN)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14024
		      || errno == EINTR
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14025
#   ifdef IRIX5_3
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14026
		      || (errno == ECONNREFUSED)
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14027
#   endif
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14028
		     )
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14029
	);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14030
	if (hp == 0) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14031
	    switch (h_errno) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14032
	    case HOST_NOT_FOUND:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14033
		errorString = @symbol(unknownHost);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14034
		break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14035
	    case NO_ADDRESS:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14036
		errorString = @symbol(noAddress);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14037
		break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14038
	    case NO_RECOVERY:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14039
		errorString = @symbol(permanentFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14040
		break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14041
	    case TRY_AGAIN:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14042
		errorString = @symbol(tryAgain);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14043
		break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14044
	    default:
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14045
		errorString = @symbol(unknownError);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14046
		break;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14047
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14048
	    error = __mkSmallInteger(h_errno);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14049
	    goto out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14050
	}
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14051
#  else /* !USE_H_ERRNO */
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14052
	hp = gethostbyname(__hostName);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14053
	if (hp == 0) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14054
	    errorString = @symbol(unknownHost);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14055
	    error = __mkSmallInteger(-1);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14056
	    goto out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14057
	}
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14058
#  endif /* !USE_H_ERRNO*/
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14059
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14060
	if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14061
	    errorString = @symbol(unknownHost);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14062
	    error = __mkSmallInteger(-2);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14063
	    goto out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14064
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14065
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14066
	for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14067
	    cnt++;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14068
	addrpp = hp->h_addr_list;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14069
    } else {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14070
	cnt = 1;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14071
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14072
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14073
    result = __ARRAY_NEW_INT(cnt);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14074
    if (result == nil) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14075
	error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14076
	goto out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14077
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14078
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14079
    for (i = 0; i < cnt; i++) {
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14080
	OBJ o, resp;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14081
	struct sockaddr_in *sa;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14082
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14083
	resp = __ARRAY_NEW_INT(6);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14084
	if (resp == nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14085
	    error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14086
	    goto out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14087
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14088
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14089
	__ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14090
	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14091
	__ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14092
	__ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14093
	__PROTECT__(resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14094
	o = __BYTEARRAY_NEW_INT(sizeof(*sa));
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14095
	__UNPROTECT__(resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14096
	if (o == nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14097
	    error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14098
	    goto out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14099
	}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14100
	__ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14101
	sa = (struct sockaddr_in *)__byteArrayVal(o);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14102
	sa->sin_port = port;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14103
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14104
	if (__hostName) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14105
	    sa->sin_family = hp->h_addrtype;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14106
	    memcpy(&sa->sin_addr, *addrpp, hp->h_length);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14107
	    __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14108
	    if (hp->h_name) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14109
		__PROTECT__(resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14110
		o = __MKSTRING(hp->h_name);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14111
		__UNPROTECT__(resp);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14112
		if (o == nil) {
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14113
		    error = @symbol(allocationFailure);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14114
		    goto out;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14115
		}
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14116
		__ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14117
	    }
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14118
	    addrpp++;
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14119
	} else{
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14120
	    __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14121
	}
21158
f2a874c26418 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21072
diff changeset
 14122
    }
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14123
# endif /* ! AI_NUMERICHOST */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14124
}
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14125
#else /* ! HAS_SOCKET */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14126
    error = @symbol(notImplemented);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14127
#endif
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 14128
out:;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14129
%}.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14130
    error notNil ifTrue:[
22829
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14131
	errorString notNil ifTrue:[
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14132
	    ^ errorString.
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14133
	].
f8f21ccd46d5 +getOSTimeWithNanos
Claus Gittinger <cg@exept.de>
parents: 22815
diff changeset
 14134
	^ error.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14135
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 14136
    ^ result.
22666
4366ac264f07 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22664
diff changeset
 14137
4366ac264f07 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22664
diff changeset
 14138
    "Modified: / 09-04-2018 / 19:08:55 / stefan"
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 14139
! !
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 14140
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14141
!UnixOperatingSystem::SocketHandle methodsFor:'accepting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14142
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14143
acceptWithPeerAddressBuffer:peerOrNil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14144
    "accept a connection on a server port.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14145
     Returns a new SocketHandle or nil if the operation
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14146
     would block.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14147
     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
 14148
     of the connection peer is stored into it."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14149
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14150
    |error newFd|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14151
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14152
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14153
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14154
    int sock, newSock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14155
    struct sockaddr *sap;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14156
    int alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14157
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14158
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14159
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14160
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14161
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14162
    if (peerOrNil != nil &&
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14163
	(!__isNonNilObject(peerOrNil) ||
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14164
	 (__intVal(__ClassInstPtr(__qClass(peerOrNil))->c_flags) & ARRAYMASK) != BYTEARRAY)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14165
	error = @symbol(badArgument2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14166
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14167
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14168
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14169
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14170
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14171
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14172
    if (peerOrNil == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14173
	alen = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14174
	sap = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14175
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14176
	alen =  __byteArraySize(peerOrNil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14177
	sap = (struct sockaddr *)__byteArrayVal(peerOrNil);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14178
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14179
    newSock = accept(sock, sap, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14180
    if (newSock < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14181
	switch (errno) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14182
	case EINTR:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14183
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14184
	    goto again;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14185
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14186
#ifdef EWOULDBLOCK
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14187
	case EWOULDBLOCK:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14188
# if defined(EAGAIN) && (EAGAIN != EWOULDBLOCK)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14189
	case EAGAIN:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14190
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14191
#else
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14192
# ifdef EAGAIN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14193
	case EAGAIN:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14194
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14195
#endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14196
	    RETURN(nil);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14197
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14198
	default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14199
	    error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14200
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14201
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14202
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14203
    newFd = __mkSmallInteger(newSock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14204
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14205
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14206
#endif /* not NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14207
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14208
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14209
	^ self error:error.
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14210
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14211
    ^ self class for:newFd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14212
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14213
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14214
!UnixOperatingSystem::SocketHandle methodsFor:'binding'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14215
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14216
bindTo:socketAddress
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14217
    "low level bind -
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14218
     Set the local address of the socket"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14219
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14220
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14221
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14222
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14223
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14224
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14225
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14226
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14227
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14228
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14229
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14230
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14231
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14232
    if (!__isNonNilObject(socketAddress) ||
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14233
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14234
	error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14235
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14236
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14237
    sockaddr_size = __byteArraySize(socketAddress);
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
 14238
    sock = __smallIntegerVal(__INST(fd));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14239
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14240
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14241
    ret = bind(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14242
    if (ret < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14243
	if (errno == EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14244
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14245
	    goto again;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14246
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14247
	    error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14248
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14249
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14250
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14251
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14252
    err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14253
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14254
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14255
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14256
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14257
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14258
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14259
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14260
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14261
     (Socket domain:#inet type:#stream)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14262
	 bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14263
	 reuseAddress:false ;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14264
     yourself
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14265
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14266
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14267
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14268
!UnixOperatingSystem::SocketHandle methodsFor:'connecting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14269
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14270
cancelConnect
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14271
    "cancel an asynchronous connect in progress"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14272
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14273
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14274
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14275
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14276
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14277
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14278
    int ret;
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 14279
    struct sockaddr sockaddr;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14280
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14281
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14282
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14283
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14284
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14285
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14286
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14287
    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14288
     * (dis-) connect by connecting to AF_UNSPEC socket
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14289
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14290
again:
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 14291
    sockaddr.sa_family = AF_UNSPEC;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14292
    ret = connect(sock, &sockaddr, sizeof(sockaddr));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14293
    if (ret < 0) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14294
       switch(errno) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14295
	   case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14296
# ifdef EAGAIN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14297
	    case EAGAIN:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14298
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14299
		__HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14300
		goto again;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14301
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14302
	    default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14303
		error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14304
		break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14305
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14306
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14307
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14308
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14309
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14310
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14311
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14312
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14313
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14314
    ].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14315
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14316
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14317
connectTo:socketAddress
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14318
    "low level connect; connect to a socket address.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14319
     Return true if connection has been established,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14320
     false, when the connection has been initiated but not yet
20257
bf95d404e329 #OTHER by mawalch
mawalch
parents: 20125
diff changeset
 14321
     completed. If an error occurred, an OSError is raised"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14322
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14323
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14324
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14325
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14326
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14327
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14328
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14329
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14330
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14331
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14332
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14333
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14334
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14335
    if (!__isNonNilObject(socketAddress) ||
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14336
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14337
	error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14338
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14339
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14340
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14341
    sockaddr_size = __qSize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14342
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14343
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14344
    ret = connect(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14345
    if (ret >= 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14346
	RETURN(true)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14347
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14348
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14349
    switch(errno) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14350
	case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14351
# ifdef EAGAIN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14352
	case EAGAIN:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14353
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14354
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14355
	    goto again;
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14356
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14357
# if defined(EINPROGRESS) || defined(EALREADY)
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14358
#  ifdef EINPROGRESS
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14359
	case EINPROGRESS:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14360
#  endif
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14361
#  ifdef EALREADY
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14362
	case EALREADY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14363
#  endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14364
	    RETURN(false);
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 14365
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14366
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14367
    default:
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14368
	error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14369
	break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14370
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14371
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14372
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14373
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14374
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14375
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14376
	 ^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14377
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14378
    ^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14379
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14380
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14381
     Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:7)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14382
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14383
     Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:5768)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14384
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14385
     Socket newTCP connectTo:(IPSocketAddress hostAddress:#[1 2 3 4] port:7)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14386
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14387
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14388
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14389
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14390
!UnixOperatingSystem::SocketHandle methodsFor:'datagram transmission'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14391
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14392
receiveFrom:socketAddress buffer:aDataBuffer start:startIndex for:nBytes flags:flags
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14393
    "receive datagramm data - put address of originating host into
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14394
     anAddressBuffer, data into aBuffer. For ST-80 compatibility,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14395
     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
 14396
     the addressBytes-message (i.e. be a SocketAddress instance).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14397
     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
 14398
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14399
     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
 14400
     receiving, using #readWait or #readWaitWithTimeout:."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14401
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14402
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14403
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14404
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14405
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14406
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14407
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14408
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14409
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14410
    int alen0, alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14411
    int n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14412
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14413
    int __flags, __startIndex, __nBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14414
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14415
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14416
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14417
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14418
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14419
    if (!__isSmallInteger(startIndex) ||
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14420
	(__startIndex = __intVal(startIndex)-1) < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14421
	if (startIndex == nil) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14422
	    __startIndex = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14423
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14424
	    error = @symbol(badArgument3);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14425
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14426
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14427
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14428
    if (__isSmallInteger(nBytes)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14429
	__nBytes = __intVal(nBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14430
    } else if (nBytes == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14431
	__nBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14432
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14433
	error = @symbol(badArgument4);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14434
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14435
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14436
    if (!__isInteger(flags)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14437
	error = @symbol(badArgument5);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14438
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14439
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14440
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14441
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14442
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14443
    oClass = __Class(aDataBuffer);
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 14444
    switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14445
	case BYTEARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14446
	case WORDARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14447
	case SWORDARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14448
	case LONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14449
	case SLONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14450
	case FLOATARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14451
	case DOUBLEARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14452
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14453
	default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14454
	    error = @symbol(badArgument2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14455
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14456
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14457
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 14458
    nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14459
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14460
    objSize = __qSize(aDataBuffer) - nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14461
    nInstBytes += __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14462
    objSize -= __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14463
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14464
    if (__nBytes >= 0 &&__nBytes < objSize) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14465
	objSize = __nBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14466
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14467
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14468
    if (socketAddress == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14469
	alen0 = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14470
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14471
	if (!__isNonNilObject(socketAddress) ||
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14472
	    (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14473
	    error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14474
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14475
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14476
	alen0 = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14477
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14478
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14479
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14480
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14481
    alen = alen0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14482
    if (alen)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14483
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14484
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14485
    n = recvfrom(sock, cp, objSize, __flags, saPtr, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14486
    if (n < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14487
	if (errno == EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14488
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14489
	    goto again;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14490
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14491
	    error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14492
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14493
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14494
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14495
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14496
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14497
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14498
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14499
    ^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14500
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14501
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14502
sendTo:socketAddress buffer:aDataBuffer start:startIndex for:maxBytes flags:flags
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14503
    "send datagramm data - fetch address of destination host from
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14504
     anAddressBuffer, data from aDataBuffer starting at startIndex,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14505
     sending count bytes.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14506
     SocketAddress must be an instance of SocketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14507
     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
 14508
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14509
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14510
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14511
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14512
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14513
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14514
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14515
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14516
    int alen, n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14517
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14518
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14519
    int __flags;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14520
    int offs, __startIndex, __maxBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14521
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14522
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14523
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14524
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14525
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14526
    if (!__isSmallInteger(startIndex) ||
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14527
	(__startIndex = __intVal(startIndex)-1) < 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14528
	if (startIndex == nil) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14529
	    __startIndex = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14530
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14531
	    error = @symbol(badArgument3);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14532
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14533
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14534
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14535
    if (__isSmallInteger(maxBytes)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14536
	__maxBytes = __intVal(maxBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14537
    } else if (maxBytes == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14538
	__maxBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14539
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14540
	error = @symbol(badArgument4);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14541
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14542
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14543
    if (!__isInteger(flags)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14544
	error = @symbol(badArgument5);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14545
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14546
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14547
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14548
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14549
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14550
    oClass = __Class(aDataBuffer);
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 14551
    switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14552
	case BYTEARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14553
	    offs = __startIndex;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14554
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14555
	case WORDARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14556
	case SWORDARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14557
	    offs = __startIndex * 2;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14558
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14559
	case LONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14560
	case SLONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14561
	    offs = __startIndex * 4;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14562
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14563
	case LONGLONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14564
	case SLONGLONGARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14565
	    offs = __startIndex * 8;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14566
# ifdef __NEED_LONGLONG_ALIGN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14567
	    offs += 4;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14568
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14569
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14570
	case FLOATARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14571
	    offs = __startIndex * sizeof(float);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14572
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14573
	case DOUBLEARRAY:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14574
	    offs = __startIndex * sizeof(double);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14575
# ifdef __NEED_DOUBLE_ALIGN
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14576
	    offs += 4;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14577
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14578
	    break;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14579
	default:
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14580
	    error = @symbol(badArgument2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14581
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14582
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14583
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 14584
    nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14585
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14586
    objSize = __qSize(aDataBuffer) - nInstBytes - offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14587
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14588
    if (__maxBytes >= 0 && __maxBytes < objSize) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14589
# ifdef DGRAM_DEBUG
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14590
	printf("cut off ...\n");
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14591
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14592
	objSize = __maxBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14593
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14594
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14595
    if (socketAddress == nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14596
	alen = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14597
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14598
	if (! __isByteArrayLike(socketAddress)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14599
	    error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14600
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14601
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14602
	alen = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14603
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14604
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14605
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14606
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14607
    if (alen)
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14608
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14609
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes + offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14610
    n = sendto(sock, cp, objSize, __flags, saPtr, alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14611
    if (n < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14612
	if (errno == EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14613
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14614
	    goto again;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14615
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14616
	    error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14617
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14618
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14619
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14620
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14621
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14622
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14623
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14624
    ^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14625
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14626
6434
f23d12900e18 category rename
Claus Gittinger <cg@exept.de>
parents: 6421
diff changeset
 14627
!UnixOperatingSystem::SocketHandle methodsFor:'initialization'!
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14628
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14629
domain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14630
    "set up socket with domain, type and protocol number.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14631
     This is a low level entry; no binding, listening or connect is done.
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14632
     All arguments must be symbols from one of
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14633
     domainArg: #AF_INET, #AF_UNIX, #AF_APPLETALK (#inet, #unix, #appletalk, #x25) ..
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14634
     type: #SOCK_STREAM, #SOCK_DGRAM (#stream, #datagram, #raw) ..
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14635
     protocol: #tcp, #udp, #raw ..
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14636
    "
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14637
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14638
    |error domainCode typeCode protocolNumber|
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14639
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14640
    domainCode := OperatingSystem domainCodeOf:domainArg.
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14641
    typeCode := OperatingSystem socketTypeCodeOf:typeArg.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14642
    protocolArg notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14643
	protocolNumber := self class protocolCodeOf:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14644
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14645
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14646
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14647
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14648
    int dom, typ, proto = 0, sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14649
    int on = 1;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14650
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14651
    if (__INST(fd) != nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14652
	error = @symbol(internalError);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14653
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14654
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14655
    if (! __isSmallInteger(domainCode)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14656
	error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14657
	goto err;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14658
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14659
    if (! __isSmallInteger(typeArg)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14660
	error = @symbol(badArgument2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14661
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14662
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14663
    if (protocolNumber != nil) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14664
	if (!__isSmallInteger(protocolNumber)) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14665
	    error = @symbol(badArgument3);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14666
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14667
	}
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14668
	proto = __smallIntegerVal(protocolNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14669
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14670
    dom = __smallIntegerVal(domainCode);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14671
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14672
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14673
     * get socket-type and protocol-type
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14674
     */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14675
    typ = __intVal(typeArg);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14676
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14677
againSocket:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14678
    sock = socket(dom, typ, proto);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14679
    if (sock < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14680
	if (errno == EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14681
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14682
	    goto againSocket;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14683
	} else
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14684
# if defined(EPROTONOSUPPORT) /* for SGI */
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14685
	if (errno == EPROTONOSUPPORT && proto != 0) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14686
	    proto = 0;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14687
	    goto againSocket;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14688
	} else
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14689
# endif
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14690
	{
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14691
	    error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14692
	    goto err;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14693
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14694
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14695
    __INST(fd) = __mkSmallInteger(sock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14696
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14697
err:;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14698
# else /* NOSOCKET */
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14699
    error = @symbol(notImplemented);
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14700
# endif /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14701
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14702
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14703
	^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14704
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14705
    self register.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14706
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14707
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14708
     self new domain:#inet type:#stream protocol:nil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14709
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14710
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14711
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14712
!UnixOperatingSystem::SocketHandle methodsFor:'misc'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14713
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14714
getOptionsLevel:level name:name
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14715
    "answer a ByteArray containing the socket option value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14716
     named name at level"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14717
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14718
    |error bytes size|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14719
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14720
    bytes := ByteArray new:256.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14721
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14722
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14723
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14724
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14725
    int intval, sz;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14726
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14727
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14728
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14729
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14730
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14731
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14732
    if (!__bothSmallInteger(level, name)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14733
	error = @symbol(badArgument);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14734
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14735
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14736
    if (!__isByteArray(bytes)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14737
	error = @symbol(internalError);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14738
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14739
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14740
    p = __byteArrayVal(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14741
    sz = __byteArraySize(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14742
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14743
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14744
    if (getsockopt(sock, __smallIntegerVal(level), __smallIntegerVal(name), p, &sz) < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14745
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14746
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14747
    size = __mkSmallInteger(sz);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14748
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14749
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14750
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14751
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14752
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14753
	^ self error:error
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14754
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14755
    ^ bytes copyTo:size
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14756
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14757
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14758
listenFor:aNumber
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14759
    "start listening.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14760
     aNumber is the number of connect indications queues
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14761
     by the operating system"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14762
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14763
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14764
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14765
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14766
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14767
    int sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14768
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14769
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14770
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14771
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14772
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14773
    if (!__isSmallInteger(aNumber)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14774
	error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14775
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14776
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14777
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14778
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14779
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14780
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14781
    ret = listen(sock, __smallIntegerVal(aNumber));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14782
    if (ret < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14783
	if (errno == EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14784
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14785
	    goto again;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14786
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14787
	    error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14788
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14789
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14790
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14791
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14792
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14793
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14794
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14795
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14796
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14797
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14798
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14799
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14800
setOptionsLevel:level name:name value:value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14801
    "set the socket option name at level to value.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14802
     Value may be one of SmallInteger, ByteArray or nil"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14803
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14804
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14805
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14806
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14807
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14808
    int sock;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14809
    int __level, __name, intval, sz;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14810
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14811
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14812
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14813
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14814
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14815
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14816
    if (__isSmallInteger(level)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14817
	__level = __smallIntegerVal(level);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14818
    } else if (level == @symbol(SOL_SOCKET)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14819
	__level = SOL_SOCKET;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14820
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14821
	error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14822
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14823
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14824
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14825
    if (__isSmallInteger(name)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14826
	__name = __smallIntegerVal(name);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14827
    } else if (name == @symbol(SO_REUSEADDR)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14828
	__name = SO_REUSEADDR;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14829
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14830
	error = @symbol(badArgument2);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14831
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14832
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14833
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14834
    if (__isSmallInteger(value)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14835
	intval = __intVal(value);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14836
	p = (char *) &intval;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14837
	sz = sizeof(intval);
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 14838
    } else if (__isByteArrayLike(value)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14839
	p = __byteArrayVal(value);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14840
	sz = __byteArraySize(value);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14841
    } else {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14842
	error = @symbol(badArgument3);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14843
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14844
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14845
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14846
    sock = __smallIntegerVal(__INST(fd));
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14847
    if (setsockopt(sock, __level, __name, p, sz) < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14848
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14849
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14850
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14851
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14852
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14853
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14854
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14855
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14856
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14857
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14858
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14859
shutdown:anInteger
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14860
    "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
 14861
     anInteger == 0   no reads will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14862
     anInteger == 1   no writes will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14863
     anInteger == 2   neither reads nor writes will be performed.
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14864
		      Pending data is discarded. This is faster tha
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14865
		      close, which may wait until pending (written)
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14866
		      data has been read by the other side"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14867
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14868
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14869
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14870
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14871
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14872
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14873
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14874
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14875
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14876
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14877
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14878
    if (!__isSmallInteger(anInteger)) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14879
	error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14880
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14881
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14882
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14883
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14884
    ret = shutdown(__smallIntegerVal(__INST(fd)), __smallIntegerVal(anInteger));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14885
    if (ret < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14886
	if (errno == EINTR) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14887
	    __HANDLE_INTERRUPTS__;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14888
	    goto again;
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14889
	} else {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14890
	    error = __mkSmallInteger(errno);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14891
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14892
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14893
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14894
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14895
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14896
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14897
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14898
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14899
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14900
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14901
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14902
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14903
!UnixOperatingSystem::SocketHandle methodsFor:'queries'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14904
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14905
getNameInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14906
    "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
 14907
     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
 14908
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14909
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14910
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14911
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14912
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14913
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14914
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14915
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14916
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14917
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14918
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14919
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14920
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14921
    if (!__isNonNilObject(socketAddress) ||
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14922
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14923
	error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14924
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14925
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14926
    sockaddr_size = __byteArraySize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14927
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14928
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14929
    ret = getsockname(sock, (struct sockaddr *)__byteArrayVal(socketAddress), &sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14930
    if (ret < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14931
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14932
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14933
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14934
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14935
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14936
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14937
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14938
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14939
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14940
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14941
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14942
getPeerInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14943
    "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
 14944
     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
 14945
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14946
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14947
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14948
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14949
#if 0 && !defined(NO_SOCKET)
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14950
    int __sock;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14951
    int __sockaddr_size;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14952
    int __ret;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14953
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14954
    if (!__isSmallInteger(__INST(fd))) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14955
	error = @symbol(badFd);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14956
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14957
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14958
    if (!__isNonNilObject(socketAddress) ||
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14959
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14960
	error = @symbol(badArgument1);
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14961
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14962
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14963
    __sockaddr_size = __byteArraySize(socketAddress);
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14964
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14965
    __sock = __smallIntegerVal(__INST(fd));
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14966
    __ret = getpeername(__sock, (struct sockaddr *)__byteArrayVal(socketAddress),
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14967
				&__sockaddr_size);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14968
    if (__ret < 0) {
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14969
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14970
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14971
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14972
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14973
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14974
    error notNil ifTrue:[
22578
c31e7ac76ff5 os defs; osx fix
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
 14975
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14976
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14977
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14978
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14979
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14980
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14981
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14982
version
18494
41f8a86105f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18415
diff changeset
 14983
    ^ '$Header$'
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 14984
!
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 14985
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 14986
version_CVS
18494
41f8a86105f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18415
diff changeset
 14987
    ^ '$Header$'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14988
! !
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 14989
14598
94f635641b30 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14591
diff changeset
 14990
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14991
UnixOperatingSystem initialize!
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 14992
UnixOperatingSystem::ELFConstants initialize!
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 14993
UnixOperatingSystem::FileDescriptorHandle initialize!