--- a/UnixOperatingSystem.st Tue Jul 01 13:08:18 2003 +0200
+++ b/UnixOperatingSystem.st Tue Jul 01 13:15:10 2003 +0200
@@ -1092,43 +1092,43 @@
*/
union sockaddr_u {
#ifdef AF_UNIX
- struct sockaddr_un un;
+ struct sockaddr_un un;
#endif
#ifdef AF_INET
- struct sockaddr_in in;
+ struct sockaddr_in in;
#endif
#ifdef AF_INET6
- struct sockaddr_in6 in6;
+ struct sockaddr_in6 in6;
#endif
#ifdef AF_APPLETALK
- struct sockaddr_at at;
+ struct sockaddr_at at;
#endif
#ifdef AF_DECnet
- struct sockaddr_dn dn;
+ struct sockaddr_dn dn;
#endif
#ifdef AF_X25
- struct sockaddr_x25 x25;
+ struct sockaddr_x25 x25;
#endif
#ifdef AF_AX25
- struct sockaddr_ax25 ax25;
+ struct sockaddr_ax25 ax25;
#endif
#ifdef AF_IPX
- struct sockaddr_ipx ipx;
+ struct sockaddr_ipx ipx;
#endif
#ifdef AF_NETBIOS
- struct sockaddr_nb nb;
+ struct sockaddr_nb nb;
#endif
#ifdef AF_ATM
- struct sockaddr_atm atm;
+ struct sockaddr_atm atm;
#endif
#ifdef AF_BAN
- struct sockaddr_vns vns;
+ struct sockaddr_vns vns;
#endif
#ifdef AF_VOICEVIEW
- struct sockaddr_vv vv;
+ struct sockaddr_vv vv;
#endif
#ifdef AF_IRDA
- struct sockaddr_irda irda;
+ struct sockaddr_irda irda;
#endif
};
@@ -1228,103 +1228,103 @@
sigset_t block, omask;
if (line == NULL)
- return -1;
+ return -1;
sa.sa_handler = SIG_IGN;
sa.sa_flags = 0;
__sigemptyset (&sa.sa_mask);
if (__sigaction (SIGINT, &sa, &intr) < 0) {
- DPRINTF(("1: errno=%d\n", errno));
- return -1;
+ DPRINTF(("1: errno=%d\n", errno));
+ return -1;
}
if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
- save = errno;
- (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
- errno = save;
- DPRINTF(("2: errno=%d\n", errno));
- return -1;
+ save = errno;
+ (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ errno = save;
+ DPRINTF(("2: errno=%d\n", errno));
+ return -1;
}
__sigemptyset (&block);
__sigaddset (&block, SIGCHLD);
save = errno;
if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
- if (errno == ENOSYS)
- errno = save;
- else {
- save = errno;
- (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
- (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
- errno = save;
- DPRINTF(("3: errno=%d\n", errno));
- return -1;
- }
+ if (errno == ENOSYS)
+ errno = save;
+ else {
+ save = errno;
+ (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
+ (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ errno = save;
+ DPRINTF(("3: errno=%d\n", errno));
+ return -1;
+ }
}
pid = FORK ();
if (pid == (pid_t) 0) {
- /* Child side. */
- CONST char *new_argv[4];
- new_argv[0] = SHELL_NAME;
- new_argv[1] = "-c";
- new_argv[2] = line;
- new_argv[3] = NULL;
-
- /* Restore the signals. */
- (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
- (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
- (void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
-
- /* Exec the shell. */
- (void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
- _exit (127);
+ /* Child side. */
+ CONST char *new_argv[4];
+ new_argv[0] = SHELL_NAME;
+ new_argv[1] = "-c";
+ new_argv[2] = line;
+ new_argv[3] = NULL;
+
+ /* Restore the signals. */
+ (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ (void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
+
+ /* Exec the shell. */
+ (void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
+ _exit (127);
} else {
- if (pid < (pid_t) 0) {
- /* The fork failed. */
- DPRINTF(("4: errno=%d\n", errno));
- status = -1;
- } else {
- /* Parent side. */
+ if (pid < (pid_t) 0) {
+ /* The fork failed. */
+ DPRINTF(("4: errno=%d\n", errno));
+ status = -1;
+ } else {
+ /* Parent side. */
#ifdef NO_WAITPID
- pid_t child;
-
- do {
- __BEGIN_INTERRUPTABLE__
- child = __wait (&status);
- __END_INTERRUPTABLE__
- if (child < 0 && errno != EINTR) {
- DPRINTF(("5: errno=%d\n", errno));
- status = -1;
- break;
- }
- } while (child != pid);
+ pid_t child;
+
+ do {
+ __BEGIN_INTERRUPTABLE__
+ child = __wait (&status);
+ __END_INTERRUPTABLE__
+ if (child < 0 && errno != EINTR) {
+ DPRINTF(("5: errno=%d\n", errno));
+ status = -1;
+ break;
+ }
+ } while (child != pid);
#else
- pid_t child;
-
- /* claus: the original did not care for EINTR here ... */
- do {
- __BEGIN_INTERRUPTABLE__
- child = __waitpid (pid, &status, 0);
- __END_INTERRUPTABLE__
- } while ((child != pid) && (errno == EINTR));
- if (child != pid) {
- DPRINTF(("6: errno=%d\n", errno));
- status = -1;
- }
+ pid_t child;
+
+ /* claus: the original did not care for EINTR here ... */
+ do {
+ __BEGIN_INTERRUPTABLE__
+ child = __waitpid (pid, &status, 0);
+ __END_INTERRUPTABLE__
+ } while ((child != pid) && (errno == EINTR));
+ if (child != pid) {
+ DPRINTF(("6: errno=%d\n", errno));
+ status = -1;
+ }
#endif /* NO_WAITPID */
- }
+ }
}
save = errno;
if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
| __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
| __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
- if (errno == ENOSYS) {
- errno = save;
- } else {
- status = -1;
- DPRINTF(("7: errno=%d\n", errno));
- }
+ if (errno == ENOSYS) {
+ errno = save;
+ } else {
+ status = -1;
+ DPRINTF(("7: errno=%d\n", errno));
+ }
}
return status;
@@ -1366,112 +1366,112 @@
char *path;
char resolved_path [];
{
- char copy_path[MAXPATHLEN];
- char link_path[MAXPATHLEN];
- char *new_path = resolved_path;
- char *max_path;
- int readlinks = 0;
- int n;
-
- /* Make a copy of the source path since we may need to modify it. */
- strcpy(copy_path, path);
- path = copy_path;
- max_path = copy_path + MAXPATHLEN - 2;
- /* If it's a relative pathname use getwd for starters. */
- if (*path != '/') {
+ char copy_path[MAXPATHLEN];
+ char link_path[MAXPATHLEN];
+ char *new_path = resolved_path;
+ char *max_path;
+ int readlinks = 0;
+ int n;
+
+ /* Make a copy of the source path since we may need to modify it. */
+ strcpy(copy_path, path);
+ path = copy_path;
+ max_path = copy_path + MAXPATHLEN - 2;
+ /* If it's a relative pathname use getwd for starters. */
+ if (*path != '/') {
#ifdef HAS_GETCWD
- new_path = getcwd(new_path, MAXPATHLEN - 1);
+ new_path = getcwd(new_path, MAXPATHLEN - 1);
#else
- new_path = getwd(new_path);
-#endif
- if (new_path == NULL)
- return(NULL);
-
- new_path += strlen(new_path);
- if (new_path[-1] != '/')
- *new_path++ = '/';
- }
- else {
- *new_path++ = '/';
- path++;
- }
- /* Expand each slash-separated pathname component. */
- while (*path != '\0') {
- /* Ignore stray "/". */
- if (*path == '/') {
- path++;
- continue;
- }
- if (*path == '.') {
- /* Ignore ".". */
- if (path[1] == '\0' || path[1] == '/') {
- path++;
- continue;
- }
- if (path[1] == '.') {
- if (path[2] == '\0' || path[2] == '/') {
- path += 2;
- /* Ignore ".." at root. */
- if (new_path == resolved_path + 1)
- continue;
- /* Handle ".." by backing up. */
- while ((--new_path)[-1] != '/')
- ;
- continue;
- }
- }
- }
- /* Safely copy the next pathname component. */
- while (*path != '\0' && *path != '/') {
- if (path > max_path) {
- errno = ENAMETOOLONG;
- return NULL;
- }
- *new_path++ = *path++;
- }
+ new_path = getwd(new_path);
+#endif
+ if (new_path == NULL)
+ return(NULL);
+
+ new_path += strlen(new_path);
+ if (new_path[-1] != '/')
+ *new_path++ = '/';
+ }
+ else {
+ *new_path++ = '/';
+ path++;
+ }
+ /* Expand each slash-separated pathname component. */
+ while (*path != '\0') {
+ /* Ignore stray "/". */
+ if (*path == '/') {
+ path++;
+ continue;
+ }
+ if (*path == '.') {
+ /* Ignore ".". */
+ if (path[1] == '\0' || path[1] == '/') {
+ path++;
+ continue;
+ }
+ if (path[1] == '.') {
+ if (path[2] == '\0' || path[2] == '/') {
+ path += 2;
+ /* Ignore ".." at root. */
+ if (new_path == resolved_path + 1)
+ continue;
+ /* Handle ".." by backing up. */
+ while ((--new_path)[-1] != '/')
+ ;
+ continue;
+ }
+ }
+ }
+ /* Safely copy the next pathname component. */
+ while (*path != '\0' && *path != '/') {
+ if (path > max_path) {
+ errno = ENAMETOOLONG;
+ return NULL;
+ }
+ *new_path++ = *path++;
+ }
#ifdef S_IFLNK
- /* Protect against infinite loops. */
- if (readlinks++ > MAX_READLINKS) {
- errno = ELOOP;
- return NULL;
- }
- /* See if latest pathname component is a symlink. */
- *new_path = '\0';
- n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
- if (n < 0) {
- /* EINVAL means the file exists but isn't a symlink. */
- if (errno != EINVAL)
- return NULL;
- }
- else {
- /* Note: readlink doesn't add the null byte. */
- link_path[n] = '\0';
- if (*link_path == '/')
- /* Start over for an absolute symlink. */
- new_path = resolved_path;
- else
- /* Otherwise back up over this component. */
- while (*(--new_path) != '/')
- ;
- /* Safe sex check. */
- if (strlen(path) + n >= MAXPATHLEN) {
- errno = ENAMETOOLONG;
- return NULL;
- }
- /* Insert symlink contents into path. */
- strcat(link_path, path);
- strcpy(copy_path, link_path);
- path = copy_path;
- }
+ /* Protect against infinite loops. */
+ if (readlinks++ > MAX_READLINKS) {
+ errno = ELOOP;
+ return NULL;
+ }
+ /* See if latest pathname component is a symlink. */
+ *new_path = '\0';
+ n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
+ if (n < 0) {
+ /* EINVAL means the file exists but isn't a symlink. */
+ if (errno != EINVAL)
+ return NULL;
+ }
+ else {
+ /* Note: readlink doesn't add the null byte. */
+ link_path[n] = '\0';
+ if (*link_path == '/')
+ /* Start over for an absolute symlink. */
+ new_path = resolved_path;
+ else
+ /* Otherwise back up over this component. */
+ while (*(--new_path) != '/')
+ ;
+ /* Safe sex check. */
+ if (strlen(path) + n >= MAXPATHLEN) {
+ errno = ENAMETOOLONG;
+ return NULL;
+ }
+ /* Insert symlink contents into path. */
+ strcat(link_path, path);
+ strcpy(copy_path, link_path);
+ path = copy_path;
+ }
#endif /* S_IFLNK */
- *new_path++ = '/';
- }
- /* Delete trailing slash but don't whomp a lone slash. */
- if (new_path != resolved_path + 1 && new_path[-1] == '/')
- new_path--;
- /* Make sure it's null terminated. */
- *new_path = '\0';
- return resolved_path;
+ *new_path++ = '/';
+ }
+ /* Delete trailing slash but don't whomp a lone slash. */
+ if (new_path != resolved_path + 1 && new_path[-1] == '/')
+ new_path--;
+ /* Make sure it's null terminated. */
+ *new_path = '\0';
+ return resolved_path;
}
# define HAS_REALPATH
#endif /* WANT_REALPATH && not HAS_REALPATH */
@@ -3443,29 +3443,29 @@
"Internal lowLevel entry for combined fork & exec;
If fork is false (chain a command):
- execute the OS command specified by the argument, aCommandPath, with
- arguments in argArray (no arguments, if nil).
- If successful, this method does not return and smalltalk is gone.
- If not successful, it does return.
- Normal use is with forkForCommand.
+ execute the OS command specified by the argument, aCommandPath, with
+ arguments in argArray (no arguments, if nil).
+ If successful, this method does not return and smalltalk is gone.
+ If not successful, it does return.
+ Normal use is with forkForCommand.
If fork is true (subprocess command execution):
- fork a child to do the above.
- The process id of the child process is returned; nil if the fork failed.
+ fork a child to do the above.
+ The process id of the child process is returned; nil if the fork failed.
fdColl contains the filedescriptors, to be used for the child (if fork is true).
- fdArray[1] = 15 -> use fd 15 as stdin.
- If an element of the array is set to nil, the corresponding filedescriptor
- will be closed for the child.
- fdArray[1] == StdIn for child
- fdArray[2] == StdOut for child
- fdArray[3] == StdErr for child
- on VMS, these must be channels as returned by createMailBox.
- All filedescriptors not present in fdColl will be closed for the child.
+ fdArray[1] = 15 -> use fd 15 as stdin.
+ If an element of the array is set to nil, the corresponding filedescriptor
+ will be closed for the child.
+ fdArray[1] == StdIn for child
+ fdArray[2] == StdOut for child
+ fdArray[3] == StdErr for child
+ on VMS, these must be channels as returned by createMailBox.
+ All filedescriptors not present in fdColl will be closed for the child.
If newPgrp is true, the subprocess will be established in a new process group.
- The processgroup will be equal to id.
- newPgrp is not used on WIN32 and VMS systems.
+ The processgroup will be equal to id.
+ newPgrp is not used on WIN32 and VMS systems.
environmentDictionary specifies environment variables which are passed differently from
the current environment. If non-nil, it must be a dictionary providing
@@ -3473,32 +3473,32 @@
To pass a variable as empty (i.e. unset), pass a nil value.
Notice: this used to be two separate ST-methods; however, in order to use
- vfork on some machines, it had to be merged into one, to avoid write
- accesses to ST/X memory from the vforked-child.
- The code below only does read accesses."
+ vfork on some machines, it had to be merged into one, to avoid write
+ accesses to ST/X memory from the vforked-child.
+ The code below only does read accesses."
|envArray argArray fdArray dirName cnt|
environmentDictionary size ~~ 0 ifTrue:[
- envArray := Array new:environmentDictionary size.
- cnt := 1.
- environmentDictionary keysAndValuesDo:[:key :val |
- val isNil ifTrue:[
- envArray at:cnt put:(key, '=')
- ] ifFalse:[
- envArray at:cnt put:(key, '=', val)
- ].
- cnt := cnt + 1.
- ].
+ envArray := Array new:environmentDictionary size.
+ cnt := 1.
+ environmentDictionary keysAndValuesDo:[:key :val |
+ val isNil ifTrue:[
+ envArray at:cnt put:(key, '=')
+ ] ifFalse:[
+ envArray at:cnt put:(key, '=', val)
+ ].
+ cnt := cnt + 1.
+ ].
].
argColl notNil ifTrue:[
- argArray := argColl asArray
+ argArray := argColl asArray
].
fdColl notNil ifTrue:[
- fdArray := fdColl asArray
+ fdArray := fdColl asArray
].
aDirectory notNil ifTrue:[
- dirName := aDirectory asFilename name
+ dirName := aDirectory asFilename name
].
%{ /* STACK: 16000 */
@@ -3512,213 +3512,213 @@
#endif
if (__isString(aCommandPath) &&
- ((argArray == nil) || __isArrayLike(argArray)) &&
- ((fdArray == nil) || __isArrayLike(fdArray))
+ ((argArray == nil) || __isArrayLike(argArray)) &&
+ ((fdArray == nil) || __isArrayLike(fdArray))
) {
- nargs = argArray == nil ? 0 : __arraySize(argArray);
- argv = (char **) malloc(sizeof(char *) * (nargs + 1));
- if (argv) {
- int nOldEnv, nNewEnv;
-
- for (i=0; i < nargs; i++) {
- arg = __ArrayInstPtr(argArray)->a_element[i];
- if (__isString(arg)) {
- argv[i] = (char *) __stringVal(arg);
- } else {
- argv[i] = "";
- }
- }
- argv[i] = NULL;
-
- /*
- * number of new items in environment ..
- */
- nNewEnv = 0;
- if ((envArray != nil) && __isArrayLike(envArray)) {
- nNewEnv = __arraySize(envArray);
- }
-
- if (nNewEnv == 0) {
- _nEnv = environ;
- } else {
- _env = environ;
- /*
- * get size of environment
- */
- nOldEnv = 0;
- if (_env) {
- while (*_env) {
- nOldEnv++;
- _env++;
- }
- }
-
- /*
- * generate a new environment
- * I have not found a spec which defines if
- * items at the end overwrite previous definitions,
- * or if the first encountered definition is valid.
- * To be prepared for any case, simply add the new definitions
- * at both ends - that should do it in any case.
- * Someone with more know-how may want to fix this.
- * getenv() searches for the first entry.
- * But maybe someone creates a Dictionary from the environment.
- * In this case the last entry would overwrite previous entries.
- */
- _nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
- if (_nEnv) {
- char **eO, **eN;
-
- eN = _nEnv;
- if (nNewEnv) {
- /*
- * add new items at the front ...
- */
- int i;
- OBJ *t;
-
- for (i=0, t = __arrayVal(envArray);
- i < __arraySize(envArray);
- i++, t++) {
-
- if (__isString(*t)) {
- *eN++ = (char *)__stringVal(*t);
- }
- }
- }
-
- if (nOldEnv) {
- /*
- * append old environment
- */
- for (eO = environ; *eO; *eN++ = *eO++)
- continue;
- }
-
- if (nNewEnv) {
- /*
- * append new items again at the end
- */
- for (eO = _nEnv, i=0; i<nNewEnv; i++) {
- *eN++ = *eO++;
- }
- }
- *eN = NULL;
- }
- }
-
- if (doFork == true) {
- /*
- * fork a subprocess.
- */
- int nfd;
-
- nfd = fdArray == nil ? 0 : __arraySize(fdArray);
- id = FORK ();
- if (id == 0) {
- /*
- ** In child.
- ** first: dup filedescriptors.
- */
- for (i = 0; i < nfd; i++) {
- OBJ fd;
- int rslt;
-
- fd = __arrayVal(fdArray)[i];
- if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
- do {
- rslt = dup2(__intVal(fd), i);
- } while ((rslt < 0) && (errno == EINTR));
- }
- }
- /*
- ** Second: close descriptors
- ** marked as unwanted
- ** (extra loop to allow duping of low filedescriptor numbers to
- ** higher fd numbers)
- */
- for (i = 0; i < nfd; i++) {
- if (__arrayVal(fdArray)[i] == nil) {
- close(i);
- }
- }
-
- /*
- ** third: close all filedescriptors larger
- ** then the explicitely closed or duped
- ** filedescriptors
- */
+ nargs = argArray == nil ? 0 : __arraySize(argArray);
+ argv = (char **) malloc(sizeof(char *) * (nargs + 1));
+ if (argv) {
+ int nOldEnv, nNewEnv;
+
+ for (i=0; i < nargs; i++) {
+ arg = __ArrayInstPtr(argArray)->a_element[i];
+ if (__isString(arg)) {
+ argv[i] = (char *) __stringVal(arg);
+ } else {
+ argv[i] = "";
+ }
+ }
+ argv[i] = NULL;
+
+ /*
+ * number of new items in environment ..
+ */
+ nNewEnv = 0;
+ if ((envArray != nil) && __isArrayLike(envArray)) {
+ nNewEnv = __arraySize(envArray);
+ }
+
+ if (nNewEnv == 0) {
+ _nEnv = environ;
+ } else {
+ _env = environ;
+ /*
+ * get size of environment
+ */
+ nOldEnv = 0;
+ if (_env) {
+ while (*_env) {
+ nOldEnv++;
+ _env++;
+ }
+ }
+
+ /*
+ * generate a new environment
+ * I have not found a spec which defines if
+ * items at the end overwrite previous definitions,
+ * or if the first encountered definition is valid.
+ * To be prepared for any case, simply add the new definitions
+ * at both ends - that should do it in any case.
+ * Someone with more know-how may want to fix this.
+ * getenv() searches for the first entry.
+ * But maybe someone creates a Dictionary from the environment.
+ * In this case the last entry would overwrite previous entries.
+ */
+ _nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
+ if (_nEnv) {
+ char **eO, **eN;
+
+ eN = _nEnv;
+ if (nNewEnv) {
+ /*
+ * add new items at the front ...
+ */
+ int i;
+ OBJ *t;
+
+ for (i=0, t = __arrayVal(envArray);
+ i < __arraySize(envArray);
+ i++, t++) {
+
+ if (__isString(*t)) {
+ *eN++ = (char *)__stringVal(*t);
+ }
+ }
+ }
+
+ if (nOldEnv) {
+ /*
+ * append old environment
+ */
+ for (eO = environ; *eO; *eN++ = *eO++)
+ continue;
+ }
+
+ if (nNewEnv) {
+ /*
+ * append new items again at the end
+ */
+ for (eO = _nEnv, i=0; i<nNewEnv; i++) {
+ *eN++ = *eO++;
+ }
+ }
+ *eN = NULL;
+ }
+ }
+
+ if (doFork == true) {
+ /*
+ * fork a subprocess.
+ */
+ int nfd;
+
+ nfd = fdArray == nil ? 0 : __arraySize(fdArray);
+ id = FORK ();
+ if (id == 0) {
+ /*
+ ** In child.
+ ** first: dup filedescriptors.
+ */
+ for (i = 0; i < nfd; i++) {
+ OBJ fd;
+ int rslt;
+
+ fd = __arrayVal(fdArray)[i];
+ if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
+ do {
+ rslt = dup2(__intVal(fd), i);
+ } while ((rslt < 0) && (errno == EINTR));
+ }
+ }
+ /*
+ ** Second: close descriptors
+ ** marked as unwanted
+ ** (extra loop to allow duping of low filedescriptor numbers to
+ ** higher fd numbers)
+ */
+ for (i = 0; i < nfd; i++) {
+ if (__arrayVal(fdArray)[i] == nil) {
+ close(i);
+ }
+ }
+
+ /*
+ ** third: close all filedescriptors larger
+ ** then the explicitely closed or duped
+ ** filedescriptors
+ */
#ifndef OPEN_MAX
# define OPEN_MAX 256
#endif
- for ( ;i < OPEN_MAX; i++) {
- close(i);
- }
-
- if (newPgrp == true) {
+ for ( ;i < OPEN_MAX; i++) {
+ close(i);
+ }
+
+ if (newPgrp == true) {
#ifndef NEXT
- setsid();
+ setsid();
#endif
#if defined(TIOCSCTTY)
- ioctl(0, TIOCSCTTY, 0) ;
+ ioctl(0, TIOCSCTTY, 0) ;
#endif
#if defined(TIOCSPGRP)
- {
- int pgrp = getpid();
-
- ioctl(0, TIOCSPGRP, (char *)&pgrp);
- }
+ {
+ int pgrp = getpid();
+
+ ioctl(0, TIOCSPGRP, (char *)&pgrp);
+ }
#endif
#if defined(_POSIX_JOB_CONTROL)
- (void) setpgid(0, 0);
+ (void) setpgid(0, 0);
#else
# if defined(BSD) || defined(LINUX)
- (void) setpgrp(0);
-# endif
-#endif
- }
-
- if (dirName != nil) {
- chdir(__stringVal(dirName));
- }
-
- execve(__stringVal(aCommandPath), argv, _nEnv);
- /* reached if aCommandPathh cannot be executed */
- _exit(127); /* POSIX 2 compatible exit value */
- }
- } else {
- /*
- * no subprocess (i.e. transfer to another program)
- */
- if (dirName != nil) {
- chdir(__stringVal(dirName));
- }
- execve(__stringVal(aCommandPath), argv, _nEnv);
- /*
- * reached if command-path cannot be executed
- */
- id = -1;
- }
-
- if (nNewEnv && (_nEnv != NULL)) {
- /*
- * free new environment stuff
- */
- free(_nEnv);
- }
-
- free(argv);
-
- /*
- * In parent: succes or failure
- */
- if (id == -1) {
- RETURN (nil);
- } else {
- RETURN (__MKSMALLINT(id));
- }
- }
+ (void) setpgrp(0);
+# endif
+#endif
+ }
+
+ if (dirName != nil) {
+ chdir(__stringVal(dirName));
+ }
+
+ execve(__stringVal(aCommandPath), argv, _nEnv);
+ /* reached if aCommandPathh cannot be executed */
+ _exit(127); /* POSIX 2 compatible exit value */
+ }
+ } else {
+ /*
+ * no subprocess (i.e. transfer to another program)
+ */
+ if (dirName != nil) {
+ chdir(__stringVal(dirName));
+ }
+ execve(__stringVal(aCommandPath), argv, _nEnv);
+ /*
+ * reached if command-path cannot be executed
+ */
+ id = -1;
+ }
+
+ if (nNewEnv && (_nEnv != NULL)) {
+ /*
+ * free new environment stuff
+ */
+ free(_nEnv);
+ }
+
+ free(argv);
+
+ /*
+ * In parent: succes or failure
+ */
+ if (id == -1) {
+ RETURN (nil);
+ } else {
+ RETURN (__MKSMALLINT(id));
+ }
+ }
}
%}.
"
@@ -3734,9 +3734,9 @@
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
+ 'not reached'.
]
"
"
@@ -3744,11 +3744,11 @@
id := OperatingSystem fork.
id == 0 ifTrue:[
- 'I am the child'.
- OperatingSystem
- exec:'/bin/sh'
- withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
- 'not reached'.
+ 'I am the child'.
+ OperatingSystem
+ exec:'/bin/sh'
+ withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
+ 'not reached'.
].
id printNL.
(Delay forSeconds:3.5) wait.
@@ -3905,36 +3905,36 @@
aCommandString isNil ifTrue:[^ nil].
(in := anExternalInStream) isNil ifTrue:[
- nullStream := Filename nullDevice readWriteStream.
- in := nullStream.
+ nullStream := Filename nullDevice readWriteStream.
+ in := nullStream.
].
(out := anExternalOutStream) isNil ifTrue:[
- nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
- out := nullStream.
+ nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
+ out := nullStream.
].
(err := anExternalErrStream) isNil ifTrue:[
- err := out
+ err := out
].
anAuxiliaryStream notNil ifTrue:[
- auxFd := anAuxiliaryStream fileDescriptor
+ auxFd := anAuxiliaryStream fileDescriptor
].
shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
rslt := self
- exec:(shellAndArgs at:1)
- withArguments:(shellAndArgs at:2)
- environment:anEvironmentDictionary
- fileDescriptors:(Array with:in fileDescriptor
- with:out fileDescriptor
- with:err fileDescriptor
- with:auxFd)
- fork:true
- newPgrp:true "/ false
- inDirectory:dir.
+ exec:(shellAndArgs at:1)
+ withArguments:(shellAndArgs at:2)
+ environment:anEvironmentDictionary
+ fileDescriptors:(Array with:in fileDescriptor
+ with:out fileDescriptor
+ with:err fileDescriptor
+ with:auxFd)
+ fork:true
+ newPgrp:true "/ false
+ inDirectory:dir.
nullStream notNil ifTrue:[
- nullStream close.
+ nullStream close.
].
^ rslt
@@ -3958,7 +3958,7 @@
The following will no longer work. monitorPid has disappeared
pid notNil ifTrue:[
- Processor monitorPid:pid action:[:OSstatus | sema signal ].
+ Processor monitorPid:pid action:[:OSstatus | sema signal ].
].
in close.
out close.
@@ -3977,13 +3977,13 @@
errorTo:anExternalErrStream auxFrom:anAuxiliaryStream inDirectory:dir
^ self
- startProcess:aCommandString
- inputFrom:anExternalInStream
- outputTo:anExternalOutStream
- errorTo:anExternalErrStream
- auxFrom:anAuxiliaryStream
- environment:nil
- inDirectory:dir
+ startProcess:aCommandString
+ inputFrom:anExternalInStream
+ outputTo:anExternalOutStream
+ errorTo:anExternalErrStream
+ auxFrom:anAuxiliaryStream
+ environment:nil
+ inDirectory:dir
! !
!UnixOperatingSystem class methodsFor:'file access'!
@@ -3993,11 +3993,11 @@
%{
if (__isSmallInteger(anInteger)) {
- if (@global(ExternalStream:FileOpenTrace) == true) {
- fprintf(stderr, "close [UnixOp] fd=%d\n", __intVal(anInteger));
- }
- close(__intVal(anInteger));
- RETURN(self);
+ if (@global(ExternalStream:FileOpenTrace) == true) {
+ fprintf(stderr, "close [UnixOp] fd=%d\n", __intVal(anInteger));
+ }
+ close(__intVal(anInteger));
+ RETURN(self);
}
%}.
^ self primitiveFailed.
@@ -6480,17 +6480,17 @@
slaveName = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
if ((slaveName != 0) && (_fdM >= 0)) {
- _fdS = open(slaveName, O_RDWR);
- if (_fdS < 0) {
- (void)close(_fdM);
- _fdS = _fdM = -1;
- }
+ _fdS = open(slaveName, O_RDWR);
+ if (_fdS < 0) {
+ (void)close(_fdM);
+ _fdS = _fdM = -1;
+ }
} else {
- _fdM -1;
+ _fdM -1;
}
if ((_fdM >= 0) && (_fdS >= 0)) {
- fdM = __MKSMALLINT(_fdM);
- fdS = __MKSMALLINT(_fdS);
+ fdM = __MKSMALLINT(_fdM);
+ fdS = __MKSMALLINT(_fdS);
}
# define NO_PTY_TEMPL
#endif /* IRIX5 */
@@ -6503,38 +6503,38 @@
struct group *gr;
if ((gr = getgrnam("tty")) != NULL)
- ttygid = gr->gr_gid;
+ ttygid = gr->gr_gid;
else
- ttygid = -1;
+ ttygid = -1;
_fdM = open("/dev/ptmx", O_RDWR /* |O_NDELAY */ );
if (_fdM >= 0) {
- grantpt(_fdM);
- unlockpt(_fdM);
- slaveName = ptsname(_fdM);
-
- if (slaveName != NULL) {
- /* printf("slave is: %s\n", slaveName); */
- _fdS = open(slaveName, O_RDWR);
- if (_fdS < 0) {
- (void)close(_fdM);
- _fdS = _fdM = -1;
- } else {
- ioctl(_fdS, I_PUSH, "ptem"); /* push ptem */
- ioctl(_fdS, I_PUSH, "ldterm"); /* push ldterm */
- /* (void) chown( slaveName, getuid(), ttygid ); */
- /* (void) chmod( slaveName, S_IRUSR | S_IWUSR | S_IWGRP ); */
- }
- } else {
- (void)close(_fdM);
- _fdS = _fdM = -1;
- }
+ grantpt(_fdM);
+ unlockpt(_fdM);
+ slaveName = ptsname(_fdM);
+
+ if (slaveName != NULL) {
+ /* printf("slave is: %s\n", slaveName); */
+ _fdS = open(slaveName, O_RDWR);
+ if (_fdS < 0) {
+ (void)close(_fdM);
+ _fdS = _fdM = -1;
+ } else {
+ ioctl(_fdS, I_PUSH, "ptem"); /* push ptem */
+ ioctl(_fdS, I_PUSH, "ldterm"); /* push ldterm */
+ /* (void) chown( slaveName, getuid(), ttygid ); */
+ /* (void) chmod( slaveName, S_IRUSR | S_IWUSR | S_IWGRP ); */
+ }
+ } else {
+ (void)close(_fdM);
+ _fdS = _fdM = -1;
+ }
}
if ((_fdM >= 0) && (_fdS >= 0)) {
- fdM = __MKSMALLINT(_fdM);
- fdS = __MKSMALLINT(_fdS);
+ fdM = __MKSMALLINT(_fdM);
+ fdS = __MKSMALLINT(_fdS);
}
# define NO_PTY_TEMPL
#endif /* SYSV4 */
@@ -6613,39 +6613,39 @@
# endif
if ((gr = getgrnam("tty")) != NULL)
- ttygid = gr->gr_gid;
+ ttygid = gr->gr_gid;
else
- ttygid = -1;
+ ttygid = -1;
for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
- line[len-2] = * cp1;
-
- for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
- line[PT_INDEX] = 'p';
- line[len-1] = *cp2;
-
- if ((_fdM = open(line, O_RDWR, 0)) < 0) {
- if (errno == ENOENT) {
- _fdM = _fdS = -1;
- goto getOutOfHere; /* out of ptys */
- }
- } else {
- line[PT_INDEX] = 't';
- (void) chown( line, getuid(), ttygid );
- (void) chmod( line, S_IRUSR | S_IWUSR | S_IWGRP );
-
- if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
- goto getOutOfHere;
- }
- (void) close( _fdM );
- }
- }
+ line[len-2] = * cp1;
+
+ for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
+ line[PT_INDEX] = 'p';
+ line[len-1] = *cp2;
+
+ if ((_fdM = open(line, O_RDWR, 0)) < 0) {
+ if (errno == ENOENT) {
+ _fdM = _fdS = -1;
+ goto getOutOfHere; /* out of ptys */
+ }
+ } else {
+ line[PT_INDEX] = 't';
+ (void) chown( line, getuid(), ttygid );
+ (void) chmod( line, S_IRUSR | S_IWUSR | S_IWGRP );
+
+ if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
+ goto getOutOfHere;
+ }
+ (void) close( _fdM );
+ }
+ }
}
getOutOfHere: ;
if ((_fdM >= 0) && (_fdS >= 0)) {
- fdM = __MKSMALLINT(_fdM);
- fdS = __MKSMALLINT(_fdS);
+ fdM = __MKSMALLINT(_fdM);
+ fdS = __MKSMALLINT(_fdS);
}
#endif /* PTY_TEMPL */
@@ -6654,7 +6654,7 @@
%}.
fdM notNil ifTrue:[
- ^ Array with:fdM with:fdS.
+ ^ Array with:fdM with:fdS.
].
^ nil
@@ -6728,36 +6728,36 @@
closeLeftOverFiles
"a bad bad kludge and workaround for a big bug in the linux
getAddrInfo implementation:
- if it get interrupted (via a timer, for example), its domain-name
- socket remains open and is NEVER closed.
- These open files collect up and lead to no-more-files eventually.
+ if it get interrupted (via a timer, for example), its domain-name
+ socket remains open and is NEVER closed.
+ These open files collect up and lead to no-more-files eventually.
Invoking this method helps in this situation."
|p|
p := PipeStream
- readingFrom:('lsof -p ' , (OperatingSystem getProcessId printString)).
+ readingFrom:('lsof -p ' , (OperatingSystem getProcessId printString)).
p linesDo:[:line |
- |words fd|
-
- words := line asCollectionOfWords.
- "/ COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
- words first = 'stx' ifTrue:[
- words second = (OperatingSystem getProcessId printString) ifTrue:[
- (words fourth endsWith:'u') ifTrue:[
- (words fifth = 'IPv4') ifTrue:[
- (words seventh = 'UDP') ifTrue:[
- (words last endsWith:'domain') ifTrue:[
- fd := Number readFrom:(words fourth copyWithoutLast:1).
+ |words fd|
+
+ words := line asCollectionOfWords.
+ "/ COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
+ words first = 'stx' ifTrue:[
+ words second = (OperatingSystem getProcessId printString) ifTrue:[
+ (words fourth endsWith:'u') ifTrue:[
+ (words fifth = 'IPv4') ifTrue:[
+ (words seventh = 'UDP') ifTrue:[
+ (words last endsWith:'domain') ifTrue:[
+ fd := Number readFrom:(words fourth copyWithoutLast:1).
Transcript showCR:line.
- OperatingSystem closeFd:fd.
- ]
- ]
- ]
- ]
- ]
- ]
+ OperatingSystem closeFd:fd.
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
].
p close.
@@ -7168,8 +7168,8 @@
getNetworkMACAddresses
"return a dictionary filled with
- key -> name of interface
- value -> the MAC adress (as ByteArray)
+ key -> name of interface
+ value -> the MAC adress (as ByteArray)
for each interface"
|addressArray nameArray noOfIf retDictionary error|
@@ -7193,8 +7193,8 @@
afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
if (afinet_socket < 0) {
- error = __MKSTRING("Cannot open socket");
- goto bad;
+ error = __MKSTRING("Cannot open socket");
+ goto bad;
}
/*
@@ -7205,9 +7205,9 @@
ifc.ifc_buf = (caddr_t) buf;
if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
- close(afinet_socket);
- error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
- goto bad;
+ close(afinet_socket);
+ error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
+ goto bad;
}
n_ifs = ifc.ifc_len / sizeof (struct ifreq);
@@ -7216,9 +7216,9 @@
addressArray = __MKARRAY(n_ifs);
if (nameArray == nil || addressArray == nil) {
- /* Creating a string wouldn/t work here */
- error = @symbol(allocationFailure);
- goto bad;
+ /* Creating a string wouldn/t work here */
+ error = @symbol(allocationFailure);
+ goto bad;
}
/*
@@ -7229,46 +7229,46 @@
countOfIf = 0;
for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
- /*
- ** Get Flags for this interface
- */
-
- memcpy(&ifreq, ifr, sizeof(ifreq));
- if (ioctl (afinet_socket, SIOCGIFFLAGS, &ifreq) < 0) {
- fprintf(stderr, "ioctl(SIOCGIFFLAGS) failed");
- } else {
- /*
- ** Get Hardware address for this interface
- */
- memcpy(&ifreq, ifr, sizeof(ifreq));
- if (ioctl (afinet_socket, SIOCGIFHWADDR, &ifreq) >= 0) {
- t = __MKBYTEARRAY(&ifreq.ifr_hwaddr.sa_data, IFHWADDRLEN);
- __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
- t = __MKSTRING(&ifreq.ifr_ifrn.ifrn_name, IFNAMSIZ);
- __arrayVal(nameArray)[countOfIf] = t; __STORE(addressArray, t);
- countOfIf += 1;
- }
- }
+ /*
+ ** Get Flags for this interface
+ */
+
+ memcpy(&ifreq, ifr, sizeof(ifreq));
+ if (ioctl (afinet_socket, SIOCGIFFLAGS, &ifreq) < 0) {
+ fprintf(stderr, "ioctl(SIOCGIFFLAGS) failed");
+ } else {
+ /*
+ ** Get Hardware address for this interface
+ */
+ memcpy(&ifreq, ifr, sizeof(ifreq));
+ if (ioctl (afinet_socket, SIOCGIFHWADDR, &ifreq) >= 0) {
+ t = __MKBYTEARRAY(&ifreq.ifr_hwaddr.sa_data, IFHWADDRLEN);
+ __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
+ t = __MKSTRING(&ifreq.ifr_ifrn.ifrn_name, IFNAMSIZ);
+ __arrayVal(nameArray)[countOfIf] = t; __STORE(addressArray, t);
+ countOfIf += 1;
+ }
+ }
}
close(afinet_socket);
noOfIf = __mkSmallInteger(countOfIf);
bad:
if (afinet_socket >= 0)
- close(afinet_socket);
+ close(afinet_socket);
#endif /* NET_IF_SUPPORT */
%}.
retDictionary := Dictionary new:noOfIf.
error notNil ifTrue:[
- self primitiveFailed:error.
- "return empty dictionary if proceed from error"
- ^ retDictionary.
+ self primitiveFailed:error.
+ "return empty dictionary if proceed from error"
+ ^ retDictionary.
].
1 to:noOfIf do:[:cnt|
- retDictionary at:(nameArray at:cnt) put:(addressArray at:cnt).
+ retDictionary at:(nameArray at:cnt) put:(addressArray at:cnt).
].
^ retDictionary
@@ -8385,35 +8385,35 @@
sysPath := super defaultSystemPath.
#(
- '/usr/local/lib/stx'
- '/usr/local/lib/smalltalk'
- '/usr/lib/stx'
- '/usr/lib/smalltalk'
- '/lib/stx'
- '/lib/smalltalk'
- '/opt/stx'
- '/opt/smalltalk'
+ '/usr/local/lib/stx'
+ '/usr/local/lib/smalltalk'
+ '/usr/lib/stx'
+ '/usr/lib/smalltalk'
+ '/lib/stx'
+ '/lib/smalltalk'
+ '/opt/stx'
+ '/opt/smalltalk'
) do:[:d |
- (d asFilename isDirectory) ifTrue:[
- "/ try to guess a gnu-smalltalk; skip it
- (d asFilename construct:'initialize.st') exists ifFalse:[
- releaseFile := d asFilename construct:'RELEASE'.
- releaseFile exists ifTrue:[
- s := releaseFile readStreamOrNil.
- s notNil ifTrue:[
- v := Integer readFrom:s onError:-1.
- s close.
- v == majorVersionNr ifTrue:[
- sysPath add:d
- ] ifFalse:[
- ('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE mismatch)') infoPrintCR.
- ]
- ] ifFalse:[
- ('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE missing)') infoPrintCR.
- ]
- ]
- ]
- ]
+ (d asFilename isDirectory) ifTrue:[
+ "/ try to guess a gnu-smalltalk; skip it
+ (d asFilename construct:'initialize.st') exists ifFalse:[
+ releaseFile := d asFilename construct:'RELEASE'.
+ releaseFile exists ifTrue:[
+ s := releaseFile readStreamOrNil.
+ s notNil ifTrue:[
+ v := Integer readFrom:s onError:-1.
+ s close.
+ v == majorVersionNr ifTrue:[
+ sysPath add:d
+ ] ifFalse:[
+ ('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE mismatch)') infoPrintCR.
+ ]
+ ] ifFalse:[
+ ('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE missing)') infoPrintCR.
+ ]
+ ]
+ ]
+ ]
].
^ sysPath
@@ -9916,7 +9916,7 @@
or the error number as returned by the OperatingSystem"
anErrorSymbolOrErrno isInteger ifTrue:[
- (UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError
+ (UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError
].
self primitiveFailed:anErrorSymbolOrErrno.
! !
@@ -9947,7 +9947,7 @@
"/ the 0 is possible, if an fd was open when saving a snapshot image,
"/ and we come up in the new image with no one referring to it.
(oldHandle notNil and:[oldHandle ~~ 0 and:[ oldHandle ~~ self]]) ifTrue:[
- oldHandle invalidate.
+ oldHandle invalidate.
].
self register.
@@ -9975,102 +9975,102 @@
int nInstBytes, objSize;
if (! __isSmallInteger(__INST(fd))) {
- error = @symbol(errorNotOpen);
- goto bad;
+ error = @symbol(errorNotOpen);
+ goto bad;
}
if (! __bothSmallInteger(count, firstIndex)) {
- error = @symbol(badArgument);
- goto bad;
+ error = @symbol(badArgument);
+ goto bad;
}
fd = __smallIntegerVal(__INST(fd));
cnt = __smallIntegerVal(count);
offs = __smallIntegerVal(firstIndex) - 1;
if (fd < 0) {
- error = @symbol(internalError);
- goto bad;
+ error = @symbol(internalError);
+ goto bad;
}
if (__isExternalBytesLike(aByteBuffer)) {
- OBJ sz;
-
- nInstBytes = 0;
- extPtr = (char *)(__externalBytesAddress(aByteBuffer));
- sz = __externalBytesSize(aByteBuffer);
- if (__isSmallInteger(sz)) {
- objSize = __smallIntegerVal(sz);
- } else {
- objSize = -1; /* unknown */
- }
+ OBJ sz;
+
+ nInstBytes = 0;
+ extPtr = (char *)(__externalBytesAddress(aByteBuffer));
+ sz = __externalBytesSize(aByteBuffer);
+ if (__isSmallInteger(sz)) {
+ objSize = __smallIntegerVal(sz);
+ } else {
+ objSize = -1; /* unknown */
+ }
} else {
- OBJ oClass;
- int nInstVars;
-
- oClass = __Class(aByteBuffer);
- switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
- case BYTEARRAY:
- case WORDARRAY:
- case LONGARRAY:
- case SWORDARRAY:
- case SLONGARRAY:
- case FLOATARRAY:
- case DOUBLEARRAY:
- break;
- default:
- error = @symbol(badArgument1);
- goto bad;
- }
- extPtr = (char *)0;
- nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
- nInstBytes = __OBJS2BYTES__(nInstVars);
- objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
+ OBJ oClass;
+ int nInstVars;
+
+ oClass = __Class(aByteBuffer);
+ switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
+ case BYTEARRAY:
+ case WORDARRAY:
+ case LONGARRAY:
+ case SWORDARRAY:
+ case SLONGARRAY:
+ case FLOATARRAY:
+ case DOUBLEARRAY:
+ break;
+ default:
+ error = @symbol(badArgument1);
+ goto bad;
+ }
+ extPtr = (char *)0;
+ nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
+ nInstBytes = __OBJS2BYTES__(nInstVars);
+ objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
}
if ((offs >= 0)
- && (cnt >= 0)
- && ((objSize == -1) || (objSize >= (cnt + offs)))) {
- nRead = 0;
-
- do {
- int n;
-
- if (extPtr) {
- n = read(fd, extPtr+offs, cnt);
- } else {
- char *bp;
-
- /*
- * on interrupt, anObject may be moved to another location.
- * So we recompute the byte-address here.
- */
- bp = __byteArrayVal(aByteBuffer) + nInstBytes;
-
- n = read(fd, bp + offs, cnt);
- }
- if (n > 0) {
- cnt -= n;
- offs += n;
- nRead += n;
- } else if (n == 0) {
- break;
- } else if (n < 0) {
- if (0
+ && (cnt >= 0)
+ && ((objSize == -1) || (objSize >= (cnt + offs)))) {
+ nRead = 0;
+
+ do {
+ int n;
+
+ if (extPtr) {
+ n = read(fd, extPtr+offs, cnt);
+ } else {
+ char *bp;
+
+ /*
+ * on interrupt, anObject may be moved to another location.
+ * So we recompute the byte-address here.
+ */
+ bp = __byteArrayVal(aByteBuffer) + nInstBytes;
+
+ n = read(fd, bp + offs, cnt);
+ }
+ if (n > 0) {
+ cnt -= n;
+ offs += n;
+ nRead += n;
+ } else if (n == 0) {
+ break;
+ } else if (n < 0) {
+ if (0
#ifdef EWOULDBLOCK
- || errno == EWOULDBLOCK
+ || errno == EWOULDBLOCK
#endif
#ifdef EAGAIN
- || errno == EAGAIN
-#endif
- ) {
- RETURN(nil);
- }
- if (errno != EINTR) {
- error = __mkSmallInteger(errno);
- goto bad;
- }
- __HANDLE_INTERRUPTS__;
- }
- } while (cnt > 0);
-
- RETURN (__mkSmallInteger(nRead));
+ || errno == EAGAIN
+#endif
+ ) {
+ RETURN(nil);
+ }
+ if (errno != EINTR) {
+ error = __mkSmallInteger(errno);
+ goto bad;
+ }
+ __HANDLE_INTERRUPTS__;
+ }
+ } while (cnt > 0);
+
+ RETURN (__mkSmallInteger(nRead));
}
bad: ;
%}.
@@ -10109,102 +10109,102 @@
int nInstBytes, objSize;
if (! __isSmallInteger(__INST(fd))) {
- error = @symbol(errorNotOpen);
- goto bad;
+ error = @symbol(errorNotOpen);
+ goto bad;
}
if (! __bothSmallInteger(count, firstIndex)) {
- error = @symbol(badArgument);
- goto bad;
+ error = @symbol(badArgument);
+ goto bad;
}
fd = __smallIntegerVal(__INST(fd));
cnt = __smallIntegerVal(count);
offs = __smallIntegerVal(firstIndex) - 1;
if (fd < 0) {
- error = @symbol(internalError);
- goto bad;
+ error = @symbol(internalError);
+ goto bad;
}
if (__isExternalBytesLike(aByteBuffer)) {
- OBJ sz;
-
- nInstBytes = 0;
- extPtr = (char *)(__externalBytesAddress(aByteBuffer));
- sz = __externalBytesSize(aByteBuffer);
- if (__isSmallInteger(sz)) {
- objSize = __smallIntegerVal(sz);
- } else {
- objSize = -1; /* unknown */
- }
+ OBJ sz;
+
+ nInstBytes = 0;
+ extPtr = (char *)(__externalBytesAddress(aByteBuffer));
+ sz = __externalBytesSize(aByteBuffer);
+ if (__isSmallInteger(sz)) {
+ objSize = __smallIntegerVal(sz);
+ } else {
+ objSize = -1; /* unknown */
+ }
} else {
- OBJ oClass;
- int nInstVars;
-
- oClass = __Class(aByteBuffer);
- switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
- case BYTEARRAY:
- case WORDARRAY:
- case LONGARRAY:
- case SWORDARRAY:
- case SLONGARRAY:
- case FLOATARRAY:
- case DOUBLEARRAY:
- break;
- default:
- error = @symbol(badArgument1);
- goto bad;
- }
- extPtr = (char *)0;
- nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
- nInstBytes = __OBJS2BYTES__(nInstVars);
- objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
+ OBJ oClass;
+ int nInstVars;
+
+ oClass = __Class(aByteBuffer);
+ switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
+ case BYTEARRAY:
+ case WORDARRAY:
+ case LONGARRAY:
+ case SWORDARRAY:
+ case SLONGARRAY:
+ case FLOATARRAY:
+ case DOUBLEARRAY:
+ break;
+ default:
+ error = @symbol(badArgument1);
+ goto bad;
+ }
+ extPtr = (char *)0;
+ nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
+ nInstBytes = __OBJS2BYTES__(nInstVars);
+ objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
}
if ((offs >= 0)
- && (cnt >= 0)
- && ((objSize == -1) || (objSize >= (cnt + offs)))) {
- nWritten = 0;
-
- do {
- int n;
-
- if (extPtr) {
- n = write(fd, extPtr+offs, cnt);
- } else {
- char *bp;
-
- /*
- * on interrupt, anObject may be moved to another location.
- * So we recompute the byte-address here.
- */
- bp = __byteArrayVal(aByteBuffer) + nInstBytes;
-
- n = write(fd, bp + offs, cnt);
- }
- if (n > 0) {
- cnt -= n;
- offs += n;
- nWritten += n;
- } else if (n == 0) {
- break;
- } else if (n < 0) {
- if (0
+ && (cnt >= 0)
+ && ((objSize == -1) || (objSize >= (cnt + offs)))) {
+ nWritten = 0;
+
+ do {
+ int n;
+
+ if (extPtr) {
+ n = write(fd, extPtr+offs, cnt);
+ } else {
+ char *bp;
+
+ /*
+ * on interrupt, anObject may be moved to another location.
+ * So we recompute the byte-address here.
+ */
+ bp = __byteArrayVal(aByteBuffer) + nInstBytes;
+
+ n = write(fd, bp + offs, cnt);
+ }
+ if (n > 0) {
+ cnt -= n;
+ offs += n;
+ nWritten += n;
+ } else if (n == 0) {
+ break;
+ } else if (n < 0) {
+ if (0
#ifdef EWOULDBLOCK
- || errno == EWOULDBLOCK
+ || errno == EWOULDBLOCK
#endif
#ifdef EAGAIN
- || errno == EAGAIN
-#endif
- ) {
- RETURN(nil);
- }
- if (errno != EINTR) {
- error = __mkSmallInteger(errno);
- goto bad;
- }
- __HANDLE_INTERRUPTS__;
- }
- } while (cnt > 0);
-
- RETURN (__mkSmallInteger(nWritten));
+ || errno == EAGAIN
+#endif
+ ) {
+ RETURN(nil);
+ }
+ if (errno != EINTR) {
+ error = __mkSmallInteger(errno);
+ goto bad;
+ }
+ __HANDLE_INTERRUPTS__;
+ }
+ } while (cnt > 0);
+
+ RETURN (__mkSmallInteger(nWritten));
}
bad: ;
%}.
@@ -10384,7 +10384,7 @@
OBJ handle = __externalAddressVal(self);
if (__isSmallInteger(handle)) {
- RETURN (handle);
+ RETURN (handle);
}
%}.
^ nil
@@ -11059,131 +11059,131 @@
int code = -1;
if (__isSmallInteger(aSymbolOrInteger) || aSymbolOrInteger == nil) {
- RETURN(aSymbolOrInteger);
+ RETURN(aSymbolOrInteger);
}
#ifdef AF_INET
else if ((aSymbolOrInteger == @symbol(inet)) || (aSymbolOrInteger == @symbol(AF_INET)))
- code = AF_INET;
+ code = AF_INET;
#endif
#ifdef AF_INET6
else if ((aSymbolOrInteger == @symbol(inet6)) || (aSymbolOrInteger == @symbol(AF_INET6)))
- code = AF_INET6;
+ code = AF_INET6;
#endif
#ifdef AF_UNIX
else if ((aSymbolOrInteger == @symbol(unix)) || (aSymbolOrInteger == @symbol(AF_UNIX)))
- code = AF_UNIX;
+ code = AF_UNIX;
#endif
#ifdef AF_APPLETALK
else if ((aSymbolOrInteger == @symbol(appletalk)) || (aSymbolOrInteger == @symbol(AF_APPLETALK)))
- code = AF_APPLETALK;
+ code = AF_APPLETALK;
#endif
#ifdef AF_DECnet
else if ((aSymbolOrInteger == @symbol(decnet)) || (aSymbolOrInteger == @symbol(AF_DECnet)))
- code = AF_DECnet;
+ code = AF_DECnet;
#endif
#ifdef AF_NS
else if (aSymbolOrInteger == @symbol(AF_NS))
- code = AF_NS;
+ code = AF_NS;
#endif
#ifdef AF_X25
else if (aSymbolOrInteger == @symbol(AF_X25))
- code = AF_X25;
+ code = AF_X25;
#endif
#ifdef AF_SNA
else if (aSymbolOrInteger == @symbol(AF_SNA))
- code = AF_SNA;
+ code = AF_SNA;
#endif
#ifdef AF_RAW
else if ((aSymbolOrInteger == @symbol(raw)) || (aSymbolOrInteger == @symbol(AF_RAW)))
- code = AF_RAW;
+ code = AF_RAW;
#endif
#ifdef AF_ISO
else if ((aSymbolOrInteger == @symbol(iso)) || (aSymbolOrInteger == @symbol(AF_ISO)))
- code = AF_ISO;
+ code = AF_ISO;
#endif
#ifdef AF_NETBIOS
else if (aSymbolOrInteger == @symbol(AF_NETBIOS))
- code = AF_NETBIOS;
+ code = AF_NETBIOS;
#endif
#ifdef AF_NETBEUI
else if (aSymbolOrInteger == @symbol(AF_NETBEUI))
- code = AF_NETBEUI;
+ code = AF_NETBEUI;
#endif
#ifdef AF_IPX
else if (aSymbolOrInteger == @symbol(AF_IPX))
- code = AF_IPX;
+ code = AF_IPX;
#endif
#ifdef AF_AX25
else if (aSymbolOrInteger == @symbol(AF_AX25))
- code = AF_AX25;
+ code = AF_AX25;
#endif
#ifdef AF_NETROM
else if (aSymbolOrInteger == @symbol(AF_NETROM))
- code = AF_NETROM;
+ code = AF_NETROM;
#endif
#ifdef AF_BRIDGE
else if (aSymbolOrInteger == @symbol(AF_BRIDGE))
- code = AF_BRIDGE;
+ code = AF_BRIDGE;
#endif
#ifdef AF_BSC
else if (aSymbolOrInteger == @symbol(AF_BSC))
- code = AF_BSC;
+ code = AF_BSC;
#endif
#ifdef AF_ROSE
else if (aSymbolOrInteger == @symbol(AF_ROSE))
- code = AF_ROSE;
+ code = AF_ROSE;
#endif
#ifdef AF_IRDA
else if ((aSymbolOrInteger == @symbol(atmpvc)) || (aSymbolOrInteger == @symbol(AF_IRDA)))
- code = AF_IRDA;
+ code = AF_IRDA;
#endif
#ifdef AF_BAN
else if (aSymbolOrInteger == @symbol(AF_BAN))
- code = AF_BAN;
+ code = AF_BAN;
#endif
#ifdef AF_VOICEVIEW
else if (aSymbolOrInteger == @symbol(AF_VOICEVIEW))
- code = AF_VOICEVIEW;
+ code = AF_VOICEVIEW;
#endif
#ifdef AF_ATM
else if (aSymbolOrInteger == @symbol(AF_ATM))
- code = AF_ATM;
+ code = AF_ATM;
#endif
#ifdef AF_ATMPVC
else if (aSymbolOrInteger == @symbol(AF_ATMPVC))
- code = AF_ATMPVC;
+ code = AF_ATMPVC;
#endif
#ifdef AF_ATMSVC
else if (aSymbolOrInteger == @symbol(AF_ATMSVC))
- code = AF_ATMSVC;
+ code = AF_ATMSVC;
#endif
#ifdef AF_SECURITY
else if (aSymbolOrInteger == @symbol(AF_SECURITY))
- code = AF_SECURITY;
+ code = AF_SECURITY;
#endif
#ifdef AF_KEY
else if (aSymbolOrInteger == @symbol(AF_KEY))
- code = AF_KEY;
+ code = AF_KEY;
#endif
#ifdef AF_NETLINK
else if (aSymbolOrInteger == @symbol(AF_NETLINK))
- code = AF_NETLINK;
+ code = AF_NETLINK;
#endif
#ifdef AF_PACKET
else if (aSymbolOrInteger == @symbol(AF_PACKET))
- code = AF_PACKET;
+ code = AF_PACKET;
#endif
#ifdef AF_ASH
else if (aSymbolOrInteger == @symbol(AF_ASH))
- code = AF_ASH;
+ code = AF_ASH;
#endif
#ifdef AF_ECONET
else if (aSymbolOrInteger == @symbol(AF_ECONET))
- code = AF_ECONET;
+ code = AF_ECONET;
#endif
if (code > 0)
- domainCode = __MKSMALLINT(code);
+ domainCode = __MKSMALLINT(code);
%}.
^ domainCode.
@@ -11204,153 +11204,153 @@
%{ /*NOCONTEXT*/
if (__isSmallInteger(anInteger)) {
- switch(__intVal(anInteger)) {
+ switch(__intVal(anInteger)) {
#ifdef AF_INET
- case AF_INET:
- domainSymbol = @symbol(AF_INET);
- break;
+ case AF_INET:
+ domainSymbol = @symbol(AF_INET);
+ break;
#endif
#ifdef AF_INET6
- case AF_INET6:
- domainSymbol = @symbol(AF_INET6);
- break;
+ case AF_INET6:
+ domainSymbol = @symbol(AF_INET6);
+ break;
#endif
#ifdef AF_UNIX
- case AF_UNIX:
- domainSymbol = @symbol(AF_UNIX);
- break;
+ case AF_UNIX:
+ domainSymbol = @symbol(AF_UNIX);
+ break;
#endif
#ifdef AF_APPLETALK
- case AF_APPLETALK:
- domainSymbol = @symbol(AF_APPLETALK);
- break;
+ case AF_APPLETALK:
+ domainSymbol = @symbol(AF_APPLETALK);
+ break;
#endif
#ifdef AF_DECnet
- case AF_DECnet:
- domainSymbol = @symbol(AF_DECnet);
- break;
+ case AF_DECnet:
+ domainSymbol = @symbol(AF_DECnet);
+ break;
#endif
#ifdef AF_NS
- case AF_NS:
- domainSymbol = @symbol(AF_NS);
- break;
+ case AF_NS:
+ domainSymbol = @symbol(AF_NS);
+ break;
#endif
#ifdef AF_X25
- case AF_X25:
- domainSymbol = @symbol(AF_X25);
- break;
+ case AF_X25:
+ domainSymbol = @symbol(AF_X25);
+ break;
#endif
#ifdef AF_SNA
- case AF_SNA:
- domainSymbol = @symbol(AF_SNA);
- break;
+ case AF_SNA:
+ domainSymbol = @symbol(AF_SNA);
+ break;
#endif
#ifdef AF_RAW
- case AF_RAW:
- domainSymbol = @symbol(AF_RAW);
- break;
+ case AF_RAW:
+ domainSymbol = @symbol(AF_RAW);
+ break;
#endif
#ifdef AF_ISO
- case AF_ISO:
- domainSymbol = @symbol(AF_ISO);
- break;
+ case AF_ISO:
+ domainSymbol = @symbol(AF_ISO);
+ break;
#endif
#ifdef AF_NETBIOS
- case AF_NETBIOS:
- domainSymbol = @symbol(AF_NETBIOS);
- break;
+ case AF_NETBIOS:
+ domainSymbol = @symbol(AF_NETBIOS);
+ break;
#endif
#ifdef AF_IPX
- case AF_IPX:
- domainSymbol = @symbol(AF_IPX);
- break;
+ case AF_IPX:
+ domainSymbol = @symbol(AF_IPX);
+ break;
#endif
#ifdef AF_AX25
- case AF_AX25:
- domainSymbol = @symbol(AF_AX25);
- break;
+ case AF_AX25:
+ domainSymbol = @symbol(AF_AX25);
+ break;
#endif
#ifdef AF_NETROM
- case AF_NETROM:
- domainSymbol = @symbol(AF_NETROM);
- break;
+ case AF_NETROM:
+ domainSymbol = @symbol(AF_NETROM);
+ break;
#endif
#ifdef AF_BRIDGE
- case AF_BRIDGE:
- domainSymbol = @symbol(AF_BRIDGE);
- break;
+ case AF_BRIDGE:
+ domainSymbol = @symbol(AF_BRIDGE);
+ break;
#endif
#ifdef AF_BSC
- case AF_BSC:
- domainSymbol = @symbol(AF_BSC);
- break;
+ case AF_BSC:
+ domainSymbol = @symbol(AF_BSC);
+ break;
#endif
#ifdef AF_ROSE
- case AF_ROSE:
- domainSymbol = @symbol(AF_ROSE);
- break;
+ case AF_ROSE:
+ domainSymbol = @symbol(AF_ROSE);
+ break;
#endif
#ifdef AF_IRDA
- case AF_IRDA:
- domainSymbol = @symbol(AF_IRDA);
- break;
+ case AF_IRDA:
+ domainSymbol = @symbol(AF_IRDA);
+ break;
#endif
#ifdef AF_BAN
- case AF_BAN:
- domainSymbol = @symbol(AF_BAN);
- break;
+ case AF_BAN:
+ domainSymbol = @symbol(AF_BAN);
+ break;
#endif
#ifdef AF_VOICEVIEW
- case AF_VOICEVIEW:
- domainSymbol = @symbol(AF_VOICEVIEW);
- break;
+ case AF_VOICEVIEW:
+ domainSymbol = @symbol(AF_VOICEVIEW);
+ break;
#endif
#ifdef AF_ATM
- case AF_ATM:
- domainSymbol = @symbol(AF_ATM);
- break;
+ case AF_ATM:
+ domainSymbol = @symbol(AF_ATM);
+ break;
#endif
#ifdef AF_ATMPVC
- case AF_ATMPVC:
- domainSymbol = @symbol(AF_ATMPVC);
- break;
+ case AF_ATMPVC:
+ domainSymbol = @symbol(AF_ATMPVC);
+ break;
#endif
#ifdef AF_ATMSVC
- case AF_ATMSVC:
- domainSymbol = @symbol(AF_ATMSVC);
- break;
+ case AF_ATMSVC:
+ domainSymbol = @symbol(AF_ATMSVC);
+ break;
#endif
#ifdef AF_SECURITY
- case AF_SECURITY:
- domainSymbol = @symbol(AF_SECURITY);
- break;
+ case AF_SECURITY:
+ domainSymbol = @symbol(AF_SECURITY);
+ break;
#endif
#ifdef AF_KEY
- case AF_KEY:
- domainSymbol = @symbol(AF_KEY);
- break;
+ case AF_KEY:
+ domainSymbol = @symbol(AF_KEY);
+ break;
#endif
#ifdef AF_NETLINK
- case AF_NETLINK:
- domainSymbol = @symbol(AF_NETLINK);
- break;
+ case AF_NETLINK:
+ domainSymbol = @symbol(AF_NETLINK);
+ break;
#endif
#ifdef AF_PACKET
- case AF_PACKET:
- domainSymbol = @symbol(AF_PACKET);
- break;
+ case AF_PACKET:
+ domainSymbol = @symbol(AF_PACKET);
+ break;
#endif
#ifdef AF_ASH
- case AF_ASH:
- domainSymbol = @symbol(AF_ASH);
- break;
+ case AF_ASH:
+ domainSymbol = @symbol(AF_ASH);
+ break;
#endif
#ifdef AF_ECONET
- case AF_ECONET:
- domainSymbol = @symbol(AF_ECONET);
- break;
-#endif
- }
+ case AF_ECONET:
+ domainSymbol = @symbol(AF_ECONET);
+ break;
+#endif
+ }
}
%}.
@@ -11372,15 +11372,15 @@
%{
if (__isSmallInteger(aNameOrNumber) || aNameOrNumber == nil) {
- RETURN(aNameOrNumber);
+ RETURN(aNameOrNumber);
}
%}.
ProtocolCache notNil ifTrue:[
- protocolCode := ProtocolCache at:(aNameOrNumber asSymbol) ifAbsent:[].
- protocolCode notNil ifTrue:[
- ^ protocolCode.
- ].
+ protocolCode := ProtocolCache at:(aNameOrNumber asSymbol) ifAbsent:[].
+ protocolCode notNil ifTrue:[
+ ^ protocolCode.
+ ].
].
%{
@@ -11388,21 +11388,21 @@
struct protoent *protoent = 0;
if (__isString(aNameOrNumber) || __isSymbol(aNameOrNumber)) {
- protoent = getprotobyname((char *) __stringVal(aNameOrNumber));
- if (protoent) {
- protocolCode = __MKSMALLINT(protoent->p_proto);
- protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
- }
+ protoent = getprotobyname((char *) __stringVal(aNameOrNumber));
+ if (protoent) {
+ protocolCode = __MKSMALLINT(protoent->p_proto);
+ protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
+ }
}
#endif /*NO_SOCKET*/
%}.
protocolSymbol notNil ifTrue:[
- ProtocolCache isNil ifTrue:[
- ProtocolCache := IdentityDictionary new.
- ].
- "beware of polluting the protocol cache with aliases"
- ProtocolCache at:protocolSymbol put:protocolCode.
+ ProtocolCache isNil ifTrue:[
+ ProtocolCache := IdentityDictionary new.
+ ].
+ "beware of polluting the protocol cache with aliases"
+ ProtocolCache at:protocolSymbol put:protocolCode.
].
^ protocolCode
@@ -11419,10 +11419,10 @@
|protocolSymbol|
ProtocolCache notNil ifTrue:[
- protocolSymbol := ProtocolCache keyAtIdentityValue:anInteger ifAbsent:[].
- protocolSymbol notNil ifTrue:[
- ^ protocolSymbol.
- ].
+ protocolSymbol := ProtocolCache keyAtIdentityValue:anInteger ifAbsent:[].
+ protocolSymbol notNil ifTrue:[
+ ^ protocolSymbol.
+ ].
].
%{
@@ -11430,19 +11430,19 @@
struct protoent *protoent = 0;
if (__isSmallInteger(anInteger)) {
- protoent = getprotobynumber(__intVal(anInteger));
- if (protoent) {
- protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
- }
+ protoent = getprotobynumber(__intVal(anInteger));
+ if (protoent) {
+ protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
+ }
}
#endif /*NO_SOCKET*/
%}.
protocolSymbol notNil ifTrue:[
- ProtocolCache isNil ifTrue:[
- ProtocolCache := IdentityDictionary new.
- ].
- ProtocolCache at:protocolSymbol put:anInteger.
+ ProtocolCache isNil ifTrue:[
+ ProtocolCache := IdentityDictionary new.
+ ].
+ ProtocolCache at:protocolSymbol put:anInteger.
].
^ protocolSymbol
@@ -11466,151 +11466,151 @@
int size = -1;
if (__isSmallInteger(domainCode)) {
- switch (__intVal(domainCode)) {
+ switch (__intVal(domainCode)) {
#ifdef AF_INET
- case AF_INET:
- size = sizeof(struct sockaddr_in);
- break;
+ case AF_INET:
+ size = sizeof(struct sockaddr_in);
+ break;
#endif
#ifdef AF_INET6
- case AF_INET6:
- size = sizeof(struct sockaddr_in6);
- break;
+ case AF_INET6:
+ size = sizeof(struct sockaddr_in6);
+ break;
#endif
#ifdef AF_UNIX
- case AF_UNIX:
- size = sizeof(struct sockaddr_un);
- break;
+ case AF_UNIX:
+ size = sizeof(struct sockaddr_un);
+ break;
#endif
#ifdef AF_APPLETALK
- case AF_APPLETALK:
- size = sizeof(struct sockaddr_at);
- break;
+ case AF_APPLETALK:
+ size = sizeof(struct sockaddr_at);
+ break;
#endif
#ifdef AF_DECnet
- case AF_DECnet:
- size = sizeof(struct sockaddr_dn);
- break;
+ case AF_DECnet:
+ size = sizeof(struct sockaddr_dn);
+ break;
#endif
#ifdef AF_NS
- case AF_NS:
- size = sizeof(struct sockaddr_ns);
- break;
+ case AF_NS:
+ size = sizeof(struct sockaddr_ns);
+ break;
#endif
#ifdef AF_X25
- case AF_X25:
- size = sizeof(struct sockaddr_x25);
- break;
+ case AF_X25:
+ size = sizeof(struct sockaddr_x25);
+ break;
#endif
#ifdef AF_SNA
- case AF_SNA:
- size = sizeof(struct sockaddr_sna);
- break;
+ case AF_SNA:
+ size = sizeof(struct sockaddr_sna);
+ break;
#endif
#ifdef AF_RAW
- case AF_RAW:
- size = sizeof(struct sockaddr_raw);
- break;
+ case AF_RAW:
+ size = sizeof(struct sockaddr_raw);
+ break;
#endif
#ifdef AF_ISO
- case AF_ISO:
- size = sizeof(struct sockaddr_iso);
- break;
+ case AF_ISO:
+ size = sizeof(struct sockaddr_iso);
+ break;
#endif
#ifdef AF_NETBIOS
- case AF_NETBIOS:
- size = sizeof(struct sockaddr_netbios);
- break;
+ case AF_NETBIOS:
+ size = sizeof(struct sockaddr_netbios);
+ break;
#endif
#ifdef AF_NETBEUI
- case AF_NETBEUI:
- size = sizeof(struct sockaddr_netbeui);
- break;
+ case AF_NETBEUI:
+ size = sizeof(struct sockaddr_netbeui);
+ break;
#endif
#ifdef AF_IPX
- case AF_IPX:
- size = sizeof(struct sockaddr_ipx);
- break;
+ case AF_IPX:
+ size = sizeof(struct sockaddr_ipx);
+ break;
#endif
#ifdef AF_AX25
- case AF_AX25:
- size = sizeof(struct sockaddr_ax25);
- break;
+ case AF_AX25:
+ size = sizeof(struct sockaddr_ax25);
+ break;
#endif
#ifdef AF_NETROM
- case AF_NETROM:
- size = sizeof(struct sockaddr_netrom);
- break;
+ case AF_NETROM:
+ size = sizeof(struct sockaddr_netrom);
+ break;
#endif
#ifdef AF_BRIDGE
- case AF_BRIDGE:
- size = sizeof(struct sockaddr_bridge);
- break;
+ case AF_BRIDGE:
+ size = sizeof(struct sockaddr_bridge);
+ break;
#endif
#ifdef AF_BSC
- case AF_BSC:
- size = sizeof(struct sockaddr_bsc);
- break;
+ case AF_BSC:
+ size = sizeof(struct sockaddr_bsc);
+ break;
#endif
#ifdef AF_ROSE
- case AF_ROSE:
- size = sizeof(struct sockaddr_rose);
- break;
+ case AF_ROSE:
+ size = sizeof(struct sockaddr_rose);
+ break;
#endif
#ifdef AF_IRDA
- case AF_IRDA:
- size = sizeof(struct sockaddr_irda);
- break;
+ case AF_IRDA:
+ size = sizeof(struct sockaddr_irda);
+ break;
#endif
#ifdef AF_BAN
- case AF_BAN:
- size = sizeof(struct sockaddr_ban);
- break;
+ case AF_BAN:
+ size = sizeof(struct sockaddr_ban);
+ break;
#endif
#ifdef AF_VOICEVIEW
- case AF_VOICEVIEW:
- size = sizeof(struct sockaddr_voiceview);
- break;
+ case AF_VOICEVIEW:
+ size = sizeof(struct sockaddr_voiceview);
+ break;
#endif
#ifdef AF_ATM
- case AF_ATM:
- size = sizeof(struct sockaddr_atm);
- break;
+ case AF_ATM:
+ size = sizeof(struct sockaddr_atm);
+ break;
#endif
#ifdef AF_ATMPVC
- case AF_ATMPVC:
- size = sizeof(struct sockaddr_atmpvc);
- break;
+ case AF_ATMPVC:
+ size = sizeof(struct sockaddr_atmpvc);
+ break;
#endif
#ifdef AF_ATMSVC
- case AF_ATMSVC:
- size = sizeof(struct sockaddr_atmsvc);
- break;
+ case AF_ATMSVC:
+ size = sizeof(struct sockaddr_atmsvc);
+ break;
#endif
#ifdef AF_NETLINK
- case AF_NETLINK:
- size = sizeof(struct sockaddr_netlink);
- break;
+ case AF_NETLINK:
+ size = sizeof(struct sockaddr_netlink);
+ break;
#endif
#ifdef AF_PACKET
- case AF_PACKET:
- size = sizeof(struct sockaddr_packet);
- break;
+ case AF_PACKET:
+ size = sizeof(struct sockaddr_packet);
+ break;
#endif
#ifdef AF_ASH
- case AF_ASH:
- size = sizeof(struct sockaddr_ash);
- break;
+ case AF_ASH:
+ size = sizeof(struct sockaddr_ash);
+ break;
#endif
#ifdef AF_ECONET
- case AF_ECONET:
- size = sizeof(struct sockaddr_eco);
- break;
-#endif
- }
+ case AF_ECONET:
+ size = sizeof(struct sockaddr_eco);
+ break;
+#endif
+ }
}
if (size > 0)
- socketSize = __MKSMALLINT(size);
+ socketSize = __MKSMALLINT(size);
%}.
^ socketSize
!
@@ -11623,35 +11623,35 @@
int code = -1;
if (__isSmallInteger(aSymbolOrInteger) || aSymbolOrInteger == nil) {
- RETURN(aSymbolOrInteger);
+ RETURN(aSymbolOrInteger);
}
#ifdef SOCK_STREAM
else if ((aSymbolOrInteger == @symbol(stream)) || (aSymbolOrInteger == @symbol(SOCK_STREAM)))
- code = SOCK_STREAM;
+ code = SOCK_STREAM;
#endif
#ifdef SOCK_DGRAM
else if ((aSymbolOrInteger == @symbol(datagram)) || (aSymbolOrInteger == @symbol(SOCK_DGRAM)))
- code = SOCK_DGRAM;
+ code = SOCK_DGRAM;
#endif
#ifdef SOCK_RAW
else if ((aSymbolOrInteger == @symbol(raw)) || (aSymbolOrInteger == @symbol(SOCK_RAW)))
- code = SOCK_RAW;
+ code = SOCK_RAW;
#endif
#ifdef SOCK_RDM
else if ((aSymbolOrInteger == @symbol(rdm)) || (aSymbolOrInteger == @symbol(SOCK_RDM)))
- code = SOCK_RDM;
+ code = SOCK_RDM;
#endif
#ifdef SOCK_SEQPACKET
else if ((aSymbolOrInteger == @symbol(seqpacket)) || (aSymbolOrInteger == @symbol(SOCK_SEQPACKET)))
- code = SOCK_SEQPACKET;
+ code = SOCK_SEQPACKET;
#endif
#ifdef SOCK_PACKET
else if ((aSymbolOrInteger == @symbol(packet)) || (aSymbolOrInteger == @symbol(SOCK_PACKET)))
- code = SOCK_PACKET;
+ code = SOCK_PACKET;
#endif
if (code > 0)
- typeCode = __MKSMALLINT(code);
+ typeCode = __MKSMALLINT(code);
%}.
^ typeCode.
@@ -11670,38 +11670,38 @@
%{ /*NOCONTEXT*/
if (__isSmallInteger(anInteger)) {
- switch(__intVal(anInteger)) {
+ switch(__intVal(anInteger)) {
#ifdef SOCK_STREAM
- case SOCK_STREAM:
- socketTypeSymbol = @symbol(SOCK_STREAM);
- break;
+ case SOCK_STREAM:
+ socketTypeSymbol = @symbol(SOCK_STREAM);
+ break;
#endif
#ifdef SOCK_DGRAM
- case SOCK_DGRAM:
- socketTypeSymbol = @symbol(SOCK_DGRAM);
- break;
+ case SOCK_DGRAM:
+ socketTypeSymbol = @symbol(SOCK_DGRAM);
+ break;
#endif
#ifdef SOCK_RAW
- case SOCK_RAW:
- socketTypeSymbol = @symbol(SOCK_RAW);
- break;
+ case SOCK_RAW:
+ socketTypeSymbol = @symbol(SOCK_RAW);
+ break;
#endif
#ifdef SOCK_RDM
- case SOCK_RDM:
- socketTypeSymbol = @symbol(SOCK_RDM);
- break;
+ case SOCK_RDM:
+ socketTypeSymbol = @symbol(SOCK_RDM);
+ break;
#endif
#ifdef SOCK_SEQPACKET
- case SOCK_SEQPACKET:
- socketTypeSymbol = @symbol(SOCK_SEQPACKET);
- break;
+ case SOCK_SEQPACKET:
+ socketTypeSymbol = @symbol(SOCK_SEQPACKET);
+ break;
#endif
#ifdef SOCK_PACKET
- case SOCK_PACKET:
- socketTypeSymbol = @symbol(SOCK_PACKET);
- break;
-#endif
- }
+ case SOCK_PACKET:
+ socketTypeSymbol = @symbol(SOCK_PACKET);
+ break;
+#endif
+ }
}
%}.
^ socketTypeSymbol.
@@ -11960,24 +11960,24 @@
int ret, cnt = 0;
if (hostName == nil) {
- __hostName = 0;
+ __hostName = 0;
} else if (__isString(hostName) || __isSymbol(hostName)) {
- __hostName = __stringVal(hostName);
+ __hostName = __stringVal(hostName);
} else {
- error = @symbol(badArgument1);
- goto err;
+ error = @symbol(badArgument1);
+ goto err;
}
if (serviceName == nil) {
- __serviceName = 0;
+ __serviceName = 0;
} else if (__isString(serviceName) || __isSymbol(serviceName)) {
- __serviceName = __stringVal(serviceName);
+ __serviceName = __stringVal(serviceName);
} else {
- error = @symbol(badArgument2);
- goto err;
+ error = @symbol(badArgument2);
+ goto err;
}
if (__hostName == 0 && __serviceName == 0) {
- error = @symbol(badArgument);
- goto err;
+ error = @symbol(badArgument);
+ goto err;
}
{
@@ -11991,98 +11991,98 @@
memset(&hints, 0, sizeof(hints));
if (__isSmallInteger(domain))
- hints.ai_family = __intVal(domain);
+ hints.ai_family = __intVal(domain);
if (__isSmallInteger(type))
- hints.ai_socktype = __intVal(type);
+ hints.ai_socktype = __intVal(type);
if (__isSmallInteger(proto))
- hints.ai_protocol = __intVal(proto);
+ hints.ai_protocol = __intVal(proto);
do {
- __BEGIN_INTERRUPTABLE__
- ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
- __END_INTERRUPTABLE__
+ __BEGIN_INTERRUPTABLE__
+ ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
+ __END_INTERRUPTABLE__
} while (ret == EAI_SYSTEM && errno == EINTR);
if (ret != 0) {
- switch (ret) {
- case EAI_FAMILY:
- error = @symbol(badProtocol);
- break;
- case EAI_SOCKTYPE:
- error = @symbol(badSocketType);
- break;
- case EAI_BADFLAGS:
- error = @symbol(badFlags);
- break;
- case EAI_NONAME:
- error = @symbol(unknownHost);
- break;
- case EAI_SERVICE:
- error = @symbol(unknownService);
- break;
- case EAI_ADDRFAMILY :
- error = @symbol(unknownHostForProtocol);
- break;
- case EAI_NODATA:
- error = @symbol(noAddress);
- break;
- case EAI_MEMORY:
- error = @symbol(allocationFailure);
- break;
- case EAI_FAIL:
- error = @symbol(permanentFailure);
- break;
- case EAI_AGAIN:
- error = @symbol(tryAgain);
- break;
- case EAI_SYSTEM:
- error = @symbol(systemError);
- break;
- default:
- error = @symbol(unknownError);
- }
- errorString = __MKSTRING(gai_strerror(ret));
- goto err;
+ switch (ret) {
+ case EAI_FAMILY:
+ error = @symbol(badProtocol);
+ break;
+ case EAI_SOCKTYPE:
+ error = @symbol(badSocketType);
+ break;
+ case EAI_BADFLAGS:
+ error = @symbol(badFlags);
+ break;
+ case EAI_NONAME:
+ error = @symbol(unknownHost);
+ break;
+ case EAI_SERVICE:
+ error = @symbol(unknownService);
+ break;
+ case EAI_ADDRFAMILY :
+ error = @symbol(unknownHostForProtocol);
+ break;
+ case EAI_NODATA:
+ error = @symbol(noAddress);
+ break;
+ case EAI_MEMORY:
+ error = @symbol(allocationFailure);
+ break;
+ case EAI_FAIL:
+ error = @symbol(permanentFailure);
+ break;
+ case EAI_AGAIN:
+ error = @symbol(tryAgain);
+ break;
+ case EAI_SYSTEM:
+ error = @symbol(systemError);
+ break;
+ default:
+ error = @symbol(unknownError);
+ }
+ errorString = __MKSTRING(gai_strerror(ret));
+ goto err;
}
for (cnt=0, infop=info; infop; infop=infop->ai_next)
- cnt++;
+ cnt++;
result = __ARRAY_NEW_INT(cnt);
if (result == nil) {
- error = @symbol(allocationFailure);
- goto err;
+ error = @symbol(allocationFailure);
+ goto err;
}
for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
- OBJ o, resp;
-
- resp = __ARRAY_NEW_INT(6);
- if (resp == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
-
- __ArrayInstPtr(result)->a_element[cnt] = resp;
- __STORE(result, resp);
- __ArrayInstPtr(resp)->a_element[0] = __MKSMALLINT(infop->ai_flags);
- __ArrayInstPtr(resp)->a_element[1] = __MKSMALLINT(infop->ai_family);
- __ArrayInstPtr(resp)->a_element[2] = __MKSMALLINT(infop->ai_socktype);
- __ArrayInstPtr(resp)->a_element[3] = __MKSMALLINT(infop->ai_protocol);
- o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
- if (o == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
- memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
+ OBJ o, resp;
+
+ resp = __ARRAY_NEW_INT(6);
+ if (resp == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+
+ __ArrayInstPtr(result)->a_element[cnt] = resp;
+ __STORE(result, resp);
+ __ArrayInstPtr(resp)->a_element[0] = __MKSMALLINT(infop->ai_flags);
+ __ArrayInstPtr(resp)->a_element[1] = __MKSMALLINT(infop->ai_family);
+ __ArrayInstPtr(resp)->a_element[2] = __MKSMALLINT(infop->ai_socktype);
+ __ArrayInstPtr(resp)->a_element[3] = __MKSMALLINT(infop->ai_protocol);
+ o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
+ if (o == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+ memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
__ArrayInstPtr(resp)->a_element[4] = o;
- __STORE(resp, o);
- if (infop->ai_canonname) {
- o = __MKSTRING(infop->ai_canonname);
- if (o == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
- __ArrayInstPtr(resp)->a_element[5] = o;
- __STORE(resp, o);
- }
+ __STORE(resp, o);
+ if (infop->ai_canonname) {
+ o = __MKSTRING(infop->ai_canonname);
+ if (o == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+ __ArrayInstPtr(resp)->a_element[5] = o;
+ __STORE(resp, o);
+ }
}
err:
@@ -12099,130 +12099,130 @@
int i;
if (__serviceName) {
- struct servent *sp;
- char *__proto = 0;
-
- if (__isString(protoArg) || __isSymbol(protoArg))
- __proto = __stringVal(protoArg);
-
- sp = getservbyname(__serviceName, __proto);
- if (sp == NULL) {
- errorString = @symbol(unknownService);
- error = __mkSmallInteger(-3);
- goto err;
- }
- port = sp->s_port;
+ struct servent *sp;
+ char *__proto = 0;
+
+ if (__isString(protoArg) || __isSymbol(protoArg))
+ __proto = __stringVal(protoArg);
+
+ sp = getservbyname(__serviceName, __proto);
+ if (sp == NULL) {
+ errorString = @symbol(unknownService);
+ error = __mkSmallInteger(-3);
+ goto err;
+ }
+ port = sp->s_port;
}
if (__hostName) {
# ifdef USE_H_ERRNO
- do {
- /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
- * uses a static data area
- */
- __BEGIN_INTERRUPTABLE__
- hp = gethostbyname(__hostName);
- __END_INTERRUPTABLE__
- } while ((hp == NULL)
- && (
- (h_errno == TRY_AGAIN)
- || errno == EINTR
+ do {
+ /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
+ * uses a static data area
+ */
+ __BEGIN_INTERRUPTABLE__
+ hp = gethostbyname(__hostName);
+ __END_INTERRUPTABLE__
+ } while ((hp == NULL)
+ && (
+ (h_errno == TRY_AGAIN)
+ || errno == EINTR
# ifdef IRIX5_3
- || (errno == ECONNREFUSED)
+ || (errno == ECONNREFUSED)
# endif
- )
- );
- if (hp == 0) {
- switch (h_errno) {
- case HOST_NOT_FOUND:
- errorString = @symbol(unknownHost);
- break;
- case NO_ADDRESS:
- errorString = @symbol(noAddress);
- break;
- case NO_RECOVERY:
- errorString = @symbol(permanentFailure);
- break;
- case TRY_AGAIN:
- errorString = @symbol(tryAgain);
- break;
- default:
- errorString = @symbol(unknownError);
- break;
- }
- error = __mkSmallInteger(h_errno);
- goto err;
- }
+ )
+ );
+ if (hp == 0) {
+ switch (h_errno) {
+ case HOST_NOT_FOUND:
+ errorString = @symbol(unknownHost);
+ break;
+ case NO_ADDRESS:
+ errorString = @symbol(noAddress);
+ break;
+ case NO_RECOVERY:
+ errorString = @symbol(permanentFailure);
+ break;
+ case TRY_AGAIN:
+ errorString = @symbol(tryAgain);
+ break;
+ default:
+ errorString = @symbol(unknownError);
+ break;
+ }
+ error = __mkSmallInteger(h_errno);
+ goto err;
+ }
# else /* !USE_H_ERRNO */
- hp = gethostbyname(__hostName);
- if (hp == 0) {
- errorString = @symbol(unknownHost);
- error = __mkSmallInteger(-1);
- goto err;
- }
+ hp = gethostbyname(__hostName);
+ if (hp == 0) {
+ errorString = @symbol(unknownHost);
+ error = __mkSmallInteger(-1);
+ goto err;
+ }
# endif /* !USE_H_ERRNO*/
- if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
- errorString = @symbol(unknownHost);
- error = __mkSmallInteger(-2);
- goto err;
- }
-
- for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
- cnt++;
- addrpp = hp->h_addr_list;
+ if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
+ errorString = @symbol(unknownHost);
+ error = __mkSmallInteger(-2);
+ goto err;
+ }
+
+ for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
+ cnt++;
+ addrpp = hp->h_addr_list;
} else {
- cnt = 1;
+ cnt = 1;
}
result = __ARRAY_NEW_INT(cnt);
if (result == nil) {
- error = @symbol(allocationFailure);
- goto err;
+ error = @symbol(allocationFailure);
+ goto err;
}
for (i = 0; i < cnt; i++) {
- OBJ o, resp;
- struct sockaddr_in *sa;
-
- resp = __ARRAY_NEW_INT(6);
- if (resp == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
-
- __ArrayInstPtr(result)->a_element[i] = resp;
- __STORE(result, resp);
- __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
- __ArrayInstPtr(resp)->a_element[2] = type;
- __ArrayInstPtr(resp)->a_element[3] = proto;
- o = __BYTEARRAY_NEW_INT(sizeof(*sa));
- if (o == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
- __ArrayInstPtr(resp)->a_element[4] = o;
- __STORE(resp, o);
- sa = (struct sockaddr_in *)__byteArrayVal(o);
- sa->sin_port = port;
-
- if (__hostName) {
- sa->sin_family = hp->h_addrtype;
- memcpy(&sa->sin_addr, *addrpp, hp->h_length);
- __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
- if (hp->h_name) {
- o = __MKSTRING(hp->h_name);
- if (o == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
- __ArrayInstPtr(resp)->a_element[5] = o;
- __STORE(resp, o);
- }
- addrpp++;
- } else{
- __ArrayInstPtr(resp)->a_element[1] = domain;
- }
+ OBJ o, resp;
+ struct sockaddr_in *sa;
+
+ resp = __ARRAY_NEW_INT(6);
+ if (resp == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+
+ __ArrayInstPtr(result)->a_element[i] = resp;
+ __STORE(result, resp);
+ __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
+ __ArrayInstPtr(resp)->a_element[2] = type;
+ __ArrayInstPtr(resp)->a_element[3] = proto;
+ o = __BYTEARRAY_NEW_INT(sizeof(*sa));
+ if (o == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+ __ArrayInstPtr(resp)->a_element[4] = o;
+ __STORE(resp, o);
+ sa = (struct sockaddr_in *)__byteArrayVal(o);
+ sa->sin_port = port;
+
+ if (__hostName) {
+ sa->sin_family = hp->h_addrtype;
+ memcpy(&sa->sin_addr, *addrpp, hp->h_length);
+ __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
+ if (hp->h_name) {
+ o = __MKSTRING(hp->h_name);
+ if (o == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+ __ArrayInstPtr(resp)->a_element[5] = o;
+ __STORE(resp, o);
+ }
+ addrpp++;
+ } else{
+ __ArrayInstPtr(resp)->a_element[1] = domain;
+ }
}
err:;
@@ -12233,44 +12233,44 @@
#endif
%}.
error notNil ifTrue:[
- NameLookupError raiseWith:error errorString:errorString.
+ NameLookupError raiseWith:error errorString:errorString.
].
1 to:result size do:[:i |
- |entry dom info|
-
- info := SocketAddressInfo new.
- entry := result at:i.
- info flags:(entry at:1).
- info domain:(dom := self domainSymbolOf:(entry at:2)).
- info type:(self socketTypeSymbolOf:(entry at:3)).
- info protocol:(self protocolSymbolOf:(entry at:4)).
- info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
- info canonicalName:(entry at:6).
- result at:i put:info
+ |entry dom info|
+
+ info := SocketAddressInfo new.
+ entry := result at:i.
+ info flags:(entry at:1).
+ info domain:(dom := self domainSymbolOf:(entry at:2)).
+ info type:(self socketTypeSymbolOf:(entry at:3)).
+ info protocol:(self protocolSymbolOf:(entry at:4)).
+ info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
+ info canonicalName:(entry at:6).
+ result at:i put:info
].
^ result
"
self getAddressInfo:'localhost' serviceName:nil
- domain:nil type:nil protocol:nil flags:nil
+ domain:nil type:nil protocol:nil flags:nil
self getAddressInfo:'localhost' serviceName:nil
- domain:#inet type:#stream protocol:nil flags:nil
+ domain:#inet type:#stream protocol:nil flags:nil
self getAddressInfo:'localhost' serviceName:nil
- domain:#inet type:#stream protocol:#tcp flags:nil
+ domain:#inet type:#stream protocol:#tcp flags:nil
self getAddressInfo:'blurb.exept.de' serviceName:nil
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:'1.2.3.4' serviceName:'bla'
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:'localhost' serviceName:'echo'
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:nil serviceName:'echo'
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:nil serviceName:nil
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:'www.google.de' serviceName:nil
- domain:nil type:nil protocol:nil flags:nil
+ domain:nil type:nil protocol:nil flags:nil
self getAddressInfo:'smc1' serviceName:nil
- domain:nil type:nil protocol:nil flags:nil
+ domain:nil type:nil protocol:nil flags:nil
"
!
@@ -12302,20 +12302,20 @@
int nInstBytes, sockAddrSize;
if (wantHostName == true) {
- hp = host;
- hsz = sizeof(host);
+ hp = host;
+ hsz = sizeof(host);
}
if (wantServiceName == true) {
- sp = service;
- ssz = sizeof(service);
+ sp = service;
+ ssz = sizeof(service);
}
if (hp == 0 && sp == 0) {
- error = @symbol(badArgument);
- goto err;
+ error = @symbol(badArgument);
+ goto err;
}
if (!__isBytes(socketAddress)) {
- error = @symbol(badArgument1);
- goto err;
+ error = @symbol(badArgument1);
+ goto err;
}
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
@@ -12323,167 +12323,167 @@
sockAddrSize -= nInstBytes;
if (!__isSmallInteger(flags)) {
- error = @symbol(badArgument5);
- goto err;
+ error = @symbol(badArgument5);
+ goto err;
}
__flags = __intVal(flags);
#if defined(NI_NUMERICHOST)
if (useDatagram == true) {
- __flags |= NI_DGRAM;
+ __flags |= NI_DGRAM;
}
{
- bp = (char *)(__byteArrayVal(socketAddress));
- bp += nInstBytes;
- __BEGIN_INTERRUPTABLE__
- ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
- hp, hsz, sp, ssz, __flags);
- __END_INTERRUPTABLE__
+ bp = (char *)(__byteArrayVal(socketAddress));
+ bp += nInstBytes;
+ __BEGIN_INTERRUPTABLE__
+ ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
+ hp, hsz, sp, ssz, __flags);
+ __END_INTERRUPTABLE__
} while (ret == EAI_SYSTEM && errno == EINTR);
if (ret != 0) {
- switch (ret) {
- case EAI_FAMILY:
- error = @symbol(badProtocol);
- break;
- case EAI_SOCKTYPE:
- error = @symbol(badSocketType);
- break;
- case EAI_BADFLAGS:
- error = @symbol(badFlags);
- break;
- case EAI_NONAME:
- error = @symbol(unknownHost);
- break;
- case EAI_SERVICE:
- error = @symbol(unknownService);
- break;
- case EAI_ADDRFAMILY :
- error = @symbol(unknownHostForProtocol);
- break;
- case EAI_NODATA:
- error = @symbol(noAddress);
- break;
- case EAI_MEMORY:
- error = @symbol(allocationFailure);
- break;
- case EAI_FAIL:
- error = @symbol(permanentFailure);
- break;
- case EAI_AGAIN:
- error = @symbol(tryAgain);
- break;
- case EAI_SYSTEM:
- error = @symbol(systemError);
- break;
- default:
- error = @symbol(unknownError);
- }
- errorString = __MKSTRING(gai_strerror(ret));
- goto err;
+ switch (ret) {
+ case EAI_FAMILY:
+ error = @symbol(badProtocol);
+ break;
+ case EAI_SOCKTYPE:
+ error = @symbol(badSocketType);
+ break;
+ case EAI_BADFLAGS:
+ error = @symbol(badFlags);
+ break;
+ case EAI_NONAME:
+ error = @symbol(unknownHost);
+ break;
+ case EAI_SERVICE:
+ error = @symbol(unknownService);
+ break;
+ case EAI_ADDRFAMILY :
+ error = @symbol(unknownHostForProtocol);
+ break;
+ case EAI_NODATA:
+ error = @symbol(noAddress);
+ break;
+ case EAI_MEMORY:
+ error = @symbol(allocationFailure);
+ break;
+ case EAI_FAIL:
+ error = @symbol(permanentFailure);
+ break;
+ case EAI_AGAIN:
+ error = @symbol(tryAgain);
+ break;
+ case EAI_SYSTEM:
+ error = @symbol(systemError);
+ break;
+ default:
+ error = @symbol(unknownError);
+ }
+ errorString = __MKSTRING(gai_strerror(ret));
+ goto err;
}
# else /* ! NI_NUMERICHOST */
{
- /*
- * Do it using gethostbyaddr()
- */
- struct sockaddr_in *sa;
-
- if (sockAddrSize < sizeof(*sa)) {
- error = @symbol(badArgument1);
- goto err;
- }
- bp = (char *)(__byteArrayVal(socketAddress));
- bp += nInstBytes;
- sa = (struct sockaddr_in *)bp;
+ /*
+ * Do it using gethostbyaddr()
+ */
+ struct sockaddr_in *sa;
+
+ if (sockAddrSize < sizeof(*sa)) {
+ error = @symbol(badArgument1);
+ goto err;
+ }
+ bp = (char *)(__byteArrayVal(socketAddress));
+ bp += nInstBytes;
+ sa = (struct sockaddr_in *)bp;
- if (sp) {
- struct servent *servp;
- char *__proto = 0;
-
- __proto = (useDatagram == true ? "udp" : "tcp");
-
- servp = getservbyport(sa->sin_port, __proto);
- if (servp) {
- sp = servp->s_name;
- }
- }
- if (hp) {
- struct hostent *hostp;
+ if (sp) {
+ struct servent *servp;
+ char *__proto = 0;
+
+ __proto = (useDatagram == true ? "udp" : "tcp");
+
+ servp = getservbyport(sa->sin_port, __proto);
+ if (servp) {
+ sp = servp->s_name;
+ }
+ }
+ if (hp) {
+ struct hostent *hostp;
# ifdef USE_H_ERRNO
- do {
- /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
- */
- hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
- /* __END_INTERRUPTABLE__ */
- } while ((hp == NULL)
- && ((h_errno == TRY_AGAIN)
- || errno == EINTR
+ do {
+ /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
+ */
+ hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
+ /* __END_INTERRUPTABLE__ */
+ } while ((hostp == NULL)
+ && ((h_errno == TRY_AGAIN)
+ || errno == EINTR
# ifdef IRIX5_3
- || (errno == ECONNREFUSED)
+ || (errno == ECONNREFUSED)
# endif
- )
- );
- if (hp == 0) {
- switch (h_errno) {
- case HOST_NOT_FOUND:
- errorString = @symbol(unknownHost);
- break;
- case NO_ADDRESS:
- errorString = @symbol(noAddress);
- break;
- case NO_RECOVERY:
- errorString = @symbol(permanentFailure);
- break;
- case TRY_AGAIN:
- errorString = @symbol(tryAgain);
- break;
- default:
- errorString = @symbol(unknownError);
- break;
- }
- error = __mkSmallInteger(h_errno);
- goto err;
- }
+ )
+ );
+ if (hostp == 0) {
+ switch (h_errno) {
+ case HOST_NOT_FOUND:
+ errorString = @symbol(unknownHost);
+ break;
+ case NO_ADDRESS:
+ errorString = @symbol(noAddress);
+ break;
+ case NO_RECOVERY:
+ errorString = @symbol(permanentFailure);
+ break;
+ case TRY_AGAIN:
+ errorString = @symbol(tryAgain);
+ break;
+ default:
+ errorString = @symbol(unknownError);
+ break;
+ }
+ error = __mkSmallInteger(h_errno);
+ goto err;
+ }
# else /* !USE_H_ERRNO */
- hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
- if (hostp == 0) {
- errorString = @symbol(unknownHost);
- error = __mkSmallInteger(-1);
- goto err;
- }
+ hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
+ if (hostp == 0) {
+ errorString = @symbol(unknownHost);
+ error = __mkSmallInteger(-1);
+ goto err;
+ }
# endif /* !USE_H_ERRNO*/
- hp = hostp->h_name;
- }
+ hp = hostp->h_name;
+ }
}
# endif /* ! NI_NUMERICHOST */
if (hp)
- hostName = __MKSTRING(hp);
+ hostName = __MKSTRING(hp);
if (sp)
- serviceName = __MKSTRING(sp);
+ serviceName = __MKSTRING(sp);
err:;
#else
error = @symbol(notImplemented);
#endif
%}.
error notNil ifTrue:[
- NameLookupError raiseWith:error errorString:errorString.
- ^ nil
+ NameLookupError raiseWith:error errorString:errorString.
+ ^ nil
].
^ Array with:hostName with:serviceName
"
self getNameInfo:
- (self getAddressInfo:'localhost' serviceName:'echo'
- domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
- wantHostName:true wantServiceName:true datagram:false flags:0
+ (self getAddressInfo:'localhost' serviceName:'echo'
+ domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
+ wantHostName:true wantServiceName:true datagram:false flags:0
self getNameInfo:
- (self getAddressInfo:'exept.exept.de' serviceName:'echo'
- domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
- wantHostName:true wantServiceName:true datagram:false flags:0
+ (self getAddressInfo:'exept.exept.de' serviceName:'echo'
+ domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
+ wantHostName:true wantServiceName:true datagram:false flags:0
"
! !
@@ -12505,49 +12505,49 @@
int alen;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (peerOrNil != nil &&
- (!__isNonNilObject(peerOrNil) ||
- (__intVal(__ClassInstPtr(__qClass(peerOrNil))->c_flags) & ARRAYMASK) != BYTEARRAY)) {
- error = @symbol(badArgument2);
- goto err;
+ (!__isNonNilObject(peerOrNil) ||
+ (__intVal(__ClassInstPtr(__qClass(peerOrNil))->c_flags) & ARRAYMASK) != BYTEARRAY)) {
+ error = @symbol(badArgument2);
+ goto err;
}
sock = __smallIntegerVal(__INST(fd));
again:
if (peerOrNil == nil) {
- alen = 0;
- sap = 0;
+ alen = 0;
+ sap = 0;
} else {
- alen = __byteArraySize(peerOrNil);
- sap = (struct sockaddr *)__byteArrayVal(peerOrNil);
+ alen = __byteArraySize(peerOrNil);
+ sap = (struct sockaddr *)__byteArrayVal(peerOrNil);
}
newSock = accept(sock, sap, &alen);
if (newSock < 0) {
- switch (errno) {
- case EINTR:
- __HANDLE_INTERRUPTS__;
- goto again;
+ switch (errno) {
+ case EINTR:
+ __HANDLE_INTERRUPTS__;
+ goto again;
#ifdef EWOULDBLOCK
- case EWOULDBLOCK:
+ case EWOULDBLOCK:
# if defined(EAGAIN) && (EAGAIN != EWOULDBLOCK)
- case EAGAIN:
+ case EAGAIN:
# endif
#else
# ifdef EAGAIN
- case EAGAIN:
-# endif
-#endif
- RETURN(nil);
-
- default:
- error = __mkSmallInteger(errno);
- goto err;
- }
+ case EAGAIN:
+# endif
+#endif
+ RETURN(nil);
+
+ default:
+ error = __mkSmallInteger(errno);
+ goto err;
+ }
}
newFd = __mkSmallInteger(newSock);
@@ -12555,7 +12555,7 @@
#endif /* not NO_SOCKET */
%}.
error notNil ifTrue:[
- ^ self error:error.
+ ^ self error:error.
].
^ self class for:newFd
! !
@@ -12575,13 +12575,13 @@
int ret;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (!__isNonNilObject(socketAddress) ||
- (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
- error = @symbol(badArgument1);
- goto err;
+ (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
+ error = @symbol(badArgument1);
+ goto err;
}
sockaddr_size = __byteArraySize(socketAddress);
sock = __smallIntegerVal(__INST(fd));
@@ -12589,27 +12589,27 @@
again:
ret = bind(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
if (ret < 0) {
- if (errno == EINTR) {
- __HANDLE_INTERRUPTS__;
- goto again;
- } else {
- error = __mkSmallInteger(errno);
- goto err;
- }
+ if (errno == EINTR) {
+ __HANDLE_INTERRUPTS__;
+ goto again;
+ } else {
+ error = __mkSmallInteger(errno);
+ goto err;
+ }
}
err:;
#endif /* NO_SOCKET */
%}.
error notNil ifTrue:[
- ^ self error:error.
+ ^ self error:error.
].
^ nil
"
(Socket domain:#inet type:#stream)
- bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
- reuseAddress:false ;
+ bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
+ reuseAddress:false ;
yourself
"
! !
@@ -12628,8 +12628,8 @@
struct sockaddr sockaddr = { AF_UNSPEC };
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
sock = __smallIntegerVal(__INST(fd));
@@ -12640,17 +12640,17 @@
ret = connect(sock, &sockaddr, sizeof(sockaddr));
if (ret < 0) {
switch(errno) {
- case EINTR:
+ case EINTR:
# ifdef EAGAIN
- case EAGAIN:
-# endif
- __HANDLE_INTERRUPTS__;
- goto again;
-
- default:
- error = __MKSMALLINT(errno);
- break;
- }
+ case EAGAIN:
+# endif
+ __HANDLE_INTERRUPTS__;
+ goto again;
+
+ default:
+ error = __MKSMALLINT(errno);
+ break;
+ }
}
err:;
@@ -12658,7 +12658,7 @@
%}.
error notNil ifTrue:[
- ^ self error:error.
+ ^ self error:error.
].
!
@@ -12677,13 +12677,13 @@
int sockaddr_size;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (!__isNonNilObject(socketAddress) ||
- (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
- error = @symbol(badArgument1);
- goto err;
+ (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
+ error = @symbol(badArgument1);
+ goto err;
}
sock = __smallIntegerVal(__INST(fd));
sockaddr_size = __qSize(socketAddress);
@@ -12691,47 +12691,47 @@
again:
ret = connect(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
if (ret >= 0) {
- RETURN(true)
+ RETURN(true)
}
switch(errno) {
- case EINTR:
+ case EINTR:
# ifdef EAGAIN
- case EAGAIN:
-# endif
- __HANDLE_INTERRUPTS__;
- goto again;
+ case EAGAIN:
+# endif
+ __HANDLE_INTERRUPTS__;
+ goto again;
# if defined(EINPROGRESS) || defined(EALREADY)
# ifdef EINPROGRESS
- case EINPROGRESS:
+ case EINPROGRESS:
# endif
# ifdef EALREADY
- case EALREADY:
-# endif
- RETURN(false);
+ case EALREADY:
+# endif
+ RETURN(false);
# endif
default:
- error = __MKSMALLINT(errno);
- break;
+ error = __MKSMALLINT(errno);
+ break;
}
err:;
#endif /* NO_SOCKET */
%}.
error notNil ifTrue:[
- ^ self error:error.
+ ^ self error:error.
].
^ true
"
Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:7)
- withTimeout:nil.
+ withTimeout:nil.
Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:5768)
- withTimeout:nil.
+ withTimeout:nil.
Socket newTCP connectTo:(IPSocketAddress hostAddress:#[1 2 3 4] port:7)
- withTimeout:nil.
+ withTimeout:nil.
"
! !
@@ -12761,46 +12761,46 @@
int __flags, __startIndex, __nBytes;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (!__isSmallInteger(startIndex) ||
- (__startIndex = __intVal(startIndex)-1) < 0) {
- if (startIndex == nil) {
- __startIndex = 0;
- } else {
- error = @symbol(badArgument3);
- goto err;
- }
+ (__startIndex = __intVal(startIndex)-1) < 0) {
+ if (startIndex == nil) {
+ __startIndex = 0;
+ } else {
+ error = @symbol(badArgument3);
+ goto err;
+ }
}
if (__isSmallInteger(nBytes)) {
- __nBytes = __intVal(nBytes);
+ __nBytes = __intVal(nBytes);
} else if (nBytes == nil) {
- __nBytes = -1;
+ __nBytes = -1;
} else {
- error = @symbol(badArgument4);
- goto err;
+ error = @symbol(badArgument4);
+ goto err;
}
if (!__isInteger(flags)) {
- error = @symbol(badArgument5);
- goto err;
+ error = @symbol(badArgument5);
+ goto err;
}
__flags = __longIntVal(flags);
sock = __smallIntegerVal(__INST(fd));
oClass = __Class(aDataBuffer);
switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
- case BYTEARRAY:
- case WORDARRAY:
- case SWORDARRAY:
- case LONGARRAY:
- case SLONGARRAY:
- case FLOATARRAY:
- case DOUBLEARRAY:
- break;
- default:
- error = @symbol(badArgument2);
- goto err;
+ case BYTEARRAY:
+ case WORDARRAY:
+ case SWORDARRAY:
+ case LONGARRAY:
+ case SLONGARRAY:
+ case FLOATARRAY:
+ case DOUBLEARRAY:
+ break;
+ default:
+ error = @symbol(badArgument2);
+ goto err;
}
nInstVars = __intVal(_ClassInstPtr(oClass)->c_ninstvars);
@@ -12810,35 +12810,35 @@
objSize -= __startIndex;
if (__nBytes >= 0 &&__nBytes < objSize) {
- objSize = __nBytes;
+ objSize = __nBytes;
}
if (socketAddress == nil) {
- alen0 = 0;
+ alen0 = 0;
} else {
- if (!__isNonNilObject(socketAddress) ||
- (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
- error = @symbol(badArgument1);
- goto err;
- }
- alen0 = __byteArraySize(socketAddress);
+ if (!__isNonNilObject(socketAddress) ||
+ (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
+ error = @symbol(badArgument1);
+ goto err;
+ }
+ alen0 = __byteArraySize(socketAddress);
}
saPtr = (struct sockaddr *)0;
again:
alen = alen0;
if (alen)
- saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
+ saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
cp = (char *)__InstPtr(aDataBuffer) + nInstBytes;
n = recvfrom(sock, cp, objSize, __flags, saPtr, &alen);
if (n < 0) {
- if (errno == EINTR) {
- __HANDLE_INTERRUPTS__;
- goto again;
- } else {
- error = __MKSMALLINT(errno);
- goto err;
- }
+ if (errno == EINTR) {
+ __HANDLE_INTERRUPTS__;
+ goto again;
+ } else {
+ error = __MKSMALLINT(errno);
+ goto err;
+ }
}
RETURN (__mkSmallInteger(n));
#endif
@@ -12868,64 +12868,64 @@
int offs, __startIndex, __maxBytes;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (!__isSmallInteger(startIndex) ||
- (__startIndex = __intVal(startIndex)-1) < 0) {
- if (startIndex == nil) {
- __startIndex = 0;
- } else {
- error = @symbol(badArgument3);
- goto err;
- }
+ (__startIndex = __intVal(startIndex)-1) < 0) {
+ if (startIndex == nil) {
+ __startIndex = 0;
+ } else {
+ error = @symbol(badArgument3);
+ goto err;
+ }
}
if (__isSmallInteger(maxBytes)) {
- __maxBytes = __intVal(maxBytes);
+ __maxBytes = __intVal(maxBytes);
} else if (maxBytes == nil) {
- __maxBytes = -1;
+ __maxBytes = -1;
} else {
- error = @symbol(badArgument4);
- goto err;
+ error = @symbol(badArgument4);
+ goto err;
}
if (!__isInteger(flags)) {
- error = @symbol(badArgument5);
- goto err;
+ error = @symbol(badArgument5);
+ goto err;
}
__flags = __longIntVal(flags);
sock = __smallIntegerVal(__INST(fd));
oClass = __Class(aDataBuffer);
switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
- case BYTEARRAY:
- offs = __startIndex;
- break;
- case WORDARRAY:
- case SWORDARRAY:
- offs = __startIndex * 2;
- break;
- case LONGARRAY:
- case SLONGARRAY:
- offs = __startIndex * 4;
- break;
- case LONGLONGARRAY:
- case SLONGLONGARRAY:
- offs = __startIndex * 8;
+ case BYTEARRAY:
+ offs = __startIndex;
+ break;
+ case WORDARRAY:
+ case SWORDARRAY:
+ offs = __startIndex * 2;
+ break;
+ case LONGARRAY:
+ case SLONGARRAY:
+ offs = __startIndex * 4;
+ break;
+ case LONGLONGARRAY:
+ case SLONGLONGARRAY:
+ offs = __startIndex * 8;
# ifdef __NEED_LONGLONG_ALIGN
- offs += 4;
-# endif
- case FLOATARRAY:
- offs = __startIndex * sizeof(float);
- break;
- case DOUBLEARRAY:
- offs = __startIndex * sizeof(double);
+ offs += 4;
+# endif
+ case FLOATARRAY:
+ offs = __startIndex * sizeof(float);
+ break;
+ case DOUBLEARRAY:
+ offs = __startIndex * sizeof(double);
# ifdef __NEED_DOUBLE_ALIGN
- offs += 4;
-# endif
- break;
- default:
- error = @symbol(badArgument2);
- goto err;
+ offs += 4;
+# endif
+ break;
+ default:
+ error = @symbol(badArgument2);
+ goto err;
}
nInstVars = __smallIntegerVal(_ClassInstPtr(oClass)->c_ninstvars);
@@ -12934,35 +12934,35 @@
if (__maxBytes >= 0 && __maxBytes < objSize) {
# ifdef DGRAM_DEBUG
- printf("cut off ...\n");
-# endif
- objSize = __maxBytes;
+ printf("cut off ...\n");
+# endif
+ objSize = __maxBytes;
}
if (socketAddress == nil) {
- alen = 0;
+ alen = 0;
} else {
- if (! __isByteArray(socketAddress)) {
- error = @symbol(badArgument1);
- goto err;
- }
- alen = __byteArraySize(socketAddress);
+ if (! __isByteArray(socketAddress)) {
+ error = @symbol(badArgument1);
+ goto err;
+ }
+ alen = __byteArraySize(socketAddress);
}
saPtr = (struct sockaddr *)0;
again:
if (alen)
- saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
+ saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
cp = (char *)__InstPtr(aDataBuffer) + nInstBytes + offs;
n = sendto(sock, cp, objSize, __flags, saPtr, alen);
if (n < 0) {
- if (errno == EINTR) {
- __HANDLE_INTERRUPTS__;
- goto again;
- } else {
- error = __MKSMALLINT(errno);
- goto err;
- }
+ if (errno == EINTR) {
+ __HANDLE_INTERRUPTS__;
+ goto again;
+ } else {
+ error = __MKSMALLINT(errno);
+ goto err;
+ }
}
RETURN (__mkSmallInteger(n));
#endif
@@ -13134,12 +13134,12 @@
int sock, ret;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (!__isSmallInteger(aNumber)) {
- error = @symbol(badArgument1);
- goto err;
+ error = @symbol(badArgument1);
+ goto err;
}
sock = __smallIntegerVal(__INST(fd));
@@ -13147,19 +13147,19 @@
again:
ret = listen(sock, __smallIntegerVal(aNumber));
if (ret < 0) {
- if (errno == EINTR) {
- __HANDLE_INTERRUPTS__;
- goto again;
- } else {
- error = __mkSmallInteger(errno);
- }
+ if (errno == EINTR) {
+ __HANDLE_INTERRUPTS__;
+ goto again;
+ } else {
+ error = __mkSmallInteger(errno);
+ }
}
err:;
#endif
%}.
error notNil ifTrue:[
- ^ self error:error.
+ ^ self error:error.
].
^ nil
!
@@ -13177,48 +13177,48 @@
char *p;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (__isSmallInteger(level)) {
- __level = __smallIntegerVal(level);
+ __level = __smallIntegerVal(level);
} else if (level == @symbol(SOL_SOCKET)) {
- __level = SOL_SOCKET;
+ __level = SOL_SOCKET;
} else {
- error = @symbol(badArgument1);
- goto err;
+ error = @symbol(badArgument1);
+ goto err;
}
if (__isSmallInteger(name)) {
- __name = __smallIntegerVal(name);
+ __name = __smallIntegerVal(name);
} else if (name == @symbol(SO_REUSEADDR)) {
- __name = SO_REUSEADDR;
+ __name = SO_REUSEADDR;
} else {
- error = @symbol(badArgument2);
- goto err;
+ error = @symbol(badArgument2);
+ goto err;
}
if (__isSmallInteger(value)) {
- intval = __intVal(value);
- p = (char *) &intval;
- sz = sizeof(intval);
+ intval = __intVal(value);
+ p = (char *) &intval;
+ sz = sizeof(intval);
} else if (__isByteArray(value)) {
- p = __byteArrayVal(value);
- sz = __byteArraySize(value);
+ p = __byteArrayVal(value);
+ sz = __byteArraySize(value);
} else {
- error = @symbol(badArgument3);
- goto err;
+ error = @symbol(badArgument3);
+ goto err;
}
sock = __smallIntegerVal(__INST(fd));
if (setsockopt(sock, __level, __name, p, sz) < 0) {
- error = __mkSmallInteger(errno);
+ error = __mkSmallInteger(errno);
}
err:;
#endif
%}.
error notNil ifTrue:[
- ^ self error:error
+ ^ self error:error
].
^ nil.
!
@@ -13228,9 +13228,9 @@
anInteger == 0 no reads will be performed
anInteger == 1 no writes will be performed
anInteger == 2 neither reads nor writes will be performed.
- Pending data is discarded. This is faster tha
- close, which may wait until pending (written)
- data has been read by the other side"
+ Pending data is discarded. This is faster tha
+ close, which may wait until pending (written)
+ data has been read by the other side"
|error|
@@ -13239,30 +13239,30 @@
int ret;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (!__isSmallInteger(anInteger)) {
- error = @symbol(badArgument1);
- goto err;
+ error = @symbol(badArgument1);
+ goto err;
}
again:
ret = shutdown(__smallIntegerVal(__INST(fd)), __smallIntegerVal(anInteger));
if (ret < 0) {
- if (errno == EINTR) {
- __HANDLE_INTERRUPTS__;
- goto again;
- } else {
- error = __mkSmallInteger(errno);
- }
+ if (errno == EINTR) {
+ __HANDLE_INTERRUPTS__;
+ goto again;
+ } else {
+ error = __mkSmallInteger(errno);
+ }
}
err:;
#endif /*NO_SOCKET*/
%}.
error notNil ifTrue:[
- ^ self error:error
+ ^ self error:error
].
^ nil.
! !
@@ -13282,26 +13282,26 @@
int ret;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (!__isNonNilObject(socketAddress) ||
- (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
- error = @symbol(badArgument1);
- goto err;
+ (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
+ error = @symbol(badArgument1);
+ goto err;
}
sockaddr_size = __byteArraySize(socketAddress);
sock = __smallIntegerVal(__INST(fd));
ret = getsockname(sock, (struct sockaddr *)__byteArrayVal(socketAddress), &sockaddr_size);
if (ret < 0) {
- error = __MKSMALLINT(errno);
+ error = __MKSMALLINT(errno);
}
err:;
#endif /* NO_SOCKET */
%}.
error notNil ifTrue:[
- ^ self error:error
+ ^ self error:error
].
^ nil.
!
@@ -13319,27 +13319,27 @@
int __ret;
if (!__isSmallInteger(__INST(fd))) {
- error = @symbol(badFd);
- goto err;
+ error = @symbol(badFd);
+ goto err;
}
if (!__isNonNilObject(socketAddress) ||
- (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
- error = @symbol(badArgument1);
- goto err;
+ (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
+ error = @symbol(badArgument1);
+ goto err;
}
__sockaddr_size = __byteArraySize(socketAddress);
__sock = __smallIntegerVal(__INST(fd));
__ret = getpeername(__sock, (struct sockaddr *)__byteArrayVal(socketAddress),
- &__sockaddr_size);
+ &__sockaddr_size);
if (__ret < 0) {
- error = __mkSmallInteger(errno);
+ error = __mkSmallInteger(errno);
}
err:;
#endif /* NO_SOCKET */
%}.
error notNil ifTrue:[
- ^ self error:error
+ ^ self error:error
].
^ nil
! !
@@ -13347,7 +13347,7 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.170 2003-06-30 10:09:18 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.171 2003-07-01 11:15:10 stefan Exp $'
! !
UnixOperatingSystem initialize!