UnixOperatingSystem.st
author Merge Script
Sun, 07 Jun 2015 06:38:49 +0200
branchjv
changeset 18457 214d760f8247
parent 18418 a1b089286b67
child 18500 3ae00a51f1ff
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17681
8894d153e26a class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17637
diff changeset
     1
"{ Encoding: utf8 }"
8894d153e26a class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17637
diff changeset
     2
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 1988 by Claus Gittinger
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
     5
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 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
     8
 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
     9
 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
    10
 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
    11
 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
    12
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    14
"{ Package: 'stx:libbasic' }"
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    15
17281
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
    16
"{ NameSpace: Smalltalk }"
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
    17
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
AbstractOperatingSystem subclass:#UnixOperatingSystem
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    19
	instanceVariableNames:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    20
	classVariableNames:'Initialized HostName DomainName SlowFork ForkFailed
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    21
		CurrentDirectory LastTimeInfo LastTimeInfoSeconds
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    22
		LastTimeInfoMilliseconds LastTimeInfoIsLocal CachedMountPoints
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    23
		CacheMountPointsTimeStamp Codeset CodesetEncoder'
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    24
	poolDictionaries:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    25
	category:'OS-Unix'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    26
!
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    27
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    28
SharedPool subclass:#ELFConstants
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    29
	instanceVariableNames:''
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    30
	classVariableNames:'EI_MAG0 ELFMAG0 EI_MAG1 ELFMAG1 EI_MAG2 ELFMAG2 EI_MAG3 ELFMAG3
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    31
		EI_CLASS ELFCLASSNONE ELFCLASS32 ELFCLASS64 ELFCLASSNUM EI_DATA
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    32
		ELFDATANONE ELFDATA2LSB ELFDATA2MSB ELFDATANUM EI_VERSION
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    33
		EI_OSABI ELFOSABI_NONE ELFOSABI_SYSV ELFOSABI_HPUX
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    34
		ELFOSABI_NETBSD ELFOSABI_GNU ELFOSABI_LINUX ELFOSABI_SOLARIS
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    35
		ELFOSABI_AIX ELFOSABI_IRIX ELFOSABI_FREEBSD ELFOSABI_TRU64
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    36
		ELFOSABI_MODESTO ELFOSABI_OPENBSD ELFOSABI_ARM_AEABI ELFOSABI_ARM
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    37
		ELFOSABI_STANDALONE EI_ABIVERSION EI_PAD ET_NONE ET_REL ET_EXEC
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    38
		ET_DYN ET_CORE ET_LOOS ET_HIOS ET_LOPROC ET_HIPROC EM_NONE EM_M32
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    39
		EM_SPARC EM_386 EM_68K EM_88K EM_860 EM_MIPS EM_S370
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    40
		EM_MIPS_RS3_LE EM_PARISC EM_VPP500 EM_SPARC32PLUS EM_960 EM_PPC
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    41
		EM_PPC64 EM_S390 EM_V800 EM_FR20 EM_RH32 EM_RCE EM_ARM
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    42
		EM_FAKE_ALPHA EM_SH EM_SPARCV9 EM_TRICORE EM_ARC EM_H8_300
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    43
		EM_H8_300H EM_H8S EM_H8_500 EM_IA_64 EM_MIPS_X EM_COLDFIRE
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    44
		EM_68HC12 EM_MMA EM_PCP EM_NCPU EM_NDR1 EM_STARCORE EM_ME16
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    45
		EM_ST100 EM_TINYJ EM_X86_64 EM_PDSP EM_FX66 EM_ST9PLUS EM_ST7
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    46
		EM_68HC16 EM_68HC11 EM_68HC08 EM_68HC05 EM_SVX EM_ST19 EM_VAX
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    47
		EM_CRIS EM_JAVELIN EM_FIREPATH EM_ZSP EM_MMIX EM_HUANY EM_PRISM
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    48
		EM_AVR EM_FR30 EM_D10V EM_D30V EM_V850 EM_M32R EM_MN10300
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    49
		EM_MN10200 EM_PJ EM_OPENRISC EM_ARC_A5 EM_XTENSA EM_AARCH64
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    50
		EM_TILEPRO EM_MICROBLAZE EM_TILEGX EM_ALPHA EV_NONE EV_CURRENT'
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    51
	poolDictionaries:''
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    52
	privateIn:UnixOperatingSystem
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
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    55
Object subclass:#ELFFileHeader
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    56
	instanceVariableNames:'file data msb'
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    57
	classVariableNames:''
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    58
	poolDictionaries:'UnixOperatingSystem::ELFConstants'
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    59
	privateIn:UnixOperatingSystem
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    60
!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
    61
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    62
Object subclass:#FileDescriptorHandle
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    63
	instanceVariableNames:'fd'
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    64
	classVariableNames:'OpenFiles'
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    65
	poolDictionaries:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    66
	privateIn:UnixOperatingSystem
6301
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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    69
OSFileHandle subclass:#FilePointerHandle
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    70
	instanceVariableNames:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    71
	classVariableNames:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    72
	poolDictionaries:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    73
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    74
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    75
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    76
Object subclass:#FileStatusInfo
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    77
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    78
		sourcePath targetPath numLinks'
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    79
	classVariableNames:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    80
	poolDictionaries:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    81
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    84
Object subclass:#MountInfo
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    85
	instanceVariableNames:'mountPointPath deviceOrRemotePath fsType attributeString'
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    86
	classVariableNames:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    87
	poolDictionaries:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    88
	privateIn:UnixOperatingSystem
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    89
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    90
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    91
Object subclass:#OSProcessStatus
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    92
	instanceVariableNames:'pid status code core'
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    93
	classVariableNames:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    94
	poolDictionaries:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    95
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
16390
fb3ad2464cac class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16388
diff changeset
    98
UnixOperatingSystem::FilePointerHandle subclass:#SocketHandle
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
    99
	instanceVariableNames:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
   100
	classVariableNames:'ProtocolCache'
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
   101
	poolDictionaries:''
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
   102
	privateIn:UnixOperatingSystem
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   103
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   104
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
!UnixOperatingSystem primitiveDefinitions!
18164
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   106
%{
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   107
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   108
#include "stxOSDefs.h"
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   109
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   110
#if defined(_AIX)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   111
# ifndef WANT_REALPATH
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   112
#  define WANT_REALPATH
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   113
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   114
# ifndef WANT_SYSTEM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   115
#  define WANT_SYSTEM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   116
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   117
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   118
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   119
#ifdef LINUX
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   120
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   121
# define __xxUSE_GNU      /* new */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   122
# undef HAS_UTS_DOMAINNAME
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   123
# define NET_IF_SUPPORT
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   124
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   125
# ifndef _STDIO_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   126
#  include <stdio.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   127
#  define _STDIO_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   128
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   129
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   130
# ifndef _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   131
#  include <sys/types.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   132
#  define _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   133
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   134
  /* use inline string macros */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   135
# define __STRINGDEFS__
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   136
# include "linuxIntern.h"
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   137
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   138
# ifndef WANT_SYSTEM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   139
#  define WANT_SYSTEM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   140
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   141
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   142
# define WANT_SHM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   143
# define HAS_SETENV
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   144
# define HAS_UNSETENV
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   145
# include <time.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   146
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   147
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   148
#if defined(IRIX5) || defined(ultrix) || defined(hpux) || defined(solaris)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   149
# define WANT_SYSTEM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   150
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   151
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   152
#if defined(SYSV4) && defined(__i386__) /* e.g. unixware */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   153
# define WANT_SYSTEM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   154
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   155
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   156
#if defined __osx__
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   157
# define NET_IF_SUPPORT
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   158
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   159
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   160
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   161
 * notice: although many systems' include files
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   162
 * already block against multiple inclusion, some
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   163
 * do not. Therefore, this is done here again.
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   164
 * (it does not hurt)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   165
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   166
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   167
#ifdef WANT_REALPATH
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   168
# ifndef NO_SYS_PARAM_H
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   169
#  include <sys/param.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   170
#  define _SYS_PARAM_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   171
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   172
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   173
# include <errno.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   174
# define _ERRNO_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   175
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   176
# include <sys/stat.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   177
# define _SYS_STAT_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   178
#endif /* WANT_REALPATH */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   179
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   180
# ifdef HAS_OPENDIR
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   181
#  include <sys/types.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   182
#  ifdef NEXT
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   183
#   include <sys/dir.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   184
#   define DIRENT_STRUCT        struct direct
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   185
#  else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   186
#   include <dirent.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   187
#   define DIRENT_STRUCT        struct dirent
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   188
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   189
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   190
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   191
#ifdef WANT_SHM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   192
# ifndef _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   193
#  include <sys/types.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   194
#  define _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   195
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   196
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   197
# include <sys/ipc.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   198
# define _SYS_IPC_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   199
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   200
# include <sys/shm.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   201
# define _SYS_SHM_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   202
#endif /* WANT_SHM */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   203
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   204
#ifdef IRIX5
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   205
# include <sys/syssgi.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   206
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   207
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   208
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   209
#ifdef transputer
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   210
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   211
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   212
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   213
#else /* not transputer */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   214
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   215
# ifdef __arm__
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   216
#  ifndef _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   217
#   include <sys/types.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   218
#   define _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   219
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   220
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   221
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   222
# ifndef _SIGNAL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   223
#  include <signal.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   224
#  define _SIGNAL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   225
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   226
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   227
# ifdef SYSV
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   228
#  ifndef _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   229
#   include <sys/types.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   230
#   define _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   231
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   232
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   233
#  ifndef _SYS_PARAM_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   234
#   ifndef NO_SYS_PARAM_H
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   235
#    include <sys/param.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   236
#    define _SYS_PARAM_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   237
#   endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   238
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   239
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   240
#  ifndef _SYS_TIMES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   241
#   include <sys/times.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   242
#   define _SYS_TIMES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   243
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   244
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   245
#  ifndef _SYS_FILE_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   246
#   include <sys/file.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   247
#   define _SYS_FILE_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   248
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   249
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   250
#  ifndef _UNISTD_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   251
#   include <unistd.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   252
#   define _UNISTD_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   253
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   254
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   255
#  ifndef _TIME_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   256
#   include <time.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   257
#   define _TIME_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   258
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   259
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   260
# else /* not SYSV */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   261
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   262
#  ifndef _SYS_TIME_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   263
#   include <sys/time.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   264
#   define _SYS_TIME_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   265
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   266
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   267
#  ifndef _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   268
#   include <sys/types.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   269
#   define _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   270
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   271
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   272
# endif /* not SYSV */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   273
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   274
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   275
# ifdef aix
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   276
#  ifndef _TIME_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   277
#   include <time.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   278
#   define _TIME_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   279
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   280
#  ifndef _SYS_SELECT_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   281
#   include <sys/select.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   282
#   define _SYS_SELECT_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   283
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   284
# endif /* aix */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   285
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   286
# ifdef __osx__
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   287
#  include <time.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   288
#  define HAS_TIMEGM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   289
18188
4b21fc6f1e75 struct tm now found in header files (OSX)
Claus Gittinger <cg@exept.de>
parents: 18164
diff changeset
   290
#  ifdef NO_LONGER_NEEDED
4b21fc6f1e75 struct tm now found in header files (OSX)
Claus Gittinger <cg@exept.de>
parents: 18164
diff changeset
   291
// struct tm seems to be defined now (new XCODE/CLANG compiler)
18164
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   292
struct tm {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   293
	int     tm_sec;         /* seconds after the minute [0-60] */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   294
	int     tm_min;         /* minutes after the hour [0-59] */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   295
	int     tm_hour;        /* hours since midnight [0-23] */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   296
	int     tm_mday;        /* day of the month [1-31] */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   297
	int     tm_mon;         /* months since January [0-11] */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   298
	int     tm_year;        /* years since 1900 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   299
	int     tm_wday;        /* days since Sunday [0-6] */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   300
	int     tm_yday;        /* days since January 1 [0-365] */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   301
	int     tm_isdst;       /* Daylight Savings Time flag */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   302
	long    tm_gmtoff;      /* offset from CUT in seconds */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   303
	char    *tm_zone;       /* timezone abbreviation */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   304
};
18188
4b21fc6f1e75 struct tm now found in header files (OSX)
Claus Gittinger <cg@exept.de>
parents: 18164
diff changeset
   305
#  endif /* NO_LONGER */
18164
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   306
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   307
#  include <crt_externs.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   308
#  include <net/if_dl.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   309
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   310
# endif /* __osx__ */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   311
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   312
# ifndef _STDIO_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   313
#  include <stdio.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   314
#  define _STDIO_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   315
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   316
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   317
# ifndef _PWD_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   318
#  include <pwd.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   319
#  define _PWD_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   320
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   321
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   322
# ifndef NO_GRP_H
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   323
#  ifndef _GRP_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   324
#   include <grp.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   325
#   define _GRP_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   326
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   327
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   328
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   329
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   330
# ifndef _SYS_STAT_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   331
#  include <sys/stat.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   332
#  define _SYS_STAT_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   333
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   334
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   335
# ifndef _SYS_FILE_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   336
#  include <sys/file.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   337
#  define _SYS_FILE_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   338
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   339
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   340
# ifndef _ERRNO_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   341
#  include <errno.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   342
#  define _ERRNO_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   343
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   344
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   345
# ifndef _FCNTL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   346
#  include <fcntl.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   347
#  define _FCNTL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   348
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   349
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   350
# ifndef _SYS_IOCTL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   351
#  include <sys/ioctl.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   352
#  define _SYS_IOCTL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   353
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   354
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   355
# if defined(LINUX)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   356
#  define HAS_LOCALECONV
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   357
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   358
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   359
# if defined (HAS_LOCALECONV)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   360
#  ifndef _LOCALE_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   361
#   include <locale.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   362
#   define _LOCALE_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   363
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   364
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   365
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   366
# if defined (HAS_FTIME)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   367
#  include <sys/timeb.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   368
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   369
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   370
// #include <signal.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   371
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   372
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   373
 * posix systems should define these ...
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   374
 * but on some (older) systems, they are not.
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   375
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   376
# ifndef S_IXUSR
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   377
#  ifdef S_IEXEC
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   378
#   define S_IXUSR S_IEXEC
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   379
#   define S_IXGRP (S_IEXEC>>3)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   380
#   define S_IXOTH (S_IEXEC>>6)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   381
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   382
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   383
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   384
# ifndef S_IXUSR
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   385
#  define S_IXUSR 0100
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   386
#  define S_IXGRP 0010
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   387
#  define S_IXOTH 0001
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   388
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   389
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   390
# ifndef S_IRUSR
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   391
#  define S_IRUSR 0400
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   392
#  define S_IRGRP 0040
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   393
#  define S_IROTH 0004
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   394
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   395
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   396
# ifndef S_IWUSR
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   397
#  define S_IWUSR 0200
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   398
#  define S_IWGRP 0020
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   399
#  define S_IWOTH 0002
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   400
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   401
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   402
# ifndef MAXPATHLEN
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   403
#  ifndef NO_SYS_PARAM_H
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   404
#   include <sys/param.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   405
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   406
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   407
#  ifndef MAXPATHLEN
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   408
#   ifdef PATH_MAX
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   409
#    define MAXPATHLEN PATH_MAX
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   410
#   else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   411
#    define MAXPATHLEN 1024
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   412
#   endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   413
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   414
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   415
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   416
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   417
# if defined(HAS_UNAME)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   418
#  include <sys/utsname.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   419
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   420
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   421
# if defined(SYSV4)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   422
#  include <stropts.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   423
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   424
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   425
# ifndef aix
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   426
#  include <sys/termios.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   427
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   428
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   429
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   430
 * NeXT has no pid_t
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   431
 * and no sigemptyset
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   432
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   433
# ifdef NEXT3
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   434
   typedef int pid_t;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   435
#  define sigemptyset(set)      ((*(set) = 0L), 0)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   436
#  define HAS_GETDOMAINNAME
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   437
#  define NO_WAITPID
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   438
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   439
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   440
# ifdef sunos
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   441
#  undef NO_WAITPID
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   442
#  undef HAS_WAITPID
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   443
#  define HAS_WAIT3
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   444
#  define HAS_SIGACTION
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   445
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   446
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   447
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   448
 * some (BSD ?) have no timezone global,
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   449
 * but provide the info in struct timezone.
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   450
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   451
# if defined(ultrix) || defined(sunos) || defined(NEXT)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   452
#  define HAS_NO_TIMEZONE
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   453
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   454
# if defined(__osx__)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   455
#  define HAS_NO_TIMEZONE
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   456
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   457
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   458
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   459
 * sigaction dummies (you won't believe these call themself ``POSIX'' systems ...)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   460
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   461
# ifndef SA_RESTART
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   462
#  define SA_RESTART    0
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   463
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   464
# ifndef SA_SIGINFO
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   465
#  define SA_SIGINFO    0
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   466
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   467
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   468
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   469
#  include <sys/wait.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   470
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   471
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   472
# if defined(HAS_SYSINFO)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   473
#  include <sys/systeminfo.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   474
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   475
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   476
# ifdef LINUX
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   477
#  include <linux/kernel.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   478
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   479
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   480
# if defined(HAS_GETSYSINFO)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   481
#  include <sys/sysinfo.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   482
#  include <machine/hal_sysinfo.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   483
#  include <machine/hal/cpuconf.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   484
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   485
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   486
# if defined(HAS_SYSCONF)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   487
#  ifndef _UNISTD_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   488
#   include <unistd.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   489
#   define _UNISTD_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   490
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   491
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   492
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   493
# if defined(HAS_SYSCTL)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   494
#  include <sys/types.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   495
#  include <sys/sysctl.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   496
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   497
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   498
#endif /* not transputer */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   499
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   500
#ifndef NO_SOCKET
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   501
# define __USE_GNU      // For AI_IDN in netdb.h
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   502
# include <netdb.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   503
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   504
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   505
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   506
 * on some systems errno is a macro ... check for it here
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   507
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   508
#ifndef errno
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   509
 extern errno;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   510
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   511
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   512
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   513
 * some (old ?) systems do not define this ...
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   514
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   515
#if !defined(R_OK) && !defined(_AIX)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   516
# define R_OK    4       /* Test for Read permission */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   517
# define W_OK    2       /* Test for Write permission */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   518
# define X_OK    1       /* Test for eXecute permission */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   519
# define F_OK    0       /* Test for existence of File */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   520
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   521
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   522
#define SIGHANDLER_ARG
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   523
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   524
#ifdef sunos
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   525
# define NO_WAITPID
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   526
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   527
#ifdef NEXT
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   528
# define NO_WAITPID
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   529
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   530
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   531
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   532
 * where is the timezone info ?
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   533
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   534
#ifdef HAS_TM_GMTOFF
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   535
# define TIMEZONE(tmPtr)       (-((tmPtr)->tm_gmtoff))
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   536
#else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   537
# if defined(HAS_NO_TIMEZONE)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   538
#  if defined(HAS_NO_TM_GMTOFF)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   539
#   define TIMEZONE(tmPtr)       0
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   540
#  else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   541
#   define TIMEZONE(tmPtr)       (-((tmPtr)->tm_gmtoff))
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   542
#  endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   543
# else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   544
#  if defined(HAS_ALTZONE)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   545
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : altzone)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   546
#  else  /*!HAS_ALTZONE*/
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   547
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : timezone-3600)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   548
#  endif /*!HAS_ALTZONE*/
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   549
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   550
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   551
#ifndef CONST
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   552
# ifdef __GNUC__
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   553
#  define CONST const
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   554
# else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   555
#  define CONST /* nothing */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   556
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   557
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   558
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   559
#ifndef        FORK
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   560
# if defined(HAS_VFORK)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   561
#  define     FORK            vfork
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   562
# else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   563
#  define     FORK            fork
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   564
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   565
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   566
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   567
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   568
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   569
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   570
 * Socket defines
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   571
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   572
#include "stxOSDefs.h"
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   573
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   574
#ifdef NET_IF_SUPPORT  /* for mac address of interfaces */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   575
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   576
# ifndef _NET_IF_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   577
#  include <net/if.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   578
#  define _NET_IF_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   579
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   580
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   581
# ifndef _SYS_IOCTL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   582
#  include <sys/ioctl.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   583
#  define _SYS_IOCTL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   584
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   585
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   586
#endif /* NET_IF_SUPPORT */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   587
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   588
#if defined(TRY_AGAIN) || defined(HOST_NOT_FOUND)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   589
# define USE_H_ERRNO
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   590
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   591
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   592
#ifdef USE_H_ERRNO
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   593
# ifndef h_errno
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   594
 extern h_errno;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   595
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   596
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   597
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   598
#if (defined(__ELD__) || defined (ELF))
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   599
# ifndef ELFMAG1
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   600
#  include <elf.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   601
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   602
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   603
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   604
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   605
%}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   606
! !
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
!UnixOperatingSystem primitiveFunctions!
18164
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   609
%{
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   610
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   611
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   612
 * some systems' system() is broken in that it does not correctly
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   613
 * handle EINTR and returns failure even though it actually succeeded.
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   614
 * (LINUX is one of them)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   615
 * Here is a fixed version. If you encounter EINTR returns from
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   616
 * UnixOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   617
 * in the xxxIntern.h file to get this fixed version.
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   618
 *
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   619
 * As an added BONUS, this system() enables interrupts while waiting
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   620
 * for the child which enables other threads to continue.
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   621
 * (i.e. it is RT safe)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   622
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   623
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   624
#if defined(WANT_SYSTEM)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   625
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   626
/* # define DPRINTF(x)     printf x */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   627
# define DPRINTF(x)     /* nothing */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   628
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   629
# ifndef _STDDEF_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   630
#  include <stddef.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   631
#  define _STDDEF_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   632
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   633
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   634
# ifndef _STDLIB_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   635
#  include <stdlib.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   636
#  define _STDLIB_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   637
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   638
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   639
# ifndef _UNISTD_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   640
#  include <unistd.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   641
#  define _UNISTD_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   642
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   643
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   644
# ifndef _SYS_WAIT_H_INCLUDED
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   645
#  include <sys/wait.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   646
#  define _SYS_WAIT_H_INCLUDED
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   647
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   648
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   649
# ifndef _SIGNAL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   650
#  include <signal.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   651
#  define _SIGNAL_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   652
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   653
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   654
# ifndef _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   655
#  include <sys/types.h>
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   656
#  define _SYS_TYPES_H_INCLUDED_
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   657
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   658
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   659
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   660
#  define       __environ       environ
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   661
#  if 1 /* !defined(LINUX) */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   662
#   define      __sigemptyset   sigemptyset
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   663
#   define      __sigaction     sigaction
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   664
#   define      __sigaddset     sigaddset
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   665
#   define      __sigprocmask   sigprocmask
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   666
#   define      __execve        execve
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   667
#   define      __wait          wait
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   668
#   define      __waitpid       waitpid
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   669
#  endif /* ! LINUX */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   670
    extern char **environ;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   671
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   672
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   673
# define      __sigprocmask   sigprocmask
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   674
# define      __execve        execve
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   675
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   676
# define        SHELL_PATH      "/bin/sh"       /* Path of the shell.  */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   677
# define        SHELL_NAME      "sh"            /* Name to give it.  */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   678
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   679
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   680
static int
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   681
mySystem(line)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   682
    register CONST char *line;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   683
{
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   684
    int status, save;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   685
    pid_t pid;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   686
    struct sigaction sa, intr, quit;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   687
    sigset_t block, omask;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   688
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   689
    if (line == NULL)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   690
	return -1;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   691
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   692
    sa.sa_handler = SIG_IGN;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   693
    sa.sa_flags = 0;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   694
    __sigemptyset (&sa.sa_mask);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   695
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   696
    if (__sigaction (SIGINT, &sa, &intr) < 0) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   697
	DPRINTF(("1: errno=%d\n", errno));
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   698
	return -1;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   699
    }
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   700
    if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   701
	save = errno;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   702
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   703
	errno = save;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   704
	DPRINTF(("2: errno=%d\n", errno));
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   705
	return -1;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   706
    }
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   707
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   708
    __sigemptyset (&block);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   709
    __sigaddset (&block, SIGCHLD);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   710
    save = errno;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   711
    if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   712
	if (errno == ENOSYS)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   713
	    errno = save;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   714
	else {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   715
	    save = errno;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   716
	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   717
	    (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   718
	    errno = save;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   719
	    DPRINTF(("3: errno=%d\n", errno));
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   720
	    return -1;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   721
	}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   722
    }
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   723
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   724
    pid = FORK ();
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   725
    if (pid == (pid_t) 0) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   726
	/* Child side.  */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   727
	CONST char *new_argv[4];
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   728
	new_argv[0] = SHELL_NAME;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   729
	new_argv[1] = "-c";
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   730
	new_argv[2] = line;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   731
	new_argv[3] = NULL;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   732
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   733
	/* Restore the signals.  */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   734
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   735
	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   736
	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   737
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   738
	/* Exec the shell.  */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   739
	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   740
	_exit (127);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   741
    } else {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   742
	if (pid < (pid_t) 0) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   743
	    /* The fork failed.  */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   744
	    DPRINTF(("4: errno=%d\n", errno));
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   745
	    status = -1;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   746
	} else {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   747
	    /* Parent side.  */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   748
#ifdef  NO_WAITPID
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   749
	    pid_t child;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   750
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   751
	    do {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   752
		__BEGIN_INTERRUPTABLE__
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   753
		child = __wait (&status);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   754
		__END_INTERRUPTABLE__
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   755
		if (child < 0 && errno != EINTR) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   756
		    DPRINTF(("5: errno=%d\n", errno));
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   757
		    status = -1;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   758
		    break;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   759
		}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   760
	    } while (child != pid);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   761
#else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   762
	    pid_t child;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   763
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   764
	    /* claus: the original did not care for EINTR here ... */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   765
	    do {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   766
		__BEGIN_INTERRUPTABLE__
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   767
		child = __waitpid (pid, &status, 0);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   768
		__END_INTERRUPTABLE__
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   769
	    } while ((child != pid) && (errno == EINTR));
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   770
	    if (child != pid) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   771
		DPRINTF(("6: errno=%d\n", errno));
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   772
		status = -1;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   773
	    }
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   774
#endif /* NO_WAITPID */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   775
	}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   776
    }
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   777
    save = errno;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   778
    if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   779
     | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   780
     | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   781
	if (errno == ENOSYS) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   782
	    errno = save;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   783
	} else {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   784
	    status = -1;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   785
	    DPRINTF(("7: errno=%d\n", errno));
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   786
	}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   787
    }
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   788
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   789
    return status;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   790
}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   791
#else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   792
# define __wait wait
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   793
#endif /* WANT_SYSTEM */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   794
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   795
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   796
/*
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   797
 * some systems do not have realpath();
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   798
 * the alternative of reading from a 'pwd'-pipe
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   799
 * is way too slow. Here is a realpath for the rest of us.
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   800
 * define WANT_REALPATH in the xxxIntern-file to get it.
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   801
 */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   802
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   803
#if defined(HAS_REALPATH)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   804
# undef WANT_REALPATH
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   805
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   806
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   807
# undef WANT_REALPATH
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   808
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   809
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   810
#if defined(WANT_REALPATH)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   811
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   812
# ifndef NULL
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   813
#  define NULL (char *)0
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   814
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   815
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   816
# define MAX_READLINKS 32
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   817
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   818
# ifndef MAXPATHLEN
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   819
#  define MAXPATHLEN     1024
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   820
# endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   821
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   822
static char *
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   823
realpath(const char *path, char *resolved_path)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   824
{
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   825
	char copy_path[MAXPATHLEN];
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   826
	char link_path[MAXPATHLEN];
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   827
	char *new_path, *max_path, *mallocedPath;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   828
	int readlinks = 0;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   829
	int n;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   830
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   831
	if (resolved_path == NULL) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   832
	    mallocedPath = resolved_path = malloc(MAXPATHLEN+1);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   833
	}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   834
	new_path = resolved_path;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   835
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   836
	/* Make a copy of the source path since we may need to modify it. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   837
	strcpy(copy_path, path);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   838
	path = copy_path;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   839
	max_path = copy_path + MAXPATHLEN - 2;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   840
	/* If it's a relative pathname use getwd for starters. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   841
	if (*path != '/') {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   842
#ifdef HAS_GETCWD
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   843
		new_path = getcwd(new_path, MAXPATHLEN - 1);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   844
#else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   845
		new_path = getwd(new_path);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   846
#endif
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   847
		if (new_path == NULL) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   848
		    if (mallocedPath) free(mallocedPath);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   849
		    return(NULL);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   850
		}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   851
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   852
		new_path += strlen(new_path);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   853
		if (new_path[-1] != '/')
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   854
			*new_path++ = '/';
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   855
	}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   856
	else {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   857
		*new_path++ = '/';
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   858
		path++;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   859
	}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   860
	/* Expand each slash-separated pathname component. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   861
	while (*path != '\0') {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   862
		/* Ignore stray "/". */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   863
		if (*path == '/') {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   864
			path++;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   865
			continue;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   866
		}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   867
		if (*path == '.') {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   868
			/* Ignore ".". */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   869
			if (path[1] == '\0' || path[1] == '/') {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   870
				path++;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   871
				continue;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   872
			}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   873
			if (path[1] == '.') {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   874
				if (path[2] == '\0' || path[2] == '/') {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   875
					path += 2;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   876
					/* Ignore ".." at root. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   877
					if (new_path == resolved_path + 1)
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   878
						continue;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   879
					/* Handle ".." by backing up. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   880
					while ((--new_path)[-1] != '/')
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   881
						;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   882
					continue;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   883
				}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   884
			}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   885
		}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   886
		/* Safely copy the next pathname component. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   887
		while (*path != '\0' && *path != '/') {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   888
			if (path > max_path) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   889
			    if (mallocedPath) free(mallocedPath);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   890
			    errno = ENAMETOOLONG;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   891
			    return NULL;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   892
			}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   893
			*new_path++ = *path++;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   894
		}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   895
#ifdef S_IFLNK
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   896
		/* Protect against infinite loops. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   897
		if (readlinks++ > MAX_READLINKS) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   898
		    if (mallocedPath) free(mallocedPath);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   899
		    errno = ELOOP;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   900
		    return NULL;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   901
		}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   902
		/* See if latest pathname component is a symlink. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   903
		*new_path = '\0';
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   904
		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   905
		if (n < 0) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   906
			/* EINVAL means the file exists but isn't a symlink. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   907
			if (errno != EINVAL) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   908
			    if (mallocedPath) free(mallocedPath);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   909
			    return NULL;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   910
			}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   911
		}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   912
		else {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   913
			/* Note: readlink doesn't add the null byte. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   914
			link_path[n] = '\0';
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   915
			if (*link_path == '/')
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   916
				/* Start over for an absolute symlink. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   917
				new_path = resolved_path;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   918
			else
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   919
				/* Otherwise back up over this component. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   920
				while (*(--new_path) != '/')
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   921
					;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   922
			/* Safe sex check. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   923
			if (strlen(path) + n >= MAXPATHLEN) {
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   924
			    if (mallocedPath) free(mallocedPath);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   925
			    errno = ENAMETOOLONG;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   926
			    return NULL;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   927
			}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   928
			/* Insert symlink contents into path. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   929
			strcat(link_path, path);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   930
			strcpy(copy_path, link_path);
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   931
			path = copy_path;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   932
		}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   933
#endif /* S_IFLNK */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   934
		*new_path++ = '/';
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   935
	}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   936
	/* Delete trailing slash but don't whomp a lone slash. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   937
	if (new_path != resolved_path + 1 && new_path[-1] == '/')
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   938
		new_path--;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   939
	/* Make sure it's null terminated. */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   940
	*new_path = '\0';
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   941
	return resolved_path;
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   942
}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   943
# define HAS_REALPATH
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   944
#endif /* WANT_REALPATH && not HAS_REALPATH */
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   945
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   946
%}
769928425577 oops - code corrupted due to bad merge
Claus Gittinger <cg@exept.de>
parents: 18155
diff changeset
   947
! !
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   948
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   949
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
copyright
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
 COPYRIGHT (c) 1988 by Claus Gittinger
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   954
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   956
 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
   957
 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
   958
 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
   959
 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
   960
 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
   961
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
    this class realizes access to most (all ?) required operating system services;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
    some of it is very specific for unix, so do not depend on
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   969
    things available here in your applications
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
    - some may not be found in other OS's or be slightly different ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
    (On the other hand: I do not want to hide all features
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
     from you - in some situations it MAY be interesting to be
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
     able to get down to a select or fork system call easily (at least on Unix systems).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
     You decide - portability vs. functionality)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
    [Class variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   979
	HostName        <String>        remembered hostname
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   980
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   981
	DomainName      <String>        remembered domainname
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   982
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   983
	SlowFork        <Boolean>       if set, fork and popen are avoided;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   984
					(more or less obsolete now)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   985
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   986
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   987
	CurrentDirectory <String>       remembered currentDirectories path
3496
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
    [author:]
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   990
	Claus Gittinger
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
    [see also:]
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   993
	OSProcessStatus
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   994
	Filename Date Time
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
   995
	ExternalStream FileStream PipeStream Socket
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
!
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
examples
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
  various queries
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1002
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1003
    Transcript
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1004
	showCR:'hello ' , (OperatingSystem getLoginName)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1005
								[exEnd]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1006
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1007
								[exBegin]
3793
aff27e755ffd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  1008
    OperatingSystem isUNIXlike ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1009
	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
  1010
    ] ifFalse:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1011
	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
  1012
    ]
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1013
								[exEnd]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1014
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1015
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1016
    Transcript
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1017
	showCR:'this machine is called ' , OperatingSystem getHostName
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1018
								[exEnd]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1019
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1020
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1021
    Transcript
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1022
	showCR:('this machine is in the '
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1023
	       , OperatingSystem getDomainName
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1024
	       , ' domain')
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1025
								[exEnd]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1026
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1027
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1028
    Transcript
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1029
	showCR:('this machine''s CPU is a '
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1030
	       , OperatingSystem getCPUType
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1031
	       )
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1032
								[exEnd]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1033
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1034
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1035
    Transcript showCR:'executing ls command ...'.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  1036
    OperatingSystem executeCommand:'ls'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
    Transcript showCR:'... done.'.
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1038
								[exEnd]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1040
  locking a file
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
  (should be executed on two running smalltalks - not in two threads):
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1042
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
    |f|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
    f := 'testFile' asFilename readWriteStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
    10 timesRepeat:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1048
	'about to lock ...' printCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1049
	[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1050
	  OperatingSystem
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1051
	    lockFD:(f fileDescriptor)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1052
	    shared:false
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1053
	    blocking:false
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1054
	] whileFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1055
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1056
	    Delay waitForSeconds:1
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1057
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1058
	'LOCKED ...' printCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1059
	Delay waitForSeconds:10.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1060
	'unlock ...' printCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1061
	(OperatingSystem
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1062
	    unlockFD:(f fileDescriptor)) printCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1063
	Delay waitForSeconds:3.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
    ]
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1065
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
!UnixOperatingSystem class methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
initialize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
    "initialize the class"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
17530
267a6722ddfb class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17519
diff changeset
  1074
    "/ protect against double initialization
267a6722ddfb class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17519
diff changeset
  1075
    Initialized isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1076
	ObjectMemory addDependent:self.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1077
	self initializeCachedData.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1078
	Initialized := true.
17530
267a6722ddfb class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17519
diff changeset
  1079
    ].
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1080
!
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1081
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1082
initializeCachedData
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
    HostName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
    DomainName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
    LastErrorNumber := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
    PipeFailed := false.
4395
53122eb3ce70 clear ForkFailed flag; made it a classVar
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1087
    ForkFailed := false.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
    SlowFork := false.
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1089
    CurrentDirectory := nil.
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1090
    self initializeCodeset.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1091
!
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1092
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1093
initializeCodeset
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1094
    "initialize the codeset, we are running under.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1095
     The codeset is determined from the environment.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1096
     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
  1097
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1098
    |codeset|
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  1099
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1100
%{
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1101
#include <langinfo.h>
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1102
    char *__codeset;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1103
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1104
    setlocale(LC_CTYPE, "");
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1105
    __codeset = nl_langinfo(CODESET);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1106
    if (strlen(__codeset) > 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1107
	codeset = __MKSTRING(__codeset);
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1108
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1109
%}.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1110
    codeset notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1111
	codeset := codeset asLowercase.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1112
	codeset = 'utf-8' ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1113
	    codeset := #utf8.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1114
	] ifFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1115
	    codeset := codeset asSymbol.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1116
	].
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1117
    ].
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1118
    Codeset := codeset.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1119
    ^ codeset.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1120
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1121
    "
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1122
     OperatingSystem initializeCodeset
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  1123
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
update:something with:aParameter from:changedObject
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
    "catch image restart and flush some cached data"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
    something == #earlyRestart ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1130
	self initializeCachedData
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
    ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1133
    "Created: / 15.6.1996 / 15:22:37 / cg"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1134
    "Modified: / 7.1.1997 / 19:36:11 / stefan"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1135
    "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
  1136
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
!UnixOperatingSystem class methodsFor:'OS signal constants'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
sigABRT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
    "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
  1142
     (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
  1143
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1144
    ^ self signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1145
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1146
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1147
     OperatingSystem sigABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1148
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
sigALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
    "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
  1153
     (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
  1154
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1155
    ^ self signalNamed:#SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1156
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1157
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1158
     OperatingSystem sigALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1159
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
sigBREAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
    "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
  1164
     This is an MSDOS specific signal"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1166
    ^ self signalNamed:#SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1167
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1168
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1169
     OperatingSystem sigBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1170
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
sigBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
    "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
  1175
     (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
  1176
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1177
    ^ self signalNamed:#SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1178
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1179
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1180
     OperatingSystem sigBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1181
    "
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1184
sigCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
    "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
  1186
     (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
  1187
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1188
    ^ self signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1189
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1190
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1191
     OperatingSystem sigCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1192
    "
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
sigCONT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
    "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
  1197
     (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
  1198
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1199
    ^ self signalNamed:#SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1200
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1201
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1202
     OperatingSystem sigCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1203
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
sigDANGER
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
    "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
  1208
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1210
    ^ self signalNamed:#SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1211
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1212
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1213
     OperatingSystem sigDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1214
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
sigEMT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
    "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
  1219
     (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
  1220
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1221
    ^ self signalNamed:#SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1222
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1223
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1224
     OperatingSystem sigEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1225
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
sigFP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1229
    "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
  1230
     (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
  1231
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1232
    ^ self signalNamed:#SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1233
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1234
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1235
     OperatingSystem sigFP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1236
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
sigGRANT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
    "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
  1241
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1243
    ^ self signalNamed:#SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1244
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1245
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1246
     OperatingSystem sigGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1247
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
sigHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1251
    "return the signal number for SIGHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1252
     (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
  1253
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1254
    ^ self signalNamed:#SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1255
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1256
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1257
     OperatingSystem sigHUP
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1260
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
sigILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
    "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
  1264
     (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
  1265
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1266
    ^ self signalNamed:#SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1267
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1268
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1269
     OperatingSystem sigILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1270
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
sigINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1274
    "return the signal number for SIGINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1275
     (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
  1276
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1277
    ^ self signalNamed:#SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1278
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1279
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1280
     OperatingSystem sigINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1281
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
sigIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
    "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
  1286
     (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
  1287
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1288
    ^ self signalNamed:#SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1289
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1290
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1291
     OperatingSystem sigIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1292
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1293
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1294
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1295
sigIOT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1296
    "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
  1297
     (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
  1298
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1299
    ^ self signalNamed:#SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1300
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1301
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1302
     OperatingSystem sigIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1303
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
sigKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1307
    "return the signal number for SIGKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1308
     (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
  1309
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1310
    ^ self signalNamed:#SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1311
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1312
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1313
     OperatingSystem sigKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1314
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1316
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
sigLOST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
    "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
  1319
     (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
  1320
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1321
    ^ self signalNamed:#SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1322
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1323
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1324
     OperatingSystem sigLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1325
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1326
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1327
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1328
sigMIGRATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
    "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
  1330
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1332
    ^ self signalNamed:#SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1333
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1334
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1335
     OperatingSystem sigMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1336
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1337
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1338
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
sigMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
    "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
  1341
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1343
    ^ self signalNamed:#SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1344
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1345
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1346
     OperatingSystem sigMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1347
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
sigPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
    "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
  1352
     (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
  1353
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1354
    ^ self signalNamed:#SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1355
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1356
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1357
     OperatingSystem sigPIPE
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
!
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
sigPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1363
    "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
  1364
     (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
  1365
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1366
    ^ self signalNamed:#SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1367
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1368
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1369
     OperatingSystem sigPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1370
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
sigPRE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
    "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
  1375
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1377
    ^ self signalNamed:#SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1378
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1379
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1380
     OperatingSystem sigPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1381
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
sigPROF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
    "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
  1386
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1388
    ^ self signalNamed:#SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1389
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1390
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1391
     OperatingSystem sigPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1392
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1393
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
sigPWR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
    "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
  1397
     (not available on all systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1399
    ^ self signalNamed:#SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1400
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1401
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1402
     OperatingSystem sigPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1403
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1404
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1405
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
sigQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
    "return the signal number for SIGQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1408
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1409
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1410
    ^ self signalNamed:#SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1411
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1412
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1413
     OperatingSystem sigQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1414
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1415
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1416
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1417
sigRETRACT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
    "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
  1419
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1421
    ^ self signalNamed:#SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1422
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1423
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1424
     OperatingSystem sigRETRACT
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1427
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
sigSAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
    "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
  1431
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1433
    ^ self signalNamed:#SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1434
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1435
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1436
     OperatingSystem sigSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1437
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1438
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
sigSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
    "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
  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:#SIGSEGV
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 sigSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1449
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1450
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
sigSOUND
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
    "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
  1455
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1456
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1457
    ^ self signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1458
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1459
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1460
     OperatingSystem sigSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1461
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1462
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
sigSTOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1466
    "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
  1467
     (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
  1468
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1469
    ^ self signalNamed:#SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1470
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1471
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1472
     OperatingSystem sigSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1473
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1474
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1475
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
sigSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1477
    "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
  1478
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1480
    ^ self signalNamed:#SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1481
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1482
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1483
     OperatingSystem sigSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1484
    "
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
sigTERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1488
    "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
  1489
     (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
  1490
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1491
    ^ self signalNamed:#SIGTERM
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
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1494
     OperatingSystem sigTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1495
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1496
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
sigTRAP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
    "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
  1501
     (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
  1502
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1503
    ^ self signalNamed:#SIGTRAP
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
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1506
     OperatingSystem sigTRAP
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
sigTSTP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
    "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
  1512
     (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
  1513
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1514
    ^ self signalNamed:#SIGTSTP
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 sigTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1518
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1519
!
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
sigTTIN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
    "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
  1523
     (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
  1524
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1525
    ^ self signalNamed:#SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1526
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1527
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1528
     OperatingSystem sigTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1529
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1530
!
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
sigTTOU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1533
    "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
  1534
     (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
  1535
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1536
    ^ self signalNamed:#SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1537
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1538
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1539
     OperatingSystem sigTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1540
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1541
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1542
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1543
sigURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1544
    "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
  1545
     (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
  1546
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1547
    ^ self signalNamed:#SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1548
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1549
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1550
     OperatingSystem sigURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1551
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1553
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1554
sigUSR1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1555
    "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
  1556
     (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
  1557
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1558
    ^ self signalNamed:#SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1559
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1560
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1561
     OperatingSystem sigUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1562
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1563
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1564
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1565
sigUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1566
    "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
  1567
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1568
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1569
    ^ self signalNamed:#SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1570
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1571
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1572
     OperatingSystem sigUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1573
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1575
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1576
sigVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1577
    "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
  1578
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1579
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1580
    ^ self signalNamed:#SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1581
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1582
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1583
     OperatingSystem sigVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1584
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1585
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
sigWINCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1588
    "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
  1589
     (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
  1590
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1591
    ^ self signalNamed:#SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1592
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1593
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1594
     OperatingSystem sigWINCH
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1597
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
sigXCPU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
    "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
  1601
     (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
  1602
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1603
    ^ self signalNamed:#SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1604
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1605
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1606
     OperatingSystem sigXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1607
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1608
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
sigXFSZ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1612
    "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
  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:#SIGXFSZ
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 sigXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1619
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1620
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1621
!
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1622
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1623
signalNamed:signalName
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1624
    "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
  1625
     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
  1626
     (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
  1627
      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
  1628
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1629
%{  /* NOCONTEXT */
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1630
#ifdef SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1631
    if (signalName == @symbol(SIGABRT)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1632
	RETURN ( __mkSmallInteger(SIGABRT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1633
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1634
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1635
#ifdef SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1636
    if (signalName == @symbol(SIGALRM)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1637
	RETURN ( __mkSmallInteger(SIGALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1638
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1639
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1640
#ifdef SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1641
    if (signalName == @symbol(SIGBREAK)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1642
	RETURN ( __mkSmallInteger(SIGBREAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1643
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1644
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1645
#ifdef SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1646
    if (signalName == @symbol(SIGBUS)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1647
	RETURN ( __mkSmallInteger(SIGBUS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1648
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1649
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1650
#ifdef SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1651
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1652
     || (signalName == @symbol(SIGCLD)) ) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1653
	RETURN ( __mkSmallInteger(SIGCHLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1654
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1655
#else
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1656
# if defined(SIGCLD)
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1657
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1658
     || (signalName == @symbol(SIGCLD)) ) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1659
	RETURN ( __mkSmallInteger(SIGCLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1660
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1661
# endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1662
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1663
#ifdef SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1664
    if (signalName == @symbol(SIGCONT)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1665
	RETURN ( __mkSmallInteger(SIGCONT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1666
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1667
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1668
#ifdef SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1669
    if (signalName == @symbol(SIGDANGER)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1670
	RETURN ( __mkSmallInteger(SIGDANGER) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1671
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1672
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1673
#ifdef SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1674
    if (signalName == @symbol(SIGEMT)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1675
	RETURN ( __mkSmallInteger(SIGEMT) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1678
#ifdef SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1679
    if (signalName == @symbol(SIGFPE)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1680
	RETURN ( __mkSmallInteger(SIGFPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1681
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1682
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1683
#ifdef SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1684
    if (signalName == @symbol(SIGGRANT)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1685
	RETURN ( __mkSmallInteger(SIGGRANT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1686
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1687
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1688
#ifdef SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1689
    if (signalName == @symbol(SIGHUP)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1690
	RETURN ( __mkSmallInteger(SIGHUP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1691
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1692
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1693
#ifdef SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1694
    if (signalName == @symbol(SIGILL)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1695
	RETURN ( __mkSmallInteger(SIGILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1696
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1697
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1698
#ifdef SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1699
    if (signalName == @symbol(SIGINT)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1700
	RETURN ( __mkSmallInteger(SIGINT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1701
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1702
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1703
#ifdef SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1704
    if (signalName == @symbol(SIGIO)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1705
	RETURN ( __mkSmallInteger(SIGIO) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1706
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1707
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1708
#ifdef SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1709
    if (signalName == @symbol(SIGIOT)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1710
	RETURN ( __mkSmallInteger(SIGIOT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1711
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1712
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1713
#ifdef SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1714
    if (signalName == @symbol(SIGKILL)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1715
	RETURN ( __mkSmallInteger(SIGKILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1716
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1717
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1718
#ifdef SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1719
    if (signalName == @symbol(SIGLOST)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1720
	RETURN ( __mkSmallInteger(SIGLOST) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1721
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1722
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1723
#ifdef SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1724
    if (signalName == @symbol(SIGMIGRATE)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1725
	RETURN ( __mkSmallInteger(SIGMIGRATE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1726
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1727
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1728
#ifdef SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1729
    if (signalName == @symbol(SIGMSG)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1730
	RETURN ( __mkSmallInteger(SIGMSG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1731
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1732
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1733
#ifdef SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1734
    if (signalName == @symbol(SIGPIPE)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1735
	RETURN ( __mkSmallInteger(SIGPIPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1736
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1737
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1738
#ifdef SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1739
    if (signalName == @symbol(SIGPOLL)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1740
	RETURN ( __mkSmallInteger(SIGPOLL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1741
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1742
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1743
#ifdef SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1744
    if (signalName == @symbol(SIGPRE)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1745
	RETURN ( __mkSmallInteger(SIGPRE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1746
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1747
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1748
#ifdef SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1749
    if (signalName == @symbol(SIGPROF)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1750
	RETURN ( __mkSmallInteger(SIGPROF) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1751
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1752
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1753
#ifdef SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1754
    if (signalName == @symbol(SIGPWR)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1755
	RETURN ( __mkSmallInteger(SIGPWR) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1756
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1757
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1758
#ifdef SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1759
    if (signalName == @symbol(SIGQUIT)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1760
	RETURN ( __mkSmallInteger(SIGQUIT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1761
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1762
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1763
#ifdef SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1764
    if (signalName == @symbol(SIGRETRACT)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1765
	RETURN ( __mkSmallInteger(SIGRETRACT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1766
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1767
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1768
#ifdef SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1769
    if (signalName == @symbol(SIGSAK)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1770
	RETURN ( __mkSmallInteger(SIGSAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1771
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1772
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1773
#ifdef SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1774
    if (signalName == @symbol(SIGSEGV)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1775
	RETURN ( __mkSmallInteger(SIGSEGV) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1776
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1777
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1778
#ifdef SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1779
    if (signalName == @symbol(SIGSOUND)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1780
	RETURN ( __mkSmallInteger(SIGSOUND) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1781
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1782
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1783
#ifdef SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1784
    if (signalName == @symbol(SIGSTOP)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1785
	RETURN ( __mkSmallInteger(SIGSTOP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1786
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1787
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1788
#ifdef SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1789
    if (signalName == @symbol(SIGSYS)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1790
	RETURN ( __mkSmallInteger(SIGSYS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1791
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1792
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1793
#ifdef SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1794
    if (signalName == @symbol(SIGTERM)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1795
	RETURN ( __mkSmallInteger(SIGTERM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1796
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1797
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1798
#ifdef SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1799
    if (signalName == @symbol(SIGTRAP)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1800
	RETURN ( __mkSmallInteger(SIGTRAP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1801
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1802
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1803
#ifdef SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1804
    if (signalName == @symbol(SIGTSTP)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1805
	RETURN ( __mkSmallInteger(SIGTSTP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1806
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1807
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1808
#ifdef SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1809
    if (signalName == @symbol(SIGTTIN)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1810
	RETURN ( __mkSmallInteger(SIGTTIN) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1811
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1812
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1813
#ifdef SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1814
    if (signalName == @symbol(SIGTTOU)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1815
	RETURN ( __mkSmallInteger(SIGTTOU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1816
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1817
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1818
#ifdef SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1819
    if (signalName == @symbol(SIGURG)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1820
	RETURN ( __mkSmallInteger(SIGURG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1821
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1822
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1823
#ifdef SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1824
    if (signalName == @symbol(SIGUSR1)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1825
	RETURN ( __mkSmallInteger(SIGUSR1) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1826
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1827
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1828
#ifdef SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1829
    if (signalName == @symbol(SIGUSR2)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1830
	RETURN ( __mkSmallInteger(SIGUSR2) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1831
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1832
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1833
#ifdef SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1834
    if (signalName == @symbol(SIGVTALRM)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1835
	RETURN ( __mkSmallInteger(SIGVTALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1836
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1837
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1838
#ifdef SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1839
    if (signalName == @symbol(SIGWINCH)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1840
	RETURN ( __mkSmallInteger(SIGWINCH) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1841
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1842
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1843
#ifdef SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1844
    if (signalName == @symbol(SIGXCPU)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1845
	RETURN ( __mkSmallInteger(SIGXCPU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1846
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1847
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1848
#ifdef SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1849
    if (signalName == @symbol(SIGXFSZ)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1850
	RETURN ( __mkSmallInteger(SIGXFSZ) );
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1851
    }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1852
#endif
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1853
#ifdef SIGINFO
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1854
    if (signalName == @symbol(SIGINFO)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1855
	RETURN ( __mkSmallInteger(SIGINFO) );
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1856
    }
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1857
#endif
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  1858
%}.
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  1859
    ^ 0
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  1860
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1861
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1862
     OperatingSystem signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1863
     OperatingSystem signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1864
     OperatingSystem signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1865
     OperatingSystem signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1866
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1867
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1868
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1869
!UnixOperatingSystem class methodsFor:'directory access'!
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1870
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1871
closeDirectory:dirPointer
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1872
    "low level close of a directoryStream"
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1873
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1874
%{
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1875
#ifdef HAS_OPENDIR
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1876
    if (__isExternalAddressLike(dirPointer)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1877
	closedir( (DIR *)(__FILEVal(dirPointer)) );
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1878
    }
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1879
#endif
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  1880
%}.
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  1881
    self primitiveFailed
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1882
!
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1883
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1884
nextLinkInfoFrom:aDirectoryStream dirPointer:dirPointer
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1885
    "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
  1886
     Under UNIX, the returned fileStatuInfo ONLY contains the name of the file,
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1887
     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
  1888
     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
  1889
     the corresponding unix read from a readdir only returns the name."
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1890
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1891
    |entry error|
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1892
%{
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1893
#ifdef HAS_OPENDIR
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1894
    DIR *d;
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1895
    DIRENT_STRUCT *dp;
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1896
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1897
    if ((dirPointer != nil)
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1898
     && __isExternalAddressLike(dirPointer)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1899
	d = (DIR *)__FILEVal(dirPointer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1900
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1901
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1902
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1903
	    do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1904
		__threadErrno = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1905
		dp = readdir(d);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1906
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1907
		 * for compatibility with ST-80,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1908
		 * skip entries for '.' and '..'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1909
		 * If wanted, these must be added synthetically.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1910
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1911
	    } while (dp && ((strcmp(dp->d_name, ".")==0) || (strcmp(dp->d_name, "..")==0)));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1912
	} while ((dp == NULL) && (__threadErrno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1913
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1914
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1915
	if (dp != NULL) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1916
	    entry = __MKSTRING((char *)(dp->d_name));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1917
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1918
	    if (__threadErrno) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1919
		error = __mkSmallInteger(__threadErrno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1920
	    }
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1921
       }
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1922
    }
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1923
#endif /* HAS_OPENDIR */
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1924
%}.
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1925
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1926
	^ StreamIOError newException
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1927
	    errorCode:error;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1928
	    osErrorHolder:(OperatingSystem errorHolderForNumber:error);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1929
	    parameter:aDirectoryStream;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1930
	    raiseRequest
17311
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
    entry notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1933
	^ FileStatusInfo new sourcePath:(self decodePath:entry).
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1934
    ].
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1935
    ^ aDirectoryStream pastEndRead
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1936
! !
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  1937
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1938
!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
  1939
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1940
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
  1941
    "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
  1942
     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
  1943
     operationSymbol is one of:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1944
	open
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1945
	edit
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1946
	explore
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1947
     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
  1948
     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
  1949
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1950
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1951
    | cmd |
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1952
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1953
    cmd := self openApplicationHelperCommand.
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1954
    cmd notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1955
	(cmd includesSubString:'%1') ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1956
	    cmd := cmd bindWith:aFilenameOrString asString.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1957
	] ifFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1958
	    cmd := cmd, ' "', aFilenameOrString asString, '"'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1959
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1960
	(self
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1961
		startProcess:cmd
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1962
		inputFrom:nil outputTo:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1963
		errorTo:nil auxFrom:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1964
		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
  1965
    ].
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1966
    ^ 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
  1967
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1968
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1969
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1970
     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
  1971
     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
  1972
     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
  1973
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1974
     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
  1975
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1976
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1977
    "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
  1978
!
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1979
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1980
openApplicationHelperCommand
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1981
    "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
  1982
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1983
    | xdgCurrentDesktop |
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1984
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1985
    xdgCurrentDesktop := self getEnvironment: 'XDG_CURRENT_DESKTOP'.
17299
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  1986
    ((xdgCurrentDesktop = 'GNOME') and:[self canExecuteCommand: 'gnome-open']) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1987
	^ 'gnome-open'
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1988
    ].
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1989
    "/ Guess...
17299
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  1990
    ((xdgCurrentDesktop = 'KDE') and:[self canExecuteCommand: 'kde-open']) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1991
	^ 'kde-open'
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1992
    ].
17299
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  1993
    (self canExecuteCommand: 'xdg-open') ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  1994
	^ 'xdg-open'
17298
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1995
    ].
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1996
    ^ nil
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1997
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1998
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  1999
     self openApplicationHelperCommand
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2000
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2001
     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
  2002
     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
  2003
    "
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2004
4ca27d747797 Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17288
diff changeset
  2005
    "Created: / 13-01-2015 / 09:02:07 / 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
  2006
17299
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  2007
! !
7a4cec6d4964 Oops, fix after bad merge
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17298
diff changeset
  2008
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2009
!UnixOperatingSystem class methodsFor:'error messages'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2011
currentErrorNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2012
    "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
  2013
     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
  2014
     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
  2015
     request to the OS.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2016
     Use lastErrorNumber - currentErrorNumber is invalidated by
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2017
     many, many internal calls."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2018
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2019
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2020
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2021
     RETURN ( __mkSmallInteger(errno) );
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  2022
%}.
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  2023
    ^ 0
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  2024
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2025
     "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  2026
      OperatingSystem currentErrorNumber
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2027
     "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2028
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2029
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2030
errorHolderForNumber:errNr
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2031
    "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
  2032
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2033
    |sym typ holder|
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2034
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2035
%{
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2036
    /* claus:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2037
     * I made this primitive code, since errnos are not
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2038
     * standard across unixes
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2039
     */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2040
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2041
    if (__isSmallInteger(errNr)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2042
	switch ( __intVal(errNr)) {
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2043
	    /*
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2044
	     * POSIX errnos - these should be defined
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2045
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2046
#ifdef EPERM
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2047
	    case EPERM:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2048
		sym = @symbol(EPERM);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2049
		typ = @symbol(noPermissionsSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2050
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2051
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2052
#ifdef ENOENT
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2053
	    case ENOENT:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2054
		sym = @symbol(ENOENT);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2055
		typ = @symbol(nonexistentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2056
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2057
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2058
#ifdef ESRCH
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2059
	    case ESRCH:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2060
		sym = @symbol(ESRCH);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2061
		typ = @symbol(unavailableReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2062
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2063
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2064
#ifdef EINTR
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2065
	    case EINTR:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2066
		sym = @symbol(EINTR);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2067
		typ = @symbol(transientErrorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2068
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2069
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2070
#ifdef EIO
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2071
	    case EIO:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2072
		sym = @symbol(EIO);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2073
		typ = @symbol(transferFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2074
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2075
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2076
#ifdef ENXIO
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2077
	    case ENXIO:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2078
		sym = @symbol(ENXIO);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2079
		typ = @symbol(unavailableReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2080
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2081
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2082
#ifdef E2BIG
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2083
	    case E2BIG:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2084
		sym = @symbol(E2BIG);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2085
		typ = @symbol(invalidArgumentsSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2086
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2087
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2088
#ifdef ENOEXEC
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2089
	    case ENOEXEC:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2090
		sym = @symbol(ENOEXEC);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2091
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2092
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2093
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2094
#ifdef EBADF
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2095
	    case EBADF:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2096
		sym = @symbol(EBADF);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2097
		typ = @symbol(badAccessorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2098
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2099
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2100
#ifdef ECHILD
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2101
	    case ECHILD:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2102
		sym = @symbol(ECHILD);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2103
		typ = @symbol(informationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2104
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2105
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2106
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2107
	    case EAGAIN:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2108
		sym = @symbol(EAGAIN);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2109
		typ = @symbol(notReadySignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2110
		break;
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2111
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2112
#ifdef EOVERFLOW
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2113
	    case EOVERFLOW:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2114
		sym = @symbol(EOVERFLOW);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2115
		typ = @symbol(rangeErrorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2116
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2117
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2118
#ifdef ENOMEM
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2119
	    case ENOMEM:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2120
		sym = @symbol(ENOMEM);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2121
		typ = @symbol(noMemorySignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2122
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2123
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2124
#ifdef EACCES
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2125
	    case EACCES:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2126
		sym = @symbol(EACCES);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2127
		typ = @symbol(noPermissionsSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2128
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2129
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2130
#ifdef EFAULT
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2131
	    case EFAULT:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2132
		sym = @symbol(EFAULT);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2133
		typ = @symbol(invalidArgumentsSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2134
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2135
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2136
#ifdef EBUSY
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2137
	    case EBUSY:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2138
		sym = @symbol(EBUSY);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2139
		typ = @symbol(unavailableReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2140
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2141
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2142
#ifdef EEXIST
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2143
	    case EEXIST:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2144
		sym = @symbol(EEXIST);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2145
		typ = @symbol(existingReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2146
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2147
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2148
#ifdef EXDEV
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2149
	    case EXDEV:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2150
		sym = @symbol(EXDEV);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2151
		typ = @symbol(inappropriateReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2152
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2153
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2154
#ifdef ENODEV
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2155
	    case ENODEV:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2156
		sym = @symbol(ENODEV);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2157
		typ = @symbol(inaccessibleSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2158
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2159
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2160
#ifdef ENOTDIR
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2161
	    case ENOTDIR:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2162
		sym = @symbol(ENOTDIR);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2163
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2164
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2165
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2166
#ifdef EISDIR
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2167
	    case EISDIR:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2168
		sym = @symbol(EISDIR);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2169
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2170
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2171
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2172
#ifdef EINVAL
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2173
	    case EINVAL:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2174
		sym = @symbol(EINVAL);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2175
		typ = @symbol(invalidArgumentsSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2176
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2177
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2178
#ifdef ENFILE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2179
	    case ENFILE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2180
		sym = @symbol(ENFILE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2181
		typ = @symbol(noResourcesSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2182
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2183
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2184
#ifdef EMFILE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2185
	    case EMFILE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2186
		sym = @symbol(EMFILE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2187
		typ = @symbol(noResourcesSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2188
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2189
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2190
#ifdef ENOTTY
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2191
	    case ENOTTY:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2192
		sym = @symbol(ENOTTY);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2193
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2194
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2195
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2196
#ifdef EFBIG
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2197
	    case EFBIG:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2198
		sym = @symbol(EFBIG);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2199
		typ = @symbol(noResourcesSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2200
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2201
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2202
#ifdef ENOSPC
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2203
	    case ENOSPC:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2204
		sym = @symbol(ENOSPC);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2205
		typ = @symbol(noResourcesSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2206
		break;
18198
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2207
#endif
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2208
#ifdef ENOTSUP
18205
182612a550dd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18198
diff changeset
  2209
# if !defined(EOPNOTSUPP) || (ENOTSUP != EOPNOTSUPP)
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2210
	    case ENOTSUP:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2211
		sym = @symbol(ENOTSUP);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2212
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2213
		break;
18205
182612a550dd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18198
diff changeset
  2214
# endif
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2215
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2216
#ifdef ESPIPE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2217
	    case ESPIPE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2218
		sym = @symbol(ESPIPE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2219
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2220
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2221
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2222
#ifdef EROFS
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2223
	    case EROFS:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2224
		sym = @symbol(EROFS);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2225
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2226
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2227
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2228
#ifdef EMLINK
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2229
	    case EMLINK:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2230
		sym = @symbol(EMLINK);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2231
		typ = @symbol(rangeErrorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2232
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2233
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2234
#ifdef EPIPE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2235
	    case EPIPE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2236
		sym = @symbol(EPIPE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2237
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2238
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2239
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2240
#ifdef EDOM
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2241
	    case EDOM:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2242
		sym = @symbol(EDOM);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2243
		typ = @symbol(rangeErrorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2244
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2245
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2246
#ifdef ERANGE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2247
	    case ERANGE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2248
		sym = @symbol(ERANGE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2249
		typ = @symbol(rangeErrorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2250
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2251
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2252
#ifdef EDEADLK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2253
# if EDEADLK != EWOULDBLOCK
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2254
	    case EDEADLK:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2255
		sym = @symbol(EDEADLK);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2256
		typ = @symbol(noResourcesSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2257
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2258
# endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2259
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2260
#ifdef ENAMETOOLONG
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2261
	    case ENAMETOOLONG:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2262
		sym = @symbol(ENAMETOOLONG);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2263
		typ = @symbol(rangeErrorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2264
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2265
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2266
#ifdef ENOLCK
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2267
	    case ENOLCK:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2268
		sym = @symbol(ENOLCK);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2269
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2270
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2271
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2272
#ifdef ENOSYS
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2273
	    case ENOSYS:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2274
		sym = @symbol(ENOSYS);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2275
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2276
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2277
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2278
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2279
	    case ENOTEMPTY:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2280
		sym = @symbol(ENOTEMPTY);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2281
		typ = @symbol(inappropriateReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2282
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2283
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2284
#ifdef EILSEQ
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2285
	    case EILSEQ:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2286
		sym = @symbol(EILSEQ);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2287
		typ = @symbol(transferFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2288
		break;
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2289
#endif
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2290
	    /*
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2291
	     * XPG3 errnos - defined on most systems
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2292
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2293
#ifdef ENOTBLK
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2294
	    case ENOTBLK:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2295
		sym = @symbol(ENOTBLK);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2296
		typ = @symbol(inappropriateReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2297
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2298
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2299
#ifdef ETXTBSY
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2300
	    case ETXTBSY:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2301
		sym = @symbol(ETXTBSY);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2302
		typ = @symbol(inaccessibleSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2303
		break;
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2304
#endif
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2305
	    /*
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2306
	     * some others
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2307
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2308
#ifdef EWOULDBLOCK
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2309
	    case EWOULDBLOCK:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2310
		sym = @symbol(EWOULDBLOCK);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2311
		typ = @symbol(notReadySignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2312
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2313
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2314
#ifdef ENOMSG
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2315
	    case ENOMSG:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2316
		sym = @symbol(ENOMSG);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2317
		typ = @symbol(noDataSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2318
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2319
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2320
#ifdef ELOOP
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2321
	    case ELOOP:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2322
		sym = @symbol(ELOOP);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2323
		typ = @symbol(rangeErrorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2324
		break;
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2325
#endif
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2326
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2327
	    /*
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2328
	     * some stream errors
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2329
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2330
#ifdef ETIME
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2331
	    case ETIME:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2332
		sym = @symbol(ETIME);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2333
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2334
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2335
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2336
#ifdef ENOSR
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2337
	    case ENOSR:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2338
		sym = @symbol(ENOSR);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2339
		typ = @symbol(noResourcesSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2340
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2341
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2342
#ifdef ENOSTR
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2343
	    case ENOSTR:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2344
		sym = @symbol(ENOSTR);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2345
		typ = @symbol(inappropriateReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
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
#ifdef ECOMM
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2349
	    case ECOMM:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2350
		sym = @symbol(ECOMM);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2351
		typ = @symbol(transferFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2352
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2353
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2354
#ifdef EPROTO
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2355
	    case EPROTO:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2356
		sym = @symbol(EPROTO);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2357
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2358
		break;
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2359
#endif
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2360
	    /*
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2361
	     * nfs errors
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2362
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2363
#ifdef ESTALE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2364
	    case ESTALE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2365
		sym = @symbol(ESTALE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2366
		typ = @symbol(unavailableReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2367
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2368
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2369
#ifdef EREMOTE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2370
	    case EREMOTE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2371
		sym = @symbol(EREMOTE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2372
		typ = @symbol(rangeErrorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2373
		break;
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2374
#endif
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2375
	    /*
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2376
	     * some networking errors
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2377
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2378
#ifdef EINPROGRESS
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2379
	    case EINPROGRESS:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2380
		sym = @symbol(EINPROGRESS);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2381
		typ = @symbol(operationStartedSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2382
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2383
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2384
#ifdef EALREADY
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2385
	    case EALREADY:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2386
		sym = @symbol(EALREADY);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2387
		typ = @symbol(operationStartedSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2388
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2389
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2390
#ifdef ENOTSOCK
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2391
	    case ENOTSOCK:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2392
		sym = @symbol(ENOTSOCK);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2393
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2394
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2395
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2396
#ifdef EDESTADDRREQ
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2397
	    case EDESTADDRREQ:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2398
		sym = @symbol(EDESTADDRREQ);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2399
		typ = @symbol(underspecifiedSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2400
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2401
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2402
#ifdef EMSGSIZE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2403
	    case EMSGSIZE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2404
		sym = @symbol(EMSGSIZE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2405
		typ = @symbol(rangeErrorSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2406
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2407
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2408
#ifdef EPROTOTYPE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2409
	    case EPROTOTYPE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2410
		sym = @symbol(EPROTOTYPE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2411
		typ = @symbol(wrongSubtypeForOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2412
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2413
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2414
#ifdef ENOPROTOOPT
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2415
	    case ENOPROTOOPT:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2416
		sym = @symbol(ENOPROTOOPT);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2417
		typ = @symbol(unsupportedOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2418
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2419
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2420
#ifdef EPROTONOSUPPORT
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2421
	    case EPROTONOSUPPORT:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2422
		sym = @symbol(EPROTONOSUPPORT);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2423
		typ = @symbol(unsupportedOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2424
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2425
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2426
#ifdef ESOCKTNOSUPPORT
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2427
	    case ESOCKTNOSUPPORT:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2428
		sym = @symbol(ESOCKTNOSUPPORT);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2429
		typ = @symbol(unsupportedOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2430
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2431
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2432
#ifdef EOPNOTSUPP
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2433
	    case EOPNOTSUPP:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2434
		sym = @symbol(EOPNOTSUPP);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2435
		typ = @symbol(inappropriateOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2436
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2437
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2438
#ifdef EPFNOSUPPORT
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2439
	    case EPFNOSUPPORT:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2440
		sym = @symbol(EPFNOSUPPORT);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2441
		typ = @symbol(unsupportedOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2442
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2443
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2444
#ifdef EAFNOSUPPORT
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2445
	    case EAFNOSUPPORT:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2446
		sym = @symbol(EAFNOSUPPORT);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2447
		typ = @symbol(unsupportedOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2448
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2449
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2450
#ifdef EADDRINUSE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2451
	    case EADDRINUSE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2452
		sym = @symbol(EADDRINUSE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2453
		typ = @symbol(existingReferentSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2454
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2455
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2456
#ifdef EADDRNOTAVAIL
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2457
	    case EADDRNOTAVAIL:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2458
		sym = @symbol(EADDRNOTAVAIL);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2459
		typ = @symbol(noPermissionsSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2460
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2461
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2462
#ifdef ETIMEDOUT
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2463
	    case ETIMEDOUT:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2464
		sym = @symbol(ETIMEDOUT);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2465
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2466
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2467
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2468
#ifdef ECONNREFUSED
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2469
	    case ECONNREFUSED:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2470
		sym = @symbol(ECONNREFUSED);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2471
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2472
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2473
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2474
#ifdef ENETDOWN
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2475
	    case ENETDOWN:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2476
		sym = @symbol(ENETDOWN);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2477
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2478
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2479
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2480
#ifdef ENETUNREACH
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2481
	    case ENETUNREACH:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2482
		sym = @symbol(ENETUNREACH);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2483
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2484
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2485
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2486
#ifdef ENETRESET
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2487
	    case ENETRESET:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2488
		sym = @symbol(ENETRESET);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2489
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2490
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2491
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2492
#ifdef ECONNABORTED
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2493
	    case ECONNABORTED:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2494
		sym = @symbol(ECONNABORTED);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2495
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2496
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2497
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2498
#ifdef ECONNRESET
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2499
	    case ECONNRESET:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2500
		sym = @symbol(ECONNRESET);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2501
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2502
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2503
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2504
#ifdef EISCONN
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2505
	    case EISCONN:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2506
		sym = @symbol(EISCONN);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2507
		typ = @symbol(unpreparedOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2508
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2509
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2510
#ifdef ENOTCONN
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2511
	    case ENOTCONN:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2512
		sym = @symbol(ENOTCONN);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2513
		typ = @symbol(unpreparedOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2514
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2515
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2516
#ifdef ESHUTDOWN
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2517
	    case ESHUTDOWN:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2518
		sym = @symbol(ESHUTDOWN);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2519
		typ = @symbol(unpreparedOperationSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2520
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2521
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2522
#ifdef EHOSTDOWN
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2523
	    case EHOSTDOWN:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2524
		sym = @symbol(EHOSTDOWN);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2525
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2526
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2527
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2528
#ifdef EHOSTUNREACH
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2529
	    case EHOSTUNREACH:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2530
		sym = @symbol(EHOSTUNREACH);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2531
		typ = @symbol(peerFaultSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2532
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2533
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2534
#ifdef EDQUOT
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2535
	    case EDQUOT:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2536
		sym = @symbol(EDQUOT);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2537
		typ = @symbol(noResourcesSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2538
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2539
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2540
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2541
#ifdef ENOMEDIUM
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2542
	    case ENOMEDIUM:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2543
		sym = @symbol(ENOMEDIUM);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2544
		typ = @symbol(noResourcesSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2545
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2546
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2547
#ifdef EMEDIUMTYPE
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2548
	    case EMEDIUMTYPE:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2549
		sym = @symbol(EMEDIUMTYPE);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2550
		typ = @symbol(noResourcesSignal);
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2551
		break;
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2552
#endif
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2553
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2554
	    default:
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2555
		break;
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2556
	}
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2557
    }
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2558
%}.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2559
    holder := OSErrorHolder new.
16301
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2560
    sym isNil ifTrue:[
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2561
	sym := #ERROR_OTHER.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2562
	errNr notNil ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2563
	    "keep symbols as symbols"
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2564
	    holder parameter:(errNr isString ifTrue:[errNr] ifFalse:[errNr asString]).
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2565
	].
16301
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2566
    ].
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2567
    holder errorSymbol:sym errorCategory:(typ ? #defaultOsErrorSignal).
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2568
    ^ holder
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2569
16301
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2570
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2571
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2572
     OperatingSystem errorHolderForNumber:4
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2573
     OperatingSystem errorHolderForNumber:45
16301
9eb74aad5c2b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16290
diff changeset
  2574
     OperatingSystem errorHolderForNumber:#badArgument
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2575
     self errorHolderForNumber:(self errorNumberFor:#EPERM)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2576
     self errorHolderForNumber:(self errorNumberFor:#EIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2577
     self errorHolderForNumber:(self errorNumberFor:#ENXIO)
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2578
     self errorHolderForNumber:(self errorNumberFor:#EOVERFLOW)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2579
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2580
!
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2581
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2582
errorNumberFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2583
    "given a symbolic error, return the numeric;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2584
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2585
     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
  2586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2587
%{   /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2588
    OBJ sym = aSymbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2589
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2590
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2591
     * POSIX errnos - these should be defined
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2592
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2593
#ifdef EPERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2594
    if (sym == @symbol(EPERM)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2595
	RETURN ( __mkSmallInteger(EPERM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2596
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2597
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2599
#ifdef ENOENT
14435
fc486e748569 changed: #errorNumberFor:
Stefan Vogel <sv@exept.de>
parents: 14377
diff changeset
  2600
    /* 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
  2601
    if (sym == @symbol(ENOENT) || sym == @symbol(ERROR_FILE_NOT_FOUND)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2602
	RETURN ( __mkSmallInteger(ENOENT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2603
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2604
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2605
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2606
#ifdef ESRCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2607
    if (sym == @symbol(ESRCH)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2608
	RETURN ( __mkSmallInteger(ESRCH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2609
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2610
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2611
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2612
#ifdef EINTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2613
    if (sym == @symbol(EINTR)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2614
	RETURN ( __mkSmallInteger(EINTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2615
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2616
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2617
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2618
#ifdef EIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2619
    if (sym == @symbol(EIO)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2620
	RETURN ( __mkSmallInteger(EIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2621
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2622
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2623
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2624
#ifdef ENXIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2625
    if (sym == @symbol(ENXIO)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2626
	RETURN ( __mkSmallInteger(ENXIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2627
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2628
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2629
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2630
#ifdef E2BIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2631
    if (sym == @symbol(E2BIG)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2632
	RETURN ( __mkSmallInteger(E2BIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2633
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2634
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2635
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2636
#ifdef ENOEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2637
    if (sym == @symbol(ENOEXEC)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2638
	RETURN ( __mkSmallInteger(ENOEXEC) );
18198
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2639
    }
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2640
#endif
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2641
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2642
#ifdef ENOTSUP
18205
182612a550dd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18198
diff changeset
  2643
# if !defined(EOPNOTSUPP) || (ENOTSUP != EOPNOTSUPP)
18198
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  2644
    if (sym == @symbol(ENOTSUP)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2645
	RETURN ( __mkSmallInteger(ENOTSUP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2646
    }
18205
182612a550dd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18198
diff changeset
  2647
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2648
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2649
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2650
#ifdef EBADF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2651
    if (sym == @symbol(EBADF)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2652
	RETURN ( __mkSmallInteger(EBADF) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2653
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2654
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2655
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2656
#ifdef ECHILD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2657
    if (sym == @symbol(ECHILD)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2658
	RETURN ( __mkSmallInteger(ECHILD) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2659
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2660
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2661
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2662
#if defined(EAGAIN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2663
    if (sym == @symbol(EAGAIN)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2664
	RETURN ( __mkSmallInteger(EAGAIN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2665
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2666
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2667
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2668
#ifdef ENOMEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2669
    if (sym == @symbol(ENOMEM)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2670
	RETURN ( __mkSmallInteger(ENOMEM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2671
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2672
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2673
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2674
#ifdef EACCES
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2675
    if (sym == @symbol(EACCES)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2676
	RETURN ( __mkSmallInteger(EACCES) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2677
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
#endif
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
#ifdef EFAULT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2681
    if (sym == @symbol(EFAULT)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2682
	RETURN ( __mkSmallInteger(EFAULT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2683
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2684
#endif
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
#ifdef EBUSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2687
    if (sym == @symbol(EBUSY)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2688
	RETURN ( __mkSmallInteger(EBUSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2689
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2690
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2691
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2692
#ifdef EXDEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2693
    if (sym == @symbol(EXDEV)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2694
	RETURN ( __mkSmallInteger(EXDEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2695
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2696
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2697
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2698
#ifdef ENODEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2699
    if (sym == @symbol(ENODEV)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2700
	RETURN ( __mkSmallInteger(ENODEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2701
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2702
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2703
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2704
#ifdef ENOTDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2705
    if (sym == @symbol(ENOTDIR)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2706
	RETURN ( __mkSmallInteger(ENOTDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2707
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2708
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2709
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2710
#ifdef EISDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2711
    if (sym == @symbol(EISDIR)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2712
	RETURN ( __mkSmallInteger(EISDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2713
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2714
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2715
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2716
#ifdef EINVAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2717
    if (sym == @symbol(EINVAL)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2718
	RETURN ( __mkSmallInteger(EINVAL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2719
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2720
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2721
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2722
#ifdef ENFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2723
    if (sym == @symbol(ENFILE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2724
	RETURN ( __mkSmallInteger(ENFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2725
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2726
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2728
#ifdef EMFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2729
    if (sym == @symbol(EMFILE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2730
	RETURN ( __mkSmallInteger(EMFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2731
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2732
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2733
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2734
#ifdef ENOTTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2735
    if (sym == @symbol(ENOTTY)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2736
	RETURN ( __mkSmallInteger(ENOTTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2737
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2738
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2739
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2740
#ifdef EFBIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2741
    if (sym == @symbol(EFBIG)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2742
	RETURN ( __mkSmallInteger(EFBIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2743
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2744
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2745
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2746
#ifdef ENOSPC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2747
    if (sym == @symbol(ENOSPC)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2748
	RETURN ( __mkSmallInteger(ENOSPC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2749
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2751
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2752
#ifdef ESPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2753
    if (sym == @symbol(ESPIPE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2754
	RETURN ( __mkSmallInteger(ESPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2755
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2757
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2758
#ifdef EROFS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2759
    if (sym == @symbol(EROFS)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2760
	RETURN ( __mkSmallInteger(EROFS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2761
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2762
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2763
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2764
#ifdef EMLINK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2765
    if (sym == @symbol(EMLINK)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2766
	RETURN ( __mkSmallInteger(EMLINK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2767
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2768
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2769
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2770
#ifdef EPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2771
    if (sym == @symbol(EPIPE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2772
	RETURN ( __mkSmallInteger(EPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2773
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2774
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2775
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2776
#ifdef EDOM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2777
    if (sym == @symbol(EDOM)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2778
	RETURN ( __mkSmallInteger(EDOM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2779
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2780
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2781
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2782
#ifdef ERANGE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2783
    if (sym == @symbol(ERANGE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2784
	RETURN ( __mkSmallInteger(ERANGE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2785
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2786
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2787
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2788
#ifdef EDEADLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2789
    if (sym == @symbol(EDEADLK)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2790
	RETURN ( __mkSmallInteger(EDEADLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2791
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2792
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2793
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2794
#ifdef ENAMETOOLONG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2795
    if (sym == @symbol(ENAMETOOLONG)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2796
	RETURN ( __mkSmallInteger(ENAMETOOLONG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2797
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2798
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2799
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2800
#ifdef ENOLCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2801
    if (sym == @symbol(ENOLCK)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2802
	RETURN ( __mkSmallInteger(ENOLCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2803
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2804
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2805
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2806
#ifdef ENOSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2807
    if (sym == @symbol(ENOSYS)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2808
	RETURN ( __mkSmallInteger(ENOSYS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2809
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2810
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2811
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2812
#ifdef ENOTEMPTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2813
    if (sym == @symbol(ENOTEMPTY)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2814
	RETURN ( __mkSmallInteger(ENOTEMPTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2815
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2816
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2817
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2818
#ifdef EEXIST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2819
    if (sym == @symbol(EEXIST)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2820
	RETURN ( __mkSmallInteger(EEXIST) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2821
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2823
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
#ifdef EILSEQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2825
    if (sym == @symbol(EILSEQ)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2826
	RETURN ( __mkSmallInteger(EILSEQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2827
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2828
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2829
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2830
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2831
     * XPG3 errnos - defined on most systems
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
#ifdef ENOTBLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2834
    if (sym == @symbol(ENOTBLK)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2835
	RETURN ( __mkSmallInteger(ENOTBLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2836
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2837
#endif
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
#ifdef ETXTBSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2840
    if (sym == @symbol(ETXTBSY)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2841
	RETURN ( __mkSmallInteger(ETXTBSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2842
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2843
#endif
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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2846
     * some others
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2847
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2848
#ifdef EWOULDBLOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2849
    if (sym == @symbol(EWOULDBLOCK)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2850
	RETURN ( __mkSmallInteger(EWOULDBLOCK) );
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2851
    }
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2852
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2853
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2854
#ifdef EOVERFLOW
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2855
    if (sym == @symbol(EOVERFLOW)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2856
	RETURN ( __mkSmallInteger(EOVERFLOW) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2858
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2859
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2860
#ifdef ENOMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2861
    if (sym == @symbol(ENOMSG)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2862
	RETURN ( __mkSmallInteger(ENOMSG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2863
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2864
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2866
#ifdef ELOOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2867
    if (sym == @symbol(ELOOP)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2868
	RETURN ( __mkSmallInteger(ELOOP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2869
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2870
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2871
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2872
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2873
     * some stream errors
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
#ifdef ETIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2876
    if (sym == @symbol(ETIME)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2877
	RETURN ( __mkSmallInteger(ETIME) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2878
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2879
#endif
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
#ifdef ENOSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2882
    if (sym == @symbol(ENOSR)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2883
	RETURN ( __mkSmallInteger(ENOSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2884
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2885
#endif
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
#ifdef ENOSTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2888
    if (sym == @symbol(ENOSTR)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2889
	RETURN ( __mkSmallInteger(ENOSTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2890
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2891
#endif
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
#ifdef ECOMM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2894
    if (sym == @symbol(ECOMM)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2895
	RETURN ( __mkSmallInteger(ECOMM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2896
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2897
#endif
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
#ifdef EPROTO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2900
    if (sym == @symbol(EPROTO)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2901
	RETURN ( __mkSmallInteger(EPROTO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2902
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2903
#endif
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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2906
     * nfs errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2907
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2908
#ifdef ESTALE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2909
    if (sym == @symbol(ESTALE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2910
	RETURN ( __mkSmallInteger(ESTALE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2911
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2912
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2913
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2914
#ifdef EREMOTE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2915
    if (sym == @symbol(EREMOTE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2916
	RETURN ( __mkSmallInteger(EREMOTE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2917
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2918
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2919
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2920
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2921
     * some networking errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2922
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2923
#ifdef EINPROGRESS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2924
    if (sym == @symbol(EINPROGRESS)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2925
	RETURN ( __mkSmallInteger(EINPROGRESS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2926
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2927
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2928
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2929
#ifdef EALREADY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2930
    if (sym == @symbol(EALREADY)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2931
	RETURN ( __mkSmallInteger(EALREADY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2932
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2933
#endif
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
#ifdef ENOTSOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2936
    if (sym == @symbol(ENOTSOCK)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2937
	RETURN ( __mkSmallInteger(ENOTSOCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2938
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2939
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2940
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2941
#ifdef EDESTADDRREQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2942
    if (sym == @symbol(EDESTADDRREQ)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2943
	RETURN ( __mkSmallInteger(EDESTADDRREQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2944
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2945
#endif
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
#ifdef EMSGSIZE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2948
    if (sym == @symbol(EMSGSIZE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2949
	RETURN ( __mkSmallInteger(EMSGSIZE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2950
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2951
#endif
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
#ifdef EPROTOTYPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2954
    if (sym == @symbol(EPROTOTYPE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2955
	RETURN ( __mkSmallInteger(EPROTOTYPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2956
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2957
#endif
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
#ifdef ENOPROTOOPT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2960
    if (sym == @symbol(ENOPROTOOPT)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2961
	RETURN ( __mkSmallInteger(ENOPROTOOPT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2962
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2963
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2964
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2965
#ifdef EPROTONOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2966
    if (sym == @symbol(EPROTONOSUPPORT)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2967
	RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2968
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2969
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2970
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2971
#ifdef ESOCKTNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2972
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2973
	RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2974
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2975
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2976
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2977
#ifdef EOPNOTSUPP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2978
    if (sym == @symbol(EOPNOTSUPP)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2979
	RETURN ( __mkSmallInteger(EOPNOTSUPP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2980
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2981
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2982
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2983
#ifdef EPFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2984
    if (sym == @symbol(EPFNOSUPPORT)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2985
	RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2986
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2987
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2988
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2989
#ifdef EAFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2990
    if (sym == @symbol(EAFNOSUPPORT)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2991
	RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2992
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2993
#endif
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
#ifdef EADDRINUSE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2996
    if (sym == @symbol(EADDRINUSE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  2997
	RETURN ( __mkSmallInteger(EADDRINUSE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2998
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2999
#endif
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
#ifdef EADDRNOTAVAIL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3002
    if (sym == @symbol(EADDRNOTAVAIL)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3003
	RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3004
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3005
#endif
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
#ifdef ETIMEDOUT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3008
    if (sym == @symbol(ETIMEDOUT)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3009
	RETURN ( __mkSmallInteger(ETIMEDOUT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3010
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3011
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3012
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3013
#ifdef ECONNREFUSED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3014
    if (sym == @symbol(ECONNREFUSED)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3015
	RETURN ( __mkSmallInteger(ECONNREFUSED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3016
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3017
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3018
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3019
#ifdef ENETDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3020
    if (sym == @symbol(ENETDOWN)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3021
	RETURN ( __mkSmallInteger(ENETDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3022
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3023
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3025
#ifdef ENETUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3026
    if (sym == @symbol(ENETUNREACH)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3027
	RETURN ( __mkSmallInteger(ENETUNREACH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3028
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3029
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3030
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3031
#ifdef ENETRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3032
    if (sym == @symbol(ENETRESET)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3033
	RETURN ( __mkSmallInteger(ENETRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3034
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3035
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3036
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3037
#ifdef ECONNABORTED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3038
    if (sym == @symbol(ECONNABORTED)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3039
	RETURN ( __mkSmallInteger(ECONNABORTED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3040
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3041
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3042
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3043
#ifdef ECONNRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3044
    if (sym == @symbol(ECONNRESET)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3045
	RETURN ( __mkSmallInteger(ECONNRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3046
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3047
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3048
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3049
#ifdef EISCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3050
    if (sym == @symbol(EISCONN)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3051
	RETURN ( __mkSmallInteger(EISCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3052
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3053
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3054
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3055
#ifdef ENOTCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3056
    if (sym == @symbol(ENOTCONN)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3057
	RETURN ( __mkSmallInteger(ENOTCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3058
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3059
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3060
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3061
#ifdef ESHUTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3062
    if (sym == @symbol(ESHUTDOWN)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3063
	RETURN ( __mkSmallInteger(ESHUTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3064
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3065
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3066
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3067
#ifdef EHOSTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3068
    if (sym == @symbol(EHOSTDOWN)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3069
	RETURN ( __mkSmallInteger(EHOSTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3070
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3071
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3072
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3073
#ifdef EHOSTUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3074
    if (sym == @symbol(EHOSTUNREACH)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3075
	RETURN ( __mkSmallInteger(EHOSTUNREACH) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3076
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3077
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3078
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3079
#ifdef EREMOTEIO
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3080
    if (sym == @symbol(EREMOTEIO)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3081
	RETURN ( __mkSmallInteger(EREMOTEIO) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3082
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3083
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3084
#ifdef EDQUOT
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3085
    if (sym == @symbol(EDQUOT)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3086
	RETURN ( __mkSmallInteger(EDQUOT) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3087
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3088
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3089
#ifdef ENOMEDIUM
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3090
    if (sym == @symbol(ENOMEDIUM)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3091
	RETURN ( __mkSmallInteger(ENOMEDIUM) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3092
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3093
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3094
#ifdef EMEDIUMTYPE
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3095
    if (sym == @symbol(EMEDIUMTYPE)) {
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3096
	RETURN ( __mkSmallInteger(EMEDIUMTYPE) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3097
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3098
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3099
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3100
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3101
    ^ -1
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  3102
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  3103
    "
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  3104
     self errorNumberFor:#EOVERFLOW
18198
1777d76a3844 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 18193
diff changeset
  3105
     self errorNumberFor:#ENOTSUP
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  3106
    "
3496
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
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3109
!UnixOperatingSystem class methodsFor:'executing OS commands-implementation'!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3110
14576
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  3111
exec:aCommandPathArg withArguments:argColl environment:environmentDictionary
7170
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  3112
    fileDescriptors:fdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  3113
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3114
    "Internal lowLevel entry for combined fork & exec;
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3115
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3116
     If fork is false (chain a command):
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3117
	 execute the OS command specified by the argument, aCommandPath, with
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3118
	 arguments in argArray (no arguments, if nil).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3119
	 If successful, this method does not return and smalltalk is gone.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3120
	 If not successful, it does return.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3121
	 Normal use is with forkForCommand.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3122
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3123
     If fork is true (subprocess command execution):
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3124
	fork a child to do the above.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3125
	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
  3126
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7072
diff changeset
  3127
     fdColl contains the filedescriptors, to be used for the child (if fork is true).
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3128
	fdArray[1] = 15 -> use fd 15 as stdin.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3129
	If an element of the array is set to nil, the corresponding filedescriptor
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3130
	will be closed for the child.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3131
	fdArray[1] == StdIn for child
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3132
	fdArray[2] == StdOut for child
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3133
	fdArray[3] == StdErr for child
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3134
	on VMS, these must be channels as returned by createMailBox.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3135
	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
  3136
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3137
     If newPgrp is true, the subprocess will be established in a new process group.
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3138
	The processgroup will be equal to id.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3139
	newPgrp is not used on WIN32 and VMS systems.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3140
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  3141
     environmentDictionary specifies environment variables which are passed differently from
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3142
     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
  3143
     key-value pairs for changed/added environment variables.
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3144
     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
  3145
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3146
     Notice: this used to be two separate ST-methods; however, in order to use
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3147
	    vfork on some machines, it had to be merged into one, to avoid write
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3148
	    accesses to ST/X memory from the vforked-child.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3149
	    The code below only does read accesses."
14576
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  3150
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  3151
    |envArray argArray fdArray dirName cnt aCommandPath|
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  3152
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  3153
    environmentDictionary notEmptyOrNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3154
	envArray := Array new:environmentDictionary size.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3155
	cnt := 1.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3156
	environmentDictionary keysAndValuesDo:[:key :val |
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3157
	    val isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3158
		envArray at:cnt put:((self encodePath:key), '=')
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3159
	    ] ifFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3160
		envArray at:cnt put:((self encodePath:key), '=', (self encodePath:val))
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3161
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3162
	    cnt := cnt + 1.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3163
	].
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3164
    ].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3165
    argColl notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3166
	argArray := argColl asArray collect:[:eachArg| self encodePath:eachArg].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3167
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3168
    fdColl notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3169
	fdArray := fdColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3170
    ].
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3171
    aDirectory notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3172
	dirName := aDirectory asFilename osNameForFile.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3173
	dirName := self encodePath:dirName.
14576
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  3174
    ].
14582
24adef09db30 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14576
diff changeset
  3175
    aCommandPath := self encodePath:aCommandPathArg.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3176
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3177
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3178
    char **argv;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3179
    int nargs, i, id;
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  3180
    OBJ arg;
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  3181
#ifdef __osx__
16282
a9cd85c4d2f2 getEnvironment fix for __osx__
Claus Gittinger <cg@exept.de>
parents: 16149
diff changeset
  3182
    char **environ = *_NSGetEnviron();
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  3183
#else
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3184
    extern char **environ;
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  3185
#endif
3571
9090dc66a427 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
  3186
    char **_env, **_nEnv;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3187
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3188
    if (__isStringLike(aCommandPath) &&
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3189
	((argArray == nil) || __isArrayLike(argArray)) &&
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3190
	((fdArray == nil) || __isArrayLike(fdArray))
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3191
    ) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3192
	nargs = argArray == nil ? 0 : __arraySize(argArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3193
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3194
	if (argv) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3195
	    int nOldEnv, nNewEnv;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3196
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3197
	    for (i=0; i < nargs; i++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3198
		arg = __ArrayInstPtr(argArray)->a_element[i];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3199
		if (__isStringLike(arg)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3200
		    argv[i] = (char *) __stringVal(arg);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3201
		} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3202
		    argv[i] = "";
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3203
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3204
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3205
	    argv[i] = NULL;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3206
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3207
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3208
	     * number of new items in environment ..
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3209
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3210
	    nNewEnv = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3211
	    if ((envArray != nil) && __isArrayLike(envArray)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3212
		nNewEnv = __arraySize(envArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3213
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3214
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3215
	    if (nNewEnv == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3216
		_nEnv = environ;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3217
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3218
		_env = environ;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3219
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3220
		 * get size of environment
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3221
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3222
		nOldEnv = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3223
		if (_env) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3224
		    while (*_env) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3225
			nOldEnv++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3226
			_env++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3227
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3228
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3229
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3230
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3231
		 * generate a new environment
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3232
		 * I have not found a spec which defines if
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3233
		 * items at the end overwrite previous definitions,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3234
		 * or if the first encountered definition is valid.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3235
		 * To be prepared for any case, simply add the new definitions
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3236
		 * at both ends - that should do it in any case.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3237
		 * Someone with more know-how may want to fix this.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3238
		 * getenv() searches for the first entry.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3239
		 * But maybe someone creates a Dictionary from the environment.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3240
		 * In this case the last entry would overwrite previous entries.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3241
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3242
		_nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3243
		if (_nEnv) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3244
		    char **eO, **eN;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3245
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3246
		    eN = _nEnv;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3247
		    if (nNewEnv) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3248
			/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3249
			 * add new items at the front ...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3250
			 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3251
			int i;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3252
			OBJ *t;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3253
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3254
			for (i=0, t = __arrayVal(envArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3255
			     i < __arraySize(envArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3256
			     i++, t++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3257
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3258
			    if (__isStringLike(*t)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3259
				*eN++ = (char *)__stringVal(*t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3260
			    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3261
			}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3262
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3263
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3264
		    if (nOldEnv) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3265
			/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3266
			 * append old environment
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3267
			 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3268
			for (eO = environ; *eO; *eN++ = *eO++)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3269
			    continue;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3270
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3271
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3272
		    if (nNewEnv) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3273
			/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3274
			 * append new items again at the end
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3275
			 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3276
			for (eO = _nEnv, i=0; i<nNewEnv; i++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3277
			    *eN++ = *eO++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3278
			}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3279
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3280
		    *eN = NULL;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3281
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3282
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3283
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3284
	    if (doFork == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3285
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3286
		 * fork a subprocess.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3287
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3288
		int nfd;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3289
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3290
		nfd = fdArray == nil ? 0 : __arraySize(fdArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3291
		id = FORK ();
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3292
		if (id == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3293
		    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3294
		    ** In child.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3295
		    ** first: dup filedescriptors.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3296
		    */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3297
		    for (i = 0; i < nfd; i++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3298
			OBJ fd;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3299
			int rslt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3300
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3301
			fd = __arrayVal(fdArray)[i];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3302
			if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3303
			    do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3304
				rslt = dup2(__intVal(fd), i);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3305
			    } while ((rslt < 0) && (errno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3306
			}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3307
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3308
		    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3309
		    ** Second: close descriptors
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3310
		    **         marked as unwanted
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3311
		    ** (extra loop to allow duping of low filedescriptor numbers to
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3312
		    **  higher fd numbers)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3313
		    */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3314
		    for (i = 0; i < nfd; i++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3315
			if (__arrayVal(fdArray)[i] == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3316
			    close(i);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3317
			}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3318
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3319
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3320
		    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3321
		    ** third: close all filedescriptors larger
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3322
		    ** then the explicitely closed or duped
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3323
		    ** filedescriptors
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3324
		    */
7072
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3325
#ifndef OPEN_MAX
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3326
# define OPEN_MAX       256
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3327
#endif
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3328
		    for ( ;i < OPEN_MAX; i++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3329
			close(i);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3330
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3331
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3332
		    if (newPgrp == true) {
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3333
#ifndef NEXT
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3334
			setsid();
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3335
#endif
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3336
#if defined(TIOCSCTTY)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3337
			ioctl(0, TIOCSCTTY, 0) ;
3561
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3338
#endif
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3339
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3340
#if defined(TIOCSPGRP)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3341
			{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3342
			    int pgrp = getpid();
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3343
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3344
			    ioctl(0, TIOCSPGRP, (char *)&pgrp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3345
			}
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3346
#endif
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3347
#if defined(_POSIX_JOB_CONTROL)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3348
			(void) setpgid(0, 0);
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3349
#else
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3350
# if defined(BSD) || defined(LINUX)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3351
			(void) setpgrp(0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3352
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3353
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3354
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3355
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3356
		    if (dirName == nil || chdir((char *)__stringVal(dirName)) == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3357
			execve((char *)__stringVal(aCommandPath), argv, _nEnv);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3358
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3359
		    /* reached if chdir failed or aCommandPathh cannot be executed */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3360
		    _exit(127);                 /* POSIX 2 compatible exit value */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3361
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3362
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3363
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3364
		 * no subprocess (i.e. transfer to another program)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3365
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3366
		if (dirName == nil || chdir((char *)__stringVal(dirName)) == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3367
		    execve((char *)__stringVal(aCommandPath), argv, _nEnv);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3368
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3369
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3370
		 * reached if chdir failed or command-path cannot be executed
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3371
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3372
		id = -1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3373
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3374
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3375
	    if (nNewEnv && (_nEnv != NULL)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3376
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3377
		 * free new environment stuff
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3378
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3379
		free(_nEnv);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3380
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3381
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3382
	    free(argv);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3383
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3384
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3385
	     * In parent: succes or failure
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3386
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3387
	    if (id == -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3388
		RETURN (nil);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3389
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3390
		RETURN (__mkSmallInteger(id));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3391
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3392
	}
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3393
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3394
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3395
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3396
     path-argument not string
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3397
     or argArray not an array/nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3398
     or malloc failed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3399
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3400
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3401
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3402
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3403
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3404
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3405
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3406
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3407
     id == 0 ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3408
	'I am the child'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3409
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3410
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3411
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3412
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3413
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3414
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3415
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3416
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3417
     id == 0 ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3418
	'I am the child'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3419
	OperatingSystem
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3420
	   exec:'/bin/sh'
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3421
	   withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3422
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3423
     ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3424
     id printNL.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3425
     (Delay forSeconds:3.5) wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3426
     'killing ...' printNL.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3427
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3428
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3429
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3430
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3431
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3432
fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3433
    "fork a new (HEAVY-weight) unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3434
     Not supported with MSDOS & VMS systems.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3435
     Dont confuse this with Block>>fork, which creates
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3436
     lightweight smalltalk processes. This method will return
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3437
     0 to the child process, and a non-zero number (which is the childs
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3438
     unix-process-id) to the parent (original) process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3439
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3440
     In normal situations, you dont need to use this low level entry; see
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3441
     #startProcess: and #executCommand: for higher level interfaces."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3442
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3443
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3444
    int pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3445
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3446
    pid = fork();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3447
    RETURN ( __MKUINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3448
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3449
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3450
    "/ not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3451
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3452
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3453
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3454
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3455
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3456
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3457
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3458
     id == 0 ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3459
	'I am the child process' printCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3460
	OperatingSystem exit
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3461
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3462
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3463
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3464
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3465
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3466
    errorTo:anExternalErrStream auxFrom:anAuxiliaryStream
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3467
    environment:anEvironmentDictionary inDirectory:dir
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3468
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3469
    "start executing the OS command as specified by the argument, aCommandString
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3470
     as a separate process; do not wait for the command to finish.
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3471
     If aCommandString is a String, the commandString is passed to a shell for execution
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3472
     - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3473
     If aCommandString is an Array, the first element is the command to be executed,
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3474
     and the other elements are the arguments to the command. No shell is invoked in this case.
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3475
     The command gets stdIn, stdOut and stdErr assigned from the arguments;
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3476
     each may be nil.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3477
     Return the processId if successful, nil otherwise.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3478
     Use #monitorPid:action: for synchronization and exec status return,
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3479
     or #killProcess: to stop it."
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3480
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3481
    |nullStream in out err shellAndArgs rslt auxFd|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3482
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3483
    aCommandString isNil ifTrue:[^ nil].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3484
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3485
    (in := anExternalInStream) isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3486
	nullStream := Filename nullDevice readWriteStream.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3487
	in := nullStream.
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3488
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3489
    (out := anExternalOutStream) isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3490
	nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3491
	out := nullStream.
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3492
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3493
    (err := anExternalErrStream) isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3494
	err := out
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3495
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3496
    anAuxiliaryStream notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3497
	auxFd := anAuxiliaryStream fileDescriptor
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3498
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3499
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3500
    shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3501
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3502
    rslt := self
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3503
	exec:(shellAndArgs at:1)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3504
	withArguments:(shellAndArgs at:2)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3505
	environment:anEvironmentDictionary
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3506
	fileDescriptors:(Array with:in fileDescriptor
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3507
			       with:out fileDescriptor
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3508
			       with:err fileDescriptor
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3509
			       with:auxFd)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3510
	fork:true
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3511
	newPgrp:true "/ false
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3512
	inDirectory:dir.
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3513
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3514
    nullStream notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3515
	nullStream close.
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3516
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3517
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3518
    ^ rslt
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3519
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3520
    "blocking at current prio (i.e. only higher prio threads execute):
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3521
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3522
     OperatingSystem executeCommand:'ls -l > out'.
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3523
     OperatingSystem executeCommand:#('/bin/ls' '-l') outputTo:Transcript.
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3524
    "
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3525
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3526
    "non-blocking (lower prio threads continue):
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3527
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3528
     |in out err pid sema|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3529
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3530
     in := 'out' asFilename readStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3531
     out := 'out2' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3532
     err := 'err' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3533
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3534
     sema := Semaphore new.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3535
     pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3536
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3537
     The following will no longer work. monitorPid has disappeared
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3538
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3539
     pid notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3540
	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3541
     ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3542
     in close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3543
     out close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3544
     err close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3545
     sema wait.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3546
     Transcript showCR:'finished'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3547
    "
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3548
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3549
    "Modified: / 21.3.1997 / 10:04:35 / dq"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3550
    "Modified: / 15.7.1997 / 16:03:51 / stefan"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3551
    "Modified: / 5.6.1998 / 19:03:51 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3552
    "Created: / 12.11.1998 / 14:39:20 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3553
! !
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3554
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3555
!UnixOperatingSystem class methodsFor:'executing OS commands-queries'!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3556
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3557
commandAndArgsForOSCommand:aCommandStringOrArray
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3558
    "get a shell and shell arguments for command execution.
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3559
     If aCommandString is a String, the commandString is passed to a shell for execution
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3560
     - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3561
     If aCommandString is an Array, the first element is the command to be executed,
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3562
     and the other elements are the arguments to the command. No shell is invoked in this case."
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3563
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3564
    aCommandStringOrArray isNonByteCollection ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3565
	"if an array is passed, the command string has already been parsed an no shell is invoked"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3566
	^ Array with:aCommandStringOrArray first with:aCommandStringOrArray.
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3567
    ].
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3568
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3569
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3570
    "/ '/bin/sh -c <command>'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3571
    "/
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3572
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3573
    ^ Array with:'/bin/sh' with:(Array with:'sh' with:'-c' with:aCommandStringOrArray)
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3574
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3575
    "Modified: / 20.1.1998 / 16:57:19 / md"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3576
    "Modified: / 5.6.1998 / 17:40:48 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3577
!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3578
11046
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3579
nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3580
    "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
  3581
     Usually, 'stx' is returned -
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3582
     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
  3583
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3584
    |info path|
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3585
15206
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3586
    "shortcut - use the /proc filesystem (if present).
14376
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  3587
     Here we get an absolute path to the running executable."
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  3588
    info := '/proc/self/exe' asFilename linkInfo.
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  3589
    info notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3590
	path := info path.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3591
	path notEmptyOrNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3592
	    ^ path
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3593
	].
14376
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  3594
     ].
11046
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3595
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3596
    "Fall back - do it the hard way"
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3597
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3598
    ^ super nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3599
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3600
    "
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3601
     OperatingSystem nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3602
    "
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3603
!
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3604
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3605
pathOfCommand:aCommand
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3606
    "find where aCommand's executable file is;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3607
     return its full pathName if there is such a command, otherwise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3608
     return nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3609
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
  3610
    |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
  3611
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3612
    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
  3613
    commandFilename isAbsolute ifTrue:[
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3614
	^ 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
  3615
    ].
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
  3616
    commandFilename isExplicitRelative ifTrue:[
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3617
	 ^ commandFilename pathName
17681
8894d153e26a class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17637
diff changeset
  3618
    ].
8894d153e26a class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17637
diff changeset
  3619
    (aCommand includes:$/) ifTrue:[
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3620
	"/ something like "smalltalk/stx", if executed from a parent directory
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3621
	^ ('./',aCommand) asFilename pathName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3622
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3623
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3624
    path := self getEnvironment:'PATH'.
14370
66a4b9c492b9 Fixed: bad definition of MAXPATHLEN from PATH_MAX
Stefan Vogel <sv@exept.de>
parents: 13801
diff changeset
  3625
    path notEmptyOrNil ifTrue:[
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3626
	(path asCollectionOfSubstringsSeparatedBy:self pathSeparator) do:[:eachPathComponent |
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3627
	    eachPathComponent isEmpty ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3628
		f := commandFilename
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3629
	    ] ifFalse:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3630
		f := eachPathComponent asFilename construct:aCommand.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3631
	    ].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3632
	    self executableFileExtensions do:[:eachExtension |
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3633
		eachExtension notEmpty ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3634
		    fExt := f addSuffix:eachExtension.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3635
		] ifFalse:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3636
		    fExt := f.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3637
		].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3638
		fExt isExecutable ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3639
		    ^ fExt pathName
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3640
		].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3641
	    ].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  3642
	].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3643
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3644
    ^ nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3645
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3646
    "unix:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3647
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3648
     OperatingSystem pathOfCommand:'fooBar'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3649
     OperatingSystem pathOfCommand:'ls'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3650
     OperatingSystem pathOfCommand:'cvs'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3651
     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
  3652
     OperatingSystem pathOfCommand:'./stx'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3653
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3654
    "windows:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3655
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3656
     OperatingSystem pathOfCommand:'windbg'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3657
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3658
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3659
    "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
  3660
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3661
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3662
!UnixOperatingSystem class methodsFor:'file access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3663
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3664
closeFd:anInteger
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3665
    "low level close of a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3666
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3667
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3668
     if (__isSmallInteger(anInteger)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3669
	if (@global(ExternalStream:FileOpenTrace) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3670
	    fprintf(stderr, "close [UnixOp] fd=%d\n", (int)__intVal(anInteger));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3671
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3672
	close(__intVal(anInteger));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3673
	RETURN(self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3674
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3675
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3676
     ^ self primitiveFailed.
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3677
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3678
    "
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3679
     10 to:400 do:[:fd | OperatingSystem closeFd:fd]
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3680
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3681
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3682
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3683
copyFromFd:inFd toFd:outFd startIndex:startIdx count:count
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3684
    "directly copy from one Fd to another (if supported by the OS)"
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3685
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3686
%{
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3687
#if defined(HAS_SENDFILE)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3688
     if (__isSmallInteger(inFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3689
      && __isSmallInteger(outFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3690
      && __isSmallInteger(startIdx)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3691
      && __isSmallInteger(count)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3692
	int nWritten;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3693
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3694
	nWritten = sendfile(__intVal(outFd), __intVal(inFd), __intVal(startIdx), __intVal(count));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3695
	if (nWritten < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3696
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3697
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3698
	RETURN (__mkSmallInteger(nWritten));
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3699
     }
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3700
#endif
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3701
%}.
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3702
    ^ 0 "/ not supported
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3703
!
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3704
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3705
createDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3706
    "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
  3707
     path, or relative to the current directory.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3708
     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
  3709
     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
  3710
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3711
    ^ self createDirectory:aPathName withAccess:((self getEnvironment:'UMASK') ? 8r0755)
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3712
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3713
    "
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3714
     OperatingSystem createDirectory:'foo'
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3715
    "
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3716
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3717
    "Modified: 20.12.1995 / 11:24:13 / stefan"
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3718
    "Modified: 29.6.1996 / 14:06:54 / cg"
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3719
!
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3720
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3721
createDirectory:aPathName withAccess:umask
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3722
    "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
  3723
     path, or relative to the current directory.
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3724
     Return true if successful (or the directory existed already), false if failed.
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3725
     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
  3726
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3727
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3728
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3729
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3730
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3731
%{
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3732
    if (__isStringLike(encodedPathName) && __isSmallInteger(umask)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3733
	if (mkdir(__stringVal(encodedPathName), __smallIntegerVal(umask)) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3734
	    RETURN(true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3735
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3736
	@global(LastErrorNumber) = __mkSmallInteger(errno);
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3737
    }
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3738
%}.
11547
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3739
    "/ could not create - if it already existed this is ok
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3740
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3741
    (self isDirectory:aPathName) ifTrue:[^ true].
11547
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3742
    ^ false.
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3743
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3744
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3745
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3746
     OperatingSystem createDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3747
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3748
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3749
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3750
createFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3751
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3752
    ^ 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
  3753
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3754
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3755
createFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3756
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3757
    ^ 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
  3758
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3759
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3760
createFileForWrite:pathName
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3761
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3762
    ^ self open:pathName attributes:#(O_WRONLY O_CREAT O_TRUNC) mode:nil
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3763
!
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3764
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3765
createHardLinkFrom:oldPath to:newPath
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3766
    "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
  3767
     Return true if successful, false if not."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3768
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3769
    |encodedOldPathName encodedNewPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3770
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3771
    encodedOldPathName := self encodePath:oldPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3772
    encodedNewPathName := self encodePath:newPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3773
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3774
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3775
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3776
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3777
    if (__isStringLike(encodedOldPathName) && __isStringLike(encodedNewPathName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3778
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3779
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3780
	    ret = link((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3781
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3782
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3783
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3784
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3785
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3786
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3787
	RETURN (true);
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3788
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3789
%}.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3790
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3791
    "/ bad argument(s) given
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3792
    "/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3793
    ^ self primitiveFailed
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3794
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3795
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3796
     OperatingSystem linkFile:'foo' to:'bar'
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3797
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3798
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3799
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3800
createSymbolicLinkFrom:oldPath to:newPath
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3801
    "make a symbolic link for 'newPath' to the file 'oldPath'.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3802
     The link will be a soft (symbolic) link.
17146
e28137456d48 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17116
diff changeset
  3803
     Raise an error on error."
e28137456d48 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17116
diff changeset
  3804
e28137456d48 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17116
diff changeset
  3805
    |error encodedOldPathName encodedNewPathName|
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3806
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3807
    encodedOldPathName := self encodePath:oldPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3808
    encodedNewPathName := self encodePath:newPath.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3809
%{
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3810
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3811
    int ret;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3812
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3813
    if (__isStringLike(encodedOldPathName) && __isStringLike(encodedNewPathName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3814
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3815
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3816
	    ret = symlink((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3817
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3818
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3819
	if (ret >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3820
	    RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3821
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3822
	@global(LastErrorNumber) = error = __mkSmallInteger(errno);
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3823
    }
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3824
#endif
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3825
%}.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3826
    (encodedOldPathName isString not or:[encodedNewPathName isString not]) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3827
	"/
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3828
	"/ bad argument(s) given
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3829
	"/
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3830
	^ self primitiveFailed
17146
e28137456d48 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17116
diff changeset
  3831
    ].
e28137456d48 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17116
diff changeset
  3832
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3833
	(self errorHolderForNumber:error) reportError
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3834
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3835
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3836
    "/
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3837
    "/ 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
  3838
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3839
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3840
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3841
    "
17146
e28137456d48 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17116
diff changeset
  3842
     OperatingSystem createSymbolicLinkFrom:'foo' to:'/tmp/bar'
e28137456d48 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17116
diff changeset
  3843
     OperatingSystem createSymbolicLinkFrom:'foo' to:'/bla/bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3844
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3845
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3846
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3847
open:path attributes:attributes mode:modeInteger
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3848
    "open a file, return an os specific fileHandle.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3849
     openmode is a symbol defining the way to open
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3850
     valid modes are:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3851
	#O_RDONLY
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3852
	#O_RDWR
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3853
	#O_WRONLY
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3854
	#O_CREAT
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3855
	#O_APPEND
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3856
	#O_SYNC
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3857
	#O_LARGEFILE
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3858
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3859
     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
  3860
     which is proprietrary to the operatingSystem."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3861
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3862
    |error fileDescriptor encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3863
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3864
    encodedPathName := self encodePath:path.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3865
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3866
%{
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3867
    OBJ *ap;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3868
    int nAttributes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3869
    int fd;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3870
    int mode, openFlags = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3871
    int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3872
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3873
    if (!__isStringLike(encodedPathName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3874
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3875
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3876
    }
8934
32a063645991 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3877
    if (!__isArrayLike(attributes)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3878
	error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3879
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3880
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3881
    if (modeInteger == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3882
	mode = 0644;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3883
    } else if (__isSmallInteger(modeInteger)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3884
	mode = __intVal(modeInteger);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3885
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3886
	error = @symbol(badArgument3);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3887
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3888
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3889
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3890
    nAttributes = __arraySize(attributes);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3891
    for (n = 0, ap = __arrayVal(attributes); n < nAttributes; n++) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3892
	OBJ attribute = ap[n];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3893
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3894
	if (attribute == @symbol(O_RDONLY)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3895
	    openFlags |= O_RDONLY;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3896
	} else if (attribute == @symbol(O_RDWR)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3897
	    openFlags |= O_RDWR;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3898
	} else if (attribute == @symbol(O_WRONLY)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3899
	    openFlags |= O_WRONLY;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3900
	} else if (attribute == @symbol(O_CREAT)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3901
	    openFlags |= O_CREAT;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3902
	} else if (attribute == @symbol(O_APPEND)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3903
	    openFlags |= O_APPEND;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3904
	} else if (attribute == @symbol(O_EXCL)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3905
	    openFlags |= O_EXCL;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3906
	} else if (attribute == @symbol(O_TRUNC)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3907
	    openFlags |= O_TRUNC;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3908
	} else if (attribute == @symbol(O_LARGEFILE)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3909
#ifdef O_LARGEFILE
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3910
	    openFlags |= O_LARGEFILE;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3911
#else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3912
	    error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3913
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3914
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3915
	} else if (attribute == @symbol(O_SYNC)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3916
#ifdef O_SYNC
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3917
	    openFlags |= O_SYNC;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3918
#else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3919
	    error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3920
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3921
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3922
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3923
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3924
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3925
#if defined(O_NONBLOCK)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3926
    openFlags |= O_NONBLOCK;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  3927
#elif defined(O_NDELAY)
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3928
    openFlags |= O_NDELAY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3929
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3930
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3931
again:
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3932
    fd = open((char *) __stringVal(encodedPathName), openFlags, mode);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3933
    if (fd < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3934
	if (errno == EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3935
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3936
	    goto again;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3937
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3938
	    error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3939
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3940
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3941
    }
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  3942
    fileDescriptor = __mkSmallInteger(fd);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3943
err:;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3944
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3945
    ^ fileDescriptor notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3946
	FileDescriptorHandle for:fileDescriptor.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3947
    ] ifFalse:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3948
	(self errorHolderForNumber:error) reportError
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3949
    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3950
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3951
    "
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3952
	self open:'/etc/hosts' attributes:#(O_RDONLY) mode:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3953
	self open:'/tmp/xxzz' attributes:#(O_RDWR O_CREAT) mode:8r611
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3954
	self open:'/etc/passwd' attributes:#(O_RDWR) mode:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3955
	self open:'/no one knows this file' attributes:#(O_RDONLY) mode:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3956
	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
  3957
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3958
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3959
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3960
openFileForAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3961
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3962
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3963
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3964
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3965
openFileForRead:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3966
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3967
    ^ self open:pathName attributes:#(O_RDONLY) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3968
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3969
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3970
openFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3971
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3972
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3973
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3974
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3975
openFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3976
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3977
    ^ self open:pathName attributes:#(O_RDWR)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3978
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3979
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3980
openFileForWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3981
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3982
    ^ self open:pathName attributes:#(O_WRONLY)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3983
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3984
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3985
recursiveCopyDirectory:sourcePathName to:destination
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3986
    "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
  3987
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3988
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3989
    ^ self executeCommand:(Array with:'/bin/cp' with:'-af' with:sourcePathName with:destination)
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3990
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3991
    "
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3992
	self recursiveCopyDirectory:'packages' to:'foo'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  3993
	self recursiveRemoveDirectory:'foo'.
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  3994
    "
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3995
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3996
    "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
  3997
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3998
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3999
recursiveRemoveDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4000
    "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
  4001
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4002
17519
bb0912972d6b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17499
diff changeset
  4003
    ^ 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
  4004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4005
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4006
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4007
     OperatingSystem recursiveRemoveDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4008
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4009
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4010
    "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
  4011
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4012
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4013
removeDirectory:fullPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4014
    "remove the directory named 'fullPathName'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4015
     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
  4016
     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
  4017
     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
  4018
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4019
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4020
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4021
    encodedPathName := self encodePath:fullPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4022
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4023
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4024
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4025
    if (__isStringLike(encodedPathName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4026
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4027
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4028
	    ret = rmdir((char *) __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4029
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4030
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4031
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4032
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4033
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4034
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4035
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4036
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4037
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4038
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4039
    "/ either not a string argument,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4040
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4041
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4042
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4043
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4044
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4045
     OperatingSystem createDirectory:'foo'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4046
     OperatingSystem removeDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4047
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4048
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4049
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4050
removeFile:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4051
    "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
  4052
     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
  4053
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4054
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4055
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4056
    encodedPathName := self encodePath:fullPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4057
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4058
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4059
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4060
    if (__isStringLike(encodedPathName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4061
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4062
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4063
	    ret = unlink((char *) __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4064
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4065
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4066
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4067
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4068
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4069
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4070
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4071
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4072
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4073
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4074
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4075
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4076
renameFile:oldPath to:newPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4077
    "rename the file 'oldPath' to 'newPath'.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4078
     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
  4079
     correct for the OS used - therefore, this should not be called
11798
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  4080
     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
  4081
     any invalid names.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4082
     Returns true if successful, false if not"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4083
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4084
    |encodedOldPathName encodedNewPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4085
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4086
    encodedOldPathName := self encodePath:oldPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4087
    encodedNewPathName := self encodePath:newPath.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4088
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4089
    int ret, eno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4090
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4091
    if (__isStringLike(encodedOldPathName) && __isStringLike(encodedNewPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4092
#if defined(HAS_RENAME)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4093
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4094
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4095
	    ret = rename((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4096
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4097
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4098
#else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4099
	ret = link((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4100
	if (ret >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4101
	    ret = unlink((char *) __stringVal(encodedOldPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4102
	    if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4103
		eno = errno;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4104
		unlink((char *) __stringVal(encodedNewPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4105
		errno = eno;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4106
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4107
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4108
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4109
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4110
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4111
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4112
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4113
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4114
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4115
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4116
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4117
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4118
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4119
     OperatingSystem renameFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4120
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4121
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4122
17148
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4123
sync
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4124
    "sync all the filesystems"
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4125
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4126
%{
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4127
    sync();
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  4128
    RETURN (self);
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  4129
%}.
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  4130
    ^ self primitiveFailed
17148
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4131
!
0c3bc9a7d5e9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17146
diff changeset
  4132
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4133
syncFileSystem:handle
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4134
    "sync the filesystem where the file represented by handle resides"
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4135
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4136
%{
17155
27de82141c12 did not compile on macosx
Claus Gittinger <cg@exept.de>
parents: 17152
diff changeset
  4137
//cg must be nested ifdefs - macosx does not like it otherwise
27de82141c12 did not compile on macosx
Claus Gittinger <cg@exept.de>
parents: 17152
diff changeset
  4138
#if defined(LINUX)
27de82141c12 did not compile on macosx
Claus Gittinger <cg@exept.de>
parents: 17152
diff changeset
  4139
# if __GLIBC_PREREQ(2, 14)
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4140
    if (__isSmallInteger(handle)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4141
	if (syncfs(__intVal(handle)) == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4142
	    RETURN(self);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4143
	}
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4144
    }
17155
27de82141c12 did not compile on macosx
Claus Gittinger <cg@exept.de>
parents: 17152
diff changeset
  4145
# endif
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4146
#endif
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4147
%}.
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4148
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4149
    "fallback is to do a global sync"
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4150
    self sync.
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4151
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4152
    "
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  4153
     '/etc/passwd' asFilename readStream syncFileSystem
17149
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4154
    "
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4155
!
ec4913ade4a0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17148
diff changeset
  4156
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4157
truncateFile:aPathName to:newSize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4158
    "change a files size return true on success, false on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4159
     This may not be supported on all architectures.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4160
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4161
     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
  4162
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4163
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4164
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4165
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4166
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4167
%{
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4168
#if defined(HAS_TRUNCATE) || defined(HAS_FTRUNCATE)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4169
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4170
    off_t truncateSize;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4171
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4172
    if (!__isStringLike(encodedPathName))
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4173
	goto getOutOfHere;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4174
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4175
    if (__isSmallInteger(newSize)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4176
	truncateSize = __intVal(newSize);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4177
	if (truncateSize < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4178
	    goto getOutOfHere;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4179
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4180
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4181
	truncateSize = __signedLongIntVal(newSize);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4182
	if (truncateSize < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4183
	    goto getOutOfHere;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4184
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4185
	if (truncateSize == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4186
	    if (sizeof(truncateSize) == 8) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4187
		if (__signedLong64IntVal(newSize, &truncateSize) == 0 || truncateSize < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4188
		    goto getOutOfHere;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4189
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4190
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4191
		goto getOutOfHere;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4192
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4193
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4194
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4195
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4196
#if defined(HAS_TRUNCATE)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4197
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4198
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4199
	    ret = truncate((char *) __stringVal(encodedPathName), truncateSize);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4200
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4201
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4202
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4203
# ifdef HAS_FTRUNCATE
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4204
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4205
	int fd;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4206
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4207
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4208
	    fd = open((char *) __stringVal(encodedPathName), 2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4209
	} while (fd < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4210
	if (fd < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4211
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4212
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4213
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4214
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4215
	ret = ftruncate(fd, truncateSize);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4216
	close(fd);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4217
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4218
# endif /* HAS_FTRUNCATE */
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4219
#endif
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4220
    if (ret < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4221
	@global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4222
	RETURN ( false );
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4223
    }
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4224
    RETURN (true);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4225
getOutOfHere:;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4226
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4227
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4228
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4229
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4230
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4231
!UnixOperatingSystem class methodsFor:'file access rights'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4232
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4233
accessMaskFor:aSymbol
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4234
    "return the access bits mask for numbers as returned by
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4235
     OperatingSystem>>accessModeOf:
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4236
     and expected by OperatingSystem>>changeAccessModeOf:to:.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4237
     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
  4238
     (never hardcode 8rxxx into your code)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4239
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4240
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4241
#   ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4242
    /* posix systems should define these ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4243
#    define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4244
#    define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4245
#    define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4246
#    define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4247
#    define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4248
#    define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4249
#    define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4250
#    define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4251
#    define S_IXOTH 0001
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4252
#    define S_ISUID 04000
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4253
#    define S_ISGID 02000
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4254
#    define S_ISVTX 01000
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4255
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4256
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4257
    if (aSymbol == @symbol(readUser)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4258
	RETURN ( __mkSmallInteger(S_IRUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4259
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4260
    if (aSymbol == @symbol(writeUser)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4261
	RETURN ( __mkSmallInteger(S_IWUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4262
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4263
    if (aSymbol == @symbol(executeUser)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4264
	RETURN ( __mkSmallInteger(S_IXUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4265
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4266
    if (aSymbol == @symbol(readGroup)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4267
	RETURN ( __mkSmallInteger(S_IRGRP) );
3496
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
    if (aSymbol == @symbol(writeGroup)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4270
	RETURN ( __mkSmallInteger(S_IWGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4271
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4272
    if (aSymbol == @symbol(executeGroup)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4273
	RETURN ( __mkSmallInteger(S_IXGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4274
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4275
    if (aSymbol == @symbol(readOthers)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4276
	RETURN ( __mkSmallInteger(S_IROTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4277
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4278
    if (aSymbol == @symbol(writeOthers)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4279
	RETURN ( __mkSmallInteger(S_IWOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4280
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4281
    if (aSymbol == @symbol(executeOthers)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4282
	RETURN ( __mkSmallInteger(S_IXOTH) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4283
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4284
    if (aSymbol == @symbol(setUid)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4285
	RETURN ( __mkSmallInteger(S_ISUID) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4286
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4287
    if (aSymbol == @symbol(setGid)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4288
	RETURN ( __mkSmallInteger(S_ISGID) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4289
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4290
    if (aSymbol == @symbol(removeOnlyByOwner)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4291
	RETURN ( __mkSmallInteger(S_ISVTX) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4292
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4293
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4294
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4296
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4297
     OperatingSystem accessMaskFor:#readUser
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  4298
     OperatingSystem accessMaskFor:#removeOnlyByOwner
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4299
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4300
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4301
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4302
accessModeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4303
    "return a number representing access rights rwxrwxrwx for owner,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4304
     group and others. Return nil if such a file does not exist.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4305
     Notice that the returned number is OS dependent - use the
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4306
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4308
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4309
     this could have been implemented as:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4310
	(self infoOf:aPathName) at:#mode
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4311
     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
  4312
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4313
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4314
    |encodedPathName|
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.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4317
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4318
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4319
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4320
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4321
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4322
# ifdef TRACE_STAT_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4323
	printf("stat on '%s' for accessMode\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4324
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4325
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4326
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4327
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4328
	} while ((ret < 0) && (errno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4329
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4330
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4331
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4332
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4333
	    RETURN ( nil );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4334
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4335
	RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4336
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4337
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4338
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4339
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4340
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4341
    (OperatingSystem accessModeOf:'/') printStringRadix:8
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4342
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4343
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4344
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4345
accessModeOfFd:aFileDescriptor
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4346
    "return a number representing access rights rwxrwxrwx for owner,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4347
     group and others. Return nil if such a file does not exist.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4348
     Notice that the returned number is OS dependent - use the
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4349
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4350
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4351
%{
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4352
    struct stat buf;
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4353
    int ret;
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4354
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4355
    if (__isSmallInteger(aFileDescriptor)) {
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4356
# ifdef TRACE_STAT_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4357
	printf("fstat on '%d' for accessMode\n", __smallIntegerVal(aFileDescriptor));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4358
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4359
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4360
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4361
	    ret = fstat(__smallIntegerVal(aFileDescriptor), &buf);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4362
	} while ((ret < 0) && (errno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4363
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4364
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4365
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4366
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4367
	    RETURN ( nil );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4368
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4369
	RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4370
    }
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4371
%}.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4372
   ^ self primitiveFailed
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4373
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4374
   "
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4375
    '/' asFilename readingFileDo:[:s|
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4376
	(OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4377
    ].
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4378
   "
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4379
!
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4380
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4381
changeAccessModeOf:aPathName to:modeBits
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4382
    "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
  4383
     You should construct this mask using accessMaskFor, to be OS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4384
     independent. Return true if changed,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4385
     false if such a file does not exist or change was not allowd."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4386
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4387
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4388
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4389
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4390
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4391
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4392
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4393
    if (__isStringLike(encodedPathName) && __isSmallInteger(modeBits)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4394
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4395
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4396
	    ret = chmod((char *)__stringVal(encodedPathName), __intVal(modeBits));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4397
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4398
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4399
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4400
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4401
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4402
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4403
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4404
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4405
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4406
    ^ self primitiveFailed
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4407
!
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4408
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4409
changeAccessModeOfFd:aFileDescriptor to:modeBits
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4410
    "change the access rights of the file referenced by aFileDescriptor
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4411
     to the OS dependent modeBits.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4412
     You should construct this mask using accessMaskFor, to be OS
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4413
     independent. Return true if changed,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4414
     false if such a file does not exist or change was not allowd."
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4415
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4416
%{
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4417
    int ret;
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4418
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4419
    if (__isSmallInteger(aFileDescriptor) && __isSmallInteger(modeBits)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4420
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4421
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4422
	    ret = fchmod(__smallIntegerVal(aFileDescriptor), __intVal(modeBits));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4423
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4424
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4425
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4426
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4427
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4428
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4429
	RETURN ( true );
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4430
    }
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4431
%}.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  4432
    ^ self primitiveFailed
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4435
!UnixOperatingSystem class methodsFor:'file locking'!
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
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4438
   "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
  4439
    (such as returned by ExternalStream>>fileDescriptor).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4440
    On some systems, only advisory locks are available -
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4441
    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
  4442
    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
  4443
    (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
  4444
    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
  4445
    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
  4446
    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
  4447
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4448
    Returns true, if the lock was aquired, false otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4449
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4450
    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
  4451
    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
  4452
    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
  4453
    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
  4454
    argument."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4455
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4456
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4457
    if (__isSmallInteger(aFileDescriptor)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4458
	int fd = __intVal(aFileDescriptor);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4459
	int lockArg;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4460
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4461
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4462
	 * claus: sigh - each one has a different interface ...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4463
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4464
#if defined(F_SETLK)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4465
	{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4466
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4467
	     * new fcntl(SETLK) interface;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4468
	     * available on SYSV4 and Linux
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4469
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4470
	    struct flock flock;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4471
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4472
	    if (isSharedReadLock == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4473
		flock.l_type = F_RDLCK;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4474
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4475
		flock.l_type = F_WRLCK;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4476
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4477
	    flock.l_whence = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4478
	    flock.l_start = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4479
	    flock.l_len = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4480
	    lockArg = F_SETLK;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4481
# if defined(F_SETLKW)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4482
	    if (blockIfLocked == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4483
		lockArg = F_SETLKW;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4484
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4485
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4486
	    if (fcntl(fd, lockArg, &flock) != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4487
		RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4488
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4489
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4490
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4491
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4492
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4493
# if defined(LOCK_EX) && defined(LOCK_UN)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4494
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4495
	 * BSD 4.3 advisory locks
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4496
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4497
	lockArg = LOCK_EX;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4498
#  if defined(LOCK_SH)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4499
	if (isSharedReadLock == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4500
	    lockArg = LOCK_SH
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4501
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4502
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4503
#  if defined(LOCK_NB)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4504
	if (blockIfLocked == false) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4505
	    lockArg |= LOCK_NB;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4506
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4507
#  endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4508
	if (flock(fd, lockArg) != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4509
	    RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4510
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4511
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4512
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4513
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4514
#  if defined(F_LOCK) && defined(F_UNLOCK)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4515
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4516
	 * SYSV3 advisory locks
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4517
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4518
	if (lockf(fd, F_LOCK, 0) != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4519
	    RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4520
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4521
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4522
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4523
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4524
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4525
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4526
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4527
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4528
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4529
supportsFileLinks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4530
    "return true, if the OS supports file links (hard links).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4531
     Typically, only unix returns true here."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4532
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4533
    ^ true
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4534
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4535
    "Modified: / 5.6.1998 / 18:35:01 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4536
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4537
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4538
supportsFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4539
    "return true, if the OS supports file locking"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4540
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4541
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4542
#if defined(F_SETLK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4543
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4544
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4545
# if defined(LOCK_EX) && defined(LOCK_UN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4546
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4547
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4548
#  if defined(F_LOCK) && defined(F_UNLOCK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4549
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4550
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4551
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4552
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4553
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4554
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4555
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4556
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4557
     OperatingSystem supportsFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4558
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4559
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4560
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4561
supportsNonBlockingFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4562
    "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
  4563
     (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
  4564
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4565
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4566
#if defined(F_SETLK) && defined(F_SETLKW)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4567
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4568
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4569
# if defined(LOCK_EX) && defined(LOCK_UN) && defined(LOCK_NB)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4570
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4571
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4572
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4573
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4574
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4575
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4576
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4577
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4578
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4579
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4580
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4581
supportsSharedLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4582
    "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
  4583
     file locking."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4584
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4585
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4586
#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
  4587
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4588
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4589
# 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
  4590
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4591
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4592
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4593
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4594
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4595
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4596
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4597
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4598
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4599
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4600
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4601
unlockFD:aFileDescriptor
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4602
    "clear a file lock on the file represented by aFileDescriptor,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4603
     which was previously aquired by #lockFD:.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4604
     Return false, if the unlock failed
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4605
     (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
  4606
      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
  4607
     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
  4608
     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
  4609
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4610
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4611
    if (__isSmallInteger(aFileDescriptor)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4612
	int fd = __intVal(aFileDescriptor);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4613
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4614
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4615
	 * claus: sigh - each one has a different interface ...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4616
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4617
#if defined(F_SETLK)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4618
	{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4619
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4620
	     * new fcntl(SETLK) interface;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4621
	     * available on SYSV4 and Linux
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4622
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4623
	    struct flock flock;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4624
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4625
	    flock.l_type = F_UNLCK;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4626
	    flock.l_whence = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4627
	    flock.l_start = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4628
	    flock.l_len = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4629
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4630
		RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4631
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4632
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4633
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4634
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4635
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4636
# if defined(LOCK_EX) && defined(LOCK_UN)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4637
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4638
	 * BSD 4.3 advisory locks
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4639
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4640
	if (flock(fd, LOCK_UN) != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4641
	    RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4642
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4643
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4644
# else /* no flock available */
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 defined(F_LOCK) && defined(F_UNLOCK)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4647
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4648
	 * SYSV3 advisory locks
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4649
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4650
	if (lockf(fd, F_UNLOCK, 0) != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4651
	    RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4652
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4653
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4654
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4655
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4656
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4657
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4658
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4659
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4660
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4661
!UnixOperatingSystem class methodsFor:'file queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4662
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4663
caseSensitiveFilenames
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4664
    "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
  4665
     On MSDOS, this will return false;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4666
     on a real OS, we return true."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4667
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  4668
    "/ actually, this is wrong and may depend on the mounted volume;
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  4669
    "/ 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
  4670
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4671
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4672
    "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
  4673
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4674
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4675
compressPath:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4676
    "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
  4677
     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
  4678
     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
  4679
     if realPath and popen failed."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4680
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4681
    |names n "{ Class: SmallInteger }" |
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4682
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4683
    names := pathName
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4684
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4685
    names := names asOrderedCollection.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4686
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4687
     cut off initial double-slashes
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4688
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4689
    [names startsWith:#('' '')] whileTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4690
	names removeFirst.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4691
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4692
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4693
     cut off double-slashes at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4694
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4695
    [names endsWith:#('')] whileTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4696
	names removeLast.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4697
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4698
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4699
     cut off current-dir at beginning
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
    n := names size.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4702
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4703
	names removeFirst.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4704
	n := n - 1.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4705
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4706
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4707
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4708
     cut off parent-dirs at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4709
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4710
    [(n > 2)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4711
     and:[(names endsWith:#('..'))
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4712
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4713
	names removeLast; removeLast.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4714
	n := n - 2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4715
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4716
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4717
    ^ names asStringWith:self fileSeparator
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4718
		    from:1
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4719
		    to:n
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4720
		    compressTabs:false final:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4721
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4722
    "
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4723
     OperatingSystem compressPath:'./..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4724
     OperatingSystem compressPath:'/foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4725
     OperatingSystem compressPath:'foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4726
     OperatingSystem compressPath:'foo/bar/baz/../'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4727
     OperatingSystem compressPath:'foo/bar/baz/..///'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4728
     OperatingSystem compressPath:'///foo/bar/baz/..///'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4729
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4730
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4731
    "Modified: 1.11.1996 / 20:13:48 / cg"
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4734
fileSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4735
    "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
  4736
     This character differs for MSDOS and other systems,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4737
     (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
  4738
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4739
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4740
    ^ $/
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4741
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4742
    "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
  4743
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4744
13110
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4745
getCurrentDirectory
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4746
    "return the name of the current directory"
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4747
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4748
    |path|
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4749
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  4750
    path := self decodePath:self primGetCurrentDirectory.
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4751
    CurrentDirectory := path.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4752
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4753
    ^ path.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4754
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4755
    "
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4756
	self getCurrentDirectory
13110
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4757
    "
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4758
!
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4759
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4760
getDiskInfoOf:aDirectoryPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4761
    "return some disk info.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4762
     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
  4763
     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
  4764
     On unix, the information returned is (at least):
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4765
	freeBytes
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4766
	totalBytes
16580
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4767
    "
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4768
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4769
    |outputText keys values n info
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4770
     fileSystemIdx sizeIdx usedIdx availIdx capacityIdx mountIdx|
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4771
16580
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4772
    outputText := PipeStream outputFromCommand:('df -k ' , aDirectoryPath).
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4773
    outputText isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4774
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4775
    outputText := outputText asCollectionOfLines.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4776
    outputText size < 2 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4777
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4778
    keys := (outputText at:1) asLowercase asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4779
    values := (outputText at:2) asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4780
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4781
    "/ 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
  4782
    "/ on some rude Unix versions ...
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4783
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4784
    fileSystemIdx := 1.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4785
    sizeIdx := 2.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4786
    usedIdx := 3.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4787
    availIdx := 4.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4788
    capacityIdx := 5.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4789
    mountIdx := 6.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4790
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4791
    values size < 6 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4792
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4793
    info := IdentityDictionary new.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4794
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4795
    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
  4796
    n notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4797
	info at:#percentUsed put:n
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4798
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4799
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4800
    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
  4801
    n notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4802
	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
  4803
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4804
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4805
    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
  4806
    n notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4807
	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
  4808
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4809
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4810
    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
  4811
    n notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4812
	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
  4813
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4814
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4815
    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
  4816
    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
  4817
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4818
    ^ info
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4819
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4820
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4821
     OperatingSystem getDiskInfoOf:'/'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4822
     OperatingSystem getDiskInfoOf:'.'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4823
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4824
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4825
    "Modified: / 22.5.1999 / 00:32:13 / cg"
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4826
!
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4827
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4828
getDriveList
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4829
    "return a list of volumes in the system.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4830
     On unix, no such thing like a volume exists
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4831
     - there, a synthetic list with root, home & current is returned.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4832
     On MSDOS, a list of drive letters is returned.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4833
     On VMS, a list of volumes is returned."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4834
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4835
    "/
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4836
    "/ default: return array filled with
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4837
    "/ root, home and current directories.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4838
    "/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4839
    ^ Array
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4840
	with:'/'
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4841
	with:(self getHomeDirectory)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4842
	with:(Filename currentDirectory pathName)
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4843
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4844
    "Modified: / 5.6.1998 / 18:35:35 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4845
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4846
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4847
getMountedVolumes
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4848
    "return info about mounted volumes.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4849
     The amount of information returned depends upon the OS, and is
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4850
     not guaranteed to be consistent across architectures.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4851
     On unix, the information returned is (at least):
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4852
	mountPoint - mount point
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4853
	fileSystem - device or NFS-remotePath
16580
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4854
    "
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4855
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4856
    |outputText keys values info infoEntry|
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4857
3ce6c6d0fac2 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16536
diff changeset
  4858
    outputText := PipeStream outputFromCommand:('df -k').
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4859
    outputText isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4860
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4861
    outputText := outputText asCollectionOfLines.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4862
    outputText size < 2 ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4863
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4864
    keys := (outputText at:1) asLowercase asCollectionOfWords.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4865
    "/ we may have to validate the following column indices
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4866
    "/ on some rude Unix versions ...
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4867
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4868
    info := OrderedCollection new.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4869
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4870
    outputText from:2 do:[:line |
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4871
	values := line asCollectionOfWords.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4872
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4873
	values size >= 2 ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4874
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4875
	    infoEntry := IdentityDictionary new.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4876
	    infoEntry at:#mountPoint put:(values last).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4877
	    infoEntry at:#fileSystem put:(values first).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4878
	    info add:infoEntry.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4879
	]
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4880
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4881
    ^ info
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4882
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4883
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4884
     OperatingSystem getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4885
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4886
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4887
    "Modified: / 22.5.1999 / 00:32:13 / cg"
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4888
!
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4889
4201
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4890
getNullDevice
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4891
    "return the name of the OS's null device"
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4892
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4893
    ^ '/dev/null'
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4894
!
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4895
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4896
getObjectFileInfoFor:aStringOrFilename
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4897
    "Return and info object for given executable or shared object
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4898
     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
  4899
     shared object.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4900
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4901
     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
  4902
     least
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  4903
	#isFor32BitArchitecture
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  4904
	#isFor64BitArchitecture ... returns true, if the given object is for
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  4905
				     32bit, 64bit architecture respectively
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4906
    "
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4907
    ^ ELFFileHeader fromFile: aStringOrFilename
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4908
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4909
    "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
  4910
!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
  4911
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4912
infoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4913
    "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
  4914
     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
  4915
     the returned object) is:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4916
	 type            - a symbol giving the files type
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4917
	 mode            - numeric access mode
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4918
	 uid             - owners user id
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4919
	 gid             - owners group id
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4920
	 size            - files size
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4921
	 id              - files number (i.e. inode number)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4922
	 accessed        - last access time (as Timestamp)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4923
	 modified        - last modification time (as Timestamp)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4924
	 statusChanged   - last status change time (as Timestamp)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4925
	 alternativeName     - (windows only:) the MSDOS name of the file
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4926
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4927
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4928
	 recordAttributes    - (VMS only:) recordAttributes
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4929
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4930
	 recordSize          - (VMS only:) record size.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4931
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4932
     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
  4933
     all of the information.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4934
     Return nil if such a file does not exist.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4935
     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
  4936
     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
  4937
     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
  4938
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4939
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4940
    |type mode uid gid size id nLink aOStime mOStime cOStime error encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4941
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4942
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4943
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4944
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4945
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4946
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4947
    if (!__isStringLike(encodedPathName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4948
	error = @symbol(badArgument);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4949
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4950
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4951
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4952
# ifdef TRACE_STAT_CALLS
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4953
    printf("stat on '%s' for info\n", __stringVal(aPathName));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4954
# endif
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4955
    __BEGIN_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4956
    do {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4957
	ret = stat((char *) __stringVal(encodedPathName), &buf);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4958
    } while ((ret < 0) && (errno == EINTR));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4959
    __END_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4960
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4961
    if (ret < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4962
	error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4963
	@global(LastErrorNumber) = error;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4964
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4965
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4966
    switch (buf.st_mode & S_IFMT) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4967
	case S_IFDIR:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4968
	    type = @symbol(directory);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4969
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4970
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4971
	case S_IFREG:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4972
	    type = @symbol(regular);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4973
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4974
# ifdef S_IFCHR
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4975
	case S_IFCHR:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4976
	    type = @symbol(characterSpecial);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4977
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4978
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4979
# ifdef S_IFBLK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4980
	case S_IFBLK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4981
	    type = @symbol(blockSpecial);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4982
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4983
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4984
# ifdef S_IFMPC
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4985
	case S_IFMPC:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4986
	    type = @symbol(multiplexedCharacterSpecial);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4987
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4988
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4989
# ifdef S_IFMPB
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4990
	case S_IFMPB:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4991
	    type = @symbol(multiplexedBlockSpecial);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4992
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4993
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4994
# ifdef S_IFLNK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4995
	case S_IFLNK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4996
	    type = @symbol(symbolicLink);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  4997
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4998
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4999
# ifdef S_IFSOCK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5000
	case S_IFSOCK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5001
	    type = @symbol(socket);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5002
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5003
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5004
# ifdef S_IFIFO
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5005
	case S_IFIFO:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5006
	    type = @symbol(fifo);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5007
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5008
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5009
	default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5010
	    type = @symbol(unknown);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5011
	    break;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5012
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5013
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5014
    if (sizeof(buf.st_ino) == 8) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5015
	id = __MKUINT64(&buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5016
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5017
	id = __MKUINT(buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5018
    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5019
    mode = __mkSmallInteger(buf.st_mode & 0777);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5020
    uid = __mkSmallInteger(buf.st_uid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5021
    gid = __mkSmallInteger(buf.st_gid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5022
    nLink = __mkSmallInteger(buf.st_nlink);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5023
    if (sizeof(buf.st_size) == 8) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5024
	size = __MKINT64(&buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5025
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5026
	size = __MKINT(buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5027
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5028
    aOStime = __MKUINT(buf.st_atime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5029
    mOStime = __MKUINT(buf.st_mtime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5030
    cOStime = __MKUINT(buf.st_ctime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5031
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5032
    out:;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5033
%}.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5034
     mode notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5035
	"/ now done lazy in FileStatusInfo
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5036
	"/ atime := Timestamp fromOSTime:(aOStime * 1000).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5037
	"/ mtime := Timestamp fromOSTime:(mOStime * 1000).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5038
	"/ ctime := Timestamp fromOSTime:(cOStime * 1000).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5039
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5040
	^ FileStatusInfo
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5041
		    type:type
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5042
		    mode:mode
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5043
		    uid:uid
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5044
		    gid:gid
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5045
		    size:size
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5046
		    id:id
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5047
		    accessed:aOStime
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5048
		    modified:mOStime
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5049
		    statusChanged:cOStime
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5050
		    sourcePath:nil targetPath:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5051
		    numLinks:nLink.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5052
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5053
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5054
	^ nil.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5055
    ].
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5056
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5057
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5058
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5059
   "
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5060
    OperatingSystem infoOf:'/ccccccc'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5061
    (OperatingSystem infoOf:'/') uid
7889
5e96f8cdf9aa Fix comment
Stefan Vogel <sv@exept.de>
parents: 7886
diff changeset
  5062
    (OperatingSystem infoOf:'/') accessTime
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5063
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5064
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5065
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5066
isDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5067
    "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
  5068
     (i.e. exists and is a directory).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5069
     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
  5070
     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
  5071
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5072
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5073
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5074
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5075
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5076
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5077
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5078
    if (encodedPathName.isStringLike()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5079
	java.io.File file = new java.io.File( encodedPathName.asString() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5080
	int _mode;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5081
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5082
	if (file.exists() && file.isDirectory()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5083
	    return __c__._RETURN_true();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5084
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5085
	return __c__._RETURN_false();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5086
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5087
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5088
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5089
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5090
    if (__isStringLike(encodedPathName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5091
	struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5092
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5093
# ifdef TRACE_STAT_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5094
	printf("stat on '%s' for isDirectory\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5095
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5096
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5097
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5098
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5099
	} while ((ret < 0) && (errno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5100
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5101
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5102
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5103
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5104
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5105
	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
  5106
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5107
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5108
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5109
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5110
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5111
    "an alternative implementation would be:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5112
	^ (self infoOf:aPathName) type == #directory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5113
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5114
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5115
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5116
isExecutable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5117
    "return true, if the given file is executable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5118
     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
  5119
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5120
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5121
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5122
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5123
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5124
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5125
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5126
    if (encodedPathName.isStringLike()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5127
	java.io.File file = new java.io.File( encodedPathName.asString() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5128
	int _mode;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5129
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5130
	if (file.exists() && file.canExecute()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5131
	    return __c__._RETURN_true();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5132
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5133
	return __c__._RETURN_false();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5134
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5135
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5136
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5137
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5138
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5139
# ifdef TRACE_ACCESS_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5140
	printf("access on '%s' for executable\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5141
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5142
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5143
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5144
	    ret = access(__stringVal(encodedPathName), X_OK);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5145
	} while ((ret < 0) && (errno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5146
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5147
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5148
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5149
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5150
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5151
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5152
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5153
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5154
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5155
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5156
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5157
isReadable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5158
    "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
  5159
     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
  5160
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5161
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5162
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5163
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5164
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5165
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5166
    if (encodedPathName.isStringLike()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5167
	java.io.File file = new java.io.File( encodedPathName.asString() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5168
	int _mode;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5169
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5170
	if (file.exists() && file.canRead()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5171
	    return __c__._RETURN_true();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5172
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5173
	return __c__._RETURN_false();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5174
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5175
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5176
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5177
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5178
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5179
# ifdef TRACE_ACCESS_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5180
	printf("access on '%s' for readable\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5181
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5182
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5183
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5184
	    ret = access(__stringVal(encodedPathName), R_OK);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5185
	} while ((ret < 0) && (errno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5186
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5187
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5188
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5189
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5190
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5191
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5192
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5193
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5194
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5195
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5196
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5197
isValidPath:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5198
    "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
  5199
     (i.e. the file or directory exists)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5200
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5201
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5202
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5203
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5204
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5205
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5206
    if (encodedPathName.isStringLike()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5207
	java.io.File file = new java.io.File( encodedPathName.asString() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5208
	int _mode;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5209
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5210
	if (file.exists()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5211
	    return __c__._RETURN_true();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5212
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5213
	return __c__._RETURN_false();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5214
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5215
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5216
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5217
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5218
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5219
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5220
# ifdef TRACE_STAT_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5221
	printf("stat on '%s' for isValidPath\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5222
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5223
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5224
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5225
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5226
	} while ((ret < 0) && (errno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5227
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5228
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5229
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5230
	    RETURN (false);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5231
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5232
	RETURN ( ret ? false : true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5233
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5234
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5235
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5236
    ^ self primitiveFailed
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5237
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5238
"/ alternative:
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5239
"/        ^ (self infoOf:aPathName) notNil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5240
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5241
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5242
isWritable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5243
    "return true, if the given file is writable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5244
     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
  5245
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5246
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5247
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5248
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5249
%{
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5250
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5251
    if (encodedPathName.isStringLike()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5252
	java.io.File file = new java.io.File( encodedPathName.asString() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5253
	int _mode;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5254
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5255
	if (file.exists() && file.canWrite()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5256
	    return __c__._RETURN_true();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5257
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5258
	return __c__._RETURN_false();
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5259
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5260
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5261
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5262
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5263
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5264
# ifdef TRACE_ACCESS_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5265
	printf("access on '%s' for writable\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5266
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5267
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5268
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5269
	    ret = access(__stringVal(encodedPathName), W_OK);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5270
	} while ((ret < 0) && (errno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5271
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5272
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5273
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5274
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5275
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5276
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5277
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5278
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5279
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5280
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5281
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5282
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
  5283
    "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
  5284
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5285
     The info (for which corresponding access methods are understood by
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5286
     the returned object) is:
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5287
	 type            - a symbol giving the file's type
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5288
	 mode            - numeric access mode
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5289
	 uid             - owners user id
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5290
	 gid             - owners group id
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5291
	 size            - files size
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5292
	 id              - files number (i.e. inode number)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5293
	 accessed        - last access time (as Timestamp)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5294
	 modified        - last modification time (as Timestamp)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5295
	 statusChanged   - last status change time (as Timestamp)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5296
	 alternativeName     - (windows only:) the MSDOS name of the file
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5297
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5298
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5299
	 recordAttributes    - (VMS only:) recordAttributes
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5300
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5301
	 recordSize          - (VMS only:) record size.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5302
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5303
     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
  5304
     all of the information.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5305
15250
c73ad268f7f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15234
diff changeset
  5306
     If aPathName is invalid, nil is returned.
c73ad268f7f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15234
diff changeset
  5307
     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
  5308
     (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
  5309
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5310
     Return the info about the link itself,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5311
     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
  5312
     in case of a symbolic link."
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5313
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5314
    |type mode uid gid size id nLink aOStime mOStime cOStime path encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5315
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5316
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5317
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5318
%{  /* STACK: 1200 */
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5319
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5320
    if (encodedPathName.isStringLike()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5321
	java.io.File file = new java.io.File( encodedPathName.asString() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5322
	int _mode;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5323
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5324
	if (file.isDirectory()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5325
	    type = STSymbol._new("directory");
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5326
	} else if (file.isFile()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5327
	    type = STSymbol._new("regular");
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5328
	} else {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5329
	    type = STSymbol._new("unknown");
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5330
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5331
	_mode = 0;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5332
	if (file.canRead()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5333
	    _mode |= 0444;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5334
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5335
	if (file.canWrite()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5336
	    _mode |= 0222;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5337
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5338
	if (file.canExecute()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5339
	    _mode |= 0111;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5340
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5341
	mode = STInteger._new( _mode );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5342
	uid = STInteger._0;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5343
	gid = STInteger._0;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5344
	nLink = STInteger._0;
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5345
	size = STInteger._new( file.length());
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5346
	aOStime = STInteger._new( file.lastModified() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5347
	mOStime = STInteger._new( file.lastModified() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5348
	cOStime = STInteger._new( file.lastModified() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5349
	path = new STString( file.getPath() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5350
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5351
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5352
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5353
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5354
    char pathBuffer[1024];
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  5355
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5356
    if (__isStringLike(encodedPathName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5357
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5358
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5359
	    ret = lstat((char *) __stringVal(encodedPathName), &buf);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5360
	} while ((ret < 0) && (errno == EINTR));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5361
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5362
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5363
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5364
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5365
	    RETURN ( nil );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5366
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5367
	switch (buf.st_mode & S_IFMT) {
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5368
# ifdef S_IFLNK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5369
	    case S_IFLNK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5370
		type = @symbol(symbolicLink);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5371
		if ((ret = readlink((char *) __stringVal(encodedPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5372
		    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5373
		    RETURN ( nil );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5374
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5375
		pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5376
		path = __MKSTRING(pathBuffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5377
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5378
# endif
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5379
	    case S_IFDIR:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5380
		type = @symbol(directory);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5381
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5382
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5383
	    case S_IFREG:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5384
		type = @symbol(regular);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5385
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5386
# ifdef S_IFCHR
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5387
	    case S_IFCHR:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5388
		type = @symbol(characterSpecial);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5389
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5390
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5391
# ifdef S_IFBLK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5392
	    case S_IFBLK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5393
		type = @symbol(blockSpecial);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5394
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5395
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5396
# ifdef S_IFMPC
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5397
	    case S_IFMPC:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5398
		type = @symbol(multiplexedCharacterSpecial);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5399
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5400
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5401
# ifdef S_IFMPB
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5402
	    case S_IFMPB:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5403
		type = @symbol(multiplexedBlockSpecial);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5404
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5405
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5406
# ifdef S_IFSOCK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5407
	    case S_IFSOCK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5408
		type = @symbol(socket);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5409
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5410
# endif
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5411
# ifdef S_IFIFO
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5412
	    case S_IFIFO:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5413
		type = @symbol(fifo);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5414
		break;
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5415
# endif
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5416
	    default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5417
		type = @symbol(unknown);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5418
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5419
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5420
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5421
	if (sizeof(buf.st_ino) == 8) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5422
	    id = __MKUINT64(&buf.st_ino);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5423
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5424
	    id = __MKUINT(buf.st_ino);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5425
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5426
	mode = __mkSmallInteger(buf.st_mode & 0777);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5427
	uid = __mkSmallInteger(buf.st_uid);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5428
	gid = __mkSmallInteger(buf.st_gid);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5429
	nLink = __mkSmallInteger(buf.st_nlink);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5430
	if (sizeof(buf.st_size) == 8) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5431
	    size = __MKINT64(&buf.st_size);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5432
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5433
	    size = __MKINT(buf.st_size);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5434
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5435
	aOStime = __MKUINT(buf.st_atime);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5436
	mOStime = __MKUINT(buf.st_mtime);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5437
	cOStime = __MKUINT(buf.st_ctime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5438
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5439
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5440
%}.
14563
466905625978 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14435
diff changeset
  5441
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5442
    mode notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5443
	^ FileStatusInfo
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5444
	    type:type
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5445
	    mode:mode
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5446
	    uid:uid
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5447
	    gid:gid
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5448
	    size:size
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5449
	    id:id
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5450
	    accessed:aOStime
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5451
	    modified:mOStime
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5452
	    statusChanged:cOStime
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5453
	    sourcePath:aPathName targetPath:(self decodePath:path)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5454
	    numLinks:nLink.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5455
   ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5456
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5457
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5458
   "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5459
    OperatingSystem infoOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5460
    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
  5461
    OperatingSystem linkInfoOf:'/usr/tmp'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5462
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5463
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5464
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5465
mountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5466
    "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
  5467
     As this might be expensive on some systems,
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5468
     the info is cached for some time (5 minutes)"
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5469
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5470
    CacheMountPointsTimeStamp notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5471
	Timestamp now < (CacheMountPointsTimeStamp addSeconds:5*60) ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5472
	    ^ CachedMountPoints
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5473
	].
8735
531252ebbbe3 Fix a race in #mountPoints
Stefan Vogel <sv@exept.de>
parents: 8705
diff changeset
  5474
    ].
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5475
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5476
    '/proc/mounts' asFilename exists ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5477
	CachedMountPoints := self mountPointsFromProcFS.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5478
	CacheMountPointsTimeStamp := Timestamp now.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5479
	^ CachedMountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5480
    ].
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5481
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  5482
    "/ 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
  5483
    ^ #()
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5484
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5485
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5486
     OperatingSystem mountPoints
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5487
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5488
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  5489
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5490
parentDirectoryName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5491
    "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
  5492
     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
  5493
     for other systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5494
     (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
  5495
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5497
    ^ '..'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5498
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5499
16678
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5500
pathNameForDrive:driveName
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5501
    "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
  5502
     For Windows, this is the driveName itself.
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5503
     For OSX, '/Volumes' is prepended.
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5504
     Other OSs might prepent the pount point (i.e. /mnt/)"
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5505
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5506
    ^ driveName
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5507
!
125c0b557cb0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16674
diff changeset
  5508
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5509
pathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5510
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5511
     - thats the full pathname of the directory, starting at '/'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5512
     This method needs the path to be valid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5513
     (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
  5514
     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
  5515
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5516
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5517
    |p path command|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5518
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5519
    path = '.' ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5520
	^ self getCurrentDirectory.
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5521
    ].
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5522
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5523
    "some systems have a convenient function for this ..."
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5524
    path := self primPathNameOf:(self encodePath:pathName).
14575
c696ca8d05bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14568
diff changeset
  5525
    path notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5526
	path := self decodePath:path.
14575
c696ca8d05bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14568
diff changeset
  5527
    ] ifFalse:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5528
	(self isValidPath:pathName) ifFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5529
	    p := pathName.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5530
	    [(p size > 1)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5531
	     and:[p endsWith:(self fileSeparator)]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5532
	    ] whileTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5533
		p := p copyButLast.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5534
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5535
	    ^ p
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5536
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5537
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5538
	(SlowFork==true or:[PipeFailed==true]) ifFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5539
	    |directoryName fileBaseName|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5540
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5541
	    (self isDirectory:pathName) ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5542
		directoryName := pathName.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5543
		fileBaseName := nil.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5544
	    ] ifFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5545
		|pathFilename|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5546
		pathFilename := pathName asFilename.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5547
		directoryName := pathFilename directoryName.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5548
		fileBaseName := pathFilename baseName.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5549
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5550
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5551
	    PipeStream openErrorSignal handle:[:ex |
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5552
		PipeFailed := true.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5553
		'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5554
		ex return.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5555
	    ] do:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5556
		"have to fall back ..."
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5557
		command := 'cd "' , directoryName , '"; pwd'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5558
		p := PipeStream readingFrom:command.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5559
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5560
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5561
	    (p isNil or:[p atEnd]) ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5562
		('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5563
	    ] ifFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5564
		path := p nextLine.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5565
		p close.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5566
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5567
	    fileBaseName notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5568
		path := path, '/', fileBaseName.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5569
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5570
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5571
	path isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5572
	    "/
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5573
	    "/ return the original - there is nothing else can we do
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5574
	    "/
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5575
	    path := pathName
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5576
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5577
	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5578
	    path := self compressPath:path
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5579
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5580
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5581
    ^ path.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5582
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5583
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5584
     OperatingSystem pathNameOf:'.'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5585
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5586
     OperatingSystem pathNameOf:'../../..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5587
     OperatingSystem pathNameOf:'..'
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5588
     OperatingSystem pathNameOf:'/tmp////'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5589
     OperatingSystem pathNameOf:'/foo/bar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5590
     OperatingSystem pathNameOf:'/foo/bar/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5591
     OperatingSystem pathNameOf:'/foo/bar//'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5592
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5593
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5594
    "Modified: / 29.11.1996 / 18:02:12 / stefan"
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5595
    "Modified: / 5.6.1998 / 18:37:15 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5596
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5597
14584
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5598
primGetCurrentDirectory
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5599
    "return the name of the current directory"
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5600
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5601
    |path|
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5602
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5603
%{  /* UNLIMITEDSTACK */
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5604
	char nameBuffer[MAXPATHLEN + 1];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5605
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5606
	if (getcwd(nameBuffer, MAXPATHLEN)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5607
	    path = __MKSTRING(nameBuffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5608
	    RETURN(path);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5609
	}
14584
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5610
%}.
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5611
    ^ self primitiveFailed.
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5612
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5613
    "
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5614
	self primGetCurrentDirectory
14584
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5615
    "
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5616
!
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  5617
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5618
primIdOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5619
    "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
  5620
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5621
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5622
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5623
    encodedPathName := self encodePath:aPathName.
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  5624
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5625
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5626
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5627
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5628
    OBJ retVal;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5629
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5630
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5631
# ifdef TRACE_STAT_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5632
	printf("stat on '%s' for id\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5633
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5634
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5635
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5636
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5637
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5638
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5639
	if (ret >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5640
	    ino = buf.st_ino;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5641
	    retVal = __MKUINT(ino);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5642
	    RETURN (retVal);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5643
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5644
	@global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5645
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5646
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5647
    RETURN (nil);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5648
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5649
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5650
5492
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5651
primInfoOf:aPathName
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5652
   "for rel5 only"
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5653
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5654
   ^ self primitiveFailed
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5655
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5656
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5657
!
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5658
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5659
primPathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5660
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5661
     - thats the full pathname of the directory, starting at '/'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5662
     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
  5663
     realPath library function.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5664
     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
  5665
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5666
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5667
    |error|
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5668
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  5669
%{  /* UNLIMITEDSTACK */
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5670
#ifdef __SCHTEAM__
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5671
    if (pathName.isStringLike()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5672
	java.io.File file = new java.io.File( pathName.asString() );
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5673
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5674
	if (file.exists()) {
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5675
	    return __c__._RETURN( new STString( file.getAbsolutePath() ));
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5676
	}
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5677
    }
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5678
#else
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5679
    if (__isStringLike(pathName)) {
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5680
# ifdef HAS_REALPATH
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5681
	extern char *realpath();
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5682
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5683
	// POSIX-2008 says, that a NULL namebuffer causes realPath to malloc()
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5684
	// the required memory. But this does not work as of 2013-04
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5685
	char nameBuffer[MAXPATHLEN+1];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5686
	char *nameP = realpath(__stringVal(pathName), nameBuffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5687
	if (nameP) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5688
	    OBJ ret = __MKSTRING(nameP);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5689
	    // free(nameP);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5690
	    RETURN ( ret );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5691
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5692
	// 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
  5693
# endif /* ! HAS_REALPATH */
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5694
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5695
	error = @symbol(argument);     // argument is not a string
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5696
    }
18348
0a18d8774d96 comments only
Claus Gittinger <cg@exept.de>
parents: 18314
diff changeset
  5697
#endif
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5698
%}.
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5699
"/ Does not work as of 2013-04 (UNLIMITEDSTACK problem?)
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5700
"/    error notNil ifTrue:[
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5701
"/        ^ self primitiveFailed:error.
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5702
"/    ].
5451
2e21cd54b656 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5448
diff changeset
  5703
    ^ nil
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5704
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5705
    "
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5706
	self primPathNameOf:'.'
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5707
	self primPathNameOf:'/murks/quatsch/bla/.'
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5708
	self primPathNameOf:5555
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  5709
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5710
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5711
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5712
timeOfLastAccess:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5713
    "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
  5714
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5715
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5716
    "could be implemented as:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5717
	(self infoOf:aPathName) accessed
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5718
    "
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5719
    |osSeconds i encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5720
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5721
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5722
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5723
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5724
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5725
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5726
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5727
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5728
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5729
# ifdef TRACE_STAT_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5730
	printf("stat on '%s' for timeOfLastAccess\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5731
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5732
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5733
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5734
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5735
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5736
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5737
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5738
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5739
	    RETURN (nil);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5740
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5741
	osSeconds = __MKUINT(buf.st_atime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5742
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5743
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5744
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5745
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5746
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5747
    i notNil ifTrue:[^ i accessed].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5748
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5749
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5750
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5751
     OperatingSystem timeOfLastAccess:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5752
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5753
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5754
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5755
timeOfLastChange:aPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5756
    "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
  5757
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5758
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5759
    "could be implemented as:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5760
	(self infoOf:aPathName) modified
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5761
    "
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5762
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5763
    |osSeconds i encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5764
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5765
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5766
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5767
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5768
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5769
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5770
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5771
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5772
# ifdef TRACE_STAT_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5773
	printf("stat on '%s' for timeOfLastChange\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5774
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5775
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5776
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5777
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5778
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5779
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5780
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5781
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5782
	    RETURN ( nil );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5783
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5784
	osSeconds = __MKUINT(buf.st_mtime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5785
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5786
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5787
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5788
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5789
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5790
    i notNil ifTrue:[^ i modified].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5791
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5792
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5793
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5794
     OperatingSystem timeOfLastChange:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5795
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5796
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5797
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5798
typeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5799
    "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
  5800
     nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5801
     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
  5802
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5803
    |i osSeconds encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5804
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5805
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5806
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5807
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5808
     this could have been implemented as:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5809
	(self infoOf:aPathName) type
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5810
     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
  5811
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5812
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5813
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5814
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5815
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5816
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5817
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5818
# ifdef TRACE_STAT_CALLS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5819
	printf("stat on '%s' for type\n", __stringVal(encodedPathName));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5820
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5821
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5822
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5823
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5824
	} while (ret < 0 && errno == EINTR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5825
	__END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5826
	if (ret < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5827
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5828
	    RETURN ( nil );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5829
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5830
	switch (buf.st_mode & S_IFMT) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5831
	    case S_IFDIR:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5832
		RETURN ( @symbol(directory) );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5833
	    case S_IFREG:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5834
		RETURN ( @symbol(regular) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5835
# ifdef S_IFCHR
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5836
	    case S_IFCHR:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5837
		RETURN ( @symbol(characterSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5838
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5839
# ifdef S_IFBLK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5840
	    case S_IFBLK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5841
		RETURN ( @symbol(blockSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5842
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5843
# ifdef S_IFLNK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5844
	    case S_IFLNK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5845
		RETURN ( @symbol(symbolicLink) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5846
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5847
# ifdef S_IFSOCK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5848
	    case S_IFSOCK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5849
		RETURN ( @symbol(socket) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5850
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5851
# ifdef S_IFIFO
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5852
	    case S_IFIFO:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5853
		RETURN ( @symbol(fifo) );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5854
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5855
	    default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5856
		RETURN ( @symbol(unknown) );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5857
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5858
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5859
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5860
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5861
    i notNil ifTrue:[^ i type].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5862
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5863
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5864
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5865
     OperatingSystem typeOf:'/'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5866
     OperatingSystem typeOf:'.'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5867
     OperatingSystem typeOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5868
     OperatingSystem typeOf:'resources/motif.style'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5869
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5870
!
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
volumeNameOf:aPathString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5873
    "return the volumeName of the argument, aPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5874
     - thats the name of the volume where aPath is.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5875
     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
  5876
     this always returns an empty string."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5877
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5878
    ^ ''
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5879
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5880
    "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
  5881
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5882
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5883
!UnixOperatingSystem class methodsFor:'interrupts & signals'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5884
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5885
defaultSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5886
    "revert to the default action on arrival of a (Unix-)signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5887
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5888
     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
  5889
     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
  5890
     default for SIGQUIT (^ \) is to dump core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5891
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5892
     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
  5893
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5894
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5895
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5896
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5897
    if (__isSmallInteger(signalNumber)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5898
#ifdef SIG_DFL
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5899
	signal(__intVal(signalNumber), SIG_DFL);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5900
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5901
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5902
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5903
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5904
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5905
     this error is triggered on non-integer argument
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5908
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5909
    "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
  5910
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5911
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5912
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5913
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5914
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5915
     'normal ^C handling again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5916
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5917
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5918
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5919
disableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5920
    "turn off IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5921
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5922
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5923
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5924
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5925
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5926
#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
  5927
    if (__isSmallInteger(fd)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5928
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5929
# if defined(SYSV4)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5930
	ret = ioctl(f, I_SETSIG, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5931
# else /*! SYSV4*/
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5932
	flags = fcntl(f, F_GETFL, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5933
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5934
	 * if already clear, there is no need for this syscall ...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5935
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5936
	if (flags & FASYNC) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5937
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5938
	    if (ret >= 0) ret = flags;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5939
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5940
	    ret = flags;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5941
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5942
# endif /* !SYSV4 */
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5943
	RETURN ( __mkSmallInteger(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5944
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5945
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5946
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5947
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5948
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5949
     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
  5950
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5951
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5952
!
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
disableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5955
    "disable (Unix-) signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5956
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5957
     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
  5958
     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
  5959
     handling.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5960
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5961
     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
  5962
     a signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5963
     Use only for fully debugged stand alone applications."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5964
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5965
%{  /* NOCONTEXT */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5966
#ifdef __SCHTEAM__
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5967
    if (signalNumber.isSmallInteger()) {
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5968
	int sigNo = signalNumber.intValue();
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5969
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5970
	if (sigNo != 0) {
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
  5971
	    java.lang.System.err.println("ignored disable-signal: "+sigNo);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5972
	}
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5973
	return context._RETURN(self);
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5974
    }
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5975
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5976
    if (__isSmallInteger(signalNumber)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5977
	int sigNo = __intVal(signalNumber);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5978
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5979
	if (sigNo == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5980
	    RETURN (self);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5981
	}
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5982
# ifdef SIG_IGN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5983
	signal(sigNo, SIG_IGN);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  5984
	RETURN (self);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5985
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5986
    }
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  5987
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5988
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5989
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5990
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5991
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5992
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5993
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5994
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5995
     'now, ^C is totally ignored ...' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5996
     OperatingSystem disableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5997
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5998
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5999
     '^C handled again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6000
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6001
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6003
disableTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6004
    "disable timer interrupts.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6005
     WARNING:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6006
	the system will not operate correctly with timer interrupts
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6007
	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
  6008
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6009
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6011
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6012
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6013
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6014
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6015
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6016
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6017
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6018
    setitimer(ITIMER_REAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6019
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6020
#else
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
# if defined(USE_SLOW_ALARM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6023
#  if defined(SIGALRM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6024
    alarm(0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6025
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6026
#  endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6027
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6028
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6029
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6030
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6031
    ^ false
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
enableChildSignalInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6035
    "enable childSignal interrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6036
     (SIGCHLD, if the architecture supports it).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6037
     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
  6038
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
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
    self enableSignal:(self sigCHLD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6041
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6042
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6043
enableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6044
    "turn on IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6045
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6046
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6047
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6048
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6049
#ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6050
    extern void __signalIoInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6051
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6052
    static int firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6053
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6054
#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
  6055
    /*
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6056
     * 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
  6057
     * (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
  6058
     */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6059
# ifdef SIGIO
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6060
#  define THESIGNAL SIGIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6061
# else
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6062
#  ifdef SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6063
#   define THESIGNAL SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6064
#  else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6065
#   ifdef SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6066
#    define THESIGNAL SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6067
#   endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6068
#  endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6069
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6070
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6071
    if (__isSmallInteger(fd)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6072
	if (firstCall) {
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6073
# ifdef HAS_SIGACTION
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6074
	    struct sigaction act;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6075
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6076
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6077
	     * Do not add SA_RESTART here. A signal can cause a
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6078
	     * thread switch, another thread can do a garbage collect
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6079
	     * and restarted system calls may write into old
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6080
	     * (collected) addresses.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6081
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6082
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6083
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6084
	    sigemptyset(&act.sa_mask);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6085
	    act.sa_handler = __signalIoInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6086
	    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
  6087
# else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6088
#  ifdef HAS_SIGVEC
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6089
	    struct sigvec vec;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6090
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6091
	    vec.sv_flags = SV_INTERRUPT;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6092
	    sigemptyset(&vec.sv_mask);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6093
	    vec.sv_handler = __signalIoInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6094
	    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
  6095
#  else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6096
	    signal(THESIGNAL, __signalIoInterrupt);
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6097
#  endif /* SIGVEC */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6098
# endif /* SIGACTION */
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6099
	    firstCall = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6100
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6101
#undef THESIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6102
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6103
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6104
# if defined(SYSV4)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6105
	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
  6106
# else /*! SYSV4*/
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6107
	flags = fcntl(f, F_GETFL, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6108
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6109
	 * if already set, there is no need for this syscall ...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6110
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6111
	if (flags & FASYNC) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6112
	    ret = flags;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6113
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6114
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6115
	    if (ret >= 0) ret = flags;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6116
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6117
# endif /*!SYSV4*/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6118
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6119
# if defined(F_SETOWN) || defined(FIOSETOWN)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6120
	{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6121
	    int pid;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6122
	    int ok;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6123
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6124
	    pid = getpid();
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6125
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  6126
#  if defined(F_SETOWN)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6127
	    ok = fcntl(f, F_SETOWN, pid);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6128
	    /* 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
  6129
#  else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6130
	    ok = ioctl(f, FIOSETOWN, &pid);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6131
	    /* printf("FIOSETOWN returns %d (%d)\n", ret, errno); */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6132
#  endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6133
	    if (ok < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6134
		ret = ok;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6135
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6136
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6137
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6138
	RETURN ( __MKUINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6139
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6140
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6141
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6142
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6143
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6144
     or if the system does not support SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6145
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6146
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6147
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6148
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6149
enableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6150
    "enable (Unix-)signal processing for signalNumber.
15234
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  6151
     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
  6152
     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
  6153
     (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
  6154
     sends #signalInterrupt:.
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
     NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6157
     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
  6158
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6159
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6160
%{  /* NOCONTEXT */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6161
#ifdef __SCHTEAM__
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6162
    if (signalNumber.isSmallInteger()) {
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6163
	int sigNo = signalNumber.intValue();
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6164
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6165
	if (sigNo != 0) {
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
  6166
	    java.lang.System.err.println("ignored enable-signal: "+sigNo);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6167
	}
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6168
	return context._RETURN(self);
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6169
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6170
#else
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6171
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6172
# ifdef NSIG
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6173
#  define SIG_LIMIT NSIG
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6174
# else
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6175
#  ifdef SIGUSR2
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6176
#   define SIG_LIMIT SIGUSR2
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6177
#  else
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6178
#   ifdef SIGUSR
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6179
#    define SIG_LIMIT SIGUSR
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6180
#   endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6181
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6182
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6183
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6184
# if defined(SIGPOLL) && !defined(SIGIO)
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6185
#  define SIGIO SIGPOLL
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6186
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6187
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6188
# ifdef SIGCHLD
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6189
#  define CHILD_SIGNAL   SIGCHLD
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6190
# else
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6191
#  ifdef SIGCLD
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6192
#   define CHILD_SIGNAL  SIGCLD
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6193
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6194
# endif
3496
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
    int sigNr;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6197
# if defined(SIGINT) || defined(SIGQUIT)
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6198
#  ifndef __signalUserInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6199
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6200
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6201
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6202
# ifdef SIGFPE
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6203
#  ifndef __signalFpExceptionInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6204
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6205
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6206
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6207
# ifdef SIGIO
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6208
#  ifndef __signalIoInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6209
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6210
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6211
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6212
# ifdef CHILD_SIGNAL
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6213
#  ifndef __signalChildInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6214
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6215
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6216
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6217
# ifdef SIGPIPE
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6218
#  ifndef __signalPIPEInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6219
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6220
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6221
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6222
# ifdef SIGBUS
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6223
#  ifndef __signalBUSInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6224
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6225
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6226
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6227
# ifdef SIGSEGV
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6228
#  ifndef __signalSEGVInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6229
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6230
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6231
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6232
# if defined(SIGILL) || defined(SIGEMT)
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6233
#  ifndef __signalTrapInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6234
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6235
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6236
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6237
# ifdef SIGALRM
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6238
#  ifndef __signalTimerInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6239
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6240
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6241
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6242
# ifdef SIGABRT
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6243
#  ifndef __signalAbortInterrupt
15234
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  6244
    extern void __signalAbortInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6245
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6246
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6247
# ifndef __signalInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6248
    extern void __signalInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6249
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6250
    void (*handler)(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6251
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6252
    if (__isSmallInteger(signalNumber)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6253
     && ((sigNr = __intVal(signalNumber)) >= 0)
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6254
# ifdef SIG_LIMIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6255
     &&  (sigNr <= SIG_LIMIT)
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6256
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6257
    ) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6258
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6259
	 * standard signals are forced into standard handlers
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6260
	 * - all others go into general signalInterrupt
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6261
	 */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6262
# if defined(SIGPOLL) && defined(SIGIO)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6263
	if (sigNr == SIGPOLL)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6264
	    sigNr = SIGIO;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6265
# endif
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6266
	switch (sigNr) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6267
	    case 0:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6268
		/* enabling a non-supported signal */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6269
		RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6270
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6271
# ifdef SIGBREAK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6272
	    case SIGBREAK:
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6273
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6274
# ifdef SIGINT
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6275
	    case SIGINT:
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6276
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6277
# ifdef SIGQUIT
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6278
	    case SIGQUIT:
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6279
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6280
# if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6281
		handler = __signalUserInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6282
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6283
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6284
# ifdef SIGFPE
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6285
	    case SIGFPE:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6286
		handler = __signalFpExceptionInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6287
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6288
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6289
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6290
# ifdef SIGPIPE
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6291
	    case SIGPIPE:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6292
		handler = __signalPIPEInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6293
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6294
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6295
# ifdef SIGBUS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6296
	    case SIGBUS:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6297
		handler = __signalBUSInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6298
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6299
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6300
# ifdef SIGSEGV
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6301
	    case SIGSEGV:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6302
		handler = __signalSEGVInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6303
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6304
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6305
# ifdef SIGABRT
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6306
	    case SIGABRT:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6307
		handler = __signalAbortInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6308
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6309
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6310
# ifdef SIGILL
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6311
	    case SIGILL:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6312
		handler = __signalTrapInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6313
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6314
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6315
# ifdef SIGEMT
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6316
	    case SIGEMT:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6317
		handler = __signalTrapInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6318
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6319
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6320
# ifdef SIGIO
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6321
	    case SIGIO:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6322
		handler = __signalIoInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6323
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6324
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6325
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6326
# ifdef CHILD_SIGNAL
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6327
	    case CHILD_SIGNAL:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6328
		handler = __signalChildInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6329
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6330
# endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6331
# ifdef SIGALRM
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6332
	    case SIGALRM:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6333
		handler = __signalTimerInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6334
		break;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6335
# endif
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6336
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6337
	    default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6338
		handler = __signalInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6339
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6340
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6341
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6342
	{
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6343
# ifdef HAS_SIGACTION
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6344
	    struct sigaction act;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6345
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6346
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6347
	     * Do not add SA_RESTART here. A signal can cause a
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6348
	     * thread switch, another thread can do a garbage collect
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6349
	     * and restarted system calls may write into old
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6350
	     * (collected) addresses.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6351
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6352
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6353
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6354
	    sigemptyset(&act.sa_mask);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6355
	    act.sa_handler = handler;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6356
	    sigaction(sigNr, &act, 0);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6357
# else
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6358
#  ifdef HAS_SIGVEC
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6359
	    struct sigvec vec;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6360
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6361
	    vec.sv_flags = SV_INTERRUPT;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6362
	    sigemptyset(&vec.sv_mask);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6363
	    vec.sv_handler = handler;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6364
	    sigvec(sigNr, &vec, NULL);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6365
#  else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6366
	    (void) signal(sigNr, handler);
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
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6369
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6370
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6371
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6372
	 * maybe, we should ret the old enable-status
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6373
	 * as boolean here ...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6374
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6375
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6376
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6377
#endif /* not SCHTEAM */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6378
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6379
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6380
     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
  6381
     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
  6382
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6383
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6384
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6386
enableTimer:milliSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6387
    "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
  6388
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6389
%{  /* NOCONTEXT */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6390
#ifdef __SCHTEAM__
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6391
    if (milliSeconds.isSmallInteger()) {
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6392
	long millis = milliSeconds.longValue();
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6393
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
  6394
	java.lang.System.err.println("ignored enable-timer");
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6395
	return context._RETURN(self);
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6396
    }
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6397
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6398
    int millis;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6399
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6400
    millis = __intVal(milliSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6401
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6402
# ifdef SIGALRM
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6403
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6404
	static int firstCall = 1;
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6405
#  ifndef __signalTimerInterrupt
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6406
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6407
#  endif
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6408
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6409
	if (firstCall) {
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6410
#  ifdef HAS_SIGACTION
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6411
	    struct sigaction act;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6412
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6413
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6414
	    sigemptyset(&act.sa_mask);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6415
	    act.sa_handler = __signalTimerInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6416
	    sigaction(SIGALRM, &act, 0);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6417
#  else
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6418
#   ifdef HAS_SIGVEC
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6419
	    struct sigvec vec;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6420
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6421
	    vec.sv_flags = SV_INTERRUPT;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6422
	    sigemptyset(&vec.sv_mask);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6423
	    vec.sv_handler = __signalTimerInterrupt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6424
	    sigvec(SIGALRM, &vec, NULL);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6425
#   else /* neither SIGACTION nor SIGVEC */
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6426
	    signal(SIGALRM, __signalTimerInterrupt);
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6427
#   endif /* stupid system  */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6428
#  endif
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6429
	    firstCall = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6430
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6431
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6432
# endif /* SIGALRM */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6433
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6434
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6435
# if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6436
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6437
	struct itimerval dt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6438
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6439
	dt.it_interval.tv_sec = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6440
	dt.it_interval.tv_usec = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6441
	dt.it_value.tv_sec = millis / 1000;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6442
	dt.it_value.tv_usec = (millis % 1000) * 1000;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6443
	setitimer(ITIMER_REAL, &dt, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6444
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6445
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6446
# else /* no ITIMER_REAL */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6447
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6448
#  ifdef USE_SLOW_ALARM
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6449
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6450
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6451
	 * last fallback - use alarm (which only gives 1 second resolution).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6452
	 * If the system does not support any of the above, you have to life
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6453
	 * with this. The consequence is that pressing CTRL-C processing and
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6454
	 * thread switching will take place much delayed.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6455
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6456
	alarm(1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6457
	RETURN(true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6458
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6459
#  endif
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6460
# endif /* ITIMER_REAL */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  6461
#endif /* not SCHTEAM */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6462
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6463
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6464
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6465
6536
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6466
isFatalSignal:aNumber
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6467
   "return true if a signal with number aNumber is a fatal signal,
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6468
    i.e. some severe internal error occured"
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6469
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6470
   ^ (aNumber == self sigSEGV)
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6471
     or:[aNumber == self sigILL
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6472
     or:[aNumber == self sigBUS]]
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6473
!
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6474
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6475
killProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6476
    "kill a unix process.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6477
     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
  6478
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6479
     WARNING: in order to avoid zombie processes (on unix),
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6480
	      you may have to fetch the processes exitstatus with
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6481
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6482
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6483
    self sendSignal:(self sigKILL) to:processId.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6484
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6485
    "Modified: / 10.6.1998 / 11:59:12 / cg"
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6486
!
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6487
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6488
killProcessGroup:processGroupId
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6489
    "kill a unix process group.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6490
     The process has a no chance to do some cleanup.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6491
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6492
     WARNING: in order to avoid zombie processes (on unix),
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6493
	      you may have to fetch the processes exitstatus with
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6494
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6495
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6496
    self sendSignal:(self sigKILL) to:(processGroupId negated).
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6497
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6498
    "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
  6499
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6500
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6501
sendSignal:signalNumber to:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6502
    "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
  6503
     Returns false if any error occurred, true otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6504
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6505
     Do not confuse UNIX signals with Smalltalk-Signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6506
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6507
     WARNING: in order to avoid zombie processes (on unix),
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6508
	      you may have to fetch the processes exitstatus with
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6509
	      OperatingSystem>>getStatusOfProcess:aProcessId
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6510
	      if the signal terminates that process."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6511
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6512
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6513
    if (__bothSmallInteger(signalNumber, processId)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6514
	if (kill(__intVal(processId), __intVal(signalNumber)) < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6515
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6516
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6517
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6518
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6519
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6520
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6521
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6522
    "/ either invalid argument (non-integers)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6523
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6524
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6525
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6526
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6527
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6528
startSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6529
    "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
  6530
     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
  6531
     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
  6532
     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
  6533
     (which is of course less correct).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6534
     OBSOLETE: the new messageTally runs as a high prio process, not using
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6535
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6536
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6537
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6538
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6539
#ifndef __spyInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6540
    extern void __spyInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6541
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6542
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6543
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6544
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6545
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6546
# ifdef SIGVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6547
    signal(SIGVTALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6548
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6549
#  ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6550
    signal(SIGALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6551
#  else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6552
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6553
     * mhmh - system has neither SIGBTALRM nor SIGALRM ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6554
     * what should we do here ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6555
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6556
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6557
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6558
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6559
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6560
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6561
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6562
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6563
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6564
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6565
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6566
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6567
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6568
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6569
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6570
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6571
stopSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6572
    "stop spy timing - disable spy timer.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6573
     OBSOLETE: the new messageTally runs as a high prio process, not using
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6574
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6575
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6576
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6577
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6578
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6579
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6580
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6581
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6582
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6583
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6584
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6585
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6586
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6587
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6588
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6589
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6590
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6591
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6592
terminateProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6593
    "terminate a unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6594
     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
  6595
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6596
     WARNING: in order to avoid zombie processes (on unix),
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6597
	      you may have to fetch the processes exitstatus with
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6598
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6599
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  6600
    self sendSignal:(self sigTERM) to:processId.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6601
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6602
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6603
    "Modified: / 27.1.1998 / 20:05:47 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6604
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6605
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6606
terminateProcessGroup:processGroupId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6607
    "terminate a unix process group.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6608
     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
  6609
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6610
     WARNING: in order to avoid zombie processes (on unix),
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6611
	      you may have to fetch the processes exitstatus with
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6612
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6613
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  6614
    self sendSignal:(self sigTERM) to:(processGroupId negated).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6615
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6616
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6617
    "Created: / 23.4.1996 / 16:40:34 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6618
    "Modified: / 27.1.1998 / 20:05:59 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6619
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6620
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6621
!UnixOperatingSystem class methodsFor:'ipc support'!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6622
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6623
makeBidirectionalPipe
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6624
    "make a socketPair, return array with two filedescriptors on success,
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6625
     nil on failure.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6626
     This is a lowLevel entry, not for public use."
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6627
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6628
    |fd1 fd2|
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6629
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6630
%{
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6631
#ifndef NO_SOCKET
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6632
     int fds[2];
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6633
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6634
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6635
	@global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6636
	RETURN ( nil );
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6637
     }
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6638
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6639
     fd1 = __mkSmallInteger(fds[0]);
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6640
     fd2 = __mkSmallInteger(fds[1]);
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6641
#endif
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6642
%}.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6643
    fd1 notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6644
	^ Array with:fd1 with:fd2.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6645
    ].
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6646
    ^ nil
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6647
!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6648
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6649
makePTY
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6650
    "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
  6651
     on success, nil on failure.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6652
     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
  6653
     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
  6654
     public interface."
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6655
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6656
    |fdS fdM ptyName|
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6657
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6658
%{
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6659
    /*
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6660
     * Find a pseudo tty to use and open both sides.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6661
     *  _fdM receives the master file descriptor while _fdS
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6662
     *  receives the slave.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6663
     */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6664
3536
adad0d12c9a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3534
diff changeset
  6665
#ifdef IRIX5
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6666
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6667
    char *slaveName;
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6668
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6669
    slaveName = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6670
    if ((slaveName != 0) && (_fdM >= 0)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6671
	_fdS = open(slaveName, O_RDWR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6672
	if (_fdS < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6673
	    (void)close(_fdM);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6674
	    _fdS = _fdM = -1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6675
	}
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6676
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6677
	_fdM -1;
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6678
    }
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6679
    if ((_fdM >= 0) && (_fdS >= 0)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6680
	fdM = __mkSmallInteger(_fdM);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6681
	fdS = __mkSmallInteger(_fdS);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6682
	ptyName = __MKSTRING(slaveName);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6683
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6684
#   define PTY_IS_IMPLEMENTED 1
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6685
#endif /* IRIX5 */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6686
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6687
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6688
#if defined(HAS_UNIX98_PTY)
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6689
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6690
    char *slaveName;
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6691
    extern char *ptsname();     /* also in #include <stdlib.h> */
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6692
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6693
    _fdM = open("/dev/ptmx", O_RDWR | O_NOCTTY);
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6694
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6695
    if (_fdM >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6696
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6697
	** grantpt() changes owner, group and mode of the pseudo-tty
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6698
	*/
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6699
	grantpt(_fdM);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6700
	unlockpt(_fdM);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6701
	slaveName = ptsname(_fdM);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6702
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6703
	if (slaveName != NULL) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6704
	    /* printf("slave is: %s\n", slaveName); */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6705
	    _fdS = open(slaveName, O_RDWR);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6706
	    if (_fdS < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6707
		(void)close(_fdM);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6708
		_fdS = _fdM = -1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6709
	    }
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6710
#if defined(UNIXWARE) || defined(solaris)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6711
	    else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6712
		/* push terminal modules on stream */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6713
		ioctl(_fdS, I_PUSH, "ptem");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6714
		ioctl(_fdS, I_PUSH, "ldterm");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6715
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6716
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6717
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6718
	    (void)close(_fdM);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6719
	    _fdS = _fdM = -1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6720
	}
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6721
    }
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6722
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6723
    if ((_fdM >= 0) && (_fdS >= 0)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6724
	fdM = __mkSmallInteger(_fdM);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6725
	fdS = __mkSmallInteger(_fdS);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6726
	ptyName = __MKSTRING(slaveName);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6727
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6728
#   define PTY_IS_IMPLEMENTED 1
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6729
#endif /* HAS_UNIX98_PTY */
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6730
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6731
#if !defined(PTY_IS_IMPLEMENTED)
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6732
# ifdef LINUX
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6733
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6734
#   define PT_INDEX      5
3550
6c3824d07eac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  6735
#   define PTY_1_CHARS  "pqrstuabcdevwxyz"
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6736
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6737
# endif /* LINUX */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6738
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6739
# ifdef solaris
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6740
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6741
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6742
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6743
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6744
# endif /* solaris */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6745
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6746
# ifdef aix
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6747
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6748
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6749
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6750
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6751
# endif /* aix */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6752
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6753
# ifdef next3
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6754
#   define PTY_TEMPL    "/dev/ptyXX"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6755
#   define PT_INDEX      5
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6756
#   define PTY_1_CHARS  "pqr"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6757
#   define PTY_2_CHARS  "0123456789abcdef"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6758
# endif /* next3 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6759
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6760
# ifdef hpux
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6761
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6762
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6763
#   define PTY_1_CHARS  "pqrs"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6764
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6765
# endif /* hpux */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6766
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6767
# if defined(__osf__)
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6768
#   define PTY_TEMPL    "/dev/ptyXX"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6769
#   define PT_INDEX      5
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6770
#   define PTY_1_CHARS  "pq"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6771
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6772
# endif /* osf1 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6773
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6774
# if defined(BSD) && !defined(PTY_TEMPL)
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6775
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6776
#   define PT_INDEX      5
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6777
#   define PTY_1_CHARS  "p"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6778
#   define PTY_2_CHARS  "0123456789abcdefghijklmnopqrstuv"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6779
# endif /* BSD */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6780
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6781
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6782
#   include <grp.h>
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6783
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6784
    static int ttygid = -2;
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6785
    char line[128];
3575
39723f691a0e hp-cc does not recognize const keyword
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
  6786
    register CONST char *cp1, *cp2;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6787
    int len, _fdM = -1, _fdS = -1;
15484
840d6cc94534 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 15483
diff changeset
  6788
    char *slaveName = NULL;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6789
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6790
    len = sizeof(PTY_TEMPL) - 1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6791
    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
  6792
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6793
    if (ttygid == -2) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6794
	struct group *gr;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6795
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6796
	if ((gr = getgrnam("tty")) != NULL)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6797
	    ttygid = gr->gr_gid;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6798
	else
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6799
	    ttygid = -1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6800
    }
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6801
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6802
    for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6803
	line[len-2] = * cp1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6804
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6805
	for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6806
	    line[PT_INDEX] = 'p';
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6807
	    line[len-1] = *cp2;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6808
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6809
	    if ((_fdM = open(line, O_RDWR, 0)) < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6810
		if (errno == ENOENT) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6811
		    _fdM = _fdS = -1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6812
		    goto getOutOfHere; /* out of ptys */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6813
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6814
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6815
		line[PT_INDEX] = 't';
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6816
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6817
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6818
		 * try to set owner and mode.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6819
		 * this works only if running under root
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6820
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6821
		(void) chown( line, getuid(), ttygid );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6822
		(void) chmod( line, S_IRUSR | S_IWUSR | S_IWGRP );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6823
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6824
		if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6825
		    slaveName = line;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6826
		    goto getOutOfHere; /* success */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6827
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6828
		(void) close(_fdM );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6829
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6830
	}
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6831
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6832
  getOutOfHere: ;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6833
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6834
    if ((_fdM >= 0) && (_fdS >= 0)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6835
	fdM = __mkSmallInteger(_fdM);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6836
	fdS = __mkSmallInteger(_fdS);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6837
	ptyName = __MKSTRING(slaveName);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6838
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6839
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6840
#endif /* ! defined(PTY_IS_IMPLEMENTED) */
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6841
%}.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6842
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6843
    fdM notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6844
	^ Array with:fdM with:fdS with:ptyName.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6845
    ].
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6846
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6847
    ^ nil
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6848
!
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6849
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6850
makePTYPair
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6851
    "make a pty-pair, return an array with two filedescriptors on success,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6852
     nil on failure.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6853
     This is a leftover compatibility lowLevel entry, not for public use.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6854
     See NonPositionableExternalStream>>makePTYPair for a more user-friendly,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6855
     public interface."
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6856
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6857
    |triple|
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6858
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6859
    triple := self makePTY.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6860
    triple isNil ifTrue:[^ nil].
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6861
    ^ Array with:(triple at:1) with:(triple at:2)
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6862
!
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6863
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6864
makePipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6865
    "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
  6866
     nil on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6867
     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
  6868
     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
  6869
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6870
    |fd1 fd2|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6871
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6872
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6873
     int fds[2];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6874
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6875
     if (pipe(fds) < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6876
	@global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6877
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6878
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6879
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6880
     fd1 = __mkSmallInteger(fds[0]);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6881
     fd2 = __mkSmallInteger(fds[1]);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6882
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6883
    fd1 notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6884
	^ Array with:fd1 with:fd2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6885
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6886
    ^ nil
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6887
!
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6888
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6889
resetTerminalInputOutputModes:fd
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6890
    "reset the terminal attributes"
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6891
%{
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6892
    struct termios switcher;
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6893
15176
aae943ef2519 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 15175
diff changeset
  6894
    printf("setMappingMaster fd:%d\n", (int)__intVal(fd));
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6895
    if (__isSmallInteger(fd)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6896
	if (tcgetattr( __intVal(fd), &switcher) < 0) RETURN (false);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6897
	switcher.c_iflag = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6898
	switcher.c_oflag = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6899
	if (tcsetattr( __intVal(fd), TCSANOW, &switcher) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6900
	    RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6901
	}
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6902
    }
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6903
%}.
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6904
    ^ false
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6905
!
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6906
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6907
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
  6908
    "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
  6909
%{
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6910
#ifdef TIOCSWINSZ
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6911
    struct winsize wsize;
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6912
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6913
    if (__isSmallInteger(fd)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6914
     && __isSmallInteger(w)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6915
     && __isSmallInteger(h)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6916
	wsize.ws_row = (unsigned short)__intVal(h);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6917
	wsize.ws_col = (unsigned short)__intVal(w);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6918
	if (ioctl(__intVal(fd), TIOCSWINSZ, (char *)&wsize) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6919
	    RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6920
	}
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6921
    }
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6922
#endif
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6923
%}.
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6924
    ^ false
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6925
!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6926
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6927
shutdownBidirectionalPipeOutput:fileDescriptor
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6928
    "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
  6929
     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
  6930
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6931
%{
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6932
#ifndef NO_SOCKET
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6933
    if (__isSmallInteger(fileDescriptor)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6934
	shutdown(__smallIntegerVal(fileDescriptor), 1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6935
	RETURN(self);
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6936
    }
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6937
#endif
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6938
%}.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6939
    self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6940
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6941
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6942
!UnixOperatingSystem class methodsFor:'misc'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6943
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6944
closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6945
    "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
  6946
     getAddrInfo implementation:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6947
	if it gets interrupted (via a timer, for example), its domain-name
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6948
	socket remains open and is NEVER closed.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6949
	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
  6950
     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
  6951
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6952
    |p|
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6953
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6954
    p := PipeStream
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6955
	    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
  6956
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6957
    p linesDo:[:line |
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6958
	|words fd|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6959
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6960
	words := line asCollectionOfWords.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6961
	"/ COMMAND PID USER   FD   TYPE     DEVICE    SIZE    NODE NAME
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6962
	words first = 'stx' ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6963
	    words second = (OperatingSystem getProcessId printString) ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6964
		(words fourth endsWith:'u') ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6965
		    (words fifth = 'IPv4') ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6966
			(words seventh = 'UDP') ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6967
			    (words last endsWith:'domain') ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6968
				fd := Number readFrom:(words fourth copyButLast).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6969
Transcript showCR:line.
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6970
				OperatingSystem closeFd:fd.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6971
			    ]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6972
			]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6973
		    ]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6974
		]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6975
	    ]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6976
	]
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6977
    ].
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6978
    p close.
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6979
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6980
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6981
     self closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6982
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6983
!
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6984
10983
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6985
dup:aFileDescriptor
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6986
    "duplicate a file descriptor.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6987
     Only use internally"
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6988
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6989
%{
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6990
    int dupFd;
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6991
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6992
    if (__isSmallInteger(aFileDescriptor)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6993
	dupFd = dup(__smallIntegerVal(aFileDescriptor));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6994
	if (dupFd >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6995
	    RETURN(__mkSmallInteger(dupFd));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  6996
	}
10983
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6997
    }
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6998
%}.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6999
    ^ self primitiveFailed.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7000
!
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  7001
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7002
slowFork:aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7003
    "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
  7004
     Only used internally on SYSV3 systems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7005
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7006
    SlowFork := aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7007
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7008
    "Modified: 22.4.1996 / 13:13:09 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7009
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7011
!UnixOperatingSystem class methodsFor:'os queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7012
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7013
executableFileExtensions
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7014
    "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
  7015
     Only req'd for msdos like systems ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7016
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7017
    ^ #('')
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7018
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7019
    "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
  7020
    "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
  7021
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7022
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  7023
getCodeset
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  7024
    "get the codeset the system is running under"
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  7025
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  7026
    ^ Codeset
14587
d32cbeb8ca41 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14584
diff changeset
  7027
!
d32cbeb8ca41 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14584
diff changeset
  7028
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7029
getCodesetEncoder
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7030
    "Initialize CodesetEncoder used to encode/decode strings passed to/from
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7031
     the operating system (like file names, command output, environment ect.).
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7032
15981
c31f0cec5db0 osx: nil keys in getEnvironment
Claus Gittinger <cg@exept.de>
parents: 15977
diff changeset
  7033
     NOTE: DO NOT CALL this in #initialize as CharacterEncoder might not yet
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7034
     be initialized. Therefore this method is called from CharacterEncoder class>>
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7035
     #initialize. Certainly a hack, but class initialization order is undefined,
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7036
     so some sort of hack is necessary.
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7037
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7038
     NOTE2: This should be called initializeCodesetEncoder but to make it consistent
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7039
     with getCodeset it is getCodesetEncoder
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7040
     "
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7041
17492
36653db10f2d class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17327
diff changeset
  7042
    Codeset isNil ifTrue:[self initializeCodeset].
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7043
    CodesetEncoder := CharacterEncoder encoderFor: Codeset.
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7044
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7045
    "Created: / 23-01-2013 / 09:54:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7046
!
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  7047
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7048
getDomainName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7049
    "return the domain this host is in.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7050
     Notice:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7051
	not all systems support this; on some, #unknown is returned."
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7052
16495
a9eecbf739db class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16494
diff changeset
  7053
    |domainName idx hostName primDomainName|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7054
16634
e1ebc91b27af class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16592
diff changeset
  7055
    "/ use cached value, if present
16756
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7056
    (DomainName notNil and:[DomainName ~~ #unknown]) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7057
	^ DomainName
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7058
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7059
16495
a9eecbf739db class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16494
diff changeset
  7060
    primDomainName := domainName := self primGetDomainName.
16494
0a7c7ec1961a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16481
diff changeset
  7061
    domainName = '(none)' ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7062
	domainName := nil.
16494
0a7c7ec1961a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16481
diff changeset
  7063
    ].
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7064
    domainName isEmptyOrNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7065
	"sometimes, we can extract the domainName from the hostName ..."
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7066
	hostName := self primGetHostName.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7067
	hostName notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7068
	    idx := hostName indexOf:$..
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7069
	    idx ~~ 0 ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7070
		domainName := hostName copyFrom:idx+1.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7071
	    ]
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7072
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7073
	domainName isEmptyOrNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7074
	    "/ fallBack
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7075
	    domainName := self getEnvironment:'DOMAIN'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7076
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7077
	    "if #primGetDomainName did work, /bin/domainname would return the same result"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7078
	    (domainName isNil and:[primDomainName isNil]) ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7079
		domainName := self getCommandOutputFrom:'/bin/domainname'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7080
		(domainName isEmptyOrNil or:[ domainName = '(none)' ]) ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7081
		    domainName := nil.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7082
		].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7083
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7084
	    domainName isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7085
		DomainName ~~ #unknown ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7086
		    "/ only warn once - the warning can be ignored, if you do not use the domain name
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7087
		    ObjectMemory debugPrinting ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7088
			'UnixOperatingSystem [info]: cannot find out domainname' infoPrintCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7089
		    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7090
		].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7091
		domainName := #unknown.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7092
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7093
	].
16756
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7094
    ].
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7095
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7096
    "cache, because domainName fetching may be expensive;
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7097
     but if unknown, it will be tried again"
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7098
    DomainName := domainName.
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7099
    ^ domainName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7101
    "
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7102
     OperatingSystem getDomainName
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
  7103
     OperatingSystem primGetDomainName
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7104
     OperatingSystem getHostName
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7105
     OperatingSystem primGetHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7106
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7107
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7108
    "Modified: 26.4.1996 / 10:04:54 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7109
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7110
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7111
getEnvironment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7112
    "answer the whole environment as a Dictionary"
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7113
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7114
    |resultArray error dict sz "{ Class: SmallInteger }"|
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7115
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  7116
%{
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  7117
#ifdef __osx__
16282
a9cd85c4d2f2 getEnvironment fix for __osx__
Claus Gittinger <cg@exept.de>
parents: 16149
diff changeset
  7118
    char **environ = *_NSGetEnviron();
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  7119
#else
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7120
    extern char **environ;
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  7121
#endif
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7122
    char **env;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7123
    int nEnv = 0;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7124
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7125
    /*
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7126
     * get the size of the environment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7127
     */
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7128
    if (environ) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7129
	for (env = environ; *env; env++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7130
	    nEnv++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7131
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7132
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7133
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7134
    /*
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7135
     * allcate an array for keys and values
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7136
     */
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  7137
    resultArray = __ARRAY_NEW_INT(nEnv * 2);
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7138
    if (resultArray == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7139
	error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7140
	goto bad;
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7141
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7142
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7143
    if (environ) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7144
	int envIndex;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7145
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7146
	for (env = environ, envIndex = 0; *env; env++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7147
	    OBJ t;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7148
	    char *separatorPtr;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7149
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7150
	    separatorPtr = strchr(*env, '=');
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7151
	    t = __MKSTRING_L(*env, separatorPtr-*env);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7152
	    __arrayVal(resultArray)[envIndex++] = t;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7153
	    __STORE(resultArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7154
	    if (separatorPtr == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7155
		t = nil;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7156
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7157
		t = __MKSTRING(separatorPtr+1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7158
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7159
	    __arrayVal(resultArray)[envIndex++] = t;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7160
	    __STORE(resultArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7161
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7162
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7163
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7164
bad:;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7165
%}.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7166
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7167
	^ self primitiveFailed:error.
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7168
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7169
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7170
    sz := resultArray size.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7171
    dict := Dictionary new:(sz // 2).
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7172
    1 to:sz by:2 do:[:i |
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7173
	|key|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7174
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7175
	key := resultArray at:i.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7176
	key notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7177
	    "same behavior as getenv() - the first entry takes precedence"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7178
	    (dict includesKey:key) ifFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7179
		dict at:key put:(resultArray at:i+1)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7180
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7181
	].
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7182
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7183
    ^ dict
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7184
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7185
    "
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7186
     OperatingSystem getEnvironment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7187
    "
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7188
!
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7189
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7190
getEnvironment:aStringOrSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7191
    "get an environment string"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7192
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7193
%{  /* NOCONTEXT */
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7194
#ifdef __SCHTEAM__
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7195
    {
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
  7196
	java.lang.String val = java.lang.System.getenv( aStringOrSymbol.asString() );
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7197
	STObject retVal;
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7198
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7199
	if (val == null) {
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7200
	    retVal = STObject.Nil;
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7201
	} else {
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7202
	    retVal = new STString( val );
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7203
	}
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7204
	return context._RETURN( retVal );
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7205
	/* NOTREACHED */
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7206
    }
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7207
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7208
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7209
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7210
    if (__isStringLike(aStringOrSymbol)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7211
	char *env =  getenv(__stringVal(aStringOrSymbol));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7212
	if (env) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7213
	    RETURN ( __MKSTRING(env) );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7214
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7215
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7216
    }
18256
70138be99d04 comments only
Claus Gittinger <cg@exept.de>
parents: 18226
diff changeset
  7217
#endif /* not SCHTEAM */
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7218
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  7219
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7220
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7221
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7222
     OperatingSystem getEnvironment:'LANG'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7223
     OperatingSystem getEnvironment:'LOGIN'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7224
     OperatingSystem getEnvironment:'HOME'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7225
     OperatingSystem getEnvironment:'NNTPSERVER'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7226
     OperatingSystem getEnvironment:'MAIL'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7227
     OperatingSystem getEnvironment:'PATH'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7228
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7229
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7230
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7231
getHostName
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7232
    "return the hostname we are running on.
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7233
     The host name returned is fully qualified - if returned so by the system."
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7234
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7235
    |hostName|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7236
16756
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7237
    (HostName notNil and:[HostName ~~ #unknown]) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7238
	^ HostName
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7239
    ].
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7240
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7241
    hostName := self primGetHostName.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7242
    hostName isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7243
	"fallBack - in non-antique systes we never come here"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7244
	hostName := self getEnvironment:'HOST'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7245
	hostName isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7246
	    hostName := self getCommandOutputFrom:'/bin/hostname'
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7247
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7248
	hostName isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7249
	    HostName ~~ #unknown ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7250
		'UnixOperatingSystem [info]: cannot find out hostname' infoPrintCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7251
		hostName := #unknown.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7252
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7253
	].
16756
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7254
    ].
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7255
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7256
    "cache, because hostname fetching may be expensive;
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7257
     but if unknown, it will be tried again"
33c2eb0a82f6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16696
diff changeset
  7258
    HostName := hostName.
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7259
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7260
    ^ hostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7261
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7262
    "
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7263
     OperatingSystem getHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7264
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7265
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7266
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7267
getLocaleInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7268
    "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
  7269
     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
  7270
     Possible fields are:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7271
	decimalPoint                    <String>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7272
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7273
	thousandsSep                    <String>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7274
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7275
	internationalCurrencySymbol     <String>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7276
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7277
	currencySymbol                  <String>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7278
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7279
	monetaryDecimalPoint            <String>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7280
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7281
	monetaryThousandsSeparator      <String>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7282
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7283
	positiveSign                    <String>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7284
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7285
	negativeSign                    <String>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7286
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7287
	internationalFractionalDigits   <Integer>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7288
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7289
	fractionalDigits                <Integer>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7290
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7291
	positiveSignPrecedesCurrencySymbol      <Boolean>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7292
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7293
	negativeSignPrecedesCurrencySymbol      <Boolean>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7294
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7295
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7296
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7297
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7298
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7299
	positiveSignPosition                            <Symbol>
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7300
							one of: #parenthesesAround,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7301
								#signPrecedes,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7302
								#signSuceeds,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7303
								#signPrecedesCurrencySymbol,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7304
								#signSuceedsCurrencySymbol
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7305
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7306
	negativeSignPosition                            <like above>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7308
     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
  7309
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7310
     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
  7311
     it should be used by applications as required.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7312
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7314
    |info val|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7315
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7316
    LocaleInfo notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7317
	"/ return the internal info; useful on systems which do not
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7318
	"/ support this.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7319
	^ LocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7320
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7321
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7322
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7323
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7324
    char *decimalPoint;         /* something like "." (US) or "," (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7325
    char *thousandsSep;         /* something like "," (US) or "." (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7326
    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
  7327
    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
  7328
    char *monDecimalPoint;      /* money: decimal point */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7329
    char *monThousandsSep;      /* money: thousands sep */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7330
    char *positiveSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7331
    char *negativeSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7332
    int   intFractDigits;       /* money: international digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7333
    int   fractDigits;          /* money: local digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7334
    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
  7335
    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
  7336
    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
  7337
    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
  7338
    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
  7339
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7340
				/*        2: sign succeeds the value & currency symbol */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7341
				/*        3: sign immediately precedes the currency symbol */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7342
				/*        4: sign immediately suceeds the currency symbol */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7343
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7344
#if defined(HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7345
    struct lconv *conf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7346
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7347
    conf = localeconv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7348
    if (conf) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7349
	decimalPoint = conf->decimal_point;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7350
	thousandsSep = conf->thousands_sep;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7351
	intCurrencySymbol = conf->int_curr_symbol;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7352
	currencySymbol = conf->currency_symbol;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7353
	monDecimalPoint = conf->mon_decimal_point;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7354
	monThousandsSep = conf->mon_thousands_sep;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7355
	positiveSign = conf->positive_sign;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7356
	negativeSign = conf->negative_sign;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7357
	intFractDigits = conf->int_frac_digits;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7358
	fractDigits = conf->frac_digits;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7359
	csPosPrecedes = conf->p_cs_precedes;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7360
	csNegPrecedes = conf->n_cs_precedes;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7361
	csPosSepBySpace = conf->p_sep_by_space;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7362
	csNegSepBySpace = conf->n_sep_by_space;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7363
	csPosSignPosition = conf->p_sign_posn;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7364
	csNegSignPosition = conf->n_sign_posn;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7365
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7366
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7367
    decimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7368
    thousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7369
    intCurrencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7370
    currencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7371
    monDecimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7372
    monThousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7373
    positiveSign =  (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7374
    negativeSign =(char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7375
    intFractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7376
    fractDigits = -1;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7377
    csPosPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7378
    csNegPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7379
    csPosSepBySpace = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7380
    csNegSepBySpace = -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7381
    csPosSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7382
    csNegSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7383
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7384
    if (decimalPoint) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7385
	val = __MKSTRING(decimalPoint);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7386
	__AT_PUT_(info, @symbol(decimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7387
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7388
    if (thousandsSep) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7389
	val = __MKSTRING(thousandsSep);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7390
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
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
    if (intCurrencySymbol) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7393
	val = __MKSTRING(intCurrencySymbol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7394
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7395
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7396
    if (currencySymbol) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7397
	val = __MKSTRING(currencySymbol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7398
	__AT_PUT_(info, @symbol(currencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7399
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7400
    if (monDecimalPoint) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7401
	val = __MKSTRING(monDecimalPoint);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7402
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7403
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7404
    if (monThousandsSep) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7405
	val = __MKSTRING(monThousandsSep);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7406
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7407
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7408
    if (positiveSign) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7409
	val = __MKSTRING(positiveSign);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7410
	__AT_PUT_(info, @symbol(positiveSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7411
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7412
    if (negativeSign) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7413
	val = __MKSTRING(negativeSign);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7414
	__AT_PUT_(info, @symbol(negativeSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7415
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7416
    if (intFractDigits >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7417
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __mkSmallInteger(intFractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7418
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7419
    if (fractDigits >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7420
	__AT_PUT_(info, @symbol(fractionalDigits),  __mkSmallInteger(fractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7421
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7422
    if (csPosPrecedes >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7423
	if (csPosPrecedes == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7424
	    val = false;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7425
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7426
	    val = true;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7427
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7428
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7429
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7430
    if (csNegPrecedes >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7431
	if (csNegPrecedes == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7432
	    val = false;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7433
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7434
	    val = true;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7435
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7436
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7437
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7438
    if (csPosSepBySpace >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7439
	if (csPosSepBySpace == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7440
	    val = false;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7441
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7442
	    val = true;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7443
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7444
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7445
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7446
    if (csNegSepBySpace >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7447
	if (csNegSepBySpace == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7448
	    val = false;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7449
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7450
	    val = true;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7451
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7452
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7453
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7454
    switch (csPosSignPosition) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7455
	case 0:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7456
	    val = @symbol(parenthesesAround);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7457
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7458
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7459
	case 1:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7460
	    val = @symbol(signPrecedes);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7461
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7462
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7463
	case 2:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7464
	    val = @symbol(signSuceeds);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7465
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7466
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7467
	case 3:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7468
	    val = @symbol(signPrecedesCurrencySymbol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7469
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7470
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7471
	case 4:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7472
	    val = @symbol(signSuceedsCurrencySymbol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7473
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7474
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7475
	default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7476
	    val = nil;
3496
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
    if (val != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7479
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7480
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7481
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7482
    switch (csNegSignPosition) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7483
	case 0:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7484
	    val = @symbol(parenthesesAround);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7485
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7486
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7487
	case 1:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7488
	    val = @symbol(signPrecedes);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7489
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7490
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7491
	case 2:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7492
	    val = @symbol(signSuceeds);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7493
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7494
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7495
	case 3:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7496
	    val = @symbol(signPrecedesCurrencySymbol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7497
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7498
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7499
	case 4:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7500
	    val = @symbol(signSuceedsCurrencySymbol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7501
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7502
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7503
	default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7504
	    val = nil;
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
    if (val != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7507
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7508
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7509
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7510
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7511
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7512
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7513
     OperatingSystem getLocaleInfo
3496
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
    "Created: 23.12.1995 / 14:19:20 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7517
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7518
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7519
getNetworkAddressInfo
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  7520
    "return a Dictionary of network interface information.
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7521
	key -> name of interface
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7522
	value -> a Set of network address
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7523
		information for the interface - a dictionaries containing the
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7524
		information about the configuration of each interface in the system.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7525
		The dictionary keys are:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7526
		    #address
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7527
		    #netmask
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7528
		    #flags
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7529
		    #destAddress"
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7530
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7531
    |returnArray addressArray nameArray noOfIf retDictionary error retIndex|
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7532
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7533
    noOfIf := 0.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7534
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7535
%{
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7536
#if defined(LINUX)
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7537
# include <ifaddrs.h>
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7538
# include <netinet/in.h>
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7539
# include <sys/socket.h>
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7540
# include <netpacket/packet.h>
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7541
# include <net/ethernet.h> /* the L2 protocols */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7542
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7543
    struct ifaddrs *ifap, *ifaLoop;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7544
    int n_ifa = 0;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7545
    int retI = 0;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7546
    OBJ t;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7547
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7548
    if (getifaddrs(&ifap) < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7549
	error = __MKSTRING("getifaddrs() failed");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7550
	goto out;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7551
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7552
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7553
    for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) n_ifa++;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7554
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7555
    returnArray = __ARRAY_NEW_INT(n_ifa*5);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7556
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7557
    if (returnArray == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7558
	/* Creating a string wouldn't work here */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7559
	error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7560
	goto bad;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7561
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7562
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7563
    for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7564
	int family, len;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7565
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7566
	if (ifaLoop->ifa_addr == 0)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7567
	       continue;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7568
	family = ifaLoop->ifa_addr->sa_family;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7569
	switch (family) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7570
	case AF_INET:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7571
	    len = sizeof(struct sockaddr_in);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7572
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7573
	case AF_INET6:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7574
	    len = sizeof(struct sockaddr_in6);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7575
	    break;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7576
#if 0
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7577
	case AF_PACKET:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7578
	    len = sizeof(sockaddr_ll);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7579
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7580
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7581
	default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7582
	    /* skip */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7583
	    continue;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7584
	};
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7585
	t = __MKSTRING(ifaLoop->ifa_name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7586
	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7587
	t = __MKUINT(ifaLoop->ifa_flags);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7588
	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7589
	t = __MKBYTEARRAY((char *)ifaLoop->ifa_addr, len);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7590
	__arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7591
	if (ifaLoop->ifa_netmask != 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7592
	    t = __MKBYTEARRAY((char *)ifaLoop->ifa_netmask, len);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7593
	    __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7594
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7595
	retI++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7596
	if (ifaLoop->ifa_dstaddr != 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7597
	    t = __MKBYTEARRAY((char *)ifaLoop->ifa_dstaddr, len);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7598
	    __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7599
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7600
	retI++;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7601
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7602
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7603
    noOfIf = __mkSmallInteger(n_ifa);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7604
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7605
bad:
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7606
    freeifaddrs(ifap);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7607
16329
5ce84e6782e0 mac defs
Claus Gittinger <cg@exept.de>
parents: 16318
diff changeset
  7608
#elif defined(SIOCGIFADDR) && defined(SIOCGIFCONF)
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7609
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7610
    int             afinet_socket = -1;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7611
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7612
    struct ifconf   ifc;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7613
    struct ifreq    *ifr;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7614
    struct ifreq    ifreq;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7615
    unsigned char   buf[1024];
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7616
    int             n_ifs, i, countOfIf;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7617
    OBJ             t;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7618
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7619
    /*
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7620
    ** Open an INET socket
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7621
    */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7622
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7623
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7624
    if (afinet_socket < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7625
	goto bad;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7626
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7627
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7628
    /*
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7629
    ** Get the list of network interfaces
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7630
    */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7631
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7632
    ifc.ifc_len = sizeof (buf);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7633
    ifc.ifc_buf = (caddr_t) buf;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7634
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7635
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7636
	close(afinet_socket);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7637
	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7638
	goto bad;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7639
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7640
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7641
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7642
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7643
    nameArray    = __ARRAY_NEW_INT(n_ifs);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7644
    addressArray = __ARRAY_NEW_INT(n_ifs);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7645
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7646
    if (nameArray == nil || addressArray == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7647
	/* Creating a string wouldn/t work here */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7648
	error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7649
	goto bad;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7650
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7651
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7652
    /*
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7653
    ** Iterate of the list of the system's netif. Find all
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7654
    ** active interfaces and their ethernet addresses
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7655
    */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7656
    countOfIf = 0;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7657
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7658
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7659
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7660
	** Get address for this interface
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7661
	*/
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7662
	memset (&ifreq, 0, sizeof(ifreq));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7663
	memcpy (ifreq.ifr_name, ifr->ifr_name, sizeof(ifr->ifr_name));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7664
	if (ioctl (afinet_socket, SIOCGIFADDR, &ifreq) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7665
	    t = __MKBYTEARRAY((char *)&ifreq.ifr_addr, sizeof(ifreq.ifr_addr));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7666
	    __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7667
	    t = __MKSTRING(&ifreq.ifr_name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7668
	    __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7669
	    countOfIf++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7670
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7671
	    if (@global(InfoPrinting) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7672
		fprintf(stderr, "OS [warning]: SIOCGIFADDR failed: %d\n", errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7673
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7674
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7675
	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7676
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7677
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7678
    noOfIf = __mkSmallInteger(countOfIf);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7679
bad:
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7680
    if (afinet_socket >= 0)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7681
	close(afinet_socket);
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7682
#else
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7683
    error = @symbol(notSupported);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7684
#endif /* defined(SIOCGIFADDR) */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7685
out:;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7686
%}.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7687
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7688
    retDictionary := Dictionary new:noOfIf.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7689
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7690
	self primitiveFailed:error.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7691
	"return empty dictionary if proceeding from error"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7692
	^  retDictionary.
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7693
    ].
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7694
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7695
    retIndex := 1.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7696
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7697
    1 to:noOfIf do:[:cnt|
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7698
	|name addressBytes set dict|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7699
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7700
	name := returnArray at:retIndex.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7701
	addressBytes := returnArray at:retIndex+2.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7702
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7703
	addressBytes notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7704
	    set := retDictionary at:name ifAbsentPut:[Set new].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7705
	    dict := Dictionary new:5.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7706
	    dict at:#flags put:(returnArray at:retIndex+1).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7707
	    dict at:#address put:(SocketAddress fromBytes:addressBytes).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7708
	    addressBytes := returnArray at:retIndex+3.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7709
	    addressBytes notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7710
		dict at:#netMask put:(SocketAddress fromBytes:addressBytes).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7711
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7712
	    addressBytes := returnArray at:retIndex+4.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7713
	    addressBytes notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7714
		dict at:#destAddress put:(SocketAddress fromBytes:addressBytes).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7715
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7716
	    set add:dict.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7717
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7718
	retIndex := retIndex + 5.
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7719
    ].
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7720
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7721
    ^ retDictionary
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7722
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7723
    "
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7724
      OperatingSystem getNetworkAddressInfo
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7725
    "
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7726
!
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  7727
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7728
getNetworkAddresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7729
    "return a dictionary filled with
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7730
	key -> name of interface
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7731
	value -> the socket adress of the interface
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7732
     for each interface"
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7733
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7734
    |addressArray nameArray noOfIf retDictionary error|
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7735
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7736
    noOfIf := 0.
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7737
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7738
%{
16329
5ce84e6782e0 mac defs
Claus Gittinger <cg@exept.de>
parents: 16318
diff changeset
  7739
#if defined(SIOCGIFADDR) && defined(SIOCGIFCONF)
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7740
    int             afinet_socket = -1;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7741
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7742
    struct ifconf   ifc;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7743
    struct ifreq    *ifr;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7744
    struct ifreq    ifreq;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7745
    unsigned char   buf[1024];
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7746
    int             n_ifs, i, countOfIf;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7747
    OBJ             t;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7748
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7749
    /*
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7750
    ** Open an INET socket
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7751
    */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7752
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7753
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7754
    if (afinet_socket < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7755
	error = __MKSTRING("Cannot open socket");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7756
	goto bad;
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7757
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7758
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7759
    /*
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7760
    ** Get the list of network interfaces
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7761
    */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7762
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7763
    ifc.ifc_len = sizeof (buf);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7764
    ifc.ifc_buf = (caddr_t) buf;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7765
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7766
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7767
	close(afinet_socket);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7768
	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7769
	goto bad;
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7770
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7771
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7772
    // get the number of interfaces in the returned structure
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7773
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7774
    // cg: sigh
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7775
    // on linux, the records have constant size;
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7776
    // 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
  7777
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7778
    // 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
  7779
    // 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
  7780
    // see also 2nd loop below
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7781
#ifndef __osx__
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7782
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7783
#else
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7784
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7785
	unsigned char *cp = buf;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7786
	char *limit = buf + ifc.ifc_len;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7787
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7788
	n_ifs = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7789
	while (cp < limit) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7790
	    int sz;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7791
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7792
	    ifr = (struct ifreq *)cp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7793
	    sz = IFNAMSIZ + ifr->ifr_addr.sa_len;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7794
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7795
	    cp += sz;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7796
	    n_ifs++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7797
	}
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7798
    }
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7799
#endif
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7800
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  7801
    nameArray    = __ARRAY_NEW_INT(n_ifs);
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  7802
    addressArray = __ARRAY_NEW_INT(n_ifs);
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7803
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7804
    if (nameArray == nil || addressArray == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7805
	/* Creating a string wouldn/t work here */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7806
	error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7807
	goto bad;
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7808
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7809
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7810
    /*
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7811
    ** Iterate of the list of the system's netif. Find all
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7812
    ** active interfaces and their ethernet addresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7813
    */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7814
    countOfIf = 0;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7815
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7816
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7817
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7818
	** Get Flags for this interface
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7819
	*/
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7820
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7821
	memcpy(&ifreq, ifr, sizeof(ifreq));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7822
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7823
	** Get address for this interface
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7824
	*/
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7825
	memcpy(&ifreq, ifr, sizeof(ifreq));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7826
	if (ioctl (afinet_socket, SIOCGIFADDR, &ifreq) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7827
	    t = __MKBYTEARRAY((char *)&ifreq.ifr_addr, sizeof(ifreq.ifr_addr));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7828
	    __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7829
	    t = __MKSTRING(&ifreq.ifr_name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7830
	    __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7831
	    countOfIf += 1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7832
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7833
	// see (sigh) comment above
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7834
#ifndef __osx__
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7835
	ifr++;
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7836
#else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7837
	{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7838
	    int sz = IFNAMSIZ + ifr->ifr_addr.sa_len;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7839
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7840
	    ifr = (struct ifreq *)( ((char *)ifr)+sz );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7841
	}
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7842
#endif
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7843
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7844
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7845
    noOfIf = __mkSmallInteger(countOfIf);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7846
bad:
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7847
    if (afinet_socket >= 0)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7848
	close(afinet_socket);
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7849
#else
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7850
    error = @symbol(notSupported);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7851
#endif /* defined(SIOCGIFADDR) */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7852
%}.
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7853
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7854
    retDictionary := Dictionary new:noOfIf.
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7855
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7856
	self primitiveFailed:error.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7857
	"return empty dictionary if proceed from error"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7858
	^  retDictionary.
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7859
    ].
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7860
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7861
    1 to:noOfIf do:[:cnt|
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7862
	"take the first address, if there is more than one!!"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7863
	retDictionary at:(nameArray at:cnt) ifAbsentPut:(SocketAddress fromBytes:(addressArray at:cnt)).
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7864
    ].
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7865
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7866
    ^ retDictionary
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7867
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7868
    "
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7869
      OperatingSystem getNetworkAddresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7870
    "
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7871
!
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7872
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7873
getNetworkMACAddresses
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7874
    "return a dictionary filled with
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7875
	key -> name of interface
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7876
	value -> the MAC adress (as ByteArray)
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7877
     for each interface"
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7878
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7879
    |addressArray nameArray noOfIf retDictionary error|
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7880
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7881
    noOfIf := 0.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7882
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7883
%{  /* stack: 32000 */
16868
4afb8750ccbf compilable under linux
Claus Gittinger <cg@exept.de>
parents: 16867
diff changeset
  7884
#if defined(SIOCGIFCONF)
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7885
    int             afinet_socket = -1;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7886
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7887
    struct ifconf   ifc;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7888
    struct ifreq    *ifr;
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7889
    unsigned char   buf[4*1024];
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7890
    int             n_ifs, i, countOfIf;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7891
    OBJ             t;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7892
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7893
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7894
    ** Open an INET socket
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7895
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7896
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7897
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7898
    if (afinet_socket < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7899
	error = __MKSTRING("Cannot open socket");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7900
	goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7901
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7902
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7903
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7904
    ** Get the list of network interfaces
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7905
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7906
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7907
    ifc.ifc_len = sizeof (buf);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7908
    ifc.ifc_buf = (caddr_t) buf;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7909
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7910
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7911
	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7912
	goto bad;
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7913
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7914
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7915
    // get the number of interfaces in the returned structure
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7916
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7917
    // cg: sigh
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7918
    // on linux, the records have constant size;
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7919
    // 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
  7920
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7921
    // 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
  7922
    // 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
  7923
    // see also 2nd loop below
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7924
#ifndef __osx__
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7925
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7926
#else
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7927
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7928
	unsigned char *cp = buf;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7929
	char *limit = buf + ifc.ifc_len;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7930
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7931
	n_ifs = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7932
	while (cp < limit) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7933
	    int sz;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7934
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7935
	    ifr = (struct ifreq *)cp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7936
	    sz = IFNAMSIZ + ifr->ifr_addr.sa_len;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7937
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7938
	    cp += sz;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7939
	    n_ifs++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7940
	}
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7941
    }
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7942
#endif
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7943
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  7944
    nameArray    = __ARRAY_NEW_INT(n_ifs);
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  7945
    addressArray = __ARRAY_NEW_INT(n_ifs);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7946
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7947
    if (nameArray == nil || addressArray == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7948
	/* Creating a string wouldn/t work here */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7949
	error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7950
	goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7951
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7952
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7953
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7954
    ** Iterate of the list of the system's netif. Find all
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7955
    ** active interfaces and their ethernet addresses
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7956
    */
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7957
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7958
    countOfIf = 0;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7959
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7960
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7961
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7962
	** Get Flags for this interface
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7963
	*/
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  7964
16868
4afb8750ccbf compilable under linux
Claus Gittinger <cg@exept.de>
parents: 16867
diff changeset
  7965
# ifndef __osx__ // SIOCGIFFLAGS fails on osx (Q@sv: what is this needed for anyway?)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7966
	{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7967
	    struct ifreq ifreq;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7968
	    memcpy(&ifreq, ifr, sizeof(ifreq));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7969
	    if (ioctl (afinet_socket, SIOCGIFFLAGS, &ifreq) < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7970
		if (@global(InfoPrinting) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7971
		    fprintf(stderr, "OS [warning]: ioctl(SIOCGIFFLAGS) failed");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7972
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7973
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7974
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7975
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7976
	{
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7977
# ifdef SIOCGIFHWADDR
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7978
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7979
	    ** Get Hardware address for this interface
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7980
	    */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7981
	    {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7982
		struct ifreq ifreq;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7983
		memcpy(&ifreq, ifr, sizeof(ifreq));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7984
		if (ioctl (afinet_socket, SIOCGIFHWADDR, &ifreq) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7985
		    t = __MKBYTEARRAY(&ifreq.ifr_hwaddr.sa_data, IFHWADDRLEN);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7986
		    __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7987
		    t = __MKSTRING(&ifreq.ifr_name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7988
		    __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7989
		    countOfIf += 1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7990
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7991
	    }
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  7992
16868
4afb8750ccbf compilable under linux
Claus Gittinger <cg@exept.de>
parents: 16867
diff changeset
  7993
#else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7994
	    // macosx has no SIOCGIFHWADDR
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7995
	    // printf("family: %d\n", ifr->ifr_addr.sa_family);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7996
	    // printf("name: %s\n", ifr->ifr_name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7997
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7998
	    if (ifr->ifr_addr.sa_family == AF_LINK) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  7999
		struct sockaddr_dl *sdl;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8000
		char *adr;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8001
		extern char *ether_ntoa();
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8002
		unsigned char mac[6];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8003
		int a,b,c,d,e,f;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8004
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8005
		sdl = (struct sockaddr_dl *)&(ifr->ifr_addr);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8006
		adr = ether_ntoa(LLADDR(sdl));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8007
		// printf("name: %s adr: %s\n", ifr->ifr_name, adr);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8008
		sscanf(adr, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e, &f);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8009
		mac[0] = a;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8010
		mac[1] = b;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8011
		mac[2] = c;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8012
		mac[3] = d;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8013
		mac[4] = e;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8014
		mac[5] = f;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8015
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8016
		t = __MKBYTEARRAY(mac, 6);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8017
		__arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8018
		t = __MKSTRING(ifr->ifr_name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8019
		__arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8020
		countOfIf += 1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8021
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8022
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8023
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8024
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8025
	// see (sigh) comment above
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8026
#ifndef __osx__
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8027
	ifr++;
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8028
#else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8029
	{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8030
	    int sz = IFNAMSIZ + ifr->ifr_addr.sa_len;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8031
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8032
	    ifr = (struct ifreq *)( ((char *)ifr)+sz );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8033
	}
16867
13ac07fae05a fixed getNetWorkAddresses
Claus Gittinger <cg@exept.de>
parents: 16866
diff changeset
  8034
#endif
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8035
    }
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8036
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8037
    noOfIf = __mkSmallInteger(countOfIf);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8038
bad:
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8039
    if (afinet_socket >= 0)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8040
	close(afinet_socket);
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8041
#else
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8042
    error = @symbol(notSupported);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  8043
#endif /* SIOCGIFHWADDR */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8044
%}.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8045
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8046
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8047
	self primitiveFailed:error.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8048
	"return an empty dictionary if proceed from error"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8049
	^  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
  8050
    ].
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  8051
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  8052
    "we prefer OrderedDictionary here, because we want to keep the
15152
2252471df4ae class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15151
diff changeset
  8053
     order as defined in the OS."
15151
60e0fcf07b17 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15129
diff changeset
  8054
    retDictionary := OrderedDictionary new:noOfIf.
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8055
    1 to:noOfIf do:[:cnt|
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8056
	|macAddress|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8057
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8058
	macAddress := addressArray at:cnt.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8059
	macAddress ~= #[0 0 0 0 0 0] ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8060
	    retDictionary at:(nameArray at:cnt) put:macAddress.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8061
	].
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8062
    ].
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8063
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  8064
    ^ retDictionary
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8065
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8066
    "
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  8067
      OperatingSystem getNetworkMACAddresses
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  8068
    "
6363
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  8069
!
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  8070
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8071
getNumberOfProcessors
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8072
    "answer the number of physical processors in the system"
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8073
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8074
%{ /* NOCONTEXT */
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8075
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8076
#ifdef _SC_NPROCESSORS_CONF
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8077
    RETURN(__mkSmallInteger(sysconf(_SC_NPROCESSORS_CONF)));
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8078
#endif
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8079
%}.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8080
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8081
    self shouldImplement.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8082
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8083
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8084
      self getNumberOfProcessors
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8085
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8086
!
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8087
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8088
getProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8089
    "return the (unix-)processId"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8090
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8091
%{  /* NOCONTEXT */
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8092
    RETURN ( __mkSmallInteger(getpid()) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8093
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8094
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8095
     OperatingSystem getProcessId
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8096
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8097
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8098
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8099
getSystemID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8100
    "if supported by the OS, return the systemID;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8101
     a unique per machine identification.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8102
     WARNING:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8103
	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
  8104
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8105
%{  /* NOCONTEXT */
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8106
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8107
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8108
	char buffer[128];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8109
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8110
	buffer[0] = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8111
	if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8112
	    buffer[127] = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8113
	    if (strlen(buffer) > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8114
		RETURN(__MKSTRING(buffer));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8115
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8116
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8117
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8118
#elif defined(HAS_GETHOSTID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8119
    int runningId;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8120
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8121
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8122
    runningId = gethostid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8123
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8124
    *(int *)(__byteArrayVal(arr)) = runningId;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8125
    RETURN (arr);
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8126
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8127
#elif defined(IRIX5)
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8128
    char idBuffer[MAXSYSIDSIZE];
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8129
    int retVal;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8130
    OBJ arr;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8131
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8132
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8133
	arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8134
	bcopy(idBuffer, __byteArrayVal(arr), MAXSYSIDSIZE);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8135
	RETURN (arr);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8136
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8137
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8138
%}.
13726
73a69112be21 comment/format in: #getSystemType
Stefan Vogel <sv@exept.de>
parents: 13365
diff changeset
  8139
    ^ #unknown
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8140
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8141
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8142
     OperatingSystem getSystemID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8143
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8144
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8145
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8146
getSystemInfo
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8147
    "return info on the system we are running on.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8148
     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
  8149
     otherwise, some simulated info is returned.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8150
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8151
     WARNING:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8152
       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
  8153
       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
  8154
       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
  8155
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8156
       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
  8157
       information.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8158
       (in case of system/version specific OS errors, conditional workarounds and patches
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8159
	may be based upon this info).
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8160
       Also, applications could enable/disable buffering or otherwise reduce
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8161
       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
  8162
       Your application may make use of available information for tuning,
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8163
       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
  8164
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8165
     The returned info may (or may not) contain:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8166
	#system -> some operating system identification (irix, Linux, nt, win32s ...)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8167
	#version -> OS version (some os version identification)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8168
	#release -> OS release (3.5, 1.2.1 ...)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8169
	#node   -> some host identification (hostname)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8170
	#domain  -> domain name (hosts domain)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8171
	#machine -> type of CPU (i586, mips ...)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8172
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8173
     those are currently returned on some machines (no warranty)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8174
     linux:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8175
	#totalRam         -> total amount of memory available
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8176
	#sharedRam        -> amount of memory which is shared among processes
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8177
			     (i.e. shared code)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8178
	#bufferRam        -> amount used for buffers
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8179
	#swapSize         -> total size of swap space
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8180
	#freeSwap         -> free amount in swapSpace
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8181
	#numberOfCPUs     -> number of cpus in box
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8182
	#extendedInstructions -> extended instruction set info
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8183
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8184
     osf:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8185
	#physicalRam      -> total amount of physical memory
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8186
	#cpuType          -> type of cpu (more detailed than machine)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8187
	#numberOfCPUs     -> number of cpus in box
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8188
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8189
     osx:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8190
	#physicalRam      -> total amount of physical memory
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8191
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8192
     solaris:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8193
	#physicalRam      -> total amount of physical memory
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8194
	#availableRam     -> total available amount of physical memory (i.e. unused ram)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8195
	#freeRam          -> amount of free memory
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8196
	#numberOfCPUs     -> number of cpus in box (online CPUS)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8197
	[#dCacheSize]     -> bytes in data cache (only available on some solaris versions)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8198
	[#iCacheSize]     -> bytes in data cache (only available on some solaris versions)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8199
	[#instructionSets]-> instruction sets available (only available on some solaris versions)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8200
	[#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
  8201
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8202
     hpux:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8203
	#physicalRam      -> total amount of physical memory in box
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8204
	#activeRealMemory -> ? - read pstat documentation
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8205
	#activeVirtualRam -> ? - read pstat documentation
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8206
	#freeMemory       -> ? - read pstat documentation
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8207
	#realMemory       -> ? (amount of memory left to user programs)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8208
	#virtualRam       -> ? - read pstat documentation
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8209
    "
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8210
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8211
    |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
  8212
     physicalRam availableRam totalRam sharedRam bufferRam swapSize freeSwap
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8213
     numberOfCPUs numberOfPhysicalCPUs pageSize physicalPages availablePages dCacheSize iCacheSize
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8214
     virtualRam activeVirtualRam realMemory activeRealMemory freeMemory
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8215
     instructionSets extendedInstructions platform|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8216
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8217
%{  /* STACK: 4096 */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8218
#ifdef LINUX
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  8219
# ifdef ELF /* old a.out unixes do not have this ... */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8220
    /*
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8221
     * additional info available ...
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8222
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8223
    struct sysinfo infoBuffer;
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8224
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8225
    if (sysinfo(&infoBuffer) >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8226
	totalRam   = __MKUINT(infoBuffer.totalram);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8227
	sharedRam = __MKUINT(infoBuffer.sharedram);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8228
	bufferRam = __MKUINT(infoBuffer.bufferram);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8229
	swapSize  = __MKUINT(infoBuffer.totalswap);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8230
	freeSwap  = __MKUINT(infoBuffer.freeswap);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8231
    }
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  8232
# endif
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8233
#endif /* LINUX */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8234
4088
622551d3c0d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  8235
#if defined(hpux) && !defined(__GNUC__)
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8236
# include <sys/pstat.h>
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8237
    struct pst_static stat_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8238
    struct pst_dynamic dynam_buf;
11285
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8239
    union pstun pstun_static;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8240
    union pstun pstun_dynamic;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8241
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8242
    pstun_static.pst_static = &stat_buf;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8243
    pstun_dynamic.pst_dynamic = &dynam_buf;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  8244
    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
  8245
    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
  8246
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8247
    physicalRam        = __MKUINT(stat_buf.physical_memory/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8248
    virtualRam         = __MKUINT(dynam_buf.psd_vm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8249
    activeVirtualRam   = __MKUINT(dynam_buf.psd_avm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8250
    realMemory         = __MKUINT(dynam_buf.psd_rm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8251
    activeRealMemory   = __MKUINT(dynam_buf.psd_arm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8252
    freeMemory         = __MKUINT(dynam_buf.psd_free/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8253
#endif
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8254
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8255
#if defined(HAS_UNAME)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8256
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8257
	struct utsname ubuff;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8258
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8259
	if (uname(&ubuff) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8260
	    sys  = __MKSTRING(ubuff.sysname);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8261
	    node = __MKSTRING(ubuff.nodename);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8262
	    rel  = __MKSTRING(ubuff.release);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8263
	    ver  = __MKSTRING(ubuff.version);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8264
	    mach = __MKSTRING(ubuff.machine);
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8265
# if defined(HAS_UTS_DOMAINNAME) || defined(_GNU_SOURCE)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8266
	    dom  = __MKSTRING(ubuff.domainname);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8267
# endif /* no HAS_UTS_DOMAINNAME */
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8268
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8269
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8270
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8271
#else /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8272
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8273
    /*
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8274
     * use fallBack code below
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8275
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8276
#endif /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8277
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8278
#if defined(HAS_SYSINFO)
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8279
# if defined(SI_ARCHITECTURE)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8280
    if (arch == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8281
	char buffer[128];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8282
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8283
	if (sysinfo(SI_ARCHITECTURE, buffer, sizeof(buffer))) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8284
	    arch = __MKSTRING(buffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8285
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8286
    }
4923
1cacdcfc82c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4922
diff changeset
  8287
# endif /* SI_ARCHITECTURE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8288
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8289
# if defined(SI_ISALIST)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8290
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8291
	char buffer[128];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8292
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8293
	if (sysinfo(SI_ISALIST, buffer, sizeof(buffer))) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8294
	    instructionSets = __MKSTRING(buffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8295
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8296
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8297
# endif /* SI_ISALIST */
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8298
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8299
# if defined(SI_PLATFORM)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8300
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8301
	char buffer[128];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8302
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8303
	if (sysinfo(SI_PLATFORM, buffer, sizeof(buffer))) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8304
	    platform = __MKSTRING(buffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8305
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8306
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8307
# endif /* SI_PLATFORM */
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8308
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8309
# if defined(SI_RELEASE)
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8310
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8311
	char buffer[128];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8312
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8313
	if (sysinfo(SI_RELEASE, buffer, sizeof(buffer))) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8314
	    rel = __MKSTRING(buffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8315
	}
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8316
    }
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8317
# endif /* SI_RELEASE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8318
#endif /* HAS_SYSINFO */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8319
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8320
#if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8321
# ifdef _SC_NPROCESSORS_ONLN
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8322
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8323
	long val;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8324
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8325
	val = sysconf(_SC_NPROCESSORS_ONLN);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8326
	if (val > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8327
	    numberOfCPUs = __MKINT(val);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8328
	}
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8329
    }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8330
# endif
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8331
# ifdef _SC_NPROCESSORS_CONF
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8332
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8333
	long val;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8334
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8335
	val = sysconf(_SC_NPROCESSORS_CONF);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8336
	if (val > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8337
	    numberOfPhysicalCPUs = __MKINT(val);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8338
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8339
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8340
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8341
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8342
# if defined(_SC_PAGESIZE)
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8343
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8344
	long val;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8345
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8346
	val = sysconf(_SC_PAGESIZE);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8347
	if (val != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8348
	    pageSize = __MKUINT(val);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8349
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8350
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8351
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8352
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8353
# if defined(_SC_PHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8354
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8355
	long val;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8356
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8357
	val = sysconf(_SC_PHYS_PAGES);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8358
	if (val != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8359
	    physicalPages = __MKUINT(val);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8360
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8361
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8362
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8363
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8364
# if defined(_SC_AVPHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8365
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8366
	long val;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8367
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8368
	val = sysconf(_SC_AVPHYS_PAGES);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8369
	if (val != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8370
	    availablePages = __MKUINT(val);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8371
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8372
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8373
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8374
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8375
# if defined(_SC_ICACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8376
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8377
	long val;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8378
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8379
	val = sysconf(_SC_ICACHE_SZ);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8380
	if (val != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8381
	    iCacheSize = __MKUINT(val);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8382
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8383
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8384
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8385
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8386
# if defined(_SC_DCACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8387
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8388
	long val;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8389
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8390
	val = sysconf(_SC_DCACHE_SZ);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8391
	if (val != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8392
	    dCacheSize = __MKUINT(val);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8393
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8394
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8395
# endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8396
#endif /* HAS_SYSCONF */
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8397
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8398
#if defined(HAS_GETSYSINFO)
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8399
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8400
	INT index;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8401
	int retInt32 = 0;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8402
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8403
# if defined(GSI_CPU)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8404
	index = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8405
	if (getsysinfo(GSI_CPU, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8406
	    switch (retInt32) {
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8407
#  ifdef VAX_780
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8408
		case VAX_780:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8409
		    cpuType = __MKSTRING("VAX_780");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8410
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8411
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8412
#  ifdef VAX_750
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8413
		case VAX_750:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8414
		    cpuType = __MKSTRING("VAX_750");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8415
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8416
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8417
#  ifdef VAX_730
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8418
		case VAX_730:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8419
		    cpuType = __MKSTRING("VAX_730");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8420
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8421
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8422
#  ifdef VAX_8600
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8423
		case VAX_8600:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8424
		    cpuType = __MKSTRING("VAX_8600");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8425
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8426
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8427
#  ifdef VAX_8200
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8428
		case VAX_8200:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8429
		    cpuType = __MKSTRING("VAX_8200");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8430
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8431
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8432
#  ifdef VAX_8800
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8433
		case VAX_8800:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8434
		    cpuType = __MKSTRING("VAX_8800");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8435
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8436
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8437
#  ifdef MVAX_I
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8438
		case MVAX_I:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8439
		    cpuType = __MKSTRING("MVAX_I");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8440
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8441
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8442
#  ifdef MVAX_II
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8443
		case MVAX_II:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8444
		    cpuType = __MKSTRING("MVAX_II");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8445
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8446
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8447
#  ifdef V_VAX
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8448
		case V_VAX:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8449
		    cpuType = __MKSTRING("V_VAX");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8450
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8451
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8452
#  ifdef VAX_3600
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8453
		case VAX_3600:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8454
		    cpuType = __MKSTRING("VAX_3600");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8455
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8456
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8457
#  ifdef VAX_6200
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8458
		case VAX_6200:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8459
		    cpuType = __MKSTRING("VAX_6200");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8460
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8461
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8462
#  ifdef VAX_3400
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8463
		case VAX_3400:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8464
		    cpuType = __MKSTRING("VAX_3400");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8465
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8466
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8467
#  ifdef C_VAXSTAR
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8468
		case C_VAXSTAR:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8469
		    cpuType = __MKSTRING("C_VAXSTAR");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8470
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8471
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8472
#  ifdef VAX_60
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8473
		case VAX_60:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8474
		    cpuType = __MKSTRING("VAX_60");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8475
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8476
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8477
#  ifdef VAX_3900
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8478
		case VAX_3900:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8479
		    cpuType = __MKSTRING("VAX_3900");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8480
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8481
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8482
#  ifdef DS_3100
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8483
		case DS_3100:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8484
		    cpuType = __MKSTRING("DS_3100");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8485
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8486
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8487
#  ifdef VAX_8820
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8488
		case VAX_8820:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8489
		    cpuType = __MKSTRING("VAX_8820");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8490
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8491
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8492
#  ifdef DS_5400
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8493
		case DS_5400:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8494
		    cpuType = __MKSTRING("DS_5400");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8495
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8496
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8497
#  ifdef DS_5800
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8498
		case DS_5800:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8499
		    cpuType = __MKSTRING("DS_5800");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8500
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8501
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8502
#  ifdef DS_5000
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8503
		case DS_5000:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8504
		    cpuType = __MKSTRING("DS_5000");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8505
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8506
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8507
#  ifdef DS_CMAX
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8508
		case DS_CMAX:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8509
		    cpuType = __MKSTRING("DS_CMAX");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8510
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8511
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8512
#  ifdef VAX_6400
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8513
		case VAX_6400:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8514
		    cpuType = __MKSTRING("VAX_6400");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8515
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8516
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8517
#  ifdef VAXSTAR
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8518
		case VAXSTAR:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8519
		    cpuType = __MKSTRING("VAXSTAR");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8520
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8521
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8522
#  ifdef DS_5500
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8523
		case DS_5500:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8524
		    cpuType = __MKSTRING("DS_5500");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8525
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8526
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8527
#  ifdef DS_5100
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8528
		case DS_5100:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8529
		    cpuType = __MKSTRING("DS_5100");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8530
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8531
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8532
#  ifdef VAX_9000
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8533
		case VAX_9000:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8534
		    cpuType = __MKSTRING("VAX_9000");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8535
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8536
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8537
#  ifdef DS_500_100
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8538
		case DS_500_100:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8539
		    cpuType = __MKSTRING("DS_500_100");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8540
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8541
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8542
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8543
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8544
#  ifdef ALPHA_ADU
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8545
		case ALPHA_ADU:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8546
		    cpuType = __MKSTRING("ALPHA_ADU");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8547
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8548
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8549
#  ifdef DEC_4000
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8550
		case DEC_4000:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8551
		    cpuType = __MKSTRING("DEC_4000");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8552
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8553
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8554
#  ifdef DEC_3000_500
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8555
		case DEC_3000_500:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8556
		    cpuType = __MKSTRING("DEC_3000_500");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8557
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8558
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8559
#  ifdef DEC_7000
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8560
		case DEC_7000:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8561
		    cpuType = __MKSTRING("DEC_7000");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8562
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8563
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8564
#  ifdef DS_5000_300
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8565
		case DS_5000_300:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8566
		    cpuType = __MKSTRING("DS_5000_300");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8567
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8568
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8569
#  ifdef DEC_3000_300
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8570
		case DEC_3000_300:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8571
		    cpuType = __MKSTRING("DEC_3000_300");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8572
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8573
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8574
#  ifdef DEC_2000_300
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8575
		case DEC_2000_300:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8576
		    cpuType = __MKSTRING("DEC_2000_300");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8577
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8578
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8579
#  ifdef DEC_2100_A500
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8580
		case DEC_2100_A500:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8581
		    cpuType = __MKSTRING("DEC_2100_A500");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8582
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8583
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8584
#  ifdef DEC_2100_A50
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8585
		case DEC_2100_A50:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8586
		    cpuType = __MKSTRING("DEC_2100_A50");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8587
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8588
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8589
#  ifdef ALPHA_KN20AA
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8590
		case ALPHA_KN20AA:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8591
		    cpuType = __MKSTRING("ALPHA_KN20AA");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8592
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8593
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8594
#  ifdef DEC_21000
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8595
		case DEC_21000:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8596
		    cpuType = __MKSTRING("DEC_21000");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8597
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8598
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8599
#  ifdef DEC_AXPVME_64
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8600
		case DEC_AXPVME_64:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8601
		    cpuType = __MKSTRING("DEC_AXPVME_64");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8602
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8603
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8604
#  ifdef DEC_2100_C500
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8605
		case DEC_2100_C500:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8606
		    cpuType = __MKSTRING("DEC_2100_C500");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8607
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8608
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8609
#  ifdef DEC_AXPPCI_33
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8610
		case DEC_AXPPCI_33:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8611
		    cpuType = __MKSTRING("DEC_AXPPCI_33");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8612
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8613
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8614
#  ifdef DEC_1000
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8615
		case DEC_1000:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8616
		    cpuType = __MKSTRING("DEC_1000");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8617
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8618
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8619
#  ifdef EB64_PLUS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8620
		case EB64_PLUS:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8621
		    cpuType = __MKSTRING("EB64_PLUS");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8622
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8623
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8624
#  ifdef LCA_EB66
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8625
		case LCA_EB66:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8626
		    cpuType = __MKSTRING("LCA_EB66");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8627
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8628
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8629
#  ifdef ALPHA_EB164
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8630
		case ALPHA_EB164:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8631
		    cpuType = __MKSTRING("ALPHA_EB164");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8632
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8633
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8634
#  ifdef DEC_EV45_PBP
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8635
		case DEC_EV45_PBP:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8636
		    cpuType = __MKSTRING("DEC_EV45_PBP");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8637
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8638
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8639
#  ifdef DEC_1000A
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8640
		case DEC_1000A:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8641
		    cpuType = __MKSTRING("DEC_1000A");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8642
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8643
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8644
#  ifdef DEC_4100
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8645
		case DEC_4100:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8646
		    cpuType = __MKSTRING("DEC_4100");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8647
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8648
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8649
#  ifdef DEC_ALPHAVME_224
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8650
		case DEC_ALPHAVME_224:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8651
		    cpuType = __MKSTRING("DEC_ALPHAVME_224");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8652
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8653
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8654
#  ifdef DEC_1000_5
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8655
		case DEC_1000_5:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8656
		    cpuType = __MKSTRING("DEC_1000_5");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8657
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8658
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8659
#  ifdef DEC_1000A_5
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8660
		case DEC_1000A_5:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8661
		    cpuType = __MKSTRING("DEC_1000A_5");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8662
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8663
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8664
#  ifdef DEC_EV56_PBP
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8665
		case DEC_EV56_PBP:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8666
		    cpuType = __MKSTRING("DEC_EV56_PBP");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8667
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8668
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8669
#  ifdef ALPHABOOK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8670
		case ALPHABOOK:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8671
		    cpuType = __MKSTRING("ALPHABOOK");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8672
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8673
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8674
#  ifdef DEC_ALPHAVME_320
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8675
		case DEC_ALPHAVME_320:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8676
		    cpuType = __MKSTRING("DEC_ALPHAVME_320");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8677
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8678
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8679
#  ifdef DEC_550
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8680
		case DEC_550:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8681
		    cpuType = __MKSTRING("DEC_550");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8682
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8683
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8684
#  ifdef DEC_6600
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8685
		case DEC_6600:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8686
		    cpuType = __MKSTRING("DEC_6600");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8687
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8688
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8689
#  ifdef UNKN_SYSTEM
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8690
		case UNKN_SYSTEM:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8691
		    cpuType = __MKSTRING("UNKN_SYSTEM");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8692
		    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8693
#  endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8694
		default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8695
		    cpuType = __MKSTRING("OTHER_DEC_SYSTEM");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8696
		    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8697
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8698
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8699
# endif /* GSI_CPU */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8700
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8701
# if defined(GSI_CPU_INFO)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8702
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8703
	 * stupid: OSF1 pre V4.0 has no mhz, but V4.0 has it.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8704
	 * use the GSI_PLATFORM_NAME as a hint - it is only defined in
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8705
	 * V4.0 and higher ... (sigh)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8706
	 */
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  8707
#  if defined(GSI_PLATFORM_NAME)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8708
	{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8709
	    struct cpu_info cpuInfo;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8710
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8711
	    index = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8712
	    if (getsysinfo(GSI_CPU_INFO, &cpuInfo, sizeof(cpuInfo), &index, NULL) > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8713
		cpuSpeed   = __MKUINT(cpuInfo.mhz);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8714
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8715
	}
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  8716
#  endif
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8717
# endif /* GSI_CPU_INFO */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8718
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8719
# if defined(GSI_CPUS_IN_BOX)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8720
	index = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8721
	if (getsysinfo(GSI_CPUS_IN_BOX, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8722
	    numberOfCPUs   = __MKUINT(retInt32);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8723
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8724
# endif /* GSI_CPUS_IN_BOX */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8725
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8726
# if defined(GSI_PHYSMEM)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8727
	index = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8728
	if (getsysinfo(GSI_PHYSMEM, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8729
	    INT bytes = retInt32 * 1024;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8730
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8731
	    physicalRam   = __MKUINT(bytes);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8732
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8733
# endif /* GSI_PHYSMEM */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8734
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8735
# if defined(GSI_PLATFORM_NAME) && (!defined(HAS_SYSINFO) || !defined(SI_PLATFORM))
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8736
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8737
	char buffer[128];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8738
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8739
	index = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8740
	if (getsysinfo(GSI_PLATFORM_NAME, buffer, sizeof(buffer), &index, NULL) > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8741
	    platform = __MKSTRING(buffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8742
	}
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8743
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8744
# endif /* GSI_PLATFORM_NAME */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8745
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8746
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8747
#endif /* HAS_GETSYSINFO */
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  8748
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8749
#if defined(HAS_SYSCTL) /* __osx__ */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8750
    int mib[3];
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8751
    long _physmem;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8752
    size_t _len;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8753
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8754
    mib[0] = CTL_HW;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8755
    mib[1] = HW_MEMSIZE;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8756
    _len = sizeof(_physmem);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8757
    sysctl(mib, 2, &_physmem, &_len, NULL, 0);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8758
    physicalRam   = __MKUINT(_physmem);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8759
#endif /* __osx__ */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8760
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8761
#if defined(__x86_64__)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8762
    cpuType = __MKSTRING("x86_64");
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8763
#endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8764
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8765
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8766
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8767
	extern OBJ __getInstructionSetInfo();
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8768
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8769
	extendedInstructions = __getInstructionSetInfo();
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8770
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8771
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8772
    sys isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8773
	sys := self getSystemType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8774
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8775
    node isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8776
	node := self getHostName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8777
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8778
    dom isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8779
	dom := self getDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8780
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8781
    mach isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8782
	mach := self getCPUType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8783
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8784
    arch isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8785
	arch := sys.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8786
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8787
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8788
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8789
    info at:#system put:sys.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8790
    info at:#node put:node.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8791
    rel notNil ifTrue:[info at:#release put:rel].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8792
    ver notNil ifTrue:[info at:#version put:ver].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8793
    mach notNil ifTrue:[info at:#machine put:mach].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8794
    arch notNil ifTrue:[info at:#architecture put:arch].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8795
    dom notNil ifTrue:[info at:#domain put:dom].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8796
    (pageSize notNil and:[physicalPages notNil]) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8797
	physicalRam := pageSize * physicalPages. "/ done here - could be largeInt.
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8798
    ].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8799
    physicalRam notNil ifTrue:[info at:#physicalRam put:physicalRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8800
    (pageSize notNil and:[availablePages notNil]) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8801
	availableRam := pageSize * availablePages. "/ done here - could be largeInt.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8802
	availableRam notNil ifTrue:[info at:#availableRam put:availableRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8803
    ].
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8804
    totalRam notNil ifTrue:[info at:#totalRam put:totalRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8805
    sharedRam notNil ifTrue:[info at:#sharedRam put:sharedRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8806
    bufferRam notNil ifTrue:[info at:#bufferRam put:bufferRam].
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8807
    virtualRam notNil ifTrue:[info at:#virtualRam put:virtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8808
    activeVirtualRam notNil ifTrue:[info at:#activeVirtualRam put:activeVirtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8809
    realMemory notNil ifTrue:[info at:#realMemory put:realMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8810
    activeRealMemory notNil ifTrue:[info at:#activeRealMemory put:activeRealMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  8811
    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
  8812
    swapSize notNil ifTrue:[info at:#swapSize put:swapSize].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  8813
    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
  8814
    numberOfCPUs notNil ifTrue:[info at:#numberOfCPUs put:numberOfCPUs].
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8815
    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
  8816
    cpuType notNil ifTrue:[info at:#cpuType put:cpuType].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  8817
    cpuSpeed notNil ifTrue:[info at:#cpuSpeed put:cpuSpeed].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8818
    dCacheSize notNil ifTrue:[info at:#dCacheSize put:dCacheSize].
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  8819
    iCacheSize notNil ifTrue:[info at:#iCacheSize put:iCacheSize].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  8820
    instructionSets notNil ifTrue:[info at:#instructionSets put:instructionSets].
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  8821
    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
  8822
    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
  8823
    info at:#osType put:(self getOSType).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8824
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8825
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8826
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8827
     OperatingSystem getSystemInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8828
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8829
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8830
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8831
getSystemType
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8832
    "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
  8833
     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
  8834
     is slightly different for some systems (i.e. iris vs. irix).
13726
73a69112be21 comment/format in: #getSystemType
Stefan Vogel <sv@exept.de>
parents: 13365
diff changeset
  8835
     Don't depend on this - use getOSType. I dont really see a point
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8836
     here ...
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8837
     (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
  8838
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8839
    |sys|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8840
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8841
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8842
#   ifdef NEXT
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8843
#    define SYS_SYMBOL @symbol(next)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8844
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8845
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8846
#   ifdef IRIS
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8847
#    define SYS_SYMBOL @symbol(iris)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8848
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8849
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8850
#   ifdef SYS_SYMBOL
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8851
     sys = SYS_SYMBOL;
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  8852
#    undef SYS_SYMBOL
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8853
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8854
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8855
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8856
    sys isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8857
	^ self getOSType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8858
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8859
    ^ sys
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8860
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8861
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8862
     OperatingSystem getSystemType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8863
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8864
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8866
isBSDlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8867
    "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
  8868
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8869
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8870
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8871
#if defined(BSD) || defined(MACH) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8872
    RETURN ( true );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8873
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8874
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8875
    ^ false
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8876
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8877
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8878
     OperatingSystem isBSDlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8879
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8880
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8881
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8882
isLinuxLike
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8883
    "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
  8884
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8885
17579
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8886
%{  /* NOCONTEXT */
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8887
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8888
#if defined(LINUX)
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8889
    RETURN ( true );
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8890
#endif
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8891
%}.
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8892
    ^ false
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8893
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8894
    "
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8895
     OperatingSystem isLinuxLike
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8896
    "
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8897
!
4d70eacfd5d7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17530
diff changeset
  8898
14802
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8899
isOSXlike
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8900
    "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
  8901
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8902
%{  /* NOCONTEXT */
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8903
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8904
#if defined(__osx__)
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8905
    RETURN ( true );
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8906
#endif
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8907
%}.
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8908
    ^ false
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8909
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8910
    "
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8911
     OperatingSystem isOSXlike
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8912
    "
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8913
!
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  8914
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8915
isProcessIdPresent:pid
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8916
    "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
  8917
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8918
%{
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8919
    if (__isSmallInteger(pid)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8920
	/* in UNIX, a kill(pid, 0) is a noop used to check if a pid exists */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8921
	if (kill(__smallIntegerVal(pid), 0) < 0 && errno != EPERM) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8922
	    RETURN ( false );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8923
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8924
	RETURN ( true );
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8925
    }
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8926
%}.
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8927
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8928
    ^ self primitiveFailed:#invalidParameter
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8929
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8930
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8931
    "
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8932
      self isProcessIdPresent:self getProcessId
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8933
      self isProcessIdPresent:1
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8934
      self isProcessIdPresent:4711
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8935
    "
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8936
!
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  8937
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8938
isUNIXlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8939
    "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
  8940
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8941
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8942
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8943
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8944
     OperatingSystem isUNIXlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8945
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8946
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8947
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8948
maxFileNameLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8949
    "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
  8950
     CAVEAT:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8951
	 Actually, the following is somewhat wrong - some systems
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8952
	 support different sizes, depending on the volume.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8953
	 We return a somewhat conservative number here.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8954
	 Another entry, to query for volume specific max
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8955
	 will be added in the future."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8956
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8957
%{  /* NOCONTEXT */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8958
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8959
    /*
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8960
     * 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
  8961
     */
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8962
#   if defined(MAXFILENAMELEN)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8963
      RETURN ( __mkSmallInteger(MAXFILENAMELEN) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8964
#   else
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8965
#    if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8966
      RETURN ( __mkSmallInteger(255) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8967
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8968
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8969
#    ifdef realIX
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8970
       RETURN ( __mkSmallInteger(127) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8971
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8972
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8973
#    ifdef SYSV
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8974
       RETURN ( __mkSmallInteger(14) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8975
#    endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8976
#   endif
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
    "unix default"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8979
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8980
    ^ 14
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8981
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8982
    "
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8983
     OperatingSystem maxFileNameLength
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8984
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8985
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8986
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8987
maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8988
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8989
%{
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8990
     long l;
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8991
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8992
     l = sysconf(_SC_OPEN_MAX);
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8993
     if (l >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  8994
	 RETURN(__mkSmallInteger(l));
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8995
     }
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8996
%}.
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8997
     self primitiveFailed
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8998
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8999
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9000
      self maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9001
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9002
!
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  9003
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9004
maxPathLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9005
    "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
  9006
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9007
%{  /* NOCONTEXT */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9008
    RETURN ( __mkSmallInteger(MAXPATHLEN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9009
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9010
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9011
     OperatingSystem maxPathLength
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9012
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9013
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9014
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9015
pathSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9016
    "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
  9017
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9018
    ^ $:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9019
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9020
    "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
  9021
    "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
  9022
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9023
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9024
primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9025
    "return the domain this host is in.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9026
     Notice:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9027
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9028
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9029
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9030
#if defined(HAS_GETDOMAINNAME)
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  9031
    char buffer[256];
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9032
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9033
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9034
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9035
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9036
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9037
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9038
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9039
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9040
    if (uname(&ubuff) >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9041
	RETURN (__MKSTRING(ubuff.domainname));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9042
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9043
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9044
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9045
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9046
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9047
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9048
    if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9049
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9050
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9051
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9052
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9053
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9054
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9055
    ^ nil
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9056
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9057
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9058
     OperatingSystem primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9059
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9060
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9061
    "Modified: 26.4.1996 / 10:04:54 / stefan"
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9062
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9063
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9064
primGetHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9065
    "return the hostname we are running on - if there is
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9066
     a HOST environment variable, we are much faster here ...
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9067
     Notice:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9068
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9069
6960
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9070
%{  /* STACK: 100000 */
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9071
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9072
    /* sigh - with libc.so.6, gethostname needs huge amounts of stack
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9073
     * actually this is linux specific, but should not hurt others
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  9074
     */
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9075
#if defined(HAS_GETHOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9076
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9077
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9078
    if (gethostname(buffer, sizeof(buffer)) == 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9079
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9080
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9081
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9082
# if defined(HAS_UNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9083
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9084
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9085
    if (uname(&ubuff) >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9086
	RETURN (__MKSTRING(ubuff.nodename));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9087
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9088
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9089
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9090
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9091
    int ret;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9092
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9093
    if ((ret = sysinfo(SI_HOSTNAME, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9094
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9095
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9096
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9097
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9098
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9099
%}.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9100
    ^ nil
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9101
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9102
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9103
     OperatingSystem getHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9104
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9105
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  9106
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9107
randomBytesInto:bufferOrInteger
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9108
    "If bufferOrInteger is a String or a ByteArray,
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9109
	fill a given buffer with random bytes from the RtlGenRandom function
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9110
	and answer the buffer.
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9111
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9112
     If bufferOrInteger is a SmallInteger,
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9113
	return this many bytes (max 4) as a SmallInteger.
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9114
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9115
     Return nil on error (may raise PrimitiveFailure, too).
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9116
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9117
     NOTE: This is a private interface, please use RandomGenerator!!"
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9118
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9119
%{
17152
e8edb92e5a83 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17149
diff changeset
  9120
#ifdef LINUX
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9121
# include <linux/random.h>
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9122
# if defined(GRND_RANDOM) && defined(GRND_NONBLOCK)
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9123
    // getrandom(2) is upported starting with linux 3.17
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9124
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9125
    int wanted, cnt, gotSoFar = 0;
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9126
    char *buffer;
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9127
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9128
    if (__isSmallInteger(bufferOrInteger) && (wanted = __smallIntegerVal(bufferOrInteger) <= 4)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9129
	int buf = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9130
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9131
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9132
	    cnt = getrandom(&buf + gotSoFar, wanted - gotSoFar, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9133
	    if (cnt < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9134
		if (errno != EINTR && errno != EAGAIN))
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9135
		    goto error;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9136
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9137
		gotSoFar = gotSoFar + cnt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9138
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9139
	} while (gotSoFar < wanted);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9140
	RETURN(__mkSmallInteger(buf));
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9141
    } else if (__isByteArray(bufferOrinteger)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9142
	wanted = __byteArraySize(bufferOrinteger);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9143
	buffer = __byteArrayVal(bufferOrinteger);
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9144
    } else if (__isString(bufferOrinteger)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9145
	wanted = __stringSize(bufferOrinteger);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9146
	buffer = __stringVal(bufferOrinteger);
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9147
    } else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9148
	goto error;
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9149
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9150
    do {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9151
	cnt = getrandom(buffer + gotSoFar, wanted - gotSoFar, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9152
	if (cnt < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9153
	    if (errno != EINTR && errno != EAGAIN))
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9154
		goto error;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9155
	    buffer = __isByteArray(bufferOrinteger) ?
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9156
			__byteArrayVal(bufferOrinteger) : __stringVal(bufferOrinteger);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9157
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9158
	    gotSoFar = gotSoFar + cnt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9159
	}
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9160
    } while (gotSoFar < wanted);
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9161
    RETURN(bufferOrinteger);
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9162
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9163
# endif // linux
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9164
#endif  // GRND_RANDOM
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9165
error: ;
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9166
%}.
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9167
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9168
    ^ self primitiveFailed.
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9169
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9170
    "
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9171
	self randomBytesInto:2.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9172
	self randomBytesInto:(ByteArray new:16).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9173
	self randomBytesInto:(String new:16).
16866
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9174
    "
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9175
!
16a5deee71c4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16756
diff changeset
  9176
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9177
setEnvironment:aKeyStringOrSymbol to:aString
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9178
    "put a string to the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9179
     If aString isNil, the variable will be removed from the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9180
     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
  9181
     We could use ExternalBytes and keep the references in a Dictionary to free the
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9182
     memory on change or delete"
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9183
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9184
%{  /* NOCONTEXT */
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9185
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9186
    char *env;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9187
    int valueSize;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9188
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9189
    if (__isStringLike(aKeyStringOrSymbol)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9190
	if (aString == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9191
	    /* env used only temporary for deregistration */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9192
	    valueSize = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9193
	    env = __stringVal(aKeyStringOrSymbol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9194
	} else if (__isStringLike(aString)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9195
	    /* have to use stable memory for env */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9196
	    valueSize = __stringSize(aString);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9197
	    env = (char *)malloc(__stringSize(aKeyStringOrSymbol) + valueSize + 2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9198
	    if (env == 0)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9199
		goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9200
	    strcpy(env, __stringVal(aKeyStringOrSymbol));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9201
	    strcat(env, "=");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9202
	    strncat(env, __stringVal(aString), valueSize);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9203
	} else
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9204
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9205
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9206
	if (putenv(env) == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9207
	    RETURN(self);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9208
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9209
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9210
	if (valueSize > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9211
	    /* could not register, free */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9212
	    free(env);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9213
	}
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9214
err:;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9215
    }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9216
%}.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9217
    ^ self primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9218
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9219
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9220
     OperatingSystem setEnvironment:#TEST to:'abc'.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9221
     OperatingSystem getEnvironment:#TEST.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9222
     OperatingSystem executeCommand:'echo $TEST' outputTo:Transcript.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9223
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9224
     OperatingSystem setEnvironment:#TEST to:nil.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9225
     OperatingSystem setEnvironment:#TEST to:''.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9226
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9227
     OperatingSystem setEnvironment:#LD_LIBRARY_PATH to:'/opt/oracle/instantclient10_1'.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9228
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9229
!
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  9230
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9231
setLocale:categorySymbol to:localeStringOrNil
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9232
    "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
  9233
     If localeStringOrNil is nil, nothing is set.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9234
     If localeStringOrNil is empty, the locale for categorySymbol ist set from the environment.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9235
     If localeStringOrNil is 'C', the locale for categorySymbol ist set to the default.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9236
     If localeStringOrNil is to a locale name, the locale for categorySymbol ist set.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9237
     The current locale setting is returned."
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9238
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9239
    |locale error|
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9240
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9241
%{
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9242
    int __category;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9243
    char *__locale, *ret;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9244
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9245
    if (categorySymbol == @symbol(LC_ALL)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9246
	__category = LC_ALL;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9247
    } else if (categorySymbol == @symbol(LC_COLLATE)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9248
	__category = LC_COLLATE;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9249
    } else if (categorySymbol == @symbol(LC_CTYPE)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9250
	__category = LC_CTYPE;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9251
    } else if (categorySymbol == @symbol(LC_MESSAGES)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9252
	__category = LC_MESSAGES;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9253
    } else if (categorySymbol == @symbol(LC_MONETARY)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9254
	__category = LC_MONETARY;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9255
    } else if (categorySymbol == @symbol(LC_NUMERIC)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9256
	__category = LC_NUMERIC;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9257
    } else if (categorySymbol == @symbol(LC_TIME)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9258
	__category = LC_TIME;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9259
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9260
	error = @symbol(argument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9261
	goto out;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9262
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9263
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9264
    if (localeStringOrNil == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9265
	__locale = 0;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9266
    } else if (__isStringLike(localeStringOrNil)){
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9267
	__locale = __stringVal(localeStringOrNil);
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9268
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9269
	error = @symbol(argument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9270
	goto out;
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9271
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9272
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9273
    ret = setlocale(__category, __locale);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9274
    if (ret) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9275
	locale = __MKSTRING(ret);
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9276
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9277
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9278
out:;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9279
%}.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9280
    locale notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9281
	^ locale.
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9282
    ].
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9283
    ^ self primitiveFailed:error.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9284
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9285
    "
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9286
     OperatingSystem setLocale:#LC_ALL to:nil
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9287
     OperatingSystem setLocale:#LC_CTYPE to:nil
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9288
     OperatingSystem setLocale:#LC_CTYPE to:'C'
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9289
     OperatingSystem setLocale:#LC_CTYPE to:''
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9290
    "
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9291
!
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  9292
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9293
setLocaleInfo:anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9294
    "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
  9295
     (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
  9296
     See description of fields in #getLocaleInfo.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9297
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9298
     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
  9299
     it should be used by applications as required."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9300
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9301
    LocaleInfo := anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9302
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9303
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9304
     |d|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9305
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9306
     d := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9307
     d at:#decimalPoint                 put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9308
     d at:#thousandsSeparator           put:','         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9309
     d at:#currencySymbol               put:'USD'       .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9310
     d at:#monetaryDecimalPoint         put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9311
     d at:#monetaryThousandsSeparator   put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9312
     d at:#fractionalDigits             put:2           .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9313
     d at:#positiveSign                 put:'+'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9314
     d at:#negativeSign                 put:'-'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9315
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9316
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9317
     OperatingSystem setLocaleInfo:d
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9318
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9319
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9320
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9321
supportsChildInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9322
    "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
  9323
     through interrupts (i.e. SIGCHILD)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9324
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9325
%{  /* NOCONTEXT */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9326
#if defined(SIGCHLD) || defined(SIGCLD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9327
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9328
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9329
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9330
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9332
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9333
     OperatingSystem supportsChildInterrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9334
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9335
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9336
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9337
supportsIOInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9338
    "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
  9339
     (i.e. SIGPOLL/SIGIO).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9340
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9341
     Currently, this mechanism does not work on all
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9342
     systems ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9343
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9344
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9345
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9346
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9347
  /* positive defines here
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9348
   *  - irix5.2 does not work
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9349
   */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9350
#if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9351
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9352
# if defined(SIGIO) || defined(SIGPOLL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9353
#  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
  9354
#   if defined(F_SETOWN) || defined(FIOSETOWN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9355
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9356
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9357
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9358
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9359
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9360
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9361
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9362
#endif /* machines where it works */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9363
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9364
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9365
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9366
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9367
     OperatingSystem supportsIOInterrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9368
    "
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  9369
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9370
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9371
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9372
supportsNonBlockingIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9373
    "return true, if the OS supports nonblocking IO."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9374
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9375
%{  /* NOCONTEXT */
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9376
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9377
# 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
  9378
       RETURN (true);
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9379
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9380
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9381
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9382
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9383
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9384
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9385
     OperatingSystem supportsNonBlockingIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9386
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9387
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9388
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9389
supportsSymbolicLinks
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9390
    "return true, if the OS supports symbolic (soft) links;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9391
     most UNIX'es do; many other OS's do not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9392
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9393
%{  /* NOCONTEXT */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9394
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9395
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9396
    /*
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9397
     * assume yes - if that is defined.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9398
     */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9399
    RETURN(true);
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9400
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9401
%}.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9402
    ^ false
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9403
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9404
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9405
     OperatingSystem supportsSymbolicLinks
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9406
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  9407
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9408
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9409
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9410
!UnixOperatingSystem class methodsFor:'path queries'!
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9411
16417
88b61e714dd0 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16410
diff changeset
  9412
decodePathOrCommandOutput:encodedPathNameOrOutputLine
16396
4896e6f5ffda class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16391
diff changeset
  9413
    "decode the encodedPathNameOrOutputLine as returned by system calls or output by system commands.
4896e6f5ffda class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16391
diff changeset
  9414
     E.g. linux system calls return single byte strings only,
17499
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9415
     so pathNames and command output comes UTF-8 encoded.
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9416
     (actually, on a mac, it comes utf8-mac encoded)."
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9417
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9418
    Codeset notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9419
	encodedPathNameOrOutputLine notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9420
	    [
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9421
		"/ cg: I am not sure, why this shortcut.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9422
		"/ calling the decoder directly should be much faster
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9423
		Codeset == #utf8 ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9424
		    ^ encodedPathNameOrOutputLine utf8Decoded.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9425
		].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9426
		"/ Codeset encoder might not yet be initialized, sigh...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9427
		CodesetEncoder isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9428
		    self getCodesetEncoder
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9429
		].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9430
		CodesetEncoder notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9431
		    ^ CodesetEncoder decodeString: encodedPathNameOrOutputLine
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9432
		].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9433
	    ] on:InvalidEncodingError do:[:ex|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9434
		"maybe there are old filenames in ISO8859-x,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9435
		 just keep them untranslated"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9436
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9437
	].
16396
4896e6f5ffda class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16391
diff changeset
  9438
    ].
4896e6f5ffda class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16391
diff changeset
  9439
    ^ encodedPathNameOrOutputLine
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9440
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9441
    "Modified: / 23-01-2013 / 10:02:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  9442
!
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  9443
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9444
defaultSystemPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9445
    "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
  9446
     (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
  9447
16653
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9448
    |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
  9449
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  9450
    majorVersionNr := Smalltalk majorVersionNr.
16646
eb3524f545f4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16645
diff changeset
  9451
    minorVersionNr := Smalltalk minorVersionNr.
eb3524f545f4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16645
diff changeset
  9452
    vsnDirName := '%1.%2' bindWith:majorVersionNr with:minorVersionNr.
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9453
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9454
    sysPath := super defaultSystemPath.
16653
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9455
    places :=
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9456
	#(
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9457
	    '/usr/local/lib/stx'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9458
	    '/usr/local/lib/smalltalk'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9459
	    '/usr/local/lib/smalltalk-x'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9460
	    '/usr/lib/stx'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9461
	    '/usr/lib/smalltalk'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9462
	    '/usr/lib/smalltalk-x'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9463
	    '/lib/stx'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9464
	    '/lib/smalltalk'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9465
	    '/lib/smalltalk-x'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9466
	    '/opt/stx'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9467
	    '/opt/smalltalk'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9468
	    '/opt/smalltalk-x'
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9469
	).
16653
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9470
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9471
    self isOSXlike ifTrue:[
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9472
	|pathOfSTX|
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9473
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9474
	 places :=
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9475
		{
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9476
		    '/Library/Smalltalk' .
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9477
		    '/Library/Smalltalk-x' .
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9478
		    '~/Library/Smalltalk' .
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9479
		    '~/Library/Smalltalk-x' .
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9480
		} , places.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9481
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9482
	pathOfSTX := OperatingSystem pathOfSTXExecutable.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9483
	pathOfSTX notNil ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9484
	    places :=
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9485
		{
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9486
		    (pathOfSTX asFilename / '../Packages') name .
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9487
		    (pathOfSTX asFilename / '../../Packages') name .
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9488
		} , places.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9489
	]
16653
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9490
    ].
d7cee2a6cdc3 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16646
diff changeset
  9491
    places do:[:dirName |
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9492
	|dir vsnDir|
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9493
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9494
	dir := dirName asFilename.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9495
	(dir isDirectory) ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9496
	    "/ try to guess a gnu-smalltalk; skip it
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9497
	    (dir construct:'initialize.st') exists ifFalse:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9498
		vsnDir := dir / vsnDirName.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9499
		vsnDir exists ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9500
		    "/ new style: look for a major.minor directory there
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9501
		    sysPath add:vsnDir.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9502
		] ifFalse:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9503
		    "/ old style: look for a RELEASE file there and check if it matches
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9504
		    releaseFile := dir construct:'RELEASE'.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9505
		    releaseFile exists ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9506
			s := releaseFile readStreamOrNil.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9507
			s notNil ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9508
			    v := Integer readFrom:s onError:-1.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9509
			    s close.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9510
			    v == majorVersionNr ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9511
				sysPath add:dirName
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9512
			    ] ifFalse:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9513
				('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE mismatch)') infoPrintCR.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9514
			    ]
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9515
			] ifFalse:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9516
			    ('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE missing)') infoPrintCR.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9517
			]
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9518
		    ]
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9519
		]
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9520
	    ]
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
  9521
	]
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9522
    ].
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9523
    ^ sysPath
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  9524
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  9525
    "
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  9526
     OperatingSystem defaultSystemPath
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  9527
    "
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  9528
!
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  9529
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  9530
encodePath:pathName
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  9531
    "encode the pathName for use with system calls.
14839
f79ff27d7e52 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14802
diff changeset
  9532
     E.g. linux system calls accept single byte strings only,
17499
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9533
     so the pathName has been UTF-8 encoded, before using it in a system call
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9534
     (actually, on a mac, it has to be utf8-mac encoded)."
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9535
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9536
    Codeset notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9537
	pathName notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9538
	    "/ cg: I am not sure, why this shortcut.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9539
	    "/ calling the encoder directly should be much faster
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9540
	    Codeset == #utf8 ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9541
		^ pathName utf8Encoded
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9542
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9543
	    "/ Codeset encoder might not yet be initialized, sigh...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9544
	    CodesetEncoder isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9545
		self getCodesetEncoder
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9546
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9547
	    CodesetEncoder notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9548
		^ CodesetEncoder encodeString: pathName.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9549
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9550
	].
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9551
    ].
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9552
    ^ pathName
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9553
17499
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9554
    "
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9555
     Codeset := #'utf8-mac'.
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9556
     CodesetEncoder := nil.
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9557
     OperatingSystem getCodesetEncoder
17681
8894d153e26a class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17637
diff changeset
  9558
     OperatingSystem encodePath:'äöü'
17499
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9559
    "
935651e16975 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17492
diff changeset
  9560
15977
a1d7fd779a48 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15940
diff changeset
  9561
    "Modified: / 23-01-2013 / 10:00:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9562
! !
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  9563
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9564
!UnixOperatingSystem class methodsFor:'private'!
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9565
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9566
mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9567
    "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
  9568
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9569
    |entries|
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9570
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9571
    entries := OrderedCollection new.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9572
    ('/proc/mounts' asFilename) readingLinesDo:[:eachLine |
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9573
	|items mountInfo|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9574
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9575
	items := eachLine asCollectionOfWords.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9576
	mountInfo := (MountInfo new
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9577
	    mountPointPath:(items at:2)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9578
	    deviceOrRemotePath:(items at:1)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9579
	    fsType:(items at:3)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9580
	    attributeString:(items at:4)).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9581
	entries add:mountInfo
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9582
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9583
    ^ entries
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9584
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9585
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9586
     OperatingSystem mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9587
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9588
!
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9589
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9590
osProcessStatusClass
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9591
    ^ OSProcessStatus
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9592
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9593
    "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
  9594
! !
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  9595
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9596
!UnixOperatingSystem class methodsFor:'shared memory access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9597
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9598
shmAttach:id address:addr flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9599
    "low level entry to shmat()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9600
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9601
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9602
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9603
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9604
    void *address, *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9605
    int shmflg, shmid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9606
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9607
    if (__isSmallInteger(addr)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9608
     && __bothSmallInteger(flags, id)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9609
	shmaddr = (void *) __intVal(addr);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9610
	shmflg = __intVal(flags);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9611
	shmid = __intVal(id);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9612
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9613
	address = shmat(shmid, shmaddr, shmflg);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9614
	if (address != (void *)-1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9615
	    RETURN (__MKEXTERNALBYTES(addr));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9616
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9617
	@global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9618
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9619
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9620
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9621
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9622
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9623
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9624
    "Modified: 22.4.1996 / 13:15:12 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9625
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9626
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9627
shmDetach:addr
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9628
    "low level entry to shmdt()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9629
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9630
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9631
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9632
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9633
    void *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9634
    int rslt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9635
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9636
    if (__isSmallInteger(addr)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9637
	shmaddr = (void *) __intVal(addr);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9638
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9639
	rslt = shmdt(shmaddr);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9640
	if (rslt != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9641
	    RETURN (true);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9642
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9643
	@global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9644
	RETURN (false);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9645
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9646
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9647
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9648
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9649
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9650
    "Modified: 22.4.1996 / 13:15:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9651
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9652
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9653
shmGet:key size:size flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9654
    "low level entry to shmget()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9655
     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
  9656
     - use the provided wrapper class SharedExternalBytes instead."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9657
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9658
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9659
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9660
    if (__bothSmallInteger(key, size)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9661
     && __isSmallInteger(flags)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9662
	int rslt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9663
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9664
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9665
	if (rslt != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9666
	    RETURN (__mkSmallInteger(rslt));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9667
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9668
	@global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9669
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9670
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9671
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9672
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9673
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9674
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9675
    "Modified: 22.4.1996 / 13:14:46 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9676
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9677
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9678
!UnixOperatingSystem class methodsFor:'socket creation'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9679
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  9680
socketAccessor
16390
fb3ad2464cac class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16388
diff changeset
  9681
    ^ SocketHandle
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  9682
!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  9683
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9684
socketWithDomain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9685
    "set up socket with domain, type and protocol number.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9686
     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
  9687
     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
  9688
     #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9689
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9690
    ^ SocketHandle new domain:domainArg type:typeArg protocol:protocolArg
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9691
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9692
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9693
!UnixOperatingSystem class methodsFor:'time and date'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9694
16948
45832ec999e2 method name cleanup
Claus Gittinger <cg@exept.de>
parents: 16925
diff changeset
  9695
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
  9696
    "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
  9697
     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
  9698
     otherwise, in localtime including any daylight saving adjustings."
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  9699
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9700
    |osSeconds|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9701
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9702
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9703
    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
  9704
#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
  9705
#   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
  9706
#else
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9707
#   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
  9708
#endif
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9709
    TIME_T t;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9710
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9711
    if (__bothSmallInteger(y, m)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9712
     && __bothSmallInteger(d, h)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9713
     && __bothSmallInteger(min, s)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9714
	tm.tm_hour = __intVal(h);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9715
	tm.tm_min = __intVal(min);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9716
	tm.tm_sec = __intVal(s);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9717
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9718
	tm.tm_year = __intVal(y) - 1900;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9719
	tm.tm_mon = __intVal(m) - 1;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9720
	tm.tm_mday = __intVal(d);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9721
	tm.tm_isdst = -1;
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9722
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9723
#ifndef HAS_MKTIME64
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9724
	if (__intVal(y) > 2038) goto outOfRange;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9725
	if (__intVal(y) == 2038) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9726
	    if (__intVal(m) > 1) goto outOfRange;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9727
	    if (__intVal(d) > 19) goto outOfRange;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9728
	    if (__intVal(d) == 19) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9729
		if (__intVal(h) > 3) goto outOfRange;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9730
		if (__intVal(h) == 3) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9731
		    if (__intVal(min) > 14) goto outOfRange;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9732
		    if (__intVal(min) == 14) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9733
			if (__intVal(s) > 7) goto outOfRange;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9734
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9735
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9736
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9737
	}
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9738
#endif
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9739
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9740
#ifdef HAS_TIMEGM
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9741
	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
  9742
# ifdef HAS_MKTIME64
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9743
	    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
  9744
# else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9745
	    t = timegm(&tm);                    /* timegm() interprets tm as utc time */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9746
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9747
	} else
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9748
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9749
	{
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9750
#ifdef HAS_MKTIME64
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9751
	    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
  9752
#else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9753
	    t = mktime(&tm);                    /* mktime() interprets tm as localtime */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9754
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9755
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9756
	if (t != (TIME_T)-1) {
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9757
#ifndef HAS_TIMEGM
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9758
	    if (utcBoolean == true) {           /* convert to utc time */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9759
		// printf("tz=%d\n", TIMEZONE(&tm));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9760
		t = t - TIMEZONE(&tm);          /* TIMZONE = seconds westward from 0 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9761
	    }
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
  9762
#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
  9763
#ifdef HAS_MKTIME64
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9764
	    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
  9765
#else
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9766
	    /* be careful, t can be negative at the start of the epoch ! */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9767
	    osSeconds = __MKINT((INT)t);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9768
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9769
	}
16998
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9770
    }
54ee26519396 also raise an error on an attempt to convert a time after 2039
Claus Gittinger <cg@exept.de>
parents: 16970
diff changeset
  9771
  outOfRange: ;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9772
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9773
    osSeconds notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9774
	^ osSeconds * 1000 + millis
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9775
    ].
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9776
    ^ TimeConversionError raiseRequest.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9777
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9778
    "
17082
94ba9563eaba class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17029
diff changeset
  9779
     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
  9780
     OperatingSystem computeOSTimeFromYear:1970 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
  9781
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9782
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9783
17029
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9784
epochStartOSTime
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9785
    "private interface for timestamp to ask the OS what the minimum time
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9786
     (in milliseconds since the Unix epoch, 1.1.1970) is.
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9787
     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
  9788
     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
  9789
     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
  9790
     components itself.
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9791
     So it is usually (except for a little performane) no problem to return a range too small here."
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9792
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9793
    ^ -16r80000000 * 1000
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9794
!
3a13637fa5a9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17022
diff changeset
  9795
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9796
getMicrosecondTime
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9797
    "This returns the microsecond timers value - if available.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9798
     On some machines, times with this precision may not be available,
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9799
     on those, the returned value may be rounded towards some internal
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9800
     clock resolution value."
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9801
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9802
    |seconds micros error|
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9803
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9804
%{
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9805
#ifdef __SCHTEAM__
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9806
    {
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
  9807
	long nanos = java.lang.System.nanoTime();
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9808
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9809
	return context._RETURN( STInteger._new(nanos / 1000) );
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9810
    }
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9811
    /* NOTREACHED */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9812
#else
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9813
    unsigned long _secs, _micros;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9814
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9815
# if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9816
    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
  9817
    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
  9818
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  9819
    if (has_clock_gettime) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9820
	if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9821
	    _secs = ts.tv_sec;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9822
	    _micros  = ts.tv_nsec / 1000;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9823
	    goto out;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9824
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9825
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9826
	     * clock_gettime is not implemented in the kernel
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9827
	     * fall through to alternative implementation
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9828
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9829
	    has_clock_gettime = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9830
	}
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  9831
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9832
# endif
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9833
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9834
# if defined(HAS_GETTIMEOFDAY)
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9835
    struct timeval tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9836
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9837
    gettimeofday(&tb, NULL /* &tzb */);
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9838
    if (tb.tv_usec >= (1000000)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9839
	error = @symbol(bad);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9840
	goto err;
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9841
    }
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9842
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9843
    _secs = tb.tv_sec;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9844
    _micros  = tb.tv_usec;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9845
# endif
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9846
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9847
out:
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9848
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9849
# if __POINTER_SIZE__ == 8
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9850
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9851
	unsigned INT rslt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9852
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9853
	rslt = (unsigned INT)_secs * 1000000 + _micros;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9854
	RETURN (__MKUINT(rslt));
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9855
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9856
# else
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9857
#  ifdef HAS_LONGLONG
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9858
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9859
	unsigned long long rslt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9860
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9861
	rslt = (unsigned long long)_secs * 1000000 + _micros;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9862
	RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9863
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9864
#  else
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9865
    seconds = __MKUINT(_secs);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9866
    micros = __MKUINT(_micros);
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9867
#  endif /* long long */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9868
# endif /* __POINTER_SIZE__ == 8 */
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9869
err:;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9870
#endif /* not SCHTEAM */
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9871
%}.
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9872
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9873
    seconds notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9874
	^ (seconds * 1000000) + micros
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9875
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9876
    error isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9877
	^ self getMillisecondTime * 1000
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9878
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9879
    self primitiveFailed:error.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9880
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9881
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9882
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9883
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9884
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9885
!
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  9886
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9887
getMillisecondTime
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9888
    "Return the millisecond timers value.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9889
     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
  9890
     LargeInteger arithmetic when doing timeouts and delays.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9891
     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
  9892
     short relative time deltas.
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9893
     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
  9894
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9895
     BAD DESIGN:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9896
	This should be changed to return some instance of RelativeTime,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9897
	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
  9898
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9899
     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
  9900
     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
  9901
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9902
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9903
%{  /* NOCONTEXT */
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9904
#ifdef __SCHTEAM__
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9905
    {
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
  9906
	long millis = java.lang.System.currentTimeMillis();
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9907
	return context._RETURN( STInteger._new(millis) );
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9908
    }
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9909
    /* NOTREACHED */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9910
#else
13801
6e060254590d changed: #getMillisecondTime
Stefan Vogel <sv@exept.de>
parents: 13778
diff changeset
  9911
    unsigned long t = 0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9912
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9913
# if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  9914
    static has_clock_gettime = 1;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9915
    struct timespec ts;
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9916
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  9917
    if (has_clock_gettime) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9918
	if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9919
	    t = ts.tv_sec*1000 + ts.tv_nsec/1000000;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9920
	    goto out;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9921
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9922
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9923
	     * clock_gettime is not implemented in the kernel
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9924
	     * fall through to alternative implementation
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9925
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9926
	    has_clock_gettime = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9927
	}
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  9928
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9929
# endif /*  _POSIX_MONOTONIC_CLOCK */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9930
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9931
# 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
  9932
/*
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9933
 * 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
  9934
 * 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
  9935
 */
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9936
#  include <sys/times.h>
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9937
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9938
    static int millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9939
    clock_t ticks;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9940
    struct tms tb;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9941
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9942
    if (!millisecondsPerTick) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9943
	int ticksPerSecond = sysconf(_SC_CLK_TCK);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9944
	if (ticksPerSecond <= 0)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9945
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9946
	if (ticksPerSecond > 1000)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9947
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9948
	millisecondsPerTick = 1000 / ticksPerSecond;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9949
/*
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9950
printf("milliSecondsPerTick: %d\n", millisecondsPerTick);
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  9951
*/
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9952
    }
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9953
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9954
    ticks = times(&tb);
8672
f93733514fec Fix times() systemcall overflow into negative values (onl Solaris 9).
Stefan Vogel <sv@exept.de>
parents: 8618
diff changeset
  9955
    if (ticks == -1)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
  9956
	goto err;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9957
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9958
    t = ticks * millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9959
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9960
# else /* !times */
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9961
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9962
    /* assume HAS_GETTIMEOFDAY
13801
6e060254590d changed: #getMillisecondTime
Stefan Vogel <sv@exept.de>
parents: 13778
diff changeset
  9963
     * - 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
  9964
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9965
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9966
    struct timeval tb;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9967
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9968
    gettimeofday(&tb, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9969
    t = tb.tv_sec*1000 + tb.tv_usec/1000;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9970
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9971
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  9972
out:
12832
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
  9973
    RETURN ( __mkSmallInteger(t & 0x1FFFFFFF) );
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9974
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9975
err:;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
  9976
#endif /* not SCHTEAM */
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  9977
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  9978
    self primitiveFailed
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9979
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9980
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9981
    "
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9982
      self getMillisecondTime
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9983
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9984
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9985
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  9986
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9987
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9988
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9989
getOSTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9990
    "This returns the OS time.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9991
     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
  9992
     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
  9993
     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
  9994
     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
  9995
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9996
     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
  9997
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9998
     or use instances of Time, Date or Timestamp to work with."
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  9999
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10000
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10001
    |seconds millis|
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10002
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10003
%{
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10004
#ifdef __SCHTEAM__
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10005
    {
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10006
	long millisSince1970 = java.lang.System.currentTimeMillis();
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10007
	return context._RETURN( STInteger._new(millisSince1970));
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10008
    }
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10009
    /* NOTREACHED */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10010
#else
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10011
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10012
    unsigned long _secs, _millis;
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10013
# if !defined(HAS_GETTIMEOFDAY)
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10014
#  if defined(HAS_FTIME)
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10015
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10016
	struct timeb timebuffer;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10017
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10018
	ftime(&timebuffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10019
	_secs = timebuffer.time;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10020
	_millis = timebuffer.millitm;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10021
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10022
#    define HAVE_TIME
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10023
#  endif /* HAS_FTIME */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10024
# endif /* no HAS_GETTIMEOFDAY */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10025
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10026
# ifndef HAVE_TIME
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10027
    /*
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10028
     * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10029
     * 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
 10030
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10031
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10032
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10033
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10034
	 * bsd time
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10035
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10036
	struct timeval tb;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10037
	/* struct timezone tzb; */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10038
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10039
	gettimeofday(&tb, NULL /* &tzb */);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10040
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10041
	_secs = tb.tv_sec;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10042
	_millis = tb.tv_usec / 1000;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10043
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10044
# endif
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10045
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10046
# if __POINTER_SIZE__ == 8
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10047
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10048
	unsigned INT rslt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10049
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10050
	rslt = (unsigned INT)_secs * 1000 + _millis;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10051
	RETURN (__MKUINT(rslt));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10052
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10053
# else
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10054
#  ifdef HAS_LONGLONG
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10055
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10056
	unsigned long long rslt;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10057
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10058
	rslt = (unsigned long long)_secs * 1000 + _millis;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10059
	RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10060
    }
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10061
#  else
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10062
    seconds = __MKUINT(_secs);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10063
    millis = __MKUINT(_millis);
18278
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10064
#  endif /* long long */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10065
# endif /* __POINTER_SIZE__ == 8 */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10066
#endif /* SCHTEAM */
a6bb05f48a1d comment
Claus Gittinger <cg@exept.de>
parents: 18256
diff changeset
 10067
%}.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10068
    seconds notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10069
	^ (seconds * 1000) + millis
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10070
    ].
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10071
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10072
    self primitiveFailed.
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10073
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10074
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10075
    "
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10076
     OperatingSystem getOSTime printCR.
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10077
     Delay waitForSeconds:0.2.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
 10078
     OperatingSystem getOSTime printCR.
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10079
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10080
!
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
 10081
18415
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10082
microsecondSleep:micros
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10083
    "cease ANY action for some time.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10084
     This suspends the whole smalltalk (unix/windows-) process for some time.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10085
     Not really useful since not even low-prio processes and interrupt
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10086
     handling will run during the sleep.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10087
     Use either OperatingSystem>>millisecondDelay: (which makes all
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10088
     threads sleep, but handles interrupts) or use a Delay
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10089
     (which makes only the calling thread sleep)."
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10090
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10091
    |uLow uHigh|
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10092
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10093
    uLow := micros // 1000000.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10094
    uHigh := micros \\ 1000000.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10095
%{
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10096
    struct timeval tv;
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10097
    fd_set dummy;
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10098
    int success;
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10099
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10100
    int s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10101
    FD_ZERO(&dummy);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10102
    FD_SET(s, &dummy);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10103
    tv.tv_sec = __intVal(uLow);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10104
    tv.tv_usec = __intVal(uHigh);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10105
    success = (0 == select(0, 0, 0, &dummy, &tv));
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10106
    close(s);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10107
    RETURN (success ? true : false);
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10108
%}
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10109
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10110
    "
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10111
     Timestamp now printCR.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10112
     OperatingSystem microsecondSleep:100.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10113
     Timestamp now printCR.
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10114
    "
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10115
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10116
    "Created: / 28-05-2015 / 14:14:53 / gg"
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10117
!
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 10118
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10119
sleep:numberOfSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10120
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10121
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10122
    "cease ANY action for some time. This suspends the whole smalltalk
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
 10123
     (unix-) process for some time if running threadless;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10124
     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
 10125
     only block until the next clock tick and return with the next
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
 10126
     timer interrupt.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10127
     Use either OperatingSystem>>millisecondDelay: (which makes all
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10128
     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
 10129
     only the calling thread sleep)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10130
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10131
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10132
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10133
    if (__isSmallInteger(numberOfSeconds)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10134
	sleep(__intVal(numberOfSeconds));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10135
	RETURN ( self );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10136
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10137
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10138
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10139
     argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10140
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10141
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10142
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10143
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10144
     OperatingSystem sleep:2
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10145
    "
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10146
!
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10147
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10148
timeInfoFromSeconds:osSeconds milliseconds:osMilliseconds localTime:isLocalTime
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10149
    "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
 10150
     OS-second value.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10151
     An internal helper"
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10152
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10153
    |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
 10154
     dst yDay wDay info|
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10155
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10156
%{
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10157
#ifdef __SCHTEAM__
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10158
    if (osSeconds.isSmallInteger()
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10159
     && osMilliseconds.isSmallInteger()) {
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10160
	long _seconds = osSeconds.longValue();
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10161
	long _millis = osMilliseconds.longValue();
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10162
	long _millisSinceEpoch = _seconds * 1000 + _millis;
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10163
	java.util.TimeZone _tz;
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10164
	java.util.Calendar _calendar;
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10165
	int _wDay;
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10166
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10167
	if (isLocalTime == STObject.True) {
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10168
	    _tz = java.util.TimeZone.getDefault();
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10169
	} else {
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10170
	    _tz = java.util.TimeZone.getTimeZone("UTC");
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10171
	}
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10172
	_calendar = java.util.Calendar.getInstance(_tz);
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10173
	_calendar.setTimeInMillis(_millisSinceEpoch);
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10174
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10175
	year = STInteger._new( _calendar.get(java.util.Calendar.YEAR) );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10176
	month = STInteger._new( _calendar.get(java.util.Calendar.MONTH) + 1 );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10177
	day = STInteger._new( _calendar.get(java.util.Calendar.DAY_OF_MONTH) );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10178
	hours = STInteger._new( _calendar.get(java.util.Calendar.HOUR_OF_DAY) );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10179
	minutes = STInteger._new( _calendar.get(java.util.Calendar.MINUTE) );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10180
	seconds = STInteger._new( _calendar.get(java.util.Calendar.SECOND) );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10181
	yDay = STInteger._new( _calendar.get(java.util.Calendar.DAY_OF_YEAR) );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10182
	_wDay = _calendar.get(java.util.Calendar.DAY_OF_WEEK);
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10183
	// convert from 1=SUN, 2=MON,...
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10184
	// to 1=MON, 2=TUE,...
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10185
	_wDay = _wDay - 1; if (_wDay < 1) _wDay += 7;
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10186
	wDay = STInteger._new( _wDay );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10187
	utcOffset = STInteger._new( (_calendar.get(java.util.Calendar.ZONE_OFFSET)) / 1000 );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10188
	dstOffset = STInteger._new( (_calendar.get(java.util.Calendar.DST_OFFSET)) / 1000 );
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10189
    }
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10190
#else
16924
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10191
    struct tm tmValue, *result;
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10192
    time_t tt = __signedLongIntVal(osSeconds);
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10193
16925
62b6c12ce2d0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16924
diff changeset
 10194
    if (tt == 0 && !__isSmallInteger(osSeconds))
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10195
	goto out;             // __singedLongIntVal() returns 0 on failure
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10196
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10197
    /* try cache */
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10198
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10199
	OBJ lastSeconds = @global(LastTimeInfoSeconds);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10200
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10201
	if (__isInteger(lastSeconds)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10202
	     && (__signedLongIntVal(lastSeconds) == tt)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10203
	     && (@global(LastTimeInfoIsLocal) == isLocalTime)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10204
	) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10205
	    OBJ lastTimeInfo = @global(LastTimeInfo);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10206
	    if (lastTimeInfo != nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10207
		info = lastTimeInfo;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10208
		goto out;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10209
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10210
	}
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10211
    }
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10212
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10213
    result = (isLocalTime == true) ? localtime_r(&tt, &tmValue) :  gmtime_r(&tt, &tmValue);
16924
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10214
    if (result != NULL) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10215
	hours = __mkSmallInteger(tmValue.tm_hour);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10216
	minutes = __mkSmallInteger(tmValue.tm_min);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10217
	seconds = __mkSmallInteger(tmValue.tm_sec);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10218
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10219
	year = __mkSmallInteger(tmValue.tm_year + 1900);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10220
	month = __mkSmallInteger(tmValue.tm_mon + 1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10221
	day = __mkSmallInteger(tmValue.tm_mday);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10222
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10223
	yDay = __mkSmallInteger(tmValue.tm_yday+1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10224
	wDay = __mkSmallInteger(tmValue.tm_wday == 0 ? 7 : tmValue.tm_wday);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10225
	utcOffset = __mkSmallInteger(TIMEZONE(&tmValue));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10226
	dst = (tmValue.tm_isdst == 0 ? false : true);
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10227
    }
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10228
out:;
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10229
#endif
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10230
%}.
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10231
    info notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10232
	"there is a matching cached value"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10233
	LastTimeInfoMilliseconds == osMilliseconds ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10234
	    ^ info.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10235
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10236
	info := info copy.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10237
	info milliseconds:osMilliseconds.
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10238
    ] ifFalse:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10239
	year isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10240
	    TimeConversionError raiseErrorString:' - out of range'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10241
	].
18375
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10242
	dst isNil ifTrue:[
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10243
	    dst := (dstOffset ~= 0)
746134085952 comments only
Claus Gittinger <cg@exept.de>
parents: 18348
diff changeset
 10244
	].
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10245
	info := self timeInfoClass new.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10246
	info
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10247
	    year:year
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10248
	    month:month
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10249
	    day:day
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10250
	    hours:hours
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10251
	    minutes:minutes
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10252
	    seconds:seconds
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10253
	    milliseconds:osMilliseconds
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10254
	    utcOffset:utcOffset
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10255
	    dst:dst
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10256
	    dayInYear:yDay
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10257
	    dayInWeek:wDay.
16952
3e82aaac33d4 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16948
diff changeset
 10258
    ].
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10259
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10260
%{
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10261
    @global(LastTimeInfo) = info;                       __GSTORE(info);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10262
    @global(LastTimeInfoSeconds) = osSeconds;           __GSTORE(osSeconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10263
    @global(LastTimeInfoMilliseconds) = osMilliseconds; __GSTORE(osMilliseconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10264
    @global(LastTimeInfoIsLocal) = isLocalTime;         __GSTORE(isLocalTime);
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10265
%}.
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
 10266
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10267
    ^ info
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10268
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
 10269
    "
16924
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10270
     OperatingSystem timeInfoFromSeconds:3600 milliseconds:0 localTime:false
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10271
     OperatingSystem timeInfoFromSeconds:3600 milliseconds:0 localTime:true
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10272
     OperatingSystem timeInfoFromSeconds:7200 milliseconds:0 localTime:true
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10273
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10274
     OperatingSystem timeInfoFromSeconds:16r7FFFFFFF milliseconds:0 localTime:false
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10275
     OperatingSystem timeInfoFromSeconds:16r7FFFFFFF + 1 milliseconds:0 localTime:false
16925
62b6c12ce2d0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16924
diff changeset
 10276
     OperatingSystem timeInfoFromSeconds:16r7FFFFFFFFFFFFFFFFFFFFFF milliseconds:0 localTime:false
16924
9f7829dbea64 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16918
diff changeset
 10277
     OperatingSystem timeInfoFromSeconds:0 milliseconds:0 localTime:true
17022
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10278
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10279
    DST in MEZ in 1994:
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10280
      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
 10281
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10282
     no DST in MEZ in 1970:
2a06860c164b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17011
diff changeset
 10283
      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
 10284
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10285
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10286
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10287
!UnixOperatingSystem class methodsFor:'users & groups'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10288
15802
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10289
getDesktopDirectory
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10290
    "{ Pragma: +optSpace }"
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10291
    "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
 10292
15802
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10293
    |home desktop|
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10294
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10295
    home := self getHomeDirectory.
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10296
    desktop := home,'/Desktop'.
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10297
    desktop asFilename exists ifTrue:[^ desktop].
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10298
    ^ home.
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10299
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10300
    "
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10301
     OperatingSystem getDesktopDirectory
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10302
    "
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10303
!
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 10304
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10305
getEffectiveGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10306
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10308
    "return the current users (thats you) effective numeric group id.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10309
     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
 10310
     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
 10311
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10312
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10313
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10314
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10315
    uid = getegid();
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10316
    RETURN ( __mkSmallInteger(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10317
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10318
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10319
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10320
     OperatingSystem getEffectiveGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10321
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10322
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10323
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10324
getEffectiveUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10325
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10326
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10327
    "return the current users (thats you) effective numeric user id.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10328
     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
 10329
     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
 10330
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10331
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10332
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10333
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10334
    uid = geteuid();
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10335
    RETURN ( __mkSmallInteger(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10336
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10337
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10338
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10339
     OperatingSystem getEffectiveUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10340
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10341
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10342
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10343
getFullUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10344
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10345
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10346
    "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
 10347
     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
 10348
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10349
    |info gecos|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10350
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10351
    info := self userInfoOf:userID.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10352
    (info notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10353
    and:[info includesKey:#gecos]) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10354
	gecos := info at:#gecos.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10355
	(gecos includes:$,) ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10356
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10357
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10358
	^ gecos
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10359
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10360
    ^ self getUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10361
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10362
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10363
     OperatingSystem getFullUserNameFromID:0
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10364
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10365
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10366
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10367
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10368
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10369
    "Modified: 15.7.1996 / 12:44:21 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10370
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10371
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10372
getGroupID
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10373
    "return the current users (thats you) numeric group id"
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10374
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10375
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10376
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10377
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10378
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10379
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10380
    RETURN ( __mkSmallInteger(getgid()) );
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10381
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10382
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10383
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10384
     OperatingSystem getGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10385
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10386
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10387
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10388
getGroupNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10389
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10390
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10391
    "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
 10392
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10393
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10394
    struct group *g;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10395
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10396
    if (__isSmallInteger(aNumber)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10397
	g = getgrgid(__intVal(aNumber));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10398
	if (g) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10399
	    RETURN ( __MKSTRING(g->gr_name) );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10400
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10401
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10402
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10403
    ^ '???'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10404
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10405
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10406
     OperatingSystem getGroupNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10407
     OperatingSystem getGroupNameFromID:10
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10408
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10409
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10410
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10411
getHomeDirectory
15940
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10412
    "return the name of the user's home directory (i.e. yours)"
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10413
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10414
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10415
15940
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10416
    |homeDir|
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10417
15981
c31f0cec5db0 osx: nil keys in getEnvironment
Claus Gittinger <cg@exept.de>
parents: 15977
diff changeset
 10418
    homeDir := self getEnvironment:'HOME'.
15940
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10419
    homeDir isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10420
	"/ mhmh - can only happen if started via some uncorrectly
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10421
	"/ initialized subprocess...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10422
	'UnixOperatingSystem [warning]: cannot figure out home directory' errorPrintCR.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10423
	homeDir := '/tmp'.
15940
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10424
    ].
810231ca4b98 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15906
diff changeset
 10425
    ^ self decodePath:homeDir
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10426
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10427
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10428
     OperatingSystem getHomeDirectory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10429
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10430
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10431
    "Modified: 24.1.1997 / 11:32:13 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10432
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10433
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10434
getLoginName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10435
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10436
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10437
    "return a string with the users login name (thats yours)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10438
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10439
%{  /* NOCONTEXT */
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
 10440
    static char cachedName[128];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10441
    static firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10442
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10443
    extern char *getlogin();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10444
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10445
    char *name = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10446
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10447
    if (firstCall) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10448
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10449
	 * try a few common environment variables ...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10450
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10451
	name = getenv("LOGNAME");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10452
	if (! name || (name[0] == 0)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10453
	    name = getlogin();
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10454
	    if (! name || (name[0] == 0) ) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10455
		name = getenv("LOGIN");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10456
		if (! name || (name[0] == 0) ) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10457
		    name = getenv("USER");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10458
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10459
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10460
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10461
	if (name && (strlen(name) < sizeof(cachedName))) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10462
	    strcpy(cachedName, name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10463
	    firstCall = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10464
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10465
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10466
	name = cachedName;
7767
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
 10467
    }
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
 10468
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10469
    /*
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10470
     * nope - I really dont know who you are.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10471
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10472
    if (! name || (name[0] == 0) ) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10473
	name = "you";
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10474
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10475
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10476
    RETURN ( __MKSTRING(name) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10477
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10478
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10479
     OperatingSystem getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10480
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10481
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10482
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10483
getUserID
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10484
    "return the current users (thats you) numeric user id"
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10485
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10486
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10487
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10488
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10489
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
 10490
    RETURN ( __mkSmallInteger(getuid()) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10491
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10492
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10493
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10494
     OperatingSystem getUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10495
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10496
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10497
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10498
getUserNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10499
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10500
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10501
    "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
 10502
     This is the login name, not the fullName."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10503
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10504
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10505
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10506
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10507
    struct passwd *p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10508
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10509
    if (__isSmallInteger(aNumber)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10510
	p = getpwuid(__intVal(aNumber));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10511
	if (p) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10512
	    RETURN ( __MKSTRING(p->pw_name) );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10513
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
 10514
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10515
#endif /* unix-like */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10516
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10517
    aNumber == self getUserID ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10518
	^ self getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10519
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10520
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10521
    ^ '? (' , aNumber printString , ')'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10522
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10523
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10524
     OperatingSystem getUserNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10525
     OperatingSystem getUserNameFromID:100
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10526
     OperatingSystem getUserNameFromID:9991
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10527
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10528
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10529
15875
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10530
isRunningWithElevatedRootOrAdminRights
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10531
    "return true, if a NORMAL user is running with elevated admin rights."
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10532
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10533
    ^ (self getEffectiveUserID == 0)
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10534
    and:[self getUserID ~~ 0 ]
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10535
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10536
    "
15906
8bbbcd3b5765 use timegm instead of mktime
Claus Gittinger <cg@exept.de>
parents: 15875
diff changeset
 10537
     self isRunningWithElevatedRootOrAdminRights
15875
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10538
    "
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10539
!
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10540
15832
8e5cb444d6bd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15802
diff changeset
 10541
isRunningWithRootOrAdminRights
15875
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10542
    "return true, if running with root rights (either an elevated normal user
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10543
     or super user right away)."
bbba0de282ba class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15832
diff changeset
 10544
15832
8e5cb444d6bd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15802
diff changeset
 10545
    ^ self getEffectiveUserID == 0
8e5cb444d6bd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15802
diff changeset
 10546
!
8e5cb444d6bd class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15802
diff changeset
 10547
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10548
primUserInfoOf:aNameOrID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10549
    "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
 10550
     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
 10551
     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
 10552
     DOS systems return nothing;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10553
     non-SYSV4 systems have no age/comment.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10554
     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
 10555
     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
 10556
     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
 10557
     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
 10558
     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
 10559
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10560
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10561
%{ /* UNLIMITEDSTACK */  /* Don't know whether NIS, LDAP or whatever is consulted */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10562
#if !defined(NO_PWD)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10563
    struct passwd *result = 0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10564
    int ret;
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10565
    int idx = 0;
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
 10566
    OBJ returnArray;
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10567
    OBJ tmp;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10568
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10569
#if defined(_POSIX_SOURCE)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10570
    char buf[4096];
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10571
    struct passwd pwd;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10572
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
 10573
    if (__isStringLike(aNameOrID)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10574
	getpwnam_r(__stringVal(aNameOrID), &pwd, buf, sizeof(buf), &result);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10575
    } else if (__isSmallInteger(aNameOrID)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10576
	getpwuid_r(__intVal(aNameOrID), &pwd, buf, sizeof(buf), &result);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10577
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10578
#else
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10579
    if (__isStringLike(aNameOrID)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10580
	result = getpwnam(__stringVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10581
    } else if (__isSmallInteger(aNameOrID)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10582
	result = getpwuid(__intVal(aNameOrID));
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10583
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10584
#endif /* ! _POSIX_SOURCE */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10585
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10586
    if (result) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10587
	returnArray = __ARRAY_NEW_INT(20);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10588
	__PROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10589
	tmp = __MKSTRING(result->pw_name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10590
	__UNPROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10591
	__arrayVal(returnArray)[idx++] = @symbol(name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10592
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10593
#  ifndef NO_PWD_PASSWD
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10594
	__PROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10595
	tmp = __MKSTRING(result->pw_passwd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10596
	__UNPROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10597
	__arrayVal(returnArray)[idx++] = @symbol(passwd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10598
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10599
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10600
#  ifdef SYSV4
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10601
	__PROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10602
	tmp = __MKSTRING(result->pw_age);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10603
	__UNPROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10604
	__arrayVal(returnArray)[idx++] = @symbol(age);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10605
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10606
	__PROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10607
	tmp = __MKSTRING(result->pw_comment);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10608
	__UNPROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10609
	__arrayVal(returnArray)[idx++] = @symbol(comment);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10610
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10611
#  endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10612
	__PROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10613
	tmp = __MKSTRING(result->pw_dir);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10614
	__UNPROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10615
	__arrayVal(returnArray)[idx++] = @symbol(dir);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10616
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10617
#  ifndef NO_PWD_GECOS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10618
	__PROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10619
	tmp = __MKSTRING(result->pw_gecos);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10620
	__UNPROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10621
	__arrayVal(returnArray)[idx++] = @symbol(gecos);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10622
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10623
#  endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10624
	__PROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10625
	tmp = __MKSTRING(result->pw_shell);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10626
	 __UNPROTECT__(returnArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10627
	__arrayVal(returnArray)[idx++] = @symbol(shell);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10628
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10629
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10630
	__arrayVal(returnArray)[idx++] = @symbol(uid);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10631
	__arrayVal(returnArray)[idx++] = __mkSmallInteger(result->pw_uid);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10632
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10633
	__arrayVal(returnArray)[idx++] = @symbol(gid);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10634
	__arrayVal(returnArray)[idx++] = __mkSmallInteger(result->pw_gid);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10635
	RETURN(returnArray);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10636
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10637
# endif /* ! NO_PWD */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10638
%}.
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
 10639
    ^ nil
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10640
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10641
    "
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10642
     OperatingSystem primUserInfoOf:'root'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10643
     OperatingSystem primUserInfoOf:1
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10644
     OperatingSystem primUserInfoOf:'cg'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10645
     OperatingSystem primUserInfoOf:'fooBar'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10646
     OperatingSystem primUserInfoOf:(OperatingSystem getUserID)
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10647
    "
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10648
!
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10649
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10650
userInfoOf:aNameOrID
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10651
    "{ Pragma: +optSpace }"
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10652
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10653
    "return a dictionary filled with userinfo. The argument can be either
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10654
     a string with the users name or its numeric id.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10655
     Notice, that not all systems provide (all of) this info;
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10656
     DOS systems return nothing;
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10657
     non-SYSV4 systems have no age/comment.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10658
     Portable applications may want to check the systemType and NOT depend
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10659
     on all keys to be present in the returned dictionary.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10660
     Another notice: on some systems (SYSV4), the gecos field includes multiple
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10661
     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
 10662
     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
 10663
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10664
    |infoArray info name dir|
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10665
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10666
    infoArray := self primUserInfoOf:aNameOrID.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10667
    info := IdentityDictionary new.
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10668
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 10669
    infoArray notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10670
	infoArray pairWiseDo:[:key :value|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10671
	    key notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10672
		info at:key put:value.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10673
		key == #name ifTrue:[name := value].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10674
		key == #dir  ifTrue:[dir := value].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10675
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10676
	].
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10677
    ].
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10678
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10679
    name isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10680
	info at:#name put:#unknown
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10681
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10682
    dir isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10683
	aNameOrID == self getUserID ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10684
	    info at:#dir put:self getHomeDirectory
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10685
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10686
    ].
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 10687
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10688
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10689
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10690
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10691
     OperatingSystem userInfoOf:'root'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10692
     OperatingSystem userInfoOf:1
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 10693
     OperatingSystem userInfoOf:'cg'
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10694
     OperatingSystem userInfoOf:'fooBar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10695
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10696
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10697
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10698
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10699
!UnixOperatingSystem class methodsFor:'waiting for events'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10700
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10701
blockingChildProcessWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10702
     "return true, if childProcessWait: blocks, if no children are ready.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10703
      On those systems, we must be somewhat careful when looking out for
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10704
      a subprocesses status (to avoid blocking)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10705
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10706
%{ /*NOCONTEXT*/
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
 10707
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10708
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10709
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10710
    RETURN(true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10711
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10712
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10713
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10714
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10715
childProcessWait:blocking pid:pidToWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10716
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10717
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10718
    "get status changes from child processes.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10719
     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
 10720
     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
 10721
     otherwise we return immediately.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10722
     Note that win32 needs to know the HANDLE of the process on which
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10723
     it waits.  In case of an error, THIS ALWAYS WAITS and then times out."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10725
    |pid status code core|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10726
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10727
    int p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10728
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10729
#if defined(HAS_WAITPID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10730
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10731
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10732
#   define __WAIT     waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10733
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10734
#else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10735
# if defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10737
    union wait s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10738
#   define __WAIT      wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10739
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10740
# else /* neither waitpid, nor wait3; use wait, which is blocking */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10741
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10742
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10743
#   define __WAIT      wait(&s)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10744
#   define __BLOCKING_WAIT__ 1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10745
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10746
    if (blocking != true) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10747
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10748
	 * We do not support nonBlocking waits, so signal an error
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10749
	 * Sorry about the goto, but with all these ifdefs ...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10750
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10751
	goto done;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10752
    }
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10753
# endif /*!HAS_WAIT3*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10754
#endif  /*!HAS_WAITPID*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10755
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10756
#if !defined(WIFEXITED)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10757
# define WIFEXITED(stat)      (((int)((stat)&0377))==0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10758
# 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
 10759
# 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
 10760
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10761
# define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10762
# define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10763
# define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10764
#endif /*!WIFEXITED*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10765
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10766
#if !defined(WCOREDUMP)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10767
   /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10768
    * 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
 10769
    */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10770
# if defined(HAS_WAIT3)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10771
#  define WCOREDUMP(status)    (((union __wait*)&(status))->__w_coredump)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10772
# else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10773
#  define WCOREDUMP(status)    ((int)(((status)>>8)&0200))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10774
# endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10775
#endif /*!WCOREDUMP*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10776
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10777
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10778
    __BEGIN_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10779
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10780
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10781
    do {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10782
	p = __WAIT;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10783
    } while (p == -1 && errno == EINTR);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10784
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10785
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10786
    __END_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10787
#  undef __BLOCKING_WAIT__
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10788
#endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10789
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10790
#undef __WAIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10791
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10792
    if (p == 0)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10793
	RETURN(nil)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10794
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10795
    if (p == -1) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10796
	if (errno == ECHILD)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10797
	    RETURN(nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10798
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10799
	pid = __mkSmallInteger(p);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10800
	if (WIFEXITED(s)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10801
	    status = @symbol(exit);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10802
	    code = __mkSmallInteger(WEXITSTATUS(s));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10803
	    core = WCOREDUMP(s) ? true : false;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10804
	} else if (WIFSIGNALED(s)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10805
	    status = @symbol(signal);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10806
	    code = __mkSmallInteger(WTERMSIG(s));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10807
	} else if (WIFSTOPPED(s)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10808
	    status = @symbol(stop);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10809
	    code = __mkSmallInteger(WSTOPSIG(s));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10810
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10811
#if defined(WIFCONTINUED)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10812
	else if (WIFCONTINUED(s)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10813
	    status = @symbol(continue);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10814
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
 10815
#endif
3496
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
done: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10818
%}.
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
    (status isNil or:[pid isNil]) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10821
	^ self primitiveFailed
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10824
"/ 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
 10825
"/ show:' code: '; show:code; show:' core:'; showCR:core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10826
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10827
    ^ 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
 10828
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10829
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
 10830
     OperatingSystem childProcessWait:false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10831
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10832
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10833
    "Created: 5.1.1996 / 16:39:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10834
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10835
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10836
isBlockingOn:fd
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10837
    "{ Pragma: +optSpace }"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10838
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10839
    "return the blocking attribute - if set (which is the default)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10840
     a read on the fileDescriptor will block until data is available.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10841
     If clear, a read operation will immediately return with a value nil.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10842
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10843
     blocking is off"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10844
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10845
%{  /* NOCONTEXT */
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10846
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10847
    int flags;
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10848
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10849
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10850
# undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10851
# if defined(O_NONBLOCK)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10852
#  define DELAY_FLAG O_NONBLOCK
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10853
# elif defined(O_NDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10854
#  define DELAY_FLAG O_NDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10855
# elif defined(FNDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10856
#  define DELAY_FLAG FNDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10857
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10858
# if defined(DELAY_FLAG)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10859
    if (__isSmallInteger(fd)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10860
	int f = __intVal(fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10861
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10862
	flags = fcntl(f, F_GETFL, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10863
	RETURN ((flags & DELAY_FLAG) ? false : true );
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10864
    }
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10865
#  undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10866
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10867
#endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10868
%}.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10869
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10870
     fd argument not integer or bad return code
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10871
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10872
    ^ self primitiveFailed
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10873
!
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10874
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10875
numAvailableForReadOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10876
    "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
 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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10880
     * 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
 10881
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
 10882
# if 0 && defined(FIONREAD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10883
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10884
	int n;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10885
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10886
	if (__isSmallInteger(fd)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10887
	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10888
		RETURN (__MKINT(n));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10889
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10890
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10891
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10892
# endif /* FIONREAD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10893
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10894
    ^ (self readCheck:fd) ifTrue:[1] ifFalse:[0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10895
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10896
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10897
readCheck:fd
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10898
    "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
 10899
     (i.e. read is possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10900
     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
 10901
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10902
%{
18399
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10903
#ifdef __SCHTEAM__
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10904
    {
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10905
	int avail = fd.streamAvailable();
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10906
	return __c__._RETURN (avail > 0 ? STObject.True : STObject.False);
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10907
    }
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10908
    /* NOTREACHED */
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10909
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10910
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10911
     * 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
 10912
     */
18399
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10913
# if 0 && defined(FIONREAD)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10914
    if (__isSmallInteger(fd)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10915
	int result = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10916
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10917
	if (ioctl(__smallIntegerVal(fd), FIONREAD, &result) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10918
	    RETURN(result > 0 ? true : false);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10919
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10920
    }
18399
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10921
# endif /* FIONREAD */
5a3372cd04de comment
Claus Gittinger <cg@exept.de>
parents: 18375
diff changeset
 10922
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10923
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10924
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10925
    ^ super readCheck:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10926
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10927
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10928
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10929
	readableInto:readableResultFdArray writableInto:writableResultFdArray
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10930
	exceptionInto:exceptionResultFdArray
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10931
	withTimeOut:millis
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10932
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10933
    "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
 10934
     writeFdArray to become ready for writing,
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10935
     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
 10936
     Timeout after t milliseconds or - if the timeout time is 0 - immediately.
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 10937
     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
 10938
     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
 10939
     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
 10940
     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
 10941
     writableResultFdArray and exceptionResultFdArray respectively.
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 10942
     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
 10943
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10944
     Return the (overall) number of selected filedescriptors.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10945
     readableResultFdArray, writableResultFdArray and exceptionResultFdArray will
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10946
     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
 10947
     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
 10948
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10949
%{
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10950
    fd_set rset, wset, eset;
16314
3b069e0219c6 fix prev version
Stefan Vogel <sv@exept.de>
parents: 16313
diff changeset
 10951
    struct timeval wt, *wtp, et;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10952
    int maxF;
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 10953
    INT __millis;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10954
    int ret;
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 10955
    int cntR = 0, cntW = 0, cntE = 0, cntAll = 0;
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 10956
    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
 10957
    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
 10958
    int numFds = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10959
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10960
    if (readableResultFdArray != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10961
	if (! __isArrayLike(readableResultFdArray)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10962
	    goto fail;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10963
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10964
	resultSizeReadable = __arraySize(readableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10965
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10966
    if (writableResultFdArray != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10967
	if (! __isArrayLike(writableResultFdArray)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10968
	    goto fail;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10969
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10970
	resultSizeWritable = __arraySize(writableResultFdArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10971
	if (readableResultFdArray == writableResultFdArray) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10972
	    // allow common result set for read/write/except
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10973
	    pcntW = &cntR;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10974
	}
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10975
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10976
    if (exceptionResultFdArray != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10977
	if (! __isArrayLike(exceptionResultFdArray)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10978
	    goto fail;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10979
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10980
	resultSizeException = __arraySize(exceptionResultFdArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10981
	if (exceptionResultFdArray == readableResultFdArray) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10982
	    // allow common result set for read/write/except
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10983
	    pcntE = &cntR;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10984
	} else if (exceptionResultFdArray == writableResultFdArray) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10985
	    pcntE = &cntW;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10986
	}
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
 10987
    }
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10988
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10989
    FD_ZERO(&rset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10990
    FD_ZERO(&wset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10991
    FD_ZERO(&eset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10992
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 10993
    maxF = -1;
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 10994
    if (readFdArray != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10995
	int i, count;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10996
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10997
	if (! __isArrayLike(readFdArray)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10998
	    goto fail;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 10999
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11000
	count = __arraySize(readFdArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11001
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11002
	for (i=0; i<count;i++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11003
	    OBJ fd;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11004
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11005
	    fd = __arrayVal(readFdArray)[i];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11006
	    if (fd != nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11007
		if (! __isSmallInteger(fd)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11008
		    if (@global(InfoPrinting) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11009
			fprintf(stderr, "OS [warning]: funny read-fd (0x%lx) given to select\n", (unsigned long)fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11010
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11011
		} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11012
		    int f;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11013
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11014
		    f = __intVal(fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11015
		    if ((unsigned)f < FD_SETSIZE) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11016
			FD_SET(f, &rset);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11017
			if (f > maxF) maxF = f;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11018
			numFds++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11019
		    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11020
			if (@global(InfoPrinting) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11021
			    fprintf(stderr, "OS [warning]: huge read-fd (0x%lx) given to select\n", (unsigned long)fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11022
			}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11023
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11024
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11025
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11026
	}
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11027
    }
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11028
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11029
    if (writeFdArray != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11030
	int i, count;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11031
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11032
	if (! __isArrayLike(writeFdArray)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11033
	    goto fail;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11034
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11035
	count = __arraySize(writeFdArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11036
	for (i=0; i<count;i++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11037
	    OBJ fd;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11038
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11039
	    fd = __arrayVal(writeFdArray)[i];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11040
	    if (fd != nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11041
		if (! __isSmallInteger(fd)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11042
		    if (@global(InfoPrinting) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11043
			fprintf(stderr, "OS [warning]: funny write-fd (0x%lx) given to select\n", (unsigned long)fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11044
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11045
		} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11046
		    int f;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11047
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11048
		    f = __intVal(fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11049
		    if ((unsigned)f < FD_SETSIZE) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11050
			FD_SET(f, &wset);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11051
			if (f > maxF) maxF = f;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11052
			numFds++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11053
		    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11054
			if (@global(InfoPrinting) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11055
			    fprintf(stderr, "OS [warning]: huge write-fd (0x%lx) given to select\n", (unsigned long)fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11056
			}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11057
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11058
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11059
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11060
	}
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11061
    }
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11062
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11063
    if (exceptFdArray != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11064
	int i, count;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11065
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11066
	if (! __isArrayLike(exceptFdArray)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11067
	    goto fail;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11068
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11069
	count = __arraySize(exceptFdArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11070
	for (i=0; i<count;i++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11071
	    OBJ fd;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11072
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11073
	    fd = __arrayVal(exceptFdArray)[i];
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11074
	    if (fd != nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11075
		if (! __isSmallInteger(fd)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11076
		    if (@global(InfoPrinting) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11077
			fprintf(stderr, "OS [warning]: funny except-fd (0x%lx) given to select\n", (unsigned long)fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11078
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11079
		} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11080
		    int f;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11081
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11082
		    f = __intVal(fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11083
		    if ((unsigned)f < FD_SETSIZE) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11084
			FD_SET(f, &eset);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11085
			if (f > maxF) maxF = f;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11086
			numFds++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11087
		    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11088
			if (@global(InfoPrinting) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11089
			    fprintf(stderr, "OS [warning]: huge except-fd (0x%lx) given to select\n", (unsigned long)fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11090
			}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11091
		    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11092
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11093
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11094
	}
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11095
    }
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11096
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11097
    if (millis == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11098
	wtp = NULL;         // wait forever
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11099
    } else if (__isSmallInteger(millis)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11100
	__millis = __intVal(millis);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11101
	if (__millis > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11102
	    wt.tv_sec = __millis / 1000;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11103
	    wt.tv_usec = (__millis % 1000) * 1000;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11104
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11105
	    wt.tv_sec = wt.tv_usec = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11106
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11107
	wtp = &wt;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11108
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11109
	goto fail;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11110
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11111
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11112
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11113
     * 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
 11114
     * 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
 11115
     */
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11116
    __BEGIN_INTERRUPTABLE__
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11117
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11118
    if (__millis == 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11119
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11120
	 * if there is no timeout time, we can stay here interruptable.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11121
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11122
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11123
	    ret = select(maxF+1, &rset, &wset, &eset, wtp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11124
	} 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
 11125
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11126
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11127
	    ret = select(maxF+1, &rset, &wset, &eset, wtp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11128
	    /*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11129
	     * for now: don't loop; if we did, we had to adjust the vt-timeval;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11130
	     * could otherwise stay in this loop forever ...
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11131
	     * Premature ret (before the time expired) must be handled by the caller.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11132
	     * A good solution is to update the wt-timeval and redo the select.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11133
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11134
	} while (0 /* (ret < 0) && (errno == EINTR) */ );
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11135
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11136
    __END_INTERRUPTABLE__
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11137
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11138
    if (ret > 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11139
	OBJ *__resultR = __arrayVal(readableResultFdArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11140
	OBJ *__resultW = __arrayVal(writableResultFdArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11141
	OBJ *__resultE = __arrayVal(exceptionResultFdArray);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11142
	int i;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11143
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11144
	for (i=0; i <= maxF; i++) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11145
	    if (FD_ISSET(i, &rset)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11146
		if (*pcntR < resultSizeReadable) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11147
		    __resultR[*pcntR] = __mkSmallInteger(i);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11148
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11149
		(*pcntR)++; cntAll++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11150
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11151
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11152
	    if (FD_ISSET(i, &wset)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11153
		if (*pcntW < resultSizeWritable) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11154
		    __resultW[*pcntW] = __mkSmallInteger(i);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11155
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11156
		(*pcntW)++; cntAll++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11157
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11158
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11159
	    if (FD_ISSET(i, &eset)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11160
		if (*pcntE < resultSizeException) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11161
		    __resultE[*pcntE] = __mkSmallInteger(i);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11162
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11163
		(*pcntE)++;  cntAll++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11164
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11165
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11166
	/* add a delimiter */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11167
	if (*pcntR < resultSizeReadable) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11168
	    __resultR[*pcntR] = nil;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11169
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11170
	if (*pcntW < resultSizeWritable) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11171
	    __resultW[*pcntW] = nil;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11172
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11173
	if (*pcntE < resultSizeException) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11174
	    __resultE[*pcntE] = nil;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11175
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11176
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11177
	RETURN (__mkSmallInteger(cntAll));
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11178
    } else if (ret < 0 && errno != EINTR) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11179
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11180
	 * Error: Return -1
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11181
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11182
	if (@global(InfoPrinting) == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11183
	    fprintf(stderr, "OS [info]: select errno = %d\n", errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11184
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11185
	@global(LastErrorNumber) = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11186
	RETURN (__mkSmallInteger(-1));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11187
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11188
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11189
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11190
     * Return 0 (no filedescriptor ready)
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11191
     */
16313
d3d7809d529d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16301
diff changeset
 11192
    @global(LastErrorNumber) = nil;
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 11193
    RETURN (__mkSmallInteger(0));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11194
fail: ;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11195
%}.
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11196
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11197
     timeout argument not integer,
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11198
     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
 11199
     or not supported by OS
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11200
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11201
    ^ self primitiveFailed
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11202
!
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
 11203
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11204
setBlocking:aBoolean on:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11205
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11206
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11207
    "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
 11208
     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
 11209
     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
 11210
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 11211
     blocking is off.
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 11212
     Return the previous blocking state."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11213
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11214
%{  /* NOCONTEXT */
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11215
#ifdef __SCHTEAM__
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11216
    // TODO
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11217
    return context._RETURN(0);
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11218
#else
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11219
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 11220
    int ret = 0, flags;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11221
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11222
# if defined(F_GETFL) && defined(F_SETFL)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11223
#  undef DELAY_FLAG
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11224
#  if defined(O_NONBLOCK)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11225
#   define DELAY_FLAG O_NONBLOCK
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11226
#  elif defined(O_NDELAY)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11227
#   define DELAY_FLAG O_NDELAY
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11228
#  elif defined(FNDELAY)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11229
#   define DELAY_FLAG FNDELAY
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11230
#  endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11231
#  if defined(DELAY_FLAG)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11232
    if (__isSmallInteger(fd)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11233
	int f = __intVal(fd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11234
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11235
	flags = fcntl(f, F_GETFL, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11236
	if (aBoolean == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11237
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11238
	} else if (aBoolean == false) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11239
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11240
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11241
	if (ret >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11242
	    RETURN ((flags & DELAY_FLAG) ? false : true );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11243
	}
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 11244
    }
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11245
#   undef DELAY_FLAG
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11246
#  endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11247
# endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 11248
#endif /* not SCHTEAM */
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 11249
%}.
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 11250
    "
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 11251
     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
 11252
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11253
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11254
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11255
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11256
!UnixOperatingSystem::ELFConstants class methodsFor:'initialization'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11257
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11258
initialize
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11259
    "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
 11260
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11261
%{
17637
e88d00519209 ELF and OSX defines
Claus Gittinger <cg@exept.de>
parents: 17635
diff changeset
 11262
#ifdef ELF
e88d00519209 ELF and OSX defines
Claus Gittinger <cg@exept.de>
parents: 17635
diff changeset
 11263
# 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
 11264
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11265
    /* 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
 11266
       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
 11267
       may have.  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11268
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11269
    DEFCONST(EI_MAG0)           /* File identification byte 0 index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11270
    DEFCONST(EI_MAG1)           /* File identification byte 1 index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11271
    DEFCONST(EI_MAG2)           /* File identification byte 2 index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11272
    DEFCONST(EI_MAG3)           /* File identification byte 3 index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11273
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11274
    DEFCONST(EI_CLASS)          /* File class byte index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11275
    DEFCONST(ELFCLASSNONE)      /* Invalid class */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11276
    DEFCONST(ELFCLASS32)        /* 32-bit objects */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11277
    DEFCONST(ELFCLASS64)        /* 64-bit objects */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11278
    DEFCONST(ELFCLASSNUM)
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11279
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11280
    DEFCONST(EI_DATA)           /* Data encoding byte index */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11281
    DEFCONST(ELFDATANONE)       /* Invalid data encoding */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11282
    DEFCONST(ELFDATA2LSB)       /* 2's complement, little endian */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11283
    DEFCONST(ELFDATA2MSB)       /* 2's complement, big endian */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11284
    DEFCONST(ELFDATANUM)
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11285
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11286
    DEFCONST(EI_VERSION)        /* File version byte index */
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11287
				/* Value must be EV_CURRENT */
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11288
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11289
    DEFCONST(EI_OSABI)          /* OS ABI identification */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11290
    DEFCONST(ELFOSABI_NONE)     /* UNIX System V ABI */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11291
    DEFCONST(ELFOSABI_SYSV)     /* Alias.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11292
    DEFCONST(ELFOSABI_HPUX)     /* HP-UX */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11293
    DEFCONST(ELFOSABI_NETBSD)   /* NetBSD.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11294
#ifdef ELFOSABI_GNU
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11295
    DEFCONST(ELFOSABI_GNU)      /* Object uses GNU ELF extensions.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11296
#endif
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11297
    DEFCONST(ELFOSABI_LINUX)    /* Compatibility alias.  */
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11298
    DEFCONST(ELFOSABI_SOLARIS)  /* Sun Solaris.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11299
    DEFCONST(ELFOSABI_AIX)      /* IBM AIX.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11300
    DEFCONST(ELFOSABI_IRIX)     /* SGI Irix.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11301
    DEFCONST(ELFOSABI_FREEBSD)  /* FreeBSD.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11302
    DEFCONST(ELFOSABI_TRU64)    /* Compaq TRU64 UNIX.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11303
    DEFCONST(ELFOSABI_MODESTO)  /* Novell Modesto.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11304
    DEFCONST(ELFOSABI_OPENBSD)  /* OpenBSD.  */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11305
#ifdef ELFOSABI_ARM_AEABI
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11306
    DEFCONST(ELFOSABI_ARM_AEABI)/* ARM EABI */
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11307
#endif
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11308
    DEFCONST(ELFOSABI_ARM)      /* ARM */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11309
    DEFCONST(ELFOSABI_STANDALONE)/* Standalone (embedded) application */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11310
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11311
    DEFCONST(EI_ABIVERSION)     /* ABI version */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11312
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11313
    DEFCONST(EI_PAD)            /* Byte index of padding bytes */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11314
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11315
    /* Legal values for e_type (object file type).  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11316
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11317
    DEFCONST(ET_NONE)           /* No file type */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11318
    DEFCONST(ET_REL)            /* Relocatable file */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11319
    DEFCONST(ET_EXEC)           /* Executable file */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11320
    DEFCONST(ET_DYN)            /* Shared object file */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11321
    DEFCONST(ET_CORE)           /* Core file */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11322
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11323
    DEFCONST(ET_LOOS)           /* OS-specific range start */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11324
    DEFCONST(ET_HIOS)           /* OS-specific range end */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11325
    DEFCONST(ET_LOPROC)         /* Processor-specific range start */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11326
    DEFCONST(ET_HIPROC)         /* Processor-specific range end */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11327
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11328
    /* Legal values for e_machine (architecture).  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11329
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11330
    DEFCONST(EM_NONE)           /* No machine */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11331
    DEFCONST(EM_M32)            /* AT&T WE 32100 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11332
    DEFCONST(EM_SPARC)          /* SUN SPARC */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11333
    DEFCONST(EM_386)            /* Intel 80386 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11334
    DEFCONST(EM_68K)            /* Motorola m68k family */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11335
    DEFCONST(EM_88K)            /* Motorola m88k family */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11336
    DEFCONST(EM_860)            /* Intel 80860 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11337
    DEFCONST(EM_MIPS)           /* MIPS R3000 big-endian */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11338
    DEFCONST(EM_S370)           /* IBM System/370 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11339
    DEFCONST(EM_MIPS_RS3_LE)    /* MIPS R3000 little-endian */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11340
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11341
    DEFCONST(EM_PARISC)         /* HPPA */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11342
    DEFCONST(EM_VPP500)         /* Fujitsu VPP500 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11343
    DEFCONST(EM_SPARC32PLUS)    /* Sun's "v8plus" */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11344
    DEFCONST(EM_960)            /* Intel 80960 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11345
    DEFCONST(EM_PPC)            /* PowerPC */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11346
    DEFCONST(EM_PPC64)          /* PowerPC 64-bit */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11347
    DEFCONST(EM_S390)           /* IBM S390 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11348
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11349
    DEFCONST(EM_V800)           /* NEC V800 series */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11350
    DEFCONST(EM_FR20)           /* Fujitsu FR20 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11351
    DEFCONST(EM_RH32)           /* TRW RH-32 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11352
    DEFCONST(EM_RCE)            /* Motorola RCE */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11353
    DEFCONST(EM_ARM)            /* ARM */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11354
    DEFCONST(EM_FAKE_ALPHA)     /* Digital Alpha */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11355
    DEFCONST(EM_SH)             /* Hitachi SH */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11356
    DEFCONST(EM_SPARCV9)        /* SPARC v9 64-bit */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11357
    DEFCONST(EM_TRICORE)        /* Siemens Tricore */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11358
    DEFCONST(EM_ARC)            /* Argonaut RISC Core */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11359
    DEFCONST(EM_H8_300)         /* Hitachi H8/300 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11360
    DEFCONST(EM_H8_300H)        /* Hitachi H8/300H */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11361
    DEFCONST(EM_H8S)            /* Hitachi H8S */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11362
    DEFCONST(EM_H8_500)         /* Hitachi H8/500 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11363
    DEFCONST(EM_IA_64)          /* Intel Merced */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11364
    DEFCONST(EM_MIPS_X)         /* Stanford MIPS-X */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11365
    DEFCONST(EM_COLDFIRE)       /* Motorola Coldfire */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11366
    DEFCONST(EM_68HC12)         /* Motorola M68HC12 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11367
    DEFCONST(EM_MMA)            /* Fujitsu MMA Multimedia Accelerator*/
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11368
    DEFCONST(EM_PCP)            /* Siemens PCP */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11369
    DEFCONST(EM_NCPU)           /* Sony nCPU embeeded RISC */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11370
    DEFCONST(EM_NDR1)           /* Denso NDR1 microprocessor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11371
    DEFCONST(EM_STARCORE)       /* Motorola Start*Core processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11372
    DEFCONST(EM_ME16)           /* Toyota ME16 processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11373
    DEFCONST(EM_ST100)          /* STMicroelectronic ST100 processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11374
    DEFCONST(EM_TINYJ)          /* Advanced Logic Corp. Tinyj emb.fam*/
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11375
    DEFCONST(EM_X86_64)         /* AMD x86-64 architecture */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11376
    DEFCONST(EM_PDSP)           /* Sony DSP Processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11377
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11378
    DEFCONST(EM_FX66)           /* Siemens FX66 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11379
    DEFCONST(EM_ST9PLUS)        /* STMicroelectronics ST9+ 8/16 mc */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11380
    DEFCONST(EM_ST7)            /* STmicroelectronics ST7 8 bit mc */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11381
    DEFCONST(EM_68HC16)         /* Motorola MC68HC16 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11382
    DEFCONST(EM_68HC11)         /* Motorola MC68HC11 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11383
    DEFCONST(EM_68HC08)         /* Motorola MC68HC08 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11384
    DEFCONST(EM_68HC05)         /* Motorola MC68HC05 microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11385
    DEFCONST(EM_SVX)            /* Silicon Graphics SVx */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11386
    DEFCONST(EM_ST19)           /* STMicroelectronics ST19 8 bit mc */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11387
    DEFCONST(EM_VAX)            /* Digital VAX */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11388
    DEFCONST(EM_CRIS)           /* Axis Communications 32-bit embedded processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11389
    DEFCONST(EM_JAVELIN)        /* Infineon Technologies 32-bit embedded processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11390
    DEFCONST(EM_FIREPATH)       /* Element 14 64-bit DSP Processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11391
    DEFCONST(EM_ZSP)            /* LSI Logic 16-bit DSP Processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11392
    DEFCONST(EM_MMIX)           /* Donald Knuth's educational 64-bit processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11393
    DEFCONST(EM_HUANY)          /* Harvard University machine-independent object files */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11394
    DEFCONST(EM_PRISM)          /* SiTera Prism */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11395
    DEFCONST(EM_AVR)            /* Atmel AVR 8-bit microcontroller */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11396
    DEFCONST(EM_FR30)           /* Fujitsu FR30 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11397
    DEFCONST(EM_D10V)           /* Mitsubishi D10V */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11398
    DEFCONST(EM_D30V)           /* Mitsubishi D30V */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11399
    DEFCONST(EM_V850)           /* NEC v850 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11400
    DEFCONST(EM_M32R)           /* Mitsubishi M32R */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11401
    DEFCONST(EM_MN10300)        /* Matsushita MN10300 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11402
    DEFCONST(EM_MN10200)        /* Matsushita MN10200 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11403
    DEFCONST(EM_PJ)             /* picoJava */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11404
    DEFCONST(EM_OPENRISC)       /* OpenRISC 32-bit embedded processor */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11405
    DEFCONST(EM_ARC_A5)         /* ARC Cores Tangent-A5 */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11406
    DEFCONST(EM_XTENSA)         /* Tensilica Xtensa Architecture */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11407
#ifdef EM_AARCH64
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11408
    DEFCONST(EM_AARCH64)        /* ARM AARCH64 */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11409
#endif
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11410
#ifdef EM_TILEPRO
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11411
    DEFCONST(EM_TILEPRO)        /* Tilera TILEPro */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11412
#endif
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11413
#ifdef EM_MICROBLAZE
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11414
    DEFCONST(EM_MICROBLAZE)     /* Xilinx MicroBlaze */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11415
#endif
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11416
#ifdef EM_TILEGX
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11417
    DEFCONST(EM_TILEGX)         /* Tilera TILE-Gx */
17635
7453d9164a26 Conditionally define some EM_* constants
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17631
diff changeset
 11418
#endif
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11419
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11420
   /* 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
 11421
      pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11422
      chances of collision with official or non-GNU unofficial values.  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11423
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11424
    DEFCONST(EM_ALPHA)
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11425
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11426
    /* Legal values for e_version (version).  */
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11427
18193
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11428
    DEFCONST(EV_NONE)           /* Invalid ELF version */
35ff23be6b14 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 18188
diff changeset
 11429
    DEFCONST(EV_CURRENT)        /* Current version */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11430
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11431
#undef DEFCONST
17637
e88d00519209 ELF and OSX defines
Claus Gittinger <cg@exept.de>
parents: 17635
diff changeset
 11432
#endif /* ELF */
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11433
%}.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11434
    ELFMAG0 := 16r7F.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11435
    ELFMAG1 := $E codePoint.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11436
    ELFMAG2 := $L codePoint.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11437
    ELFMAG3 := $F codePoint.
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11438
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11439
    "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
 11440
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11441
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11442
!UnixOperatingSystem::ELFFileHeader class methodsFor:'instance creation'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11443
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11444
fromFile: aStringOrFilename
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11445
    ^ self new initializeOnFile: aStringOrFilename
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11446
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11447
    "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
 11448
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11449
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11450
!UnixOperatingSystem::ELFFileHeader methodsFor:'accessing'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11451
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11452
e_ident_class
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11453
    ^ data at: 1 + EI_CLASS
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11454
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11455
    "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
 11456
!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11457
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11458
e_machine
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11459
    ^ data unsignedShortAt: 1 + 16r12 bigEndian: msb
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11460
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11461
    "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
 11462
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11463
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11464
!UnixOperatingSystem::ELFFileHeader methodsFor:'initialization'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11465
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11466
initializeOnFile: aStringOrFilename
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11467
    file := aStringOrFilename asFilename.
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11468
    file exists ifFalse:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11469
	self error:'Given file does not exist'.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11470
	^ nil
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11471
    ].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11472
    file isRegularFile ifFalse:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11473
	self error:'Given file is not a regular file'.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11474
	^ nil
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11475
    ].
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11476
    file readingFileDo:[ :s |
18226
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11477
	s binary.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11478
	data := s next: 16r18.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11479
	(data at: 1 + EI_MAG0) ~~ ELFMAG0 ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11480
	    self error:'Given file is not a valid ELF file (magic not found)'.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11481
	].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11482
	(data at: 1 + EI_MAG1) ~~ ELFMAG1 ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11483
	    self error:'Given file is not a valid ELF file (magic not found)'.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11484
	].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11485
	(data at: 1 + EI_MAG2) ~~ ELFMAG2 ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11486
	    self error:'Given file is not a valid ELF file (magic not found)'.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11487
	].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11488
	(data at: 1 + EI_MAG3) ~~ ELFMAG3 ifTrue:[
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11489
	    self error:'Given file is not a valid ELF file (magic not found)'.
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11490
	].
444c446c1592 wrong ifdef (not relevant for current architectures)
Claus Gittinger <cg@exept.de>
parents: 18205
diff changeset
 11491
	msb := (data at: 1 + EI_DATA) == ELFDATA2MSB
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11492
    ].
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11493
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11494
    "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
 11495
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11496
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11497
!UnixOperatingSystem::ELFFileHeader methodsFor:'queries'!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11498
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11499
isFor32BitArchitecture
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11500
    ^ self e_ident_class == ELFCLASS32
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11501
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11502
    "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
 11503
!
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11504
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11505
isFor64BitArchitecture
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11506
    ^ self e_ident_class == ELFCLASS64
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11507
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11508
    "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
 11509
! !
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 11510
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11511
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11512
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11513
update:aspect with:argument from:anObject
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11514
    "one of our registered handles has been collected"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11515
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11516
    aspect == #ElementExpired ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11517
	OpenFiles keysAndValuesDo:[:fd :handle |
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11518
	    handle == 0 ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11519
		"Have to close the file descriptor"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11520
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11521
		OperatingSystem closeFd:fd.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11522
		OpenFiles at:fd put:nil.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11523
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11524
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11525
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11526
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11527
    "Created: 30.9.1997 / 12:57:35 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11528
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11529
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11530
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11531
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11532
initialize
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 11533
    OpenFiles := WeakArray new:10.
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 11534
    OpenFiles addDependent:self.
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 11535
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 11536
    "
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11537
	self initialize
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 11538
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11539
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11540
    "Created: 26.9.1997 / 17:15:50 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11541
    "Modified: 30.9.1997 / 12:40:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11542
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11543
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11544
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11545
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11546
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11547
    "create an instance of myself for a given fileDescriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11548
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11549
    ^ self new for:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11550
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11551
    "Created: 30.9.1997 / 14:00:00 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11552
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11553
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11554
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11555
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11556
error:anErrorSymbolOrErrno
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11557
    "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
 11558
     or the error number as returned by the OperatingSystem"
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11559
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11560
    anErrorSymbolOrErrno isInteger ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11561
	(UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11562
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11563
    self primitiveFailed:anErrorSymbolOrErrno.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11564
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11565
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11566
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11567
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11568
close
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11569
    "close the descriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11570
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11571
    |desc|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11572
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11573
    desc := fd.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11574
    self invalidate.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11575
    ^ OperatingSystem closeFd:desc.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11576
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11577
    "Modified: 30.9.1997 / 13:06:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11578
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11579
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11580
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11581
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11582
for:aFileDescriptor
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 11583
    "create a file for a handle"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11584
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11585
    |oldHandle|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11586
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11587
    fd := aFileDescriptor.
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 11588
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 11589
    "JV@2013-03-15: It may happen that OS returns a filedescriptor whose value
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 11590
     is larger than twice the lenght of the weakarray. Care for this.
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 11591
     Spotted by Martin Kobetic."
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 11592
    oldHandle := OpenFiles at:aFileDescriptor ifAbsent: [nil].
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 11593
    "/ 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
 11594
    "/ and we come up in the new image with no one referring to it.
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 11595
    (oldHandle notNil and:[oldHandle ~~ 0 and:[ oldHandle ~~ self]]) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11596
	oldHandle invalidate.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11597
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11598
    self register.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11599
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11600
    "Created: 26.9.1997 / 17:14:40 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11601
    "Modified: 30.9.1997 / 12:41:43 / stefan"
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 11602
    "Modified (comment): / 16-03-2013 / 00:04:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11603
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11604
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11605
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11606
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11607
readBytes:count into:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11608
    "read count bytes into a byte-buffer;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11609
     Return the number of bytes read.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11610
     The read is non-blocking. If the operation would block
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11611
     either an incomplete count or nil will be returned.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11612
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11613
     An exception is raised on any other error"
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11614
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11615
    |error|
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11616
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11617
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11618
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11619
    int nRead = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11620
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11621
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11622
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11623
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11624
    if (! __isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11625
	error = @symbol(errorNotOpen);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11626
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11627
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11628
    if (! __bothSmallInteger(count, firstIndex)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11629
	error = @symbol(badArgument);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11630
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11631
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11632
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11633
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11634
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11635
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11636
    if (fd < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11637
	error = @symbol(internalError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11638
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 11639
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 11640
    if (__isExternalBytesLike(aByteBuffer)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11641
	OBJ sz;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11642
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11643
	nInstBytes = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11644
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11645
	if (extPtr == NULL) goto bad;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11646
	sz = __externalBytesSize(aByteBuffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11647
	if (__isSmallInteger(sz)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11648
	    objSize = __smallIntegerVal(sz);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11649
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11650
	    objSize = -1; /* unknown */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11651
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11652
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11653
	OBJ oClass = __Class(aByteBuffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11654
	int nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11655
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11656
	nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11657
	switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11658
	    case BYTEARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11659
	    case WORDARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11660
	    case LONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11661
	    case SWORDARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11662
	    case SLONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11663
	    case FLOATARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11664
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11665
	    case DOUBLEARRAY:
15991
84ded9e95455 class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 15982
diff changeset
 11666
#ifdef __NEED_DOUBLE_ALIGN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11667
		nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11668
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11669
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11670
	    case LONGLONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11671
	    case SLONGLONGARRAY:
15991
84ded9e95455 class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 15982
diff changeset
 11672
#ifdef __NEED_LONGLONG_ALIGN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11673
		nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11674
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11675
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11676
	    default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11677
		goto bad;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11678
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11679
	extPtr = (char *)0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11680
	objSize = __Size(aByteBuffer) - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11681
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11682
    if ((offs >= 0)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11683
	&& (cnt >= 0)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11684
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11685
	nRead = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11686
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11687
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11688
	    int n;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11689
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11690
	    if (extPtr) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11691
		n = read(fd, extPtr+offs, cnt);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11692
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11693
		char *bp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11694
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11695
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11696
		 * on interrupt, anObject may be moved to another location.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11697
		 * So we recompute the byte-address here.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11698
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11699
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11700
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11701
		n = read(fd, bp + offs, cnt);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11702
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11703
	    if (n > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11704
		cnt -= n;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11705
		offs += n;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11706
		nRead += n;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11707
	    } else if (n == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11708
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11709
	    } else if (n < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11710
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11711
#ifdef EWOULDBLOCK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11712
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11713
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11714
#ifdef EAGAIN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11715
		    || errno == EAGAIN
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11716
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11717
		) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11718
		     RETURN(nil);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11719
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11720
		if (errno != EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11721
		     error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11722
		     goto bad;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11723
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11724
		__HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11725
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11726
	} while (cnt > 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11727
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11728
	RETURN (__mkSmallInteger(nRead));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11729
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11730
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11731
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11732
    ^ self error:error.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11733
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11734
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11735
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11736
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11737
     h := OperatingSystem openFileForRead:'/etc/hosts'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11738
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11739
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11740
     Transcript show:n; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11741
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11742
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11743
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11744
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11745
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11746
     h := OperatingSystem openFileForRead:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11747
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11748
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11749
     Transcript show:n printString; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11750
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11751
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11752
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11753
writeBytes:count from:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11754
    "write count bytes from a byte-buffer;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11755
     Return the number of bytes written (negative on error)"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11756
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11757
    |error|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11758
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11759
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11760
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11761
    int nWritten = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11762
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11763
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11764
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11765
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11766
    if (! __isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11767
	error = @symbol(errorNotOpen);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11768
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11769
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11770
    if (! __bothSmallInteger(count, firstIndex)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11771
	error = @symbol(badArgument);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11772
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11773
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11774
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11775
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11776
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11777
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11778
    if (fd < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11779
	error = @symbol(internalError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11780
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 11781
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 11782
    if (__isExternalBytesLike(aByteBuffer)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11783
	OBJ sz;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11784
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11785
	nInstBytes = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11786
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11787
	if (extPtr == NULL) goto bad;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11788
	sz = __externalBytesSize(aByteBuffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11789
	if (__isSmallInteger(sz)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11790
	    objSize = __smallIntegerVal(sz);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11791
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11792
	    objSize = -1; /* unknown */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11793
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11794
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11795
	OBJ oClass = __Class(aByteBuffer);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11796
	int nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11797
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11798
	nInstBytes = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11799
	switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11800
	    case BYTEARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11801
	    case WORDARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11802
	    case LONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11803
	    case SWORDARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11804
	    case SLONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11805
	    case FLOATARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11806
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11807
	    case DOUBLEARRAY:
15991
84ded9e95455 class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 15982
diff changeset
 11808
#ifdef __NEED_DOUBLE_ALIGN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11809
		nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11810
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11811
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11812
	    case LONGLONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11813
	    case SLONGLONGARRAY:
15991
84ded9e95455 class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 15982
diff changeset
 11814
#ifdef __NEED_LONGLONG_ALIGN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11815
		nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11816
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11817
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11818
	    default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11819
		goto bad;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11820
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11821
	extPtr = (char *)0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11822
	objSize = __Size(aByteBuffer) - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11823
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11824
    if ((offs >= 0)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11825
	&& (cnt >= 0)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11826
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11827
	nWritten = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11828
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11829
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11830
	    int n;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11831
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11832
	    if (extPtr) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11833
		n = write(fd, extPtr+offs, cnt);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11834
	    } else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11835
		char *bp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11836
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11837
		/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11838
		 * on interrupt, anObject may be moved to another location.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11839
		 * So we recompute the byte-address here.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11840
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11841
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11842
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11843
		n = write(fd, bp + offs, cnt);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11844
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11845
	    if (n > 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11846
		cnt -= n;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11847
		offs += n;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11848
		nWritten += n;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11849
	    } else if (n == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11850
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11851
	    } else if (n < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11852
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11853
#ifdef EWOULDBLOCK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11854
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11855
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11856
#ifdef EAGAIN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11857
		    || errno == EAGAIN
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11858
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11859
		) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11860
		     RETURN(nil);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11861
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11862
		if (errno != EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11863
		     error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11864
		     goto bad;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11865
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11866
		__HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11867
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11868
	} while (cnt > 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11869
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11870
	RETURN (__mkSmallInteger(nWritten));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11871
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11872
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11873
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11874
    ^ self error:error
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11875
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11876
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11877
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11878
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11879
     h := OperatingSystem createFileForReadWrite:'/tmp/xx'.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11880
     buff := '12345678901234567890'.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11881
     n := h writeBytes:10 from:buff startingAt:1.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11882
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11883
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11884
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11885
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11886
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11887
     h := OperatingSystem createFileForReadWrite:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11888
     buff := '12345678901234567890'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11889
     n := h writeBytes:10 from:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 11890
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11891
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11892
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11893
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11894
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11895
nextError
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11896
    "retrieve the pending error from the current fileDescriptor
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11897
     and raise an error exception.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11898
     This should be only called, when an error is pending.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11899
     Otherwise a byte may be lost"
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11900
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11901
    |dummyByte|
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11902
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11903
    dummyByte := ByteArray new:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11904
    ^ self readBytes:1 into:dummyByte startingAt:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11905
!
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11906
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11907
seekTo:newPosition from:whence
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11908
    "seek to newPosition
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11909
     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
 11910
     Return the new position."
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11911
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11912
    |error|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11913
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11914
%{
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11915
    INT fd;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11916
    INT __whence;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11917
    off_t pos, ret;
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11918
    OBJ rslt;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11919
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11920
    if (! __isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11921
	error = @symbol(errorNotOpen);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11922
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11923
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11924
    if (__isSmallInteger(newPosition)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11925
	pos = __smallIntegerVal(newPosition);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11926
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11927
	pos = __signedLongIntVal(newPosition);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11928
	if (pos < 0 && (sizeof(pos) < 8 || __signedLong64IntVal(newPosition, &pos) == 0)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11929
	    error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11930
	    goto bad;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11931
	}
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11932
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11933
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11934
    fd = __smallIntegerVal(__INST(fd));
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11935
    if (fd < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11936
	error = @symbol(internalError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11937
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11938
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11939
    if (whence == @symbol(begin)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11940
	__whence = SEEK_SET;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11941
    } else if (whence == @symbol(current)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11942
	__whence = SEEK_CUR;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11943
    } else if (whence == @symbol(end)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11944
	__whence = SEEK_END;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11945
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11946
	error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11947
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11948
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11949
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11950
again:
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11951
    ret = lseek(fd, pos, __whence);
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11952
    if (ret < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11953
	if (errno == EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11954
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11955
	    goto again;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11956
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11957
	error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11958
	goto bad;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11959
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11960
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11961
    if (sizeof(ret) == 8) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11962
	rslt = __MKINT64 (&ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11963
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11964
	rslt = __MKINT(ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11965
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 11966
    RETURN (rslt);
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11967
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11968
bad: ;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11969
%}.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11970
    ^ self error:error.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11971
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11972
    "
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11973
     |h buff n|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11974
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11975
     h := OperatingSystem openFileForRead:'/etc/hosts'.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11976
     h seekTo:10 from:#begin.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11977
     buff := ByteArray new:1000. buff inspect.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11978
     n := h readBytes:1000 into:buff startingAt:1.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11979
     Transcript show:n; space; showCR:buff asString.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 11980
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11981
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11982
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11983
selectWithTimeOut:millis
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11984
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11985
     Return true, if i/o ok, false if timed-out or interrupted.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11986
     With 0 as timeout argument, this can be used to check for availability
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11987
     of read-data.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11988
     Experimental."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11989
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11990
    ^ OperatingSystem selectOnAnyReadable:(Array with:fd)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11991
		      writable:(Array with:fd)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11992
		     exception:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 11993
		   withTimeOut:millis
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11994
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11995
    "Created: 1.10.1997 / 08:51:11 / stefan"
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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11998
setBlocking:aBoolean
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 11999
    "{ Pragma: +optSpace }"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12000
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12001
    "set/clear the blocking attribute - if set (which is the default)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12002
     a read on the fileDescriptor will block until data is available.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12003
     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
 12004
     nil if no data is available."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12005
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12006
    |err|
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12007
%{
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12008
#ifdef __SCHTEAM__
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12009
    // TODO
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12010
    return context._RETURN(0);
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12011
#else
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12012
    int ret, flags;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12013
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12014
# if defined(F_GETFL) && defined(F_SETFL)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12015
#  if defined(O_NDELAY)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12016
#   define DELAY_FLAG O_NDELAY
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12017
#  else
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12018
#   if defined(FNDELAY)
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12019
#    define DELAY_FLAG FNDELAY
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12020
#   endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12021
#  endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12022
#  if defined(DELAY_FLAG)
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12023
    if (__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12024
	int f = __intVal(__INST(fd));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12025
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12026
	flags = fcntl(f, F_GETFL, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12027
	if (aBoolean == true) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12028
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12029
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12030
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12031
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12032
	if (ret >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12033
	    RETURN(__mkSmallInteger(flags));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12034
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12035
	    err = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12036
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12037
    }
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12038
#  undef DELAY_FLAG
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12039
#  endif /* DELAY_FLAG */
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12040
# endif
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12041
#endif /* not SCHTEAM */
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12042
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12043
    err notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12044
	self error:err
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12045
    ].
18314
903fcedc61fe comment sonly
Claus Gittinger <cg@exept.de>
parents: 18278
diff changeset
 12046
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12047
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12048
     fd argument not integer
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12049
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12050
    ^ self primitiveFailed
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
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
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 12055
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'private-accessing'!
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12056
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12057
fileDescriptor
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12058
    "return the (integer) fileDescriptor"
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12059
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12060
%{
7462
05b5202d988a Fix compiler warning
Stefan Vogel <sv@exept.de>
parents: 7461
diff changeset
 12061
    OBJ handle = __externalAddressVal(self);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12062
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12063
    if (__isSmallInteger(handle)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12064
	RETURN (handle);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12065
    }
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12066
%}.
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12067
    ^ nil
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12068
!
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 12069
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12070
setFileDescriptor:anInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12071
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12072
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12073
    if (__isSmallInteger(anInteger)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12074
	__externalAddressVal(self) = (OBJ)(__smallIntegerVal(anInteger));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12075
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12076
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12077
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
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12080
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12081
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12082
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12083
canReadWithoutBlocking
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12084
    "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
 12085
     (i.e. read is possible without blocking).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12086
     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
 12087
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12088
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12089
    int fd;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12090
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12091
    if (__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12092
	fd = __smallIntegerVal(__INST(fd));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12093
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12094
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12095
	 * if available, try FIONREAD first, which is usually done faster.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12096
	 */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12097
# ifdef FIONREAD
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12098
	{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12099
	    int result = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12100
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12101
	    if (ioctl(fd, FIONREAD, &result) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12102
		RETURN(result > 0 ? true : false);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12103
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12104
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12105
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12106
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12107
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12108
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12109
    OperatingSystem supportsSelect ifFalse:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12110
	"/ mhmh - what should we do then ?
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12111
	"/ For now, return true as if data was present,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12112
	"/ and let the thread fall into the read.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12113
	"/ It will then (hopefully) be desceduled there and
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12114
	"/ effectively polling for input.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12115
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12116
	^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12117
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12118
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12119
    ^ (OperatingSystem selectOnAnyReadable:(Array with:fd)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12120
		       writable:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12121
		       exception:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12122
		       withTimeOut:0) == fd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12123
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12124
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12125
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12126
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12127
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12128
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12129
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12130
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12131
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12132
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12133
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12134
     h := OperatingSystem openFileForRead:'/dev/ttyS0'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12135
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12136
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12137
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12138
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12139
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12140
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12141
canWriteWithoutBlocking
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12142
    "return true, if filedescriptor can be written without blocking"
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12143
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12144
    OperatingSystem supportsSelect ifFalse:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12145
	"/ mhmh - what should we do then ?
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12146
	"/ For now, return true as if data was present,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12147
	"/ and let the thread fall into the write.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12148
	"/ It will then (hopefully) be desceduled there and
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12149
	"/ effectively polling for output.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12150
	^ true
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12151
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12152
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12153
    ^ (OperatingSystem selectOnAnyReadable:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12154
		       writable:(Array with:fd)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12155
		       exception:nil
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12156
		       withTimeOut:0) == fd
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12157
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12158
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12159
isValid
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12160
    "answer true, if the handle is valid, i.e. connected to
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12161
     a file or some other OS object"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12162
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12163
    ^ fd notNil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12164
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12165
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12166
numAvailableForRead
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12167
    "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
 12168
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12169
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12170
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12171
     * 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
 12172
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12173
# if defined(FIONREAD)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12174
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12175
	int n = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12176
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12177
	if (__isSmallInteger(__INST(fd))) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12178
	    if (ioctl(__smallIntegerVal(__INST(fd)), FIONREAD, &n) >= 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12179
		RETURN (__MKINT(n));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12180
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12181
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12182
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12183
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12184
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12185
    ^ self canReadWithoutBlocking ifTrue:[1] ifFalse:[0]
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12186
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12187
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12188
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12189
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12190
     n := h numAvailableForRead.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12191
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12192
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12193
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12194
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12195
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12196
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12197
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12198
register
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12199
    "register myself as an open file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12200
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12201
    |sz old|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12202
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12203
    sz := OpenFiles size.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12204
    fd > sz ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12205
	"grow for more descriptors"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12206
	old := OpenFiles.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12207
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12208
	"JV@2013-03-15: It may happen that OS returns a filedescriptor whose value
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12209
	 is larger than twice the lenght of the weakarray. Care for this.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12210
	 Spotted by Martin Kobetic."
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12211
	OpenFiles := WeakArray new:((sz * 2) max:fd).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12212
	old removeDependent:(self class).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12213
	OpenFiles addDependent:(self class).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12214
	old keysAndValuesDo:[:index :elem|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12215
	    "be careful to not overwrite new entries in OpenFiles"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12216
	    elem notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12217
		OpenFiles at:index put:elem.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12218
	    ].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12219
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12220
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12221
    OpenFiles at:fd put:self.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12222
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12223
    "Created: 30.9.1997 / 12:51:48 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12224
    "Modified: 30.9.1997 / 12:58:37 / stefan"
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 12225
    "Modified (comment): / 16-03-2013 / 00:04:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12226
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12227
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12228
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12229
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12230
invalidate
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12231
    "a file handle has become invalid"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12232
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12233
    OpenFiles at:fd put:nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12234
    fd := nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12235
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12236
    "Created: 30.9.1997 / 12:37:26 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12237
    "Modified: 30.9.1997 / 12:42:16 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12238
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12239
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12240
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'waiting'!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12241
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12242
readWaitWithTimeoutMs:timeout
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12243
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12244
     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
 12245
     If data is already available, return immediate.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12246
     Return true if a timeout occured (i.e. false, if data is available).
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12247
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12248
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12249
    |inputSema hasData wasBlocked|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12250
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12251
    fd isNil ifTrue:[^ self error:#errorNotOpen].
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12252
    self canReadWithoutBlocking ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12253
	^ false.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12254
    ].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12255
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12256
    wasBlocked := OperatingSystem blockInterrupts.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12257
    inputSema := Semaphore new name:'readWait'.
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12258
    [
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12259
	timeout notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12260
	    Processor signal:inputSema afterMilliseconds:timeout
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12261
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12262
	Processor signal:inputSema onInput:fd.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12263
	Processor activeProcess state:#ioWait.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12264
	inputSema wait.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12265
	hasData := self canReadWithoutBlocking.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12266
    ] ifCurtailed:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12267
	Processor disableSemaphore:inputSema.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12268
	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12269
    ].
16481
cbecb6681a12 class: UnixOperatingSystem>>FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16464
diff changeset
 12270
    timeout notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12271
	Processor disableSemaphore:inputSema.
16481
cbecb6681a12 class: UnixOperatingSystem>>FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16464
diff changeset
 12272
    ].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12273
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12274
    ^ hasData not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12275
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12276
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12277
writeWaitWithTimeoutMs:timeout
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12278
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12279
     becomes ready for writing or a timeout (in seconds) expired.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12280
     Return true if a timeout occured (i.e. false, if data is available).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12281
     Return immediate if the receiver is already ready.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12282
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12283
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
 12284
    |outputSema canWrite wasBlocked|
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12285
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12286
    fd isNil ifTrue:[^ self error:#errorNotOpen].
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12287
    self canWriteWithoutBlocking ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12288
	^ false.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12289
    ].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12290
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12291
    wasBlocked := OperatingSystem blockInterrupts.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12292
    outputSema := Semaphore new name:'writeWait'.
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12293
    [
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12294
	timeout notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12295
	    Processor signal:outputSema afterMilliseconds:timeout
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12296
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12297
	Processor signal:outputSema onOutput:fd.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12298
	Processor activeProcess state:#ioWait.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12299
	outputSema wait.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12300
	canWrite := self canWriteWithoutBlocking.
16464
a695c2af61fd class: UnixOperatingSystem::FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16417
diff changeset
 12301
    ] ifCurtailed:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12302
	Processor disableSemaphore:outputSema.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12303
	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12304
    ].
16481
cbecb6681a12 class: UnixOperatingSystem>>FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16464
diff changeset
 12305
    timeout notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12306
	Processor disableSemaphore:outputSema.
16481
cbecb6681a12 class: UnixOperatingSystem>>FileDescriptorHandle
Stefan Vogel <sv@exept.de>
parents: 16464
diff changeset
 12307
    ].
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12308
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12309
    ^ canWrite not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12310
! !
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 12311
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12312
!UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12313
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12314
closeFile
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12315
    "close the underlying file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12316
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12317
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12318
    FILE *f = (FILE *)(__externalAddressVal(self));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12319
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12320
    if (f) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12321
	__externalAddressVal(self) = NULL;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12322
	fclose(f);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12323
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12324
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12325
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12326
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 12327
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12328
!UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12329
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12330
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12331
    ^ self basicNew
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12332
	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
 12333
!
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12334
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12335
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
 12336
    ^ self basicNew
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12337
	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
 12338
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12339
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12340
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12341
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12342
accessTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12343
    "return accessed"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12344
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12345
    accessed isInteger ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12346
	"/ lazy time conversion
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12347
	accessed := Timestamp fromOSTime:(accessed * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12348
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12349
    ^ accessed
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12350
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12351
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12352
alternativeName
16592
cb3cbc0f525c class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16580
diff changeset
 12353
    "return the file's other name (DOS name on Windows).
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12354
     Nil if there is no other name"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12355
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12356
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12357
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12358
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12359
creationTime
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12360
    ^ nil
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12361
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12362
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12363
fileSize
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12364
    "return size"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12365
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12366
    ^ size
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12367
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12368
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12369
gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12370
    "return gid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12371
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12372
    ^ gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12373
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12374
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12375
id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12376
    "return id"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12377
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12378
    ^ id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12379
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12380
17313
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12381
linkTargetPath
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12382
    "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
 12383
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12384
    ^ targetPath
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12385
!
04d10f47d5e4 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17312
diff changeset
 12386
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12387
mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12388
    "return mode"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12389
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12390
    ^ mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12391
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12392
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12393
modificationTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12394
    "return modified"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12395
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12396
    modified isInteger ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12397
	"/ lazy time conversion
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12398
	modified := Timestamp fromOSTime:(modified * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12399
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12400
    ^ modified
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12401
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12402
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12403
numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12404
    "return numLinks"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12405
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12406
    ^ numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12407
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12408
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12409
path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12410
    "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
 12411
17288
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12412
    ^ targetPath
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12413
!
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12414
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12415
sourcePath
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12416
    ^ sourcePath
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12417
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12418
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12419
statusChangeTime
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12420
    statusChanged isInteger ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12421
	"/ lazy time conversion
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12422
	statusChanged := Timestamp fromOSTime:(statusChanged * 1000).
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12423
    ].
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12424
    ^ statusChanged
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12425
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12426
17311
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12427
targetPath
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12428
    "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
 12429
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12430
    ^ targetPath
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12431
!
bafd05547c4e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 17299
diff changeset
 12432
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12433
type
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12434
    "return type"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12435
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12436
    ^ type
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12437
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12438
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12439
uid
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12440
    "return uid"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12441
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12442
    ^ uid
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12443
! !
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12444
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12445
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing-vms'!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12446
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12447
fixedHeaderSize
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12448
    "return the fixedHeaderSize (VMS only; nil everywhere else)"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12449
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12450
    ^ nil
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12451
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12452
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12453
recordAttributes
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12454
    "return the recordAttributes (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12455
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12456
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12457
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12458
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12459
recordFormat
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12460
    "return the recordFormat (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12461
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12462
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12463
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12464
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12465
recordFormatNumeric
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12466
    "return the recordFormat as numeric (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12467
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12468
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12469
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12470
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12471
recordSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12472
    "return the recordSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12473
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12474
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12475
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12476
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12477
!UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12478
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12479
accessed
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 12480
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12481
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12482
    self obsoleteMethodWarning:'use #accessTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12483
    ^ self accessTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12484
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12485
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12486
at:key
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12487
    "backward compatibility access: in previous releases, IdentityDictionaries
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12488
     were used to hold my information. Allow access via key messages.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12489
     This method will vanish - use the proper access protocol."
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12490
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12491
    ^ self perform:key
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12492
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12493
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12494
modified
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 12495
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12496
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12497
    self obsoleteMethodWarning:'use #modificationTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12498
    ^ self modificationTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12499
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12500
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12501
statusChanged
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 12502
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12503
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 12504
    self obsoleteMethodWarning:'use #statusChangeTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 12505
    ^ self statusChangeTime
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12506
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12507
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 12508
!UnixOperatingSystem::FileStatusInfo methodsFor:'private-accessing'!
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12509
17288
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12510
sourcePath:lP
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12511
    sourcePath := lP.
17282
3e6b5f0df9e6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17281
diff changeset
 12512
!
3e6b5f0df9e6 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17281
diff changeset
 12513
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12514
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12515
    type := t.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12516
    mode := m.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12517
    uid := u.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12518
    gid := g.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12519
    size := s.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12520
    id := i.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12521
    accessed := aT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12522
    modified := mT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12523
    statusChanged := sT.
17288
eb5098cf2493 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17285
diff changeset
 12524
    targetPath := lP.
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 12525
    numLinks := nL.
17314
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12526
!
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12527
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12528
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
 12529
    type := t.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12530
    mode := m.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12531
    uid := u.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12532
    gid := g.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12533
    size := s.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12534
    id := i.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12535
    accessed := aT.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12536
    modified := mT.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12537
    statusChanged := sT.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12538
    sourcePath := sP.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12539
    targetPath := tP.
62f52fb0488f class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17313
diff changeset
 12540
    numLinks := nL.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12541
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 12542
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12543
!UnixOperatingSystem::FileStatusInfo methodsFor:'queries-access'!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12544
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12545
isGroupExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12546
    ^ mode bitTest:8r10
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12547
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12548
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12549
      '/etc/passwd' asFilename info isGroupExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12550
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12551
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12552
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12553
isGroupReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12554
    ^ mode bitTest:8r40
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12555
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12556
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12557
      '/etc/passwd' asFilename info isGroupReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12558
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12559
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12560
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12561
isGroupWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12562
    ^ mode bitTest:8r20
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12563
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12564
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12565
      '/etc/passwd' asFilename info isGroupWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12566
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12567
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12568
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12569
isOwnerExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12570
    ^ mode bitTest:8r100
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12571
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12572
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12573
      '/etc/passwd' asFilename info isOwnerExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12574
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12575
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12576
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12577
isOwnerReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12578
    ^ mode bitTest:8r400
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12579
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12580
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12581
      '/etc/passwd' asFilename info isOwnerReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12582
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12583
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12584
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12585
isOwnerWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12586
    ^ mode bitTest:8r200
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12587
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12588
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12589
      '/etc/passwd' asFilename info isOwnerWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12590
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12591
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12592
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12593
isWorldExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12594
    ^ mode bitTest:8r1
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12595
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12596
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12597
      '/etc/passwd' asFilename info isWorldExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12598
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12599
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12600
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12601
isWorldReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12602
    ^ mode bitTest:8r4
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12603
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12604
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12605
      '/etc/passwd' asFilename info isWorldReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12606
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12607
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12608
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12609
isWorldWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12610
    ^ mode bitTest:8r2
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12611
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12612
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12613
      '/etc/passwd' asFilename info isWorldWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12614
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12615
! !
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12616
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 12617
!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
 12618
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12619
isBlockSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12620
    ^ 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
 12621
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12622
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12623
isCharacterSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12624
    ^ 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
 12625
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12626
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12627
isDirectory
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12628
    ^ 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
 12629
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12630
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12631
isFifo
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12632
    ^ 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
 12633
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12634
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12635
isRegular
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12636
    ^ 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
 12637
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12638
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12639
isSocket
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12640
    ^ 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
 12641
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12642
15301
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 12643
isSpecialFile
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 12644
    ^ (type ~~ #directory
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12645
	and:[type ~~ #remoteDirectory
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12646
	and:[type ~~ #regular
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12647
	and:[type ~~ #symbolicLink
15301
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 12648
    ]]])
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 12649
!
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 12650
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12651
isSymbolicLink
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12652
    ^ 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
 12653
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12654
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12655
isUnknown
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12656
    ^ type == #unknown
17281
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 12657
!
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 12658
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 12659
isValid
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 12660
    "true if this info contains valid status info, or only the name.
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 12661
     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
 12662
     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
 12663
     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
 12664
     the corresponding unix readdir only returns the name."
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 12665
39e3141c7f21 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17225
diff changeset
 12666
    ^ 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
 12667
! !
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 12668
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12669
!UnixOperatingSystem::MountInfo methodsFor:'accessing'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12670
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12671
mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12672
    "return the value of the instance variable 'mountPointPath' (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12673
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12674
    ^ mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12675
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12676
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12677
mountPointPath:mountPointArg deviceOrRemotePath:deviceOrRemotePathArg fsType:fsTypeArg attributeString:attributeStringArg
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12678
    "set instance variables (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12679
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12680
    mountPointPath := mountPointArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12681
    deviceOrRemotePath := deviceOrRemotePathArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12682
    fsType := fsTypeArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12683
    attributeString := attributeStringArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12684
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12685
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 12686
!UnixOperatingSystem::MountInfo methodsFor:'printing'!
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 12687
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 12688
printOn:aStream
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12689
    aStream
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12690
	nextPutAll:'MountInfo for ';
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12691
	nextPutAll:mountPointPath.
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 12692
! !
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 12693
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12694
!UnixOperatingSystem::MountInfo methodsFor:'queries'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12695
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12696
isRemote
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12697
    ^ fsType = 'nfs'
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12698
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 12699
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12700
!UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12701
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12702
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12703
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12704
    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
 12705
    operating system processes (these are no smalltalk processes!!).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12706
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12707
    [Instance variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12708
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12709
	pid     <Integer>       OS-Process identifier
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12710
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12711
	status  <Symbol>        either #exit #signal #stop #continue
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12712
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12713
	code    <Integer>       either exitcode or signalnumber
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12714
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12715
	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
 12716
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12717
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12718
    [author:]
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12719
	Stefan Vogel
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12720
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12721
    [see also:]
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12722
	OperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12723
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12724
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12725
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12726
!UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12728
pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12729
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12730
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12731
    ^ 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
 12732
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12733
    "Created: 28.12.1995 / 14:16:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12734
    "Modified: 30.4.1996 / 18:25:00 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12735
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12737
processCreationFailure
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12738
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12739
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12740
    ^ 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
 12741
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12742
    "Created: 28.12.1995 / 14:35:29 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12743
    "Modified: 30.4.1996 / 18:25:05 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12744
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12745
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12746
!UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12747
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12748
code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12749
    "return the exitcode / signalNumber"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12750
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12751
    ^ code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12752
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12753
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12754
    "Modified: 30.4.1996 / 18:26:23 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12755
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12756
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12757
core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12758
    "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
 12759
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12760
    ^ core == true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12761
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12762
    "Modified: 28.12.1995 / 14:14:38 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12763
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12764
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12765
pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12766
    "return the pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12767
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12768
    ^ pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12769
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12770
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12771
    "Modified: 30.4.1996 / 18:26:30 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12772
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12773
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12774
status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12775
    "return status as a Symbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12776
     one of #exit #signal #stop #continue"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12777
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12778
    ^ status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12779
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12780
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12781
    "Modified: 30.4.1996 / 18:26:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12782
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12783
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12784
!UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12785
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12786
pid:newPid status:newStatus code:newCode core:newCore
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12787
    pid := newPid.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12788
    status := newStatus.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12789
    code := newCode.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12790
    core := newCore.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12791
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12792
    "Created: 28.12.1995 / 14:18:22 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12793
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12794
7175
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12795
!UnixOperatingSystem::OSProcessStatus methodsFor:'printing & storing'!
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12796
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12797
printOn:aStream
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12798
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12799
    aStream nextPutAll:'ExitStatus ('.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12800
    status printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12801
    aStream nextPutAll:', code='.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12802
    code printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12803
    aStream nextPut:$).
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12804
! !
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 12805
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12806
!UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12807
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12808
code:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12809
    "set the exitCode"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12810
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12811
    code := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12812
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12813
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12814
    "Modified: 30.4.1996 / 18:25:18 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12815
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12816
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12817
core:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12818
    "set core"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12819
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12820
    core := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12821
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12822
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12823
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12824
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12825
pid:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12826
    "set pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12827
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12828
    pid := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12829
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12830
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12831
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12832
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12833
status:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12834
    "set status"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12835
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12836
    status := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12837
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12838
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12839
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12840
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12841
!UnixOperatingSystem::OSProcessStatus methodsFor:'queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12842
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12843
couldNotExecute
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12844
    "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
 12845
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12846
    ^ status == #exit and:[code = 127].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12847
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12848
    "Created: 28.12.1995 / 15:43:17 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12849
    "Modified: 30.4.1996 / 18:27:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12850
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12851
16410
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 12852
isError
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 12853
    "true if process terminated with error"
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 12854
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 12855
    ^ status == #exit and:[code ~= 0]
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 12856
!
8e2a49eab15c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 16396
diff changeset
 12857
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12858
stillAlive
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12859
    "true if process is still alive"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12860
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12861
    ^ status == #stop or:[status == #continue]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12862
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12863
    "Created: 28.12.1995 / 14:27:26 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12864
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12866
success
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12867
    "true if process terminated successfully"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12868
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12869
    ^ status == #exit and:[code = 0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12870
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12871
    "Created: 28.12.1995 / 14:13:05 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12872
    "Modified: 28.12.1995 / 14:13:41 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12873
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12874
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12875
!UnixOperatingSystem::SocketHandle class methodsFor:'constants'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12876
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12877
protocolCodeOf:aNameOrNumber
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12878
    "convert a symbol to a numeric protocol code"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12879
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12880
    |protocolCode protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12881
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12882
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12883
    if (__isSmallInteger(aNameOrNumber) || aNameOrNumber == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12884
	RETURN(aNameOrNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12885
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12886
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12887
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12888
    ProtocolCache notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12889
	protocolCode := ProtocolCache at:(aNameOrNumber asSymbol) ifAbsent:[].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12890
	protocolCode notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12891
	    ^ protocolCode.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12892
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12893
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12894
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12895
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12896
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12897
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12898
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 12899
    if (__isStringLike(aNameOrNumber)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12900
	protoent = getprotobyname((char *) __stringVal(aNameOrNumber));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12901
	if (protoent) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12902
	    protocolCode = __mkSmallInteger(protoent->p_proto);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12903
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12904
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12905
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12906
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12907
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12908
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12909
    protocolSymbol notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12910
	ProtocolCache isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12911
	    ProtocolCache := IdentityDictionary new.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12912
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12913
	"beware of polluting the protocol cache with aliases"
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12914
	ProtocolCache at:protocolSymbol put:protocolCode.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12915
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12916
    ^ protocolCode
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12917
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12918
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12919
     self protocolCodeOf:#tcp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12920
     self protocolCodeOf:#udp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12921
     self protocolCodeOf:#raw
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12922
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12923
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12924
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12925
protocolSymbolOf:anInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12926
    "convert a numeric protocol code to a symbol"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12927
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12928
    |protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12929
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12930
    ProtocolCache notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12931
	protocolSymbol := ProtocolCache keyAtIdentityValue:anInteger ifAbsent:[].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12932
	protocolSymbol notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12933
	    ^ protocolSymbol.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12934
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12935
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12936
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12937
%{
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12938
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12939
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12940
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12941
    if (__isSmallInteger(anInteger)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12942
	protoent = getprotobynumber(__intVal(anInteger));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12943
	if (protoent) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12944
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12945
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12946
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12947
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12948
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12949
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12950
    protocolSymbol notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12951
	ProtocolCache isNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12952
	    ProtocolCache := IdentityDictionary new.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12953
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12954
	ProtocolCache at:protocolSymbol put:anInteger.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12955
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12956
    ^ protocolSymbol
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12957
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12958
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12959
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12960
     self protocolSymbolOf:(self protocolCodeOf:#tcp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12961
     self protocolSymbolOf:(self protocolCodeOf:#udp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12962
     self protocolSymbolOf:(self protocolCodeOf:#icmp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12963
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12964
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12965
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12966
!UnixOperatingSystem::SocketHandle class methodsFor:'initialization'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12967
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12968
reinitialize
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12969
    "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
 12970
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12971
    ProtocolCache := nil.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12972
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12973
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 12974
!UnixOperatingSystem::SocketHandle class methodsFor:'queries'!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 12975
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12976
getAddressInfo:hostName serviceName:serviceNameArg domain:domainArg type:typeArg protocol:protoArg flags:flags
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12977
    "answer an Array of socket addresses for serviceName on hostName
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12978
     Domain, type, protocol may be nil or specify a hint for the socket
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12979
     addresses to be returned."
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12980
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 12981
    |result domain type proto serviceName encodedHostName|
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12982
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12983
    domain := OperatingSystem domainCodeOf:domainArg.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12984
    type := OperatingSystem socketTypeCodeOf:typeArg.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12985
    proto := self protocolCodeOf:protoArg.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12986
    serviceNameArg notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12987
	serviceName := serviceNameArg printString.      "convert integer port numbers"
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12988
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12989
15795
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 12990
    hostName isNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12991
	encodedHostName := nil.
15795
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 12992
    ] ifFalse:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12993
	encodedHostName := hostName utf8Encoded.
15795
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 12994
    ].
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 12995
    (encodedHostName ~~ hostName and:[OperatingSystem getCodeset ~~ #utf8]) ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12996
	"hostName is not plain ASCII - so this is an IDN domain name. Have to ensure, that the locale is UTF-8.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12997
	 Block interrupt to not affect other ST/X processes while the locale is changed."
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12998
	|interruptsBlocked oldLocale|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 12999
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13000
	interruptsBlocked := OperatingSystem blockInterrupts.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13001
	oldLocale := OperatingSystem setLocale:#'LC_CTYPE' to:nil.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13002
	OperatingSystem setLocale:#'LC_CTYPE' to:'en_US.UTF-8'.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13003
	result := self primGetAddressInfo:encodedHostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13004
	OperatingSystem setLocale:#'LC_CTYPE' to:oldLocale.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13005
	interruptsBlocked ifFalse:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13006
	    OperatingSystem unblockInterrupts.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13007
	].
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13008
    ] ifFalse:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13009
	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
 13010
    ].
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13011
    result isArray ifFalse:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13012
	|request|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13013
	request := SocketAddressInfo new
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13014
	    domain:domainArg;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13015
	    type:typeArg;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13016
	    protocol:protoArg;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13017
	    canonicalName:hostName;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13018
	    serviceName:serviceName.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13019
	^ (HostNameLookupError new
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13020
		parameter:result;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13021
		messageText:' - ', (result printString);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13022
		request:request) raiseRequest.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13023
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13024
    1 to:result size do:[:i |
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13025
	|entry dom info|
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13026
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13027
	entry := result at:i.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13028
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13029
	info := SocketAddressInfo new.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13030
	info
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13031
	    flags:(entry at:1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13032
	    domain:(dom := OperatingSystem domainSymbolOf:(entry at:2));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13033
	    type:(OperatingSystem socketTypeSymbolOf:(entry at:3));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13034
	    protocol:(self protocolSymbolOf:(entry at:4));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13035
	    socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13036
	    canonicalName:(entry at:6).
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13037
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13038
	result at:i put:info.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13039
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13040
    ^ result
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13041
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13042
    "
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13043
     self getAddressInfo:'localhost' serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13044
	    domain:nil type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13045
     self getAddressInfo:'localhost' serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13046
	    domain:#inet type:#stream protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13047
     self getAddressInfo:'localhost' serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13048
	    domain:#inet type:#stream protocol:#tcp flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13049
     self getAddressInfo:'blurb.exept.de' serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13050
	    domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13051
     self getAddressInfo:'1.2.3.4' serviceName:'bla'
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13052
	    domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13053
     self getAddressInfo:'localhost' serviceName:'echo'
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13054
	    domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13055
     self getAddressInfo:nil serviceName:'echo'
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13056
	    domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13057
     self getAddressInfo:nil serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13058
	    domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13059
     self getAddressInfo:'www.google.de' serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13060
	    domain:nil type:nil protocol:nil flags:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 13061
     self getAddressInfo:'www.exept.de' serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13062
	    domain:nil type:nil protocol:nil flags:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 13063
     self getAddressInfo:'www.exept.de' serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13064
	    domain:#'AF_INET' type:nil protocol:nil flags:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 13065
     self getAddressInfo:'www.exept.de' serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13066
	    domain:#'AF_INET6' type:nil protocol:nil flags:nil
17681
8894d153e26a class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17637
diff changeset
 13067
     self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13068
	    domain:#'AF_INET' type:#stream protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13069
    "
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13070
!
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13071
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13072
getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13073
    "answer an Array containing the hostName and serviceName
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13074
     in socketAddress.
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13075
     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
 13076
     this returns multiple hostnames (if appropriate)"
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13077
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13078
    |error errorString hostName serviceName|
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13079
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 13080
%{ /* 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
 13081
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13082
#undef xxNI_NUMERICHOST /* remove xx to test gethost...() path */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13083
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13084
#if !defined(NO_SOCKET)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13085
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13086
# ifndef NI_MAXHOST
8788
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 13087
#  define NI_MAXHOST 1025
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13088
#  define NI_MAXSERV 64
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13089
# endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13090
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13091
    char host[NI_MAXHOST];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13092
    char service[NI_MAXSERV];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13093
    char *hp = 0, *sp = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13094
    int hsz = 0, ssz = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13095
    int ret, __flags;
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13096
    char *bp;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13097
    int nInstBytes, sockAddrSize;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13098
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13099
    if (wantHostName == true) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13100
	hp = host;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13101
	hsz = sizeof(host);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13102
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13103
    if (wantServiceName == true) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13104
	sp = service;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13105
	ssz = sizeof(service);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13106
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13107
    if (hp == 0 && sp == 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13108
	error = @symbol(badArgument);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13109
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13110
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13111
    if (!__isBytes(socketAddress)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13112
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13113
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13114
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13115
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13116
    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13117
    sockAddrSize = __byteArraySize(socketAddress);
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13118
    sockAddrSize -= nInstBytes;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13119
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13120
    if (!__isSmallInteger(flags)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13121
	error = @symbol(badArgument5);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13122
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13123
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13124
    __flags = __intVal(flags);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13125
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13126
#if defined(NI_NUMERICHOST)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13127
    if (useDatagram == true) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13128
	__flags |= NI_DGRAM;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13129
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13130
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13131
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13132
	bp = (char *)(__byteArrayVal(socketAddress));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13133
	bp += nInstBytes;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13134
	__BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13135
	ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13136
			  hp, hsz, sp, ssz, __flags);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13137
	__END_INTERRUPTABLE__
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13138
    } while (ret == EAI_SYSTEM && errno == EINTR);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13139
    if (ret != 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13140
	switch (ret) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13141
	case EAI_FAMILY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13142
	    error = @symbol(badProtocol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13143
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13144
	case EAI_SOCKTYPE:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13145
	    error = @symbol(badSocketType);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13146
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13147
	case EAI_BADFLAGS:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13148
	    error = @symbol(badFlags);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13149
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13150
	case EAI_NONAME:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13151
	    error = @symbol(unknownHost);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13152
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13153
	case EAI_SERVICE:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13154
	    error = @symbol(unknownService);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13155
	    break;
11626
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 13156
#ifdef EAI_ADDRFAMILY
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13157
	case EAI_ADDRFAMILY :
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13158
	    error = @symbol(unknownHostForProtocol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13159
	    break;
11626
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 13160
#endif
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 13161
#ifdef EAI_NODATA
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13162
	case EAI_NODATA:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13163
	    error = @symbol(noAddress);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13164
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13165
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13166
	case EAI_MEMORY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13167
	    error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13168
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13169
	case EAI_FAIL:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13170
	    error = @symbol(permanentFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13171
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13172
	case EAI_AGAIN:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13173
	    error = @symbol(tryAgain);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13174
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13175
	case EAI_SYSTEM:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13176
	    error = @symbol(systemError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13177
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13178
	default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13179
	    error = @symbol(unknownError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13180
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13181
	errorString = __MKSTRING(gai_strerror(ret));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13182
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13183
    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13184
# else /* ! NI_NUMERICHOST */
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13185
    {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13186
	/*
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13187
	 * Do it using gethostbyaddr()
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13188
	 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13189
	struct sockaddr_in *sa;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13190
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13191
	if (sockAddrSize < sizeof(*sa)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13192
	    error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13193
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13194
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13195
	bp = (char *)(__byteArrayVal(socketAddress));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13196
	bp += nInstBytes;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13197
	sa = (struct sockaddr_in *)bp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13198
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13199
	if (sp) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13200
	    struct servent *servp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13201
	    char *__proto = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13202
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13203
	    __proto = (useDatagram == true ? "udp" : "tcp");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13204
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13205
	    servp = getservbyport(sa->sin_port, __proto);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13206
	    if (servp) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13207
		sp = servp->s_name;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13208
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13209
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13210
	if (hp) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13211
	    struct hostent *hostp;
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13212
#  ifdef USE_H_ERRNO
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13213
	    do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13214
		bp = (char *)(__byteArrayVal(socketAddress));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13215
		bp += nInstBytes;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13216
		sa = (struct sockaddr_in *)bp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13217
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13218
		/* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13219
		 */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13220
		hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13221
		/* __END_INTERRUPTABLE__ */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13222
	    } while ((hostp == NULL)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13223
		      && ((h_errno == TRY_AGAIN)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13224
			  || errno == EINTR
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13225
#   ifdef IRIX5_3
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13226
			  || (errno == ECONNREFUSED)
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13227
#   endif
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13228
			 )
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13229
	    );
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13230
	    if (hostp == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13231
		switch (h_errno) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13232
		case HOST_NOT_FOUND:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13233
		    errorString = @symbol(unknownHost);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13234
		    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13235
		case NO_ADDRESS:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13236
		    errorString = @symbol(noAddress);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13237
		    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13238
		case NO_RECOVERY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13239
		    errorString = @symbol(permanentFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13240
		    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13241
		case TRY_AGAIN:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13242
		    errorString = @symbol(tryAgain);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13243
		    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13244
		default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13245
		    errorString = @symbol(unknownError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13246
		    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13247
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13248
		error = __mkSmallInteger(h_errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13249
		goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13250
	    }
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 13251
#  else /* !USE_H_ERRNO */
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13252
	    hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13253
	    if (hostp == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13254
		errorString = @symbol(unknownHost);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13255
		error = __mkSmallInteger(-1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13256
		goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13257
	    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13258
#  endif /* !USE_H_ERRNO*/
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13259
	    hp = hostp->h_name;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13260
	}
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13261
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13262
# endif /* ! NI_NUMERICHOST */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13263
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13264
    if (hp)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13265
	hostName = __MKSTRING(hp);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13266
    if (sp)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13267
	serviceName = __MKSTRING(sp);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13268
err:;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13269
#else
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13270
    error = @symbol(notImplemented);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13271
#endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13272
%}.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13273
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13274
	^ (HostAddressLookupError new
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13275
		parameter:error;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13276
		messageText:' - ', errorString;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13277
		request:thisContext message) raiseRequest.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13278
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13279
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13280
    ^ Array with:hostName with:serviceName
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13281
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13282
    "
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13283
     self getNameInfo:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13284
	(self getAddressInfo:'localhost' serviceName:'echo'
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13285
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13286
	 wantHostName:true wantServiceName:true datagram:false flags:0
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13287
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 13288
     self getNameInfo:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13289
	(self getAddressInfo:'exept.de' serviceName:'echo'
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13290
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13291
	 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
 13292
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 13293
     self getNameInfo:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13294
	(self getAddressInfo:'217.172.183.25' serviceName:'22'
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13295
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13296
	 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
 13297
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 13298
     self getNameInfo:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13299
	(self getAddressInfo:'1.2.3.4' serviceName:'22'
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13300
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13301
	 wantHostName:true wantServiceName:true datagram:false flags:0
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13302
    "
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13303
!
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13304
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13305
primGetAddressInfo:hostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13306
    "answer an Array of socket addresses for serviceName on hostName
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13307
     Domain, type, protocol may be nil or specify a hint for the socket
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13308
     addresses to be returned."
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13309
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13310
    |error errorString result|
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13311
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13312
%{ /* UNLIMITEDSTACK */  /* Don't know whether DNS, NIS, LDAP or whatever is consulted */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13313
#undef xxAI_NUMERICHOST /* remove xx to test gethost...() path */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13314
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13315
#if !defined(NO_SOCKET)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13316
    char *__hostName, *__serviceName;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13317
    int ret, cnt = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13318
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13319
    if (hostName == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13320
	__hostName = 0;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13321
    } else if (__isStringLike(hostName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13322
	__hostName = __stringVal(hostName);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13323
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13324
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13325
	goto out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13326
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13327
    if (serviceName == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13328
	__serviceName = 0;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13329
    } else if (__isStringLike(serviceName)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13330
	__serviceName = __stringVal(serviceName);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13331
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13332
	error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13333
	goto out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13334
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13335
    if (__hostName == 0 && __serviceName == 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13336
	error = @symbol(badArgument);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13337
	goto out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13338
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13339
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13340
{
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13341
# if defined(AI_NUMERICHOST)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13342
    /*
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13343
     * Use getaddrinfo()
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13344
     */
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13345
    struct addrinfo hints = {0};
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13346
    struct addrinfo *info = NULL, *infop;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13347
15798
2f79f67ae7b7 has no A_IDN
Claus Gittinger <cg@exept.de>
parents: 15795
diff changeset
 13348
#if defined(AI_IDN)
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13349
    hints.ai_flags = AI_IDN | AI_CANONIDN;      // map non-ascii domain names to IDN format
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13350
#endif
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13351
    if (__isSmallInteger(domain))
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13352
	hints.ai_family = __intVal(domain);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13353
    if (__isSmallInteger(type))
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13354
	hints.ai_socktype = __intVal(type);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13355
    if (__isSmallInteger(proto))
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13356
	hints.ai_protocol = __intVal(proto);
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 13357
    if (__isSmallInteger(flags))
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13358
	hints.ai_flags |= __intVal(flags);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13359
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13360
    do {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13361
	/* reload */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13362
	if (__hostName) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13363
	    __hostName = __stringVal(hostName);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13364
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13365
	if (__serviceName) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13366
	    __serviceName = __stringVal(serviceName);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13367
	}
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13368
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13369
//        __BEGIN_INTERRUPTABLE__
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13370
	ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13371
//        __END_INTERRUPTABLE__
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13372
    } while (ret == EAI_SYSTEM && errno == EINTR);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13373
    if (ret != 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13374
	switch (ret) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13375
	case EAI_FAMILY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13376
	    error = @symbol(badProtocol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13377
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13378
	case EAI_SOCKTYPE:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13379
	    error = @symbol(badSocketType);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13380
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13381
	case EAI_BADFLAGS:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13382
	    error = @symbol(badFlags);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13383
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13384
	case EAI_NONAME:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13385
	    error = @symbol(unknownHost);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13386
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13387
	case EAI_SERVICE:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13388
	    error = @symbol(unknownService);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13389
	    break;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13390
#ifdef EAI_ADDRFAMILY
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13391
	case EAI_ADDRFAMILY :
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13392
	    error = @symbol(unknownHostForProtocol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13393
	    break;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13394
#endif
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13395
#ifdef EAI_NODATA
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13396
	case EAI_NODATA:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13397
	    error = @symbol(noAddress);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13398
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13399
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13400
	case EAI_MEMORY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13401
	    error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13402
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13403
	case EAI_FAIL:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13404
	    error = @symbol(permanentFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13405
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13406
	case EAI_AGAIN:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13407
	    error = @symbol(tryAgain);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13408
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13409
	case EAI_SYSTEM:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13410
	    error = @symbol(systemError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13411
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13412
	default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13413
	    error = @symbol(unknownError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13414
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13415
	errorString = __MKSTRING(gai_strerror(ret));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13416
	goto err;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13417
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13418
    for (cnt=0, infop=info; infop; infop=infop->ai_next)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13419
	cnt++;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13420
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13421
    result = __ARRAY_NEW_INT(cnt);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13422
    if (result == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13423
	error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13424
	goto err;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13425
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13426
    for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13427
	OBJ o, resp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13428
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13429
	resp = __ARRAY_NEW_INT(6);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13430
	if (resp == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13431
	    error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13432
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13433
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13434
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13435
	__ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13436
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13437
	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13438
	__ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13439
	__ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13440
	__ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13441
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13442
	__PROTECT__(resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13443
	o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13444
	__UNPROTECT__(resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13445
	if (o == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13446
	    error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13447
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13448
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13449
	memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13450
       __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13451
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13452
	if (infop->ai_canonname) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13453
	    __PROTECT__(resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13454
	    o = __MKSTRING(infop->ai_canonname);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13455
	    __UNPROTECT__(resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13456
	    if (o == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13457
		error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13458
		goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13459
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13460
	    __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13461
	}
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13462
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13463
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13464
err:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13465
    if (info) freeaddrinfo(info);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13466
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13467
# else /* ! AI_NUMERICHOST =============================================================*/
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13468
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13469
    /*
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13470
     * Use getservbyname() / gethostByName()
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13471
     */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13472
    struct hostent *hp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13473
    char **addrpp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13474
    int port = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13475
    int i;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13476
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13477
    if (__serviceName) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13478
	struct servent *sp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13479
	char *__proto = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13480
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13481
	if (__isStringLike(protoArg))
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13482
	    __proto = __stringVal(protoArg);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13483
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13484
	sp = getservbyname(__serviceName, __proto);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13485
	if (sp == NULL) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13486
	    errorString = @symbol(unknownService);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13487
	    error = __mkSmallInteger(-3);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13488
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13489
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13490
	port = sp->s_port;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13491
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13492
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13493
    if (__hostName) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13494
#  ifdef USE_H_ERRNO
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13495
	do {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13496
	    if (hostName == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13497
		__hostName = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13498
	    } else if (__isStringLike(hostName)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13499
		__hostName = __stringVal(hostName);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13500
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13501
	    /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13502
	     * uses a static data area
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13503
	     */
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13504
	    __BEGIN_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13505
	    hp = gethostbyname(__hostName);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13506
	    __END_INTERRUPTABLE__
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13507
	} while ((hp == NULL)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13508
		  && (
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13509
			(h_errno == TRY_AGAIN)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13510
		      || errno == EINTR
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13511
#   ifdef IRIX5_3
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13512
		      || (errno == ECONNREFUSED)
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13513
#   endif
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13514
		     )
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13515
	);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13516
	if (hp == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13517
	    switch (h_errno) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13518
	    case HOST_NOT_FOUND:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13519
		errorString = @symbol(unknownHost);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13520
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13521
	    case NO_ADDRESS:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13522
		errorString = @symbol(noAddress);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13523
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13524
	    case NO_RECOVERY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13525
		errorString = @symbol(permanentFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13526
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13527
	    case TRY_AGAIN:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13528
		errorString = @symbol(tryAgain);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13529
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13530
	    default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13531
		errorString = @symbol(unknownError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13532
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13533
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13534
	    error = __mkSmallInteger(h_errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13535
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13536
	}
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13537
#  else /* !USE_H_ERRNO */
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13538
	hp = gethostbyname(__hostName);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13539
	if (hp == 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13540
	    errorString = @symbol(unknownHost);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13541
	    error = __mkSmallInteger(-1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13542
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13543
	}
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13544
#  endif /* !USE_H_ERRNO*/
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13545
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13546
	if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13547
	    errorString = @symbol(unknownHost);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13548
	    error = __mkSmallInteger(-2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13549
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13550
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13551
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13552
	for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13553
	    cnt++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13554
	addrpp = hp->h_addr_list;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13555
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13556
	cnt = 1;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13557
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13558
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13559
    result = __ARRAY_NEW_INT(cnt);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13560
    if (result == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13561
	error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13562
	goto err;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13563
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13564
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13565
    for (i = 0; i < cnt; i++) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13566
	OBJ o, resp;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13567
	struct sockaddr_in *sa;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13568
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13569
	resp = __ARRAY_NEW_INT(6);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13570
	if (resp == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13571
	    error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13572
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13573
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13574
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13575
	__ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13576
	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13577
	__ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13578
	__ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13579
	__PROTECT__(resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13580
	o = __BYTEARRAY_NEW_INT(sizeof(*sa));
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13581
	__UNPROTECT__(resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13582
	if (o == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13583
	    error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13584
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13585
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13586
	__ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13587
	sa = (struct sockaddr_in *)__byteArrayVal(o);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13588
	sa->sin_port = port;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13589
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13590
	if (__hostName) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13591
	    sa->sin_family = hp->h_addrtype;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13592
	    memcpy(&sa->sin_addr, *addrpp, hp->h_length);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13593
	    __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13594
	    if (hp->h_name) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13595
		__PROTECT__(resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13596
		o = __MKSTRING(hp->h_name);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13597
		__UNPROTECT__(resp);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13598
		if (o == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13599
		    error = @symbol(allocationFailure);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13600
		    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13601
		}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13602
		__ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13603
	    }
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13604
	    addrpp++;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13605
	} else{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13606
	    __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13607
	}
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13608
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13609
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13610
err:;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13611
# endif /* ! AI_NUMERICHOST */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13612
}
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13613
#else /* ! HAS_SOCKET */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13614
    error = @symbol(notImplemented);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13615
#endif
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 13616
out:;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13617
%}.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13618
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13619
	errorString notNil ifTrue:[
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13620
	    ^ errorString.
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13621
	].
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13622
	^ error.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13623
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 13624
    ^ result.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13625
! !
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 13626
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13627
!UnixOperatingSystem::SocketHandle methodsFor:'accepting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13628
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13629
acceptWithPeerAddressBuffer:peerOrNil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13630
    "accept a connection on a server port.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13631
     Returns a new SocketHandle or nil if the operation
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13632
     would block.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13633
     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
 13634
     of the connection peer is stored into it."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13635
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13636
    |error newFd|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13637
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13638
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 13639
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13640
    int sock, newSock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13641
    struct sockaddr *sap;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13642
    int alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13643
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13644
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13645
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13646
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13647
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13648
    if (peerOrNil != nil &&
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13649
	(!__isNonNilObject(peerOrNil) ||
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13650
	 (__intVal(__ClassInstPtr(__qClass(peerOrNil))->c_flags) & ARRAYMASK) != BYTEARRAY)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13651
	error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13652
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13653
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13654
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13655
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13656
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13657
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13658
    if (peerOrNil == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13659
	alen = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13660
	sap = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13661
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13662
	alen =  __byteArraySize(peerOrNil);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13663
	sap = (struct sockaddr *)__byteArrayVal(peerOrNil);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13664
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13665
    newSock = accept(sock, sap, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13666
    if (newSock < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13667
	switch (errno) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13668
	case EINTR:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13669
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13670
	    goto again;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13671
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13672
#ifdef EWOULDBLOCK
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13673
	case EWOULDBLOCK:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13674
# if defined(EAGAIN) && (EAGAIN != EWOULDBLOCK)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13675
	case EAGAIN:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13676
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13677
#else
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13678
# ifdef EAGAIN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13679
	case EAGAIN:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13680
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13681
#endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13682
	    RETURN(nil);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13683
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13684
	default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13685
	    error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13686
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13687
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13688
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13689
    newFd = __mkSmallInteger(newSock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13690
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13691
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13692
#endif /* not NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13693
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13694
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13695
	^ self error:error.
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13696
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13697
    ^ self class for:newFd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13698
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13699
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13700
!UnixOperatingSystem::SocketHandle methodsFor:'binding'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13701
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13702
bindTo:socketAddress
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13703
    "low level bind -
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13704
     Set the local address of the socket"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13705
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13706
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13707
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13708
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 13709
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13710
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13711
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13712
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13713
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13714
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13715
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13716
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13717
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13718
    if (!__isNonNilObject(socketAddress) ||
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13719
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13720
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13721
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13722
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13723
    sockaddr_size = __byteArraySize(socketAddress);
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
 13724
    sock = __smallIntegerVal(__INST(fd));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13725
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13726
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13727
    ret = bind(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13728
    if (ret < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13729
	if (errno == EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13730
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13731
	    goto again;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13732
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13733
	    error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13734
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13735
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13736
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13737
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13738
    err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13739
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13740
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13741
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13742
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13743
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13744
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13745
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13746
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13747
     (Socket domain:#inet type:#stream)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13748
	 bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13749
	 reuseAddress:false ;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13750
     yourself
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13751
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13752
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13753
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13754
!UnixOperatingSystem::SocketHandle methodsFor:'connecting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13755
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13756
cancelConnect
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13757
    "cancel an asynchronous connect in progress"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13758
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13759
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13760
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13761
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 13762
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13763
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13764
    int ret;
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 13765
    struct sockaddr sockaddr;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13766
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13767
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13768
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13769
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13770
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13771
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13772
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13773
    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13774
     * (dis-) connect by connecting to AF_UNSPEC socket
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13775
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13776
again:
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 13777
    sockaddr.sa_family = AF_UNSPEC;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13778
    ret = connect(sock, &sockaddr, sizeof(sockaddr));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13779
    if (ret < 0) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13780
       switch(errno) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13781
	   case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13782
# ifdef EAGAIN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13783
	    case EAGAIN:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13784
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13785
		__HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13786
		goto again;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13787
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13788
	    default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13789
		error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13790
		break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13791
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13792
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13793
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13794
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13795
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13796
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13797
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13798
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13799
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13800
    ].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13801
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13802
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13803
connectTo:socketAddress
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13804
    "low level connect; connect to a socket address.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13805
     Return true if connection has been established,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13806
     false, when the connection has been initiated but not yet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13807
     completed. If an error occured, an OSError is raised"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13808
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13809
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13810
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13811
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 13812
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13813
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13814
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13815
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13816
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13817
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13818
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13819
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13820
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13821
    if (!__isNonNilObject(socketAddress) ||
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13822
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13823
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13824
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13825
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13826
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13827
    sockaddr_size = __qSize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13828
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13829
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13830
    ret = connect(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13831
    if (ret >= 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13832
	RETURN(true)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13833
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13834
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13835
    switch(errno) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13836
	case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13837
# ifdef EAGAIN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13838
	case EAGAIN:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13839
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13840
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13841
	    goto again;
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13842
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13843
# if defined(EINPROGRESS) || defined(EALREADY)
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13844
#  ifdef EINPROGRESS
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13845
	case EINPROGRESS:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13846
#  endif
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13847
#  ifdef EALREADY
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13848
	case EALREADY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13849
#  endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13850
	    RETURN(false);
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 13851
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13852
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13853
    default:
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13854
	error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13855
	break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13856
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13857
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13858
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13859
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13860
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13861
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13862
	 ^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13863
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13864
    ^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13865
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13866
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13867
     Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:7)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13868
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13869
     Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:5768)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13870
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13871
     Socket newTCP connectTo:(IPSocketAddress hostAddress:#[1 2 3 4] port:7)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13872
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13873
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13874
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13875
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13876
!UnixOperatingSystem::SocketHandle methodsFor:'datagram transmission'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13877
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13878
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
 13879
    "receive datagramm data - put address of originating host into
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13880
     anAddressBuffer, data into aBuffer. For ST-80 compatibility,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13881
     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
 13882
     the addressBytes-message (i.e. be a SocketAddress instance).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13883
     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
 13884
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13885
     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
 13886
     receiving, using #readWait or #readWaitWithTimeout:."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13887
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13888
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13889
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13890
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 13891
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13892
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13893
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13894
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13895
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13896
    int alen0, alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13897
    int n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13898
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13899
    int __flags, __startIndex, __nBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13900
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13901
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13902
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13903
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13904
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13905
    if (!__isSmallInteger(startIndex) ||
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13906
	(__startIndex = __intVal(startIndex)-1) < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13907
	if (startIndex == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13908
	    __startIndex = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13909
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13910
	    error = @symbol(badArgument3);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13911
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13912
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13913
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13914
    if (__isSmallInteger(nBytes)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13915
	__nBytes = __intVal(nBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13916
    } else if (nBytes == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13917
	__nBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13918
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13919
	error = @symbol(badArgument4);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13920
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13921
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13922
    if (!__isInteger(flags)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13923
	error = @symbol(badArgument5);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13924
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13925
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13926
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13927
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13928
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13929
    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
 13930
    switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13931
	case BYTEARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13932
	case WORDARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13933
	case SWORDARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13934
	case LONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13935
	case SLONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13936
	case FLOATARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13937
	case DOUBLEARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13938
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13939
	default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13940
	    error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13941
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13942
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13943
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 13944
    nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13945
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13946
    objSize = __qSize(aDataBuffer) - nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13947
    nInstBytes += __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13948
    objSize -= __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13949
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13950
    if (__nBytes >= 0 &&__nBytes < objSize) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13951
	objSize = __nBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13952
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13953
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13954
    if (socketAddress == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13955
	alen0 = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13956
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13957
	if (!__isNonNilObject(socketAddress) ||
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13958
	    (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13959
	    error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13960
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13961
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13962
	alen0 = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13963
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13964
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13965
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13966
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13967
    alen = alen0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13968
    if (alen)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13969
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13970
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13971
    n = recvfrom(sock, cp, objSize, __flags, saPtr, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13972
    if (n < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13973
	if (errno == EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13974
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13975
	    goto again;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13976
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13977
	    error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13978
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 13979
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13980
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13981
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13982
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13983
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13984
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13985
    ^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13986
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13987
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13988
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
 13989
    "send datagramm data - fetch address of destination host from
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13990
     anAddressBuffer, data from aDataBuffer starting at startIndex,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13991
     sending count bytes.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13992
     SocketAddress must be an instance of SocketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13993
     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
 13994
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13995
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13996
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13997
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 13998
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13999
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14000
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14001
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14002
    int alen, n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14003
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14004
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14005
    int __flags;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14006
    int offs, __startIndex, __maxBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14007
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14008
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14009
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14010
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14011
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14012
    if (!__isSmallInteger(startIndex) ||
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14013
	(__startIndex = __intVal(startIndex)-1) < 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14014
	if (startIndex == nil) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14015
	    __startIndex = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14016
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14017
	    error = @symbol(badArgument3);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14018
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14019
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14020
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14021
    if (__isSmallInteger(maxBytes)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14022
	__maxBytes = __intVal(maxBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14023
    } else if (maxBytes == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14024
	__maxBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14025
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14026
	error = @symbol(badArgument4);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14027
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14028
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14029
    if (!__isInteger(flags)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14030
	error = @symbol(badArgument5);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14031
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14032
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14033
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14034
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14035
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14036
    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
 14037
    switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14038
	case BYTEARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14039
	    offs = __startIndex;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14040
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14041
	case WORDARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14042
	case SWORDARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14043
	    offs = __startIndex * 2;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14044
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14045
	case LONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14046
	case SLONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14047
	    offs = __startIndex * 4;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14048
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14049
	case LONGLONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14050
	case SLONGLONGARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14051
	    offs = __startIndex * 8;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14052
# ifdef __NEED_LONGLONG_ALIGN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14053
	    offs += 4;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14054
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14055
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14056
	case FLOATARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14057
	    offs = __startIndex * sizeof(float);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14058
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14059
	case DOUBLEARRAY:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14060
	    offs = __startIndex * sizeof(double);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14061
# ifdef __NEED_DOUBLE_ALIGN
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14062
	    offs += 4;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14063
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14064
	    break;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14065
	default:
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14066
	    error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14067
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14068
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14069
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 14070
    nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14071
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14072
    objSize = __qSize(aDataBuffer) - nInstBytes - offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14073
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14074
    if (__maxBytes >= 0 && __maxBytes < objSize) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14075
# ifdef DGRAM_DEBUG
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14076
	printf("cut off ...\n");
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14077
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14078
	objSize = __maxBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14079
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14080
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14081
    if (socketAddress == nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14082
	alen = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14083
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14084
	if (! __isByteArrayLike(socketAddress)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14085
	    error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14086
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14087
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14088
	alen = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14089
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14090
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14091
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14092
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14093
    if (alen)
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14094
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14095
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes + offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14096
    n = sendto(sock, cp, objSize, __flags, saPtr, alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14097
    if (n < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14098
	if (errno == EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14099
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14100
	    goto again;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14101
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14102
	    error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14103
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14104
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14105
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14106
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14107
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14108
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14109
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14110
    ^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14111
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14112
6434
f23d12900e18 category rename
Claus Gittinger <cg@exept.de>
parents: 6421
diff changeset
 14113
!UnixOperatingSystem::SocketHandle methodsFor:'initialization'!
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14114
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14115
domain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14116
    "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
 14117
     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
 14118
     All arguments must be symbols from one of
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14119
     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
 14120
     type: #SOCK_STREAM, #SOCK_DGRAM (#stream, #datagram, #raw) ..
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14121
     protocol: #tcp, #udp, #raw ..
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14122
    "
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14123
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14124
    |error domainCode typeCode protocolNumber|
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14125
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14126
    domainCode := OperatingSystem domainCodeOf:domainArg.
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14127
    typeCode := OperatingSystem socketTypeCodeOf:typeArg.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14128
    protocolArg notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14129
	protocolNumber := self class protocolCodeOf:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14130
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14131
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14132
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14133
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14134
    int dom, typ, proto = 0, sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14135
    int on = 1;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14136
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14137
    if (__INST(fd) != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14138
	error = @symbol(internalError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14139
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14140
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14141
    if (! __isSmallInteger(domainCode)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14142
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14143
	goto err;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14144
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14145
    if (! __isSmallInteger(typeArg)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14146
	error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14147
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14148
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14149
    if (protocolNumber != nil) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14150
	if (!__isSmallInteger(protocolNumber)) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14151
	    error = @symbol(badArgument3);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14152
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14153
	}
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14154
	proto = __smallIntegerVal(protocolNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14155
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14156
    dom = __smallIntegerVal(domainCode);
6350
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
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14159
     * get socket-type and protocol-type
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14160
     */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14161
    typ = __intVal(typeArg);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14162
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14163
againSocket:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14164
    sock = socket(dom, typ, proto);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14165
    if (sock < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14166
	if (errno == EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14167
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14168
	    goto againSocket;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14169
	} else
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14170
# if defined(EPROTONOSUPPORT) /* for SGI */
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14171
	if (errno == EPROTONOSUPPORT && proto != 0) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14172
	    proto = 0;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14173
	    goto againSocket;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14174
	} else
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14175
# endif
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14176
	{
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14177
	    error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14178
	    goto err;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14179
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14180
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14181
    __INST(fd) = __mkSmallInteger(sock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14182
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14183
err:;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14184
# else /* NOSOCKET */
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14185
    error = @symbol(notImplemented);
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 14186
# endif /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14187
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14188
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14189
	^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14190
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14191
    self register.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14192
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14193
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14194
     self new domain:#inet type:#stream protocol:nil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14195
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14196
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14197
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14198
!UnixOperatingSystem::SocketHandle methodsFor:'misc'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14199
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14200
getOptionsLevel:level name:name
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14201
    "answer a ByteArray containing the socket option value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14202
     named name at level"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14203
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14204
    |error bytes size|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14205
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14206
    bytes := ByteArray new:256.
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
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14209
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14210
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14211
    int intval, sz;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14212
    char *p;
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
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14215
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14216
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14217
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14218
    if (!__bothSmallInteger(level, name)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14219
	error = @symbol(badArgument);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14220
	goto err;
6350
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
    if (!__isByteArray(bytes)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14223
	error = @symbol(internalError);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14224
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14225
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14226
    p = __byteArrayVal(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14227
    sz = __byteArraySize(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14228
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14229
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14230
    if (getsockopt(sock, __smallIntegerVal(level), __smallIntegerVal(name), p, &sz) < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14231
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14232
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14233
    size = __mkSmallInteger(sz);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14234
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14235
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14236
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14237
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14238
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14239
	^ self error:error
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14240
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14241
    ^ bytes copyTo:size
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14242
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14243
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14244
listenFor:aNumber
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14245
    "start listening.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14246
     aNumber is the number of connect indications queues
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14247
     by the operating system"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14248
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14249
    |error|
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
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14252
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14253
    int sock, ret;
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
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14256
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14257
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14258
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14259
    if (!__isSmallInteger(aNumber)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14260
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14261
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14262
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14263
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14264
    sock = __smallIntegerVal(__INST(fd));
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
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14267
    ret = listen(sock, __smallIntegerVal(aNumber));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14268
    if (ret < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14269
	if (errno == EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14270
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14271
	    goto again;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14272
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14273
	    error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14274
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14275
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14276
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14277
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14278
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14279
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14280
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14281
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14282
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14283
    ^ nil
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
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14286
setOptionsLevel:level name:name value:value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14287
    "set the socket option name at level to value.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14288
     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
 14289
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14290
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14291
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14292
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14293
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14294
    int sock;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14295
    int __level, __name, intval, sz;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14296
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14297
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14298
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14299
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14300
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14301
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14302
    if (__isSmallInteger(level)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14303
	__level = __smallIntegerVal(level);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14304
    } else if (level == @symbol(SOL_SOCKET)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14305
	__level = SOL_SOCKET;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14306
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14307
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14308
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14309
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14310
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14311
    if (__isSmallInteger(name)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14312
	__name = __smallIntegerVal(name);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14313
    } else if (name == @symbol(SO_REUSEADDR)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14314
	__name = SO_REUSEADDR;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14315
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14316
	error = @symbol(badArgument2);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14317
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14318
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14319
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14320
    if (__isSmallInteger(value)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14321
	intval = __intVal(value);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14322
	p = (char *) &intval;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14323
	sz = sizeof(intval);
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 14324
    } else if (__isByteArrayLike(value)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14325
	p = __byteArrayVal(value);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14326
	sz = __byteArraySize(value);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14327
    } else {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14328
	error = @symbol(badArgument3);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14329
	goto err;
6350
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14332
    sock = __smallIntegerVal(__INST(fd));
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14333
    if (setsockopt(sock, __level, __name, p, sz) < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14334
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14335
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14336
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14337
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14338
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14339
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14340
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14341
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14342
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14343
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14344
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14345
shutdown:anInteger
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14346
    "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
 14347
     anInteger == 0   no reads will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14348
     anInteger == 1   no writes will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14349
     anInteger == 2   neither reads nor writes will be performed.
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14350
		      Pending data is discarded. This is faster tha
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14351
		      close, which may wait until pending (written)
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14352
		      data has been read by the other side"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14353
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14354
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14355
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14356
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14357
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14358
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14359
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14360
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14361
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14362
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14363
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14364
    if (!__isSmallInteger(anInteger)) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14365
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14366
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14367
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14368
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14369
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14370
    ret = shutdown(__smallIntegerVal(__INST(fd)), __smallIntegerVal(anInteger));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14371
    if (ret < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14372
	if (errno == EINTR) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14373
	    __HANDLE_INTERRUPTS__;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14374
	    goto again;
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14375
	} else {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14376
	    error = __mkSmallInteger(errno);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14377
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14378
    }
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
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14381
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14382
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14383
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14384
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14385
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14386
    ^ 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
!UnixOperatingSystem::SocketHandle methodsFor:'queries'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14390
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14391
getNameInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14392
    "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
 14393
     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
 14394
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14395
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14396
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14397
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14398
#if 0 && !defined(NO_SOCKET)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14399
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14400
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14401
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14402
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14403
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14404
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14405
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14406
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14407
    if (!__isNonNilObject(socketAddress) ||
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14408
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14409
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14410
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14411
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14412
    sockaddr_size = __byteArraySize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14413
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14414
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14415
    ret = getsockname(sock, (struct sockaddr *)__byteArrayVal(socketAddress), &sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14416
    if (ret < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14417
	error = __mkSmallInteger(errno);
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
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14420
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14421
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14422
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14423
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14424
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14425
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14426
!
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
getPeerInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14429
    "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
 14430
     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
 14431
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14432
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14433
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14434
%{
16391
d372cd62ccc0 Fix prev version
Stefan Vogel <sv@exept.de>
parents: 16390
diff changeset
 14435
#if 0 && !defined(NO_SOCKET)
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14436
    int __sock;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14437
    int __sockaddr_size;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14438
    int __ret;
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
    if (!__isSmallInteger(__INST(fd))) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14441
	error = @symbol(badFd);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14442
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14443
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14444
    if (!__isNonNilObject(socketAddress) ||
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14445
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14446
	error = @symbol(badArgument1);
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14447
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14448
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14449
    __sockaddr_size = __byteArraySize(socketAddress);
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14450
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14451
    __sock = __smallIntegerVal(__INST(fd));
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 14452
    __ret = getpeername(__sock, (struct sockaddr *)__byteArrayVal(socketAddress),
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14453
				&__sockaddr_size);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14454
    if (__ret < 0) {
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14455
	error = __mkSmallInteger(errno);
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
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14458
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14459
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14460
    error notNil ifTrue:[
17596
082b7d32692a typo in comment
Claus Gittinger <cg@exept.de>
parents: 17579
diff changeset
 14461
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14462
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 14463
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14464
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 14465
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14466
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14467
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14468
version
18415
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 14469
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.442 2015-05-28 12:55:12 cg Exp $'
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 14470
!
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 14471
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 14472
version_CVS
18415
234794128574 added microsecondSleep:
Claus Gittinger <cg@exept.de>
parents: 18399
diff changeset
 14473
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.442 2015-05-28 12:55:12 cg Exp $'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14474
! !
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 14475
14598
94f635641b30 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14591
diff changeset
 14476
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 14477
UnixOperatingSystem initialize!
17631
0441ae93a3e4 Added #getObjectFileInfoFor:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17596
diff changeset
 14478
UnixOperatingSystem::ELFConstants initialize!
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 14479
UnixOperatingSystem::FileDescriptorHandle initialize!