version 1.13, 2002/10/24 02:12:35 |
version 1.15, 2003/09/16 02:57:40 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/plugin/sm1Socket.c,v 1.12 2002/10/24 01:29:00 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/plugin/sm1Socket.c,v 1.14 2002/10/30 13:23:06 takayama Exp $ */ |
/* msg0s.c */ |
/* msg0s.c */ |
#include <stdio.h> |
#include <stdio.h> |
#include <sys/types.h> |
#include <sys/types.h> |
|
|
#include "sm1Socket.h" |
#include "sm1Socket.h" |
|
|
extern int Quiet; |
extern int Quiet; |
|
static int Post_debug=0; |
static void errorMsg1s(char *s); |
static void errorMsg1s(char *s); |
static int getContentLength(char *s); |
static int getContentLength(char *s); |
static int getReceivedContentLength(char *s); |
static int getReceivedContentLength(char *s); |
Line 30 struct object KsocketOpen(struct object obj) { |
|
Line 31 struct object KsocketOpen(struct object obj) { |
|
int on; |
int on; |
int tt; |
int tt; |
extern int errno; |
extern int errno; |
|
extern int Post_debug; |
|
|
|
if ((char *)getenv("OXWEB_DEBUG") != NULL) { |
|
Post_debug = 1; |
|
} |
|
|
if (obj.tag != Sarray) { |
if (obj.tag != Sarray) { |
errorMsg1s("KsocketOpen([optional integer,optional string name])"); |
errorMsg1s("KsocketOpen([optional integer,optional string name])"); |
} |
} |
Line 173 struct object KsocketAccept(struct object obj) { |
|
Line 179 struct object KsocketAccept(struct object obj) { |
|
} |
} |
s = KopInteger(obj1); |
s = KopInteger(obj1); |
if ((news = accept(s,NULL,NULL)) < 0) { |
if ((news = accept(s,NULL,NULL)) < 0) { |
errorMsg1s("Error in accept."); |
fprintf(stderr,"Error in accept. Retrying (KsocketAccept).\n"); |
|
/* Code added for strange behavior on cygwin. */ |
|
if ((news = accept(s,NULL,NULL)) < 0) { |
|
errorMsg1s("Error in accept. Retry failed."); |
|
} |
} |
} |
if (close(s) < 0) { |
if (close(s) < 0) { |
errorMsg1s("Error in closing the old socket."); |
errorMsg1s("Error in closing the old socket."); |
Line 209 struct object KsocketAccept2(struct object obj) { |
|
Line 219 struct object KsocketAccept2(struct object obj) { |
|
} |
} |
s = KopInteger(obj1); |
s = KopInteger(obj1); |
if ((news = accept(s,NULL,NULL)) < 0) { |
if ((news = accept(s,NULL,NULL)) < 0) { |
errorMsg1s("Error in accept."); |
fprintf(stderr,"Error in accept. Retrying (KsocketAccept2).\n"); |
|
/* Code added for strange behavior on cygwin. */ |
|
if ((news = accept(s,NULL,NULL)) < 0) { |
|
errorMsg1s("Error in accept. Retry failed."); |
|
} |
} |
} |
if (close(s) < 0) { |
if (close(s) < 0) { |
errorMsg1s("Error in closing the old socket."); |
errorMsg1s("Error in closing the old socket."); |
Line 582 struct object KsocketReadHTTP(struct object socketObj) |
|
Line 596 struct object KsocketReadHTTP(struct object socketObj) |
|
int last; |
int last; |
int contentLength=-1; |
int contentLength=-1; |
int socketid; |
int socketid; |
|
extern int Post_debug; |
nob = NullObject; |
nob = NullObject; |
|
|
if (socketObj.tag != Sarray) { |
if (socketObj.tag != Sarray) { |
Line 630 struct object KsocketReadHTTP(struct object socketObj) |
|
Line 645 struct object KsocketReadHTTP(struct object socketObj) |
|
break; |
break; |
} |
} |
} |
} |
fprintf(stderr,"Waiting in socketReadBlock. flagmax(0d,0a)=%d, content-length=%d, received content-length=%d\n",flagmax,contentLength,getReceivedContentLength(sss)); |
if (Post_debug) { |
|
fprintf(stderr,"Waiting in socketReadBlock. flagmax(0d,0a)=%d, content-length=%d, received content-length=%d\n",flagmax,contentLength,getReceivedContentLength(sss)); |
|
} |
if (strlen(s) == 0) { |
if (strlen(s) == 0) { |
fprintf(stderr,"No data. Perhaps connection is closed by foreign host.\n"); |
fprintf(stderr,"No data. Perhaps connection is closed by foreign host.\n"); |
return nob; |
return nob; |
}else{ |
}else{ |
/* for debugging. */ |
/* for debugging. */ |
for (i=0; i<strlen(sss); i++) { |
if (Post_debug) { |
if ((sss[i] >= ' ') && (sss[i] < 0x7f)) { |
for (i=0; i<strlen(sss); i++) { |
fprintf(stderr,"%c",sss[i]); |
if ((sss[i] >= ' ') && (sss[i] < 0x7f)) { |
}else{ |
fprintf(stderr,"%c",sss[i]); |
fprintf(stderr,"(%3x)",sss[i]); |
}else{ |
if (sss[i] == 0xa) fprintf(stderr,"\n"); |
fprintf(stderr,"(%3x)",sss[i]); |
} |
if (sss[i] == 0xa) fprintf(stderr,"\n"); |
|
} |
|
|
|
} |
|
fprintf(stderr,"\n"); |
} |
} |
fprintf(stderr,"\n"); |
|
} |
} |
|
|
if (KsocketSelect0(socketid,-1) != 1) { |
if (KsocketSelect0(socketid,-1) != 1) { |