프로그램을 직접 돌려서 출력값을 눈으로 보는 것이 소스를 이해 하는게 더 빠를 것 같아 질문을 다시 올립니다.
WaitHtime 함수의 출력 값을 보기 위한 메인 함수를 구현 하고 싶은데요... 제가 워낙 c언어 초짜라 어떻게 해야 될지 모르겠습니다.
pos는 83,hsec는 100 이며 Emergency는 0 또는 1 아무거나여도 상관 없습니다.
이 프로그램을 만든 사람이랑 연락 두절 상태라 물어볼데가 없습니다. 부디 좋은 답변 부탁드립니다.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
unsigned long _Time2HSec(int hour, int min, int sec, int msec)
{
long secs;
secs = hour*360000L + min*6000L + sec*100L + msec;
return secs;
}
unsigned long Time2HSec(struct time ct)
{
return
_Time2HSec(ct.ti_hour % 24,
ct.ti_min % 60,
ct.ti_sec % 60,
ct.ti_hund %100);
}
int WaitHTime(int pos, long hsec)
{
int EmerGency;
static unsigned long TS[100],TE[100];
struct time t1,t2;
static int TA[100],init=0;
if(EmerGenCy){ TA[pos]=0; return 0;}
if(pos<0 || pos>99) return 0;
if(!init) for(init=0; init<100; init++) TA[init]=0;
if(!hsec) {TA[pos]=0; return 0;}
disable();
if(!TA[pos]) {gettime(&t1); TS[pos]=Time2HSec(t1)+hsec; TA[pos]=-1;}
gettime(&t2); TE[pos]=Time2HSec(t2);
if((long)(TS[pos]-TE[pos])>4320000L) TE[pos]+=24L*60L*60L*100L;
if(TS[pos]<=TE[pos]) TA[pos]=0;
enable();
return TA[pos];
}
|