version 1.8, 2002/10/21 01:11:44 |
version 1.11, 2002/10/24 01:05:05 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/plugin/sm1Socket.c,v 1.7 2002/10/21 00:37:00 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/plugin/sm1Socket.c,v 1.10 2002/10/22 00:53:51 takayama Exp $ */ |
/* msg0s.c */ |
/* msg0s.c */ |
#include <stdio.h> |
#include <stdio.h> |
#include <sys/types.h> |
#include <sys/types.h> |
Line 574 struct object KsocketReadHTTP(struct object socketObj) |
|
Line 574 struct object KsocketReadHTTP(struct object socketObj) |
|
break; |
break; |
} |
} |
} |
} |
fprintf(stderr,"Waiting in socketReadBlock (spin lock to wait an empty line). flagmax(0d,0a)=%d, contentLength\n",flagmax,contentLength); |
fprintf(stderr,"Waiting in socketReadBlock (spin lock to wait an empty line). flagmax(0d,0a)=%d, content-length=%d, received content-length=%d\n",flagmax,contentLength,getReceivedContentLength(sss)); |
if (strlen(s) == 0) {fprintf(stderr,"but I'm not receiving data. Expecting a bug.\n"); |
if (strlen(s) == 0) {fprintf(stderr,"but I'm not receiving data. Expecting a bug.\n"); |
}else{ |
}else{ |
/* for debugging. */ |
/* for debugging. */ |
Line 582 struct object KsocketReadHTTP(struct object socketObj) |
|
Line 582 struct object KsocketReadHTTP(struct object socketObj) |
|
if ((sss[i] >= ' ') && (sss[i] < 0x7f)) { |
if ((sss[i] >= ' ') && (sss[i] < 0x7f)) { |
fprintf(stderr,"%c",sss[i]); |
fprintf(stderr,"%c",sss[i]); |
}else{ |
}else{ |
fprintf(stderr,"%3x",sss[i]); |
fprintf(stderr,"(%3x)",sss[i]); |
if (sss[i] == 0xa) fprintf(stderr,"\n"); |
if (sss[i] == 0xa) fprintf(stderr,"\n"); |
} |
} |
|
|
Line 642 struct object Kplugin_sm1Socket(char *key,struct objec |
|
Line 642 struct object Kplugin_sm1Socket(char *key,struct objec |
|
}else if (strcmp(key,"readHTTP") == 0) { |
}else if (strcmp(key,"readHTTP") == 0) { |
robj = KsocketReadHTTP(obj); |
robj = KsocketReadHTTP(obj); |
}else if (strcmp(key,"write") == 0) { |
}else if (strcmp(key,"write") == 0) { |
|
}else if (strcmp(key,"gethostname") == 0) { |
|
robj = KsocketGetHostName(); |
|
}else if (strcmp(key,"write") == 0) { |
robj = KsocketWrite(obj); |
robj = KsocketWrite(obj); |
}else if (strcmp(key,"read") == 0) { |
}else if (strcmp(key,"read") == 0) { |
robj = KsocketRead(obj); |
robj = KsocketRead(obj); |
Line 660 struct object Kplugin_sm1Socket(char *key,struct objec |
|
Line 663 struct object Kplugin_sm1Socket(char *key,struct objec |
|
|
|
static int getContentLength(char *s) { |
static int getContentLength(char *s) { |
int n; |
int n; |
int i; |
int i,j; |
int len = -1; |
int len = -1; |
char *s1 = "Content-length:"; |
char *s1 = "content-length:"; |
char *s2 = "CONTENT-LENGTH:"; |
char s0[256]; |
|
int m; |
|
m = strlen(s1); |
n = strlen(s); |
n = strlen(s); |
for (i=0; i<n; i++) { |
for (i=0; i<n; i++) { |
if ((strncmp(&(s[i]),s1,strlen(s1)) == 0) || |
strncpy(s0,&(s[i]),m+1); |
(strncmp(&(s[i]),s2,strlen(s2)) == 0)) { |
for (j=0; j<m; j++) { |
sscanf(&(s[i+strlen(s1)]),"%d",&len); |
if ((s0[j] >= 'A') && (s0[j] <= 'Z')) s0[j] = s0[j]+0x20; |
break; |
} |
} |
if (strncmp(s0,s1,strlen(s1)) == 0) { |
|
sscanf(&(s[i+strlen(s1)]),"%d",&len); |
|
break; |
|
} |
} |
} |
return len; |
return len; |
} |
} |
Line 692 static int getReceivedContentLength(char *s) { |
|
Line 700 static int getReceivedContentLength(char *s) { |
|
} |
} |
|
|
|
|
|
struct object KsocketGetHostName(void) { |
|
char name[1024]; |
|
char *s; |
|
struct object rob = NullObject; |
|
if (gethostname(name,1023) != 0) { |
|
return rob; |
|
} |
|
s = (char *)GC_malloc(sizeof(char)*(strlen(name)+2)); |
|
if (s == (char *)NULL) errorMsg1s("Out of Memory."); |
|
strcpy(s,name); |
|
return(KpoString(s)); |
|
} |
|
|
|
|
|
|