Example #1
0
void ChangeParam(tParam *p, tComplex *c){
	int flag = 1;
	printf("Welchen Parameter moechtest du aendern?\n");
	printf("(1) - Radius\n(2) - Maximale Iterationszahl\n(3) - Fraktaltyp\n(4) - Analysegebiet\n");
	printf("(5) - Linien im Analysegebiet\n(6) - c\n(0) - Ich bin fertig!\n");
	int choice;
	InputInt(&choice);
	while(flag){
	switch (choice){
	case 1:
		printf("Der alte Radius beträgt %lf. Bitte gib einen neuen an.\n", p->radius);
		InputDouble(&p->radius);
		break;
	case 2:
		printf("Der alte imax-Wert beträgt %d. Bitte gib einen neuean an.\n", p->imax);
		InputInt(&p->imax);
		break;
	case 3:
		printf("Der alte Fraktaltyp ist %d. Bitte gib einen neuen ein.\n", p->ftype);
		printf("Tipp: 0 - Apfel, 1- Julia\n");
		if (InputChar() == '0') p->ftype=apfel; else if (InputChar() == '1') p->ftype=julia; else ;
		break;
	case 4:
		printf("Das alte Analysegebiet: %lf<=x<=%lf; %lf<=y<=%lf. Bitte gib ein neues ein.\n", p->xmin, p->xmax, p->ymin, p->ymax);
		printf("x geht von ");
		InputDouble(&p->xmin);
		printf("%lf bis ", p->xmin);
		InputDouble(&p->xmax);
		printf("%lf\ny geht von ", p->xmax);
		InputDouble(&p->ymin);
		printf("%lf bis ", p->ymin);
		InputDouble(&p->ymax);
		printf("%lf.\n", p->ymax);
		break;
	case 5:
		printf("Die alte Linienzahlen sind: x=%d y=%d. Bitte gib neue Werte ein.\n Linien in x-Richtung: ", p->xpoints, p->ypoints);
		InputInt(&p->xpoints);
		printf("%d und in y-Richtung: ", p->xpoints);
		InputInt(&p->ypoints);
		printf("%d.\n", p->ypoints);
		break;
	case 6:
		printf("Der alte Wert für c beträgt: %lf+j(%lf). Bitte gib eien neuen ein.\n", c->x, c->y);
		printf("Realteil ");
		InputDouble(&c->x);
		printf("%lf und Imaginärteil ", c->x);
		InputDouble(&c->y);
		printf("%lf\n", c->y);
		break;
	case 0:
		flag = 0;
		break;
	}
	}
}
Example #2
0
static void InputString(const std::string & str, unsigned int nWaitMs)
{
	for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
	{
		unsigned char uchar = (unsigned char)*it;
		InputChar(uchar, nWaitMs);
	}
}
 void ActiveWidget::Init()
 {
     _handlers = new MethodPool<ActiveWidget, const Widget::Request >;
     _handlers->Add( &ActiveWidget::AcceptInputCursor,    InputCursor()  );
     _handlers->Add( &ActiveWidget::AcceptInputButton,    InputButton()  );
     _handlers->Add( &ActiveWidget::AcceptDoubleClick,    DoubleClick()  );
     _handlers->Add( &ActiveWidget::AcceptInputWheel ,    InputWheel()   );
     _handlers->Add( &ActiveWidget::AcceptInputReset ,    InputReset()   );
     _handlers->Add( &ActiveWidget::AcceptInputKeyboard , InputKeyboard());
     _handlers->Add( &ActiveWidget::AcceptInputChar ,     InputChar()    );
     _handlers->Add( &ActiveWidget::AcceptInputFocus,     InputFocus()   );
     _handlers->Add( &ActiveWidget::AcceptInputAccel,     InputAccel()   );
 }
Example #4
0
int ParamDialog(tParam *p, tComplex *c){
										//if failure: 0
										//else 1
	DisplayParam(p, c);
	printf("Sollen Parameter geändert werden?\n(j) Ja, bitte.\n(n) Nein, danke.\n(e) Programm beenden!");
	switch (InputChar()){
	case 'j':
		do {
			ChangeParam(p, c);			//Vllt sollte man eine maxAnzahl an Versuchen in Erwähgung ziehen?
		} while(validation(p,c) == 0);	//Schleife wird erst verlassen, wenn Werte Sinn machen.
		return 1;
		break;
	case 'n':
		return 1;
		break;
	case 'e':
		return 0;
		break;
	}
	return 0;
}
Example #5
0
///[주유소 리스트 정보 추출]/////: 1060
int main(void)
{
    int len, wlen, rlen ;
    struct sockaddr_in serv_addr;

    OPW_HEADER hd ;
    OPW_RESULT rd ;

    char search_opt[D_SEARCH_OPT_SIZE+1] = {'\0'} ;

    int i ;

    OPW_LIST_REQ in ;
    OPW_LIST_INFO *out = NULL ;

    int search_num = 0 ;
    int start_pos = 0 ;
    int pole = 0 ;
    int sort_opt = 0 ;

    memset(&hd, 0, sizeof(OPW_HEADER)) ;
    memset(&rd, 0, sizeof(OPW_RESULT)) ;
    memset(&in, 0, sizeof(OPW_LIST_REQ)) ;

    printf("====[OPW_HEADER]====\n") ;
    hd.serviceid = htonl(OPW_LIST) ;
    InputInt("hd.mdn", &(hd.mdn), 1031993325) ;
    hd.mdn = htonl(hd.mdn) ;
    InputChar("hd.menu_id", &(hd.menu_id), 'O') ;
    printf("oiltype: G-휘발유 K-경유 L-LPG A-ALL\n") ;
    InputChar("hd.oil_type", &(hd.oil_type), 'A') ;
    printf("search_opt: AL-좌표로 검색 IL-주소로 검색\n") ;
    InputString("hd.search_opt", search_opt, D_SEARCH_OPT_SIZE+1, "AL") ;
    memcpy(hd.search_opt, search_opt, D_SEARCH_OPT_SIZE) ;

    printf("====[OPW_LIST_REQ]====\n") ;
    memset(&in, 0, sizeof(OPW_LIST_REQ)) ;
    InputInt("in.search_num", &(search_num), 10) ;
    InputInt("in.start_pos", &(start_pos), 0) ;

    printf("pole: 3072-LPG 16-SK 32-GS 64-H-OIL 128-S-OIL 512-기타 144-(SK or S-OIL) 0-ALL\n") ;
    InputInt("in.pole", &(pole), 0) ;
    printf("pole: 1-휘발유 가격순 2-경유 가격순 4-LPG 가격순 5-거리순 6-휘발유/경유/LPG 순서\n") ;
    InputInt("in.sort_opt", &(sort_opt), 6) ;

    if(!strcmp(search_opt, "AL")) {			//좌표로 검색
        InputInt("in.x", &(in.x), 320821) ;
        InputInt("in.y", &(in.y), 551729) ;
        InputInt("in.radius", &(in.radius), 5000) ;
    }
    else if(!strcmp(search_opt, "IL")) {	//주소로 검색
        InputString("cido", in.sido, D_SIDO_SIZE, "인천광역시") ;
        InputString("gugun", in.gugun, D_GUGUN_SIZE, "") ;
        InputString("dong", in.dong, D_DONG_SIZE, "") ;
    }
    else {	//잘못된 선택
        return 0 ;
    }
//	sprintf(in.sido, "인천광역시") ;
//	sprintf(in.gugun, "계양구") ;

    in.search_num = htonl(search_num) ;
    in.start_pos = htonl(start_pos) ;
    in.x = htonl(in.x) ;
    in.y = htonl(in.y) ;
    in.radius = htonl(in.radius) ;
    in.nr_num = htonl(in.nr_num) ;

    in.pole = pole ;
    in.sort_opt = sort_opt ;

    in.pole = htons(in.pole) ;
    in.sort_opt = htons(in.sort_opt) ;

    memset((char *) &serv_addr, 0, sizeof(serv_addr)) ;
    serv_addr.sin_family = AF_INET ;
    serv_addr.sin_addr.s_addr = inet_addr(SM_SERVER_IP) ;
    serv_addr.sin_port = htons(SM_SERVER_PORT) ;

    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
        printf("clientsoc: can't open stream socket") ;
        close(sockfd), exit(0);
    }

    if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
        printf("clientsoc: can't connect to server") ;
        close(sockfd), exit(0);
    }

    if((wlen = write(sockfd, &hd, sizeof(OPW_HEADER))) <= 0) {
        printf("ERR: write OPW_HEADER[wlen:%d]\n", wlen) ;
        close(sockfd), exit(1) ;
    }
    printf("SEND: OPW_HEADER[wlen:%d]\n", wlen) ;

    if((wlen = write(sockfd, &in, sizeof(OPW_LIST_REQ))) < 0) {
        printf("ERR: write OPW_LIST_REQ\n") ;
        close(sockfd), exit(1) ;
    }
    printf("SEND: OPW_LIST_REQ[wlen:%d]\n", wlen) ;

    if ((rlen = read(sockfd, &rd, sizeof(OPW_RESULT))) <= 0) {
        printf("ERR: read OPW_RESULT[rlen:%d]...\n", rlen) ;
        close(sockfd), exit(1) ;
    }
    printf("READ: OPW_RESULT[rlen:%d]\n", rlen) ;
    rd.res_code = ntohl(rd.res_code) ;
    rd.total_num = ntohl(rd.total_num) ;
    rd.search_num = ntohl(rd.search_num) ;
    printf("OPW_RESULT: res_code[%d] total_num[%d] search_num[%d]\n", rd.res_code, rd.total_num, rd.search_num) ;

    if(rd.res_code == M_TRUE) {
        out = (OPW_LIST_INFO *) malloc (rd.search_num * sizeof(OPW_LIST_INFO)) ;
        memset(out, 0, rd.search_num * sizeof(OPW_LIST_INFO)) ;

        for(i = 0 ; i < rd.search_num; i++) {
            if((rlen = read(sockfd, &(out[i]), sizeof(OPW_LIST_INFO))) <= 0) {
                printf("ERR: [%d] read OPW_LIST_INFO(%d)\n", i, rlen) ;
                if(out != NULL) free(out), out = NULL ;
                close(sockfd), exit(1) ;
            }
            //	printf("READ: OPW_LIST_INFO(%d) Len:[%d]\n", i, rlen) ;
        }
        for(i = 0 ; i < rd.search_num; i ++) {
            out[i].id = ntohl(out[i].id) ;
            out[i].pole = ntohl(out[i].pole) ;
            out[i].g_price = ntohs(out[i].g_price) ;
            out[i].k_price = ntohs(out[i].k_price) ;
            out[i].d_price = ntohs(out[i].d_price) ;
            out[i].l_price = ntohs(out[i].l_price) ;
            out[i].update_date = ntohl(out[i].update_date) ;
            out[i].update_time = ntohl(out[i].update_time) ;
            out[i].x = ntohl(out[i].x) ;
            out[i].y = ntohl(out[i].y) ;
            out[i].distance = ntohl(out[i].distance) ;


            printf("[%d]-ID[%d]NAME[%.52s] POLE[%d]G[%d]K[%d]D[%d]L[%d]DATE[%d]TIME[%d]X[%d]Y[%d]DISTANCE[%d]\n",
                   i, out[i].id, out[i].name, out[i].pole,
                   out[i].g_price, out[i].k_price, out[i].d_price, out[i].l_price,
                   out[i].update_date, out[i].update_time,
                   out[i].x, out[i].y, out[i].distance) ;
        }
        if(out != NULL) free(out) ;
    }

    exit_handler() ;
}
Example #6
0
int main(void)
{
	REQUEST_HD hd;
	REQUEST_MULTI_CCTV hdc;
	RESPONSE_HD rd;

	int i, rlen, wlen, len;
	struct sockaddr_in serv_addr;
	int ret, ret_size = 0;

	char *info = NULL;
	char *data = NULL;

	char filename[256];

	FILE *fp;

	char *fdata = NULL;
	short fnum = 0;
	short fclass = 0;
	int fsize = 0;
	long uncompsize = 0;
	char data_time[12+1];
	char f_h;
	int f_e = 0, f_id = 0;

	int idlist1[120] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 87, 88, 89, 90, 91, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125};
	//int idlist1[119] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 83, 84, 85, 86, 87, 88, 89, 90, 91, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125};

	//int idlist2[10] = {1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 217, 218};
	int idlist2[145] = {1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 217, 218, 219, 220, 221, 222, 
		223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235,
	    236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 282, 284, 285,
	    286, 287, 288, 289, 290, 291, 437, 438, 439, 440, 441, 442, 443,
	    444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 474,
	    475, 476, 477, 478, 479, 480, 699, 700, 701, 702, 703, 704, 705,
	    706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719,
	    720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 925,
	    926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939,
	    940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 
	    953, 954, 955, 956, 957, 958, 959, 960, 961, 991};

	memset(&hd, 0x00, sizeof(hd));
	memset(&rd, 0x00, sizeof(rd));
	memset(&hdc, 0x00, sizeof(hdc));

	hd.version = htonl(100);
	hd.serviceid = htonl(2000);
	printf("--------IN------\n");
	InputChar("D or E", &hdc.sourceFlag, 'D');

	memset((char *) &serv_addr, 0, sizeof(serv_addr)) ;
	serv_addr.sin_family = AF_INET ;
	serv_addr.sin_addr.s_addr = inet_addr(SM_SERVER_IP) ;
	serv_addr.sin_port = htons(SM_SERVER_PORT) ;

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printf("clientsoc: can't open stream socket") ;
		close(sockfd), exit(0);
	}

	if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
		printf("clientsoc: can't connect to server") ;
		close(sockfd), exit(0);
	}

	if ((wlen = write(sockfd, &hd, sizeof(hd))) <= 0) {
		printf("ERR: IN(wlen:%d)\n", wlen);
		close(sockfd), exit(1);
	}
	printf("SEND: IN[wlen:%d]\n", wlen);

	if (hdc.sourceFlag == 'D') {
		hdc.IDNum = htons(120);
		if ((wlen = write(sockfd, &hdc, sizeof(hdc))) <= 0) {
			printf("ERR: IN(wlen:%d)\n", wlen);
			close(sockfd), exit(1);
		}
		for (i = 0; i < 120; i++) {
			printf("ID(%d)", idlist1[i]);
			idlist1[i] = htonl(idlist1[i]);
			if ((wlen = write(sockfd, &idlist1[i], sizeof(int))) <= 0) {
				printf("ERR: IN(wlen:%d)\n", wlen);
				close(sockfd), exit(1);
			}
		}
		printf("\n");
	}
	else if (hdc.sourceFlag == 'E') {
		hdc.IDNum = htons(145);
		if ((wlen = write(sockfd, &hdc, sizeof(hdc))) <= 0) {
			printf("ERR: IN(wlen:%d)\n", wlen);
			close(sockfd), exit(1);
		}
		for (i = 0; i < 145; i++) {
			idlist2[i] = htonl(idlist2[i]);
			if ((wlen = write(sockfd, &idlist2[i], sizeof(int))) <= 0) {
				printf("ERR: IN(wlen:%d)\n", wlen);
				close(sockfd), exit(1);
			}
		}
	}
	printf(">>SEND: IDLIST\n");
		
	if ((rlen = read(sockfd, &rd, sizeof(rd))) <= 0) {
		printf("ERR: OUT(rlen:%d)\n", rlen);
		close(sockfd), exit(1);
	}
	printf("RECEIVE: OUT[rlen:%d]\n", rlen);

	rd.error_code = ntohl(rd.error_code);
	rd.version = ntohl(rd.version);
	rd.serviceid = ntohl(rd.serviceid);
	rd.file_num = ntohl(rd.file_num);
	rd.comp_flag = ntohl(rd.comp_flag);
	rd.uncomp_size = ntohl(rd.uncomp_size);
	rd.comp_size = ntohl(rd.comp_size);

	printf("ECODE[%d] VER[%d] SID[%d] FNUM[%d] CFLAG[%d] UNC_SIZE[%d] C_SIZE[%d]\n", rd.error_code, rd.version, rd.serviceid, rd.file_num, rd.comp_flag, rd.uncomp_size, rd.comp_size);

	if (rd.error_code == 0) {
		if (rd.comp_flag == 0) ret_size = rd.uncomp_size;
		else ret_size = rd.comp_size;

		if ((info = (char *)malloc(rd.uncomp_size)) == NULL) {
			printf("ERR: Memory Alloc Fail\n");
			close(sockfd), exit(1);
		}
		memset(info, 0, rd.uncomp_size);

		printf("---------------------start\n");
		if ((rlen = readn(sockfd, info, ret_size)) <= 0) {
			printf("ERR: read info[rlen:%d/%d]\n", rlen, ret_size);
			close(sockfd), exit(1);
		}
		printf("READ: DATA[rlen:%d]\n", rlen);

		len = 0;
		memcpy(&fnum, info+len, sizeof(short));
		len += sizeof(short);
		memcpy(&fclass, info+len, sizeof(short));
		len += sizeof(short);

		fnum = ntohs(fnum);
		fclass = ntohs(fclass);

		printf("---- FILE_COUNT(%d) FCLASS(%d)\n", fnum, fclass);

		for (i = 0; i < fnum; i++) {
			memset(filename, 0x00, sizeof(filename));
			memset(data_time, 0x00, sizeof(data_time));
			
			memcpy(&f_h, info+len, sizeof(char));
			len += sizeof(char);
			if (f_h != 'T') {
				printf("-------------ERROR!!!(%c)\n", f_h);
				exit(-1);
			}
			memcpy(&f_h, info+len, sizeof(char));
			len += sizeof(char);
			if (f_h != 'W') {
				printf("-------------ERROR!!!(%c)\n", f_h);
				exit(-1);
			}
			memcpy(&f_e, info+len, sizeof(int));
			len += sizeof(int);
			f_e = ntohl(f_e);
			memcpy(&f_id, info+len, sizeof(int));
			len += sizeof(int);
			f_id = ntohl(f_id);
			memcpy(data_time, info+len, 12);
			len += 12;
			
			memcpy(&fsize, info+len, sizeof(int));
			len += sizeof(int);
			fsize = ntohl(fsize);

			fdata = (char *)malloc(fsize);
			memset(fdata, 0x00, fsize);
			memcpy(fdata, info+len, fsize);
			len += fsize;

			sprintf(filename, "%d_cctv.jpg", f_id);
			fp = fopen(filename, "wb");
			fwrite(fdata, fsize, 1, fp);
			fclose(fp);
			printf("Write Complete! ---- [%s](%d) (len:%d)\n", filename, fsize, len);
			free(fdata);
		}

		if (info != NULL) free(info);
		info = NULL;
		if (data != NULL) free(data);
		data = NULL;
	}
	exit_handler();
}
Example #7
0
int main(void)
{
	REQUEST_HD hd;
	RESPONSE_HD rd;
	REQUEST_CCTV hdc;

	int i, rlen, wlen, len;
	struct sockaddr_in serv_addr;
	int ret, ret_size = 0;

	char *info = NULL;
	char *data = NULL;

	char filename[256];

	FILE *fp;

	char *fdata = NULL;
	short fnum = 0;
	short fclass = 0;
	int fsize = 0;
	long uncompsize = 0;
	char data_time[12+1];
	char f_h;


	memset(&hd, 0x00, sizeof(hd));
	memset(&hdc, 0x00, sizeof(hdc));
	memset(&rd, 0x00, sizeof(rd));

	hd.version = htonl(100);
	hd.serviceid = htonl(1000);
	printf("--------IN------\n");
	InputChar("D or E", &hdc.sourceFlag, 'D');
	InputInt("Camera(CCTV) ID", &hdc.cameraID, 99);
	hdc.cameraID = htonl(hdc.cameraID);
	InputShort("¸îÀå?", &hdc.photoNum, 5);
	hdc.photoNum = htons(hdc.photoNum);

	memset((char *) &serv_addr, 0, sizeof(serv_addr)) ;
	serv_addr.sin_family = AF_INET ;
	serv_addr.sin_addr.s_addr = inet_addr(SM_SERVER_IP) ;
	serv_addr.sin_port = htons(SM_SERVER_PORT) ;

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printf("clientsoc: can't open stream socket") ;
		close(sockfd), exit(0);
	}

	if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
		printf("clientsoc: can't connect to server") ;
		close(sockfd), exit(0);
	}

	if ((wlen = write(sockfd, &hd, sizeof(hd))) <= 0) {
		printf("ERR: IN(wlen:%d)\n", wlen);
		close(sockfd), exit(1);
	}
	printf("SEND: IN[wlen:%d]\n", wlen);
	if ((wlen = write(sockfd, &hdc, sizeof(hdc))) <= 0) {
		printf("ERR: IN(wlen:%d)\n", wlen);
		close(sockfd), exit(1);
	}
	printf("SEND: IN[wlen:%d]\n", wlen);

	if ((rlen = read(sockfd, &rd, sizeof(rd))) <= 0) {
		printf("ERR: OUT(rlen:%d)\n", rlen);
		close(sockfd), exit(1);
	}
	printf("RECEIVE: OUT[rlen:%d]\n", rlen);

	rd.error_code = ntohl(rd.error_code);
	rd.version = ntohl(rd.version);
	rd.serviceid = ntohl(rd.serviceid);
	rd.file_num = ntohl(rd.file_num);
	rd.comp_flag = ntohl(rd.comp_flag);
	rd.uncomp_size = ntohl(rd.uncomp_size);
	rd.comp_size = ntohl(rd.comp_size);

	printf("ECODE[%d] VER[%d] SID[%d] FNUM[%d] CFLAG[%d] UNC_SIZE[%d] C_SIZE[%d]\n", rd.error_code, rd.version, rd.serviceid, rd.file_num, rd.comp_flag, rd.uncomp_size, rd.comp_size);

	if (rd.error_code == 0) {
		if (rd.comp_flag == 0) ret_size = rd.uncomp_size;
		else ret_size = rd.comp_size;

		if ((info = (char *)malloc(rd.uncomp_size)) == NULL) {
			printf("ERR: Memory Alloc Fail\n");
			close(sockfd), exit(1);
		}
		memset(info, 0, rd.uncomp_size);

		if ((rlen = readn(sockfd, info, ret_size)) <= 0) {
			printf("ERR: read info[rlen:%d/%d]\n", rlen, ret_size);
			close(sockfd), exit(1);
		}
		printf("READ: DATA[rlen:%d]\n", rlen);

		if (rd.comp_flag == 1) {
			if ((data = (char *) malloc(rd.uncomp_size)) == NULL) {
				printf("........Fail\n");
				close(sockfd), exit(1);
			}
			memset(data, 0, rd.uncomp_size);
			memcpy(data, info, rd.uncomp_size);
			memset(info, 0, rd.uncomp_size);
			
			uncompsize = rd.uncomp_size;
			ret = uncompress(info, &(uncompsize), data, rd.comp_size);

			rd.uncomp_size = uncompsize;

			printf("uncompress() ret[%d], un[%d], c[%d]\n", ret, rd.uncomp_size, rd.comp_size);
		}

		memset(data_time, 0x00, sizeof(data_time));
		len = 0;
		memcpy(&fnum, info+len, sizeof(short));
		len += sizeof(short);
		memcpy(&fclass, info+len, sizeof(short));
		len += sizeof(short);
		memcpy(data_time, info+len, 12);
		len += 12;

		fnum = ntohs(fnum);
		fclass = ntohs(fclass);

		printf("---- FILE_COUNT(%d) FCLASS(%d) TIME(%s)\n", fnum, fclass, data_time);

		for (i = 0; i < fnum; i++) {
			memcpy(&f_h, info+len, sizeof(char));
			len += sizeof(char);
			if (f_h != 'T') {
				printf("-------------ERROR!!!(%c)\n", f_h);
				exit(-1);
			}
			memcpy(&f_h, info+len, sizeof(char));
			len += sizeof(char);
			if (f_h != 'W') {
				printf("-------------ERROR!!!(%c)\n", f_h);
				exit(-1);
			}
			
			memset(filename, 0x00, sizeof(filename));
			memcpy(&fsize, info+len, sizeof(int));
			len += sizeof(int);
			fsize = ntohl(fsize);

			fdata = (char *)malloc(fsize);
			memset(fdata, 0x00, fsize);
			memcpy(fdata, info+len, fsize);
			len += fsize;

			sprintf(filename, "cctv%d.jpg", i+1);
			fp = fopen(filename, "wb");
			fwrite(fdata, fsize, 1, fp);
			fclose(fp);
			printf("Write Complete! ---- [%s](%d) (len:%d)\n", filename, fsize, len);
			free(fdata);
		}

		if (info != NULL) free(info);
		info = NULL;
		if (data != NULL) free(data);
		data = NULL;
	}
	exit_handler();
}