DWORD WINAPI ThreadProc(LPVOID lpParam){
PipeStruct *p=(PipeStruct *) lpParam;
- while(!p->EOF_()){
+ while(!p->EOF_input()){
if(p->nReadEnd<LINE_INPUT_MAX_CHAR-1){
p->ReadInput();
}else{
CloseHandle(hProcess);
}
-bool PipeStruct::EOF_(void){ // EOF is defined
+bool PipeStruct::EOF_input(void){ // EOF is defined
int ret;
EnterCriticalSection(&CriticalSection);
ret=state&PIPE_EOF;
return ret;
}
-void PipeStruct::set_EOF_(void){
+void PipeStruct::set_EOF_input(void){
EnterCriticalSection(&CriticalSection);
state|=PIPE_EOF;
LeaveCriticalSection(&CriticalSection);
// This just means we have read less than we could have.
ret=fgets(lpReadBuffer,LINE_INPUT_MAX_CHAR-nReadEnd,fpInput);
if(!ret){
- set_EOF_();
+ set_EOF_input();
lpReadBuffer[0]='\0';
return 0;
}
// would block during the blocking read
ret=ReadData();
EnterCriticalSection(&CriticalSection);
- if(!EOF_()){
+ if(!EOF_input()){
if(ret+nReadEnd>=LINE_INPUT_MAX_CHAR){
my_fatal("PipeStruct::ReadInput(): Internal error: buffer overflow\n");
}
}
}
LeaveCriticalSection(&CriticalSection);
- if(EOF_() || bSetEvent){
+ if(EOF_input() || bSetEvent){
SetEvent(hEvent);
}
}
+bool PipeStruct::EOF_(void){
+ int ret;
+ EnterCriticalSection(&CriticalSection);
+ if(lpFeedEnd != NULL){
+ ret=FALSE;
+ }else if(EOF_input()){
+ ret=TRUE;
+ }else{
+ ret=FALSE;
+ }
+ LeaveCriticalSection(&CriticalSection);
+ return ret;
+}
+
bool PipeStruct::GetBuffer(char *szLineStr) {
int nFeedEnd;
int ret;
return ret;
}
+
+
void PipeStruct::LineInput(char *szLineStr) {
- while(!EOF_()){
+ while(!EOF_()){
if (GetBuffer(szLineStr)) {
break;
}else{