Example #1
0
int get_tcon_text(int type)
{
	time_t t ;
	int index = 0 ;

	int sockfd ;
	int wlen, rlen ;
	struct sockaddr_in serv_addr ;

	int ret = E_NO_ERR ;
	SRH_IN in ;
	SRH_OUT out ;
	TOTAL_INFO total_info ;
	TXT_INFO txt_info ;

	char *data = NULL ;
	int offset = 0 ;
	char *content = NULL ;

//	T_INFO *info = NULL ;
	int i = 0 ;

	fd_set readset ;
	struct timeval tmv ;

	memset(&in, 0, sizeof(SRH_IN)) ;
	memset(&out, 0, sizeof(SRH_OUT)) ;
	memset(&total_info, 0, sizeof(TOTAL_INFO)) ;
	memset(&txt_info, 0, sizeof(TXT_INFO)) ;

	printLog(PUSH, "===GET_TEXT_INFO(%d) START===\n", type) ;
	t = time(&t) ;

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

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printLog(PUSH, "clientsoc: can't open stream socket[%s:%d]\n", Config.TRAFFIC_IP, Config.TRAFFIC_PORT) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}

	if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
		printLog(PUSH, "clientsoc: can't connect to server[%s:%d]\n", Config.TRAFFIC_IP, Config.TRAFFIC_PORT) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}

	in.op_code = htonl(TYPE_TCON_TEXT_INFO) ;   //: 고속도로 속보(TEXT)

//	in.limit_time = htonl((int)Config.LIMIT_TIME) ;
	in.limit_time = htonl(0) ;
	strcpy(in.req_info, Config.ID) ;

	if((wlen = writen(sockfd, &in, sizeof(SRH_IN))) != sizeof(SRH_IN)) {
		printLog(PUSH, "ERR: write SRH_IN[wlen:%d/%d]\n", wlen, sizeof(SRH_IN)) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}
	printLog(PUSH, "SEND: SRH_IN[wlen:%d]\n", wlen) ;

	FD_ZERO(&readset) ;
	FD_SET(sockfd, &readset) ;
	tmv.tv_sec = 30 ; tmv.tv_usec = 0 ;

	if(select(sockfd+1, &readset, NULL, NULL, &tmv) < 0)  {
		printLog(PUSH, "ERR: select Error : SOCKET(%d) CLOSE\n", sockfd) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}

	if (!FD_ISSET(sockfd, &readset)) { // 30초동안 msgid를 받지 못한 경우,
		printLog(PUSH, "ERR: SockFD(%d) TimeOut wait read_time(%d)\n", sockfd, tmv.tv_sec) ;
		ret = E_TCP_TIMEOUT ;
		goto error_exit ;
	}

	if((rlen = readn(sockfd, &out, sizeof(SRH_OUT))) != sizeof(SRH_OUT)) {
		printLog(PUSH, "ERR: read SRH_OUT[rlen:%d/%d]\n", rlen, sizeof(SRH_OUT)) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}

	out.result = ntohl(out.result) ;
	out.op_code = ntohl(out.op_code) ;
	out.count = ntohl(out.count) ;

	if(out.op_code == TYPE_TCON_TEXT_INFO) G_rev_op7_ret = out.result ;

	printLog(PUSH, "READ: SRH_OUT[rlen:%d]-RESULT(%d) OPCODE(%d) COUNT(%d) \n",
			rlen, out.result, out.op_code, out.count) ;

	if(out.count > 0) {
		if((data = (char *) malloc(out.count)) == NULL) {
			printLog(PUSH, "ERR: Memory Alloc Fail ==> Program Exit\n") ;
			exit_handler() ;
		}
		memset(data, 0, out.count) ;

		FD_ZERO(&readset) ;
		FD_SET(sockfd, &readset) ;
		tmv.tv_sec = 30 ; tmv.tv_usec = 0 ;

		if(select(sockfd+1, &readset, NULL, NULL, &tmv) < 0)  {
			printLog(PUSH, "ERR: select Error : SOCKET(%d) CLOSE\n", sockfd) ;
			ret = E_TCP_FAIL ;
			goto error_exit ;
		}

		if (!FD_ISSET(sockfd, &readset)) { // 30초동안 msgid를 받지 못한 경우,
			printLog(PUSH, "ERR: SockFD(%d) TimeOut wait read_time(%d)\n", sockfd, tmv.tv_sec) ;
			ret = E_TCP_TIMEOUT ;
			goto error_exit ;
		}

		if((rlen = readn(sockfd, data, out.count)) != out.count) {
			printLog(PUSH, "ERR: read T_INFO[rlen:%d/%d]\n", i, rlen, out.count) ;
			ret = E_TCP_FAIL ;
			goto error_exit ;
		}
		printLog(PUSH, "READ: DATA[%d]\n", out.count) ;

		offset = 0 ;
		memcpy(&total_info, &data[offset], sizeof(TOTAL_INFO)) ;
		offset += sizeof(TOTAL_INFO) ;

		total_info.f_cnt = ntohl(total_info.f_cnt) ;
		printLog(PUSH, "f_cnt[%d]\n", total_info.f_cnt) ;

		for(i = 0 ; i < total_info.f_cnt; i++) {
			memset(&txt_info, 0, sizeof(TXT_INFO)) ;
			memcpy(&txt_info, &data[offset], sizeof(TXT_INFO)) ;
			offset += sizeof(TXT_INFO) ;

			txt_info.f_no = ntohl(txt_info.f_no) ;
			txt_info.f_size = ntohl(txt_info.f_size) ;
			txt_info.f_cnt = ntohl(txt_info.f_cnt) ;
			txt_info.date = ntohl(txt_info.date) ;
			txt_info.time = ntohl(txt_info.time) ;

			if((content = (char *) malloc(txt_info.f_size+1)) == NULL) {
				printLog(PUSH, "ERR: Memory Alloc Fail ==> Program Exit\n") ;
				exit_handler() ;
			}
			memset(content, 0, txt_info.f_size+1) ;

			memcpy(content, &data[offset], txt_info.f_size) ;
			offset += txt_info.f_size ;

		//	printLog(PUSH, "[%d] f_no[%d] f_name[%s] f_size[%d]f_cnt[%d]date[%d]time[%d]content[%s]\n",
		//			i, txt_info.f_no, txt_info.f_name, txt_info.f_size, txt_info.f_cnt, txt_info.date, txt_info.time, content) ;
			if(content != NULL) free(content) ;
			content = NULL ;
		}
	}
	//-----------------//

	if(type == TYPE_TCON_TEXT_INFO) {
		index = (g_tcon_text_flag+1) % 2 ;
		printLog(PUSH, "NEW DATA((HIGHWAY_TEXT_INFO)) SETTING : INDEX(%d)\n", index) ;
		receive_time[index] = t ;   //: 추후 수정

		if(text_info[index].data != NULL) {
			free(text_info[index].data) ;
			text_info[index].data = NULL ;
		}
		memset(&(text_info[index]), 0, sizeof(G_INFO)) ;

		text_info[index].num = total_info.f_cnt ;
		text_info[index].realSize = out.count ;       

		if(out.count > PACKET_SIZE) {
			text_info[index].compFlag = 1 ;

			if((text_info[index].data = (char *) malloc (out.count)) == NULL) {
				printLog(PUSH, "ERR: Mamory Alloc Fail=>Program Exit\n") ;
				exit_handler() ;
			}
			memset(text_info[index].data, 0, out.count) ;

			text_info[index].compSize = out.count;
			ret = compress(text_info[index].data, (long *)&(text_info[index].compSize), data, out.count) ;

			printLog(PUSH, "compress() : ret(%d) index(%d) compSize(%d) realSize(%d)\n",
					ret, index, text_info[index].compSize, text_info[index].realSize) ;
			if(data != NULL) free(data) ;
			data = NULL ;
		}
		else {
			text_info[index].compFlag = 0 ;
			text_info[index].compSize = text_info[index].realSize ;
			text_info[index].data = data ;
		}

		DataToFile(101, &(text_info[index])) ;
		printLog(PUSH, "DataToFile() - text_info END\n") ;

		pthread_mutex_lock(&tt_lock) ;
		g_tcon_text_flag = index ;
		pthread_mutex_unlock(&tt_lock) ;

	}

error_exit :
	close(sockfd) ;

	printLog(PUSH, "===GET_TEXT_INFO(%d) END===\n", type) ;
	return ret ;
}
Example #2
0
int get_tcon_speed(int type)
{
	time_t time_info ;
	time_t rev_time, cal_time ;

	int set_index = 0 ;
	int recvInfoNum = 0 ;
	char *onlyRecvInfo = NULL ;
	int onlyRecvInfoNum = 0, only_len = 0 ;
	time_t t ;
	int temp = 0 ;

	int index = 0 ;

	///---------------------------------------------------------------------///
	int sockfd ;
	int wlen, rlen ;
	struct sockaddr_in serv_addr ;

	int ret = E_NO_ERR ;
	SRH_IN in ;
	SRH_OUT out ;
	S_INFO *info = NULL ;
	int i = 0 ;

	fd_set readset ;
	struct timeval tmv ;

	memset(&in, 0, sizeof(SRH_IN)) ;
	memset(&out, 0, sizeof(SRH_OUT)) ;

	printLog(PUSH, "===GET_SPEED_INFO(%d) START===\n", type) ;
	time_info = time(&t) ;

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

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printLog(PUSH, "clientsoc: can't open stream socket[%s:%d]\n", Config.TRAFFIC_IP, Config.TRAFFIC_PORT) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}

	if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
		printLog(PUSH, "clientsoc: can't connect to server[%s:%d]\n", Config.TRAFFIC_IP, Config.TRAFFIC_PORT) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}

	in.op_code = htonl(type) ;	//: TCON

//	in.limit_time = htonl(30) ;
//	strcpy(in.req_info, "INAVION3") ;
	in.limit_time = htonl((int)Config.LIMIT_TIME) ;
//	in.limit_time = htonl(0) ;	//FULL DATA
	strcpy(in.req_info, Config.ID) ;
	
	if((wlen = writen(sockfd, &in, sizeof(SRH_IN))) != sizeof(SRH_IN)) {
		printLog(PUSH, "ERR: write SRH_IN[wlen:%d/%d]\n", wlen, sizeof(SRH_IN)) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}
	printLog(PUSH, "SEND: SRH_IN[wlen:%d]\n", wlen) ;

	FD_ZERO(&readset) ;
	FD_SET(sockfd, &readset) ;
	tmv.tv_sec = 30 ; tmv.tv_usec = 0 ;

	if(select(sockfd+1, &readset, NULL, NULL, &tmv) < 0)  {
		printLog(PUSH, "ERR: select Error : SOCKET(%d) CLOSE\n", sockfd) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}
	if (!FD_ISSET(sockfd, &readset)) { // 30초동안 msgid를 받지 못한 경우,
		printLog(PUSH, "ERR: SockFD(%d) TimeOut wait read_time(%d)\n", sockfd, tmv.tv_sec) ;
		ret = E_TCP_TIMEOUT ;
		goto error_exit ;
	}

	if((rlen = readn(sockfd, &out, sizeof(SRH_OUT))) != sizeof(SRH_OUT)) {
		printLog(PUSH, "ERR: read SRH_OUT[rlen:%d/%d]\n", rlen, sizeof(SRH_OUT)) ;
		ret = E_TCP_FAIL ;
		goto error_exit ;
	}
	printLog(PUSH, "READ: SRH_OUT[rlen:%d]\n", rlen) ;

	out.result = ntohl(out.result) ;
	out.op_code = ntohl(out.op_code) ;
	out.count = ntohl(out.count) ;
	printLog(PUSH, "TYPE(%d) - OP_CODE(%d) RESULT(%d) COUNT(%d)\n", type, out.op_code, out.result, out.count) ;
	if(out.op_code == type) {
		printLog(PUSH, "TCON 속도\n") ;
		G_rev_op6_ret = out.result ;
	}

	if(out.count > 0) {
		if((info = (S_INFO *) malloc (out.count * sizeof(S_INFO))) == NULL) {
			printLog(PUSH, "ERR: Memory Alloc Fail ==> Program Exit\n") ;
			exit_handler() ;
		}
		memset(info, 0, out.count * sizeof(S_INFO)) ;

		FD_ZERO(&readset) ;
		FD_SET(sockfd, &readset) ;
		tmv.tv_sec = 30 ; tmv.tv_usec = 0 ;

		if(select(sockfd+1, &readset, NULL, NULL, &tmv) < 0)  {
			printLog(PUSH, "ERR: select Error : SOCKET(%d) CLOSE\n", sockfd) ;
			ret = E_TCP_FAIL ;
			goto error_exit ;
		}
		if (!FD_ISSET(sockfd, &readset)) { // 30초동안 msgid를 받지 못한 경우,
			printLog(PUSH, "ERR: SockFD(%d) TimeOut wait read_time(%d)\n", sockfd, tmv.tv_sec) ;
			ret = E_TCP_TIMEOUT ;
			goto error_exit ;
		}

		if((rlen = readn(sockfd, info, sizeof(S_INFO)*out.count)) != (int) sizeof(S_INFO)*out.count) {
			printLog(PUSH, "ERR: read S_INFO[rlen:%d/%d]\n", rlen, sizeof(S_INFO)*out.count) ;
			ret = E_TCP_FAIL ;
			goto error_exit ;
		}

		printLog(PUSH, "READ: S_INFO [%d] DATA SET [%d]SIZE\n", out.count, sizeof(S_INFO)*out.count) ;

		for(i = 0 ; i < out.count ; i++) {
			info[i].speed = ntohl(info[i].speed) ;
			if(info[i].speed < 0) info[i].speed = 0 ;	//: 속도 정보가 0보다 작으면(음수) 0로 변경
		//	info[i].hour = ntohs(info[i].hour) ;
		//	info[i].min = ntohs(info[i].min) ;
			info[i].recv_date = ntohl(info[i].recv_date) ;
			info[i].recv_time = ntohl(info[i].recv_time) ;

			rev_time = makeReadTime2(info[i].recv_date, info[i].recv_time) ;
			cal_time = time_info - rev_time ;
			if(cal_time > 1800) {	// 30분 이전 데이터면 속도 0
				info[i].speed = 0 ;
				printLog(PUSH, "NOT-INVALID: DATE[%08d] TIME[%06d] CAL_TIME[%d]\n", 
						info[i].recv_date, info[i].recv_time, cal_time) ;
			}
			
			if(i%1000 == 0) 	//: HEAR_SON
				printLog(PUSH, "[%d]: sid[%s] speed[%d] recv_date[%d] recv_time[%d]\n", 
						i, info[i].sid, info[i].speed, info[i].recv_date, info[i].recv_time) ;
		}
	}
	else { //: 읽어올 정보가 없을 시에는 
		goto error_exit ;
	}
	///---------------------------------------------------------------------///

	recvInfoNum = out.count ;
	// index 결정
	if(type == TYPE_TCON_SPEED_INFO) index = (g_tcon_speed_flag+1) % 2 ;	
	receive_time[index] = time_info ;

	for(set_index = 0 ; set_index < speed_set_num ; set_index++) {
		//[TCON SPEED]//////////////
		if(type == TYPE_TCON_SPEED_INFO) {

			if(speed_set[set_index].tcon_map_num == 0) continue ;

			onlyRecvInfoNum = speed_set[set_index].tcon_map_num ;
			if((onlyRecvInfo = (char *) malloc(INT_LEN+INT_LEN+INT_LEN+onlyRecvInfoNum)) == NULL) {
				printLog(PUSH, "ERR: Mamory Alloc Fail=>Program Exit\n") ;
				exit_handler() ;
			}
			memset(onlyRecvInfo, 0, INT_LEN+INT_LEN+INT_LEN+onlyRecvInfoNum) ;

			only_len = 0 ;
			//: VERSION
			temp = htonl(speed_set[set_index].version) ;
			memcpy(&(onlyRecvInfo[only_len]), &temp, INT_LEN) ;
			only_len += INT_LEN ;

			if(out.count > 0) 
				temp = makeReadTime2(info[0].recv_date, info[0].recv_time) ;
			else
				temp = (time_t) time(&t)  ;

			temp = htonl(temp) ;
			memcpy(&(onlyRecvInfo[only_len]), &temp, INT_LEN) ;
			only_len += INT_LEN ;
			//: SIZE
			temp = htonl(onlyRecvInfoNum) ;
			memcpy(&(onlyRecvInfo[only_len]), &temp, INT_LEN) ;
			only_len += INT_LEN ;

			///INFO MAPPING()
			info_tcon_mapping(speed_set[set_index].tcon_map, 
					speed_set[set_index].tcon_map_num, info, recvInfoNum, onlyRecvInfo) ;
			///INFO MAPPING()

			//: index 공간 초기화
			if(speed_set[set_index].tcon_speed_info[index].data != NULL) {
				free(speed_set[set_index].tcon_speed_info[index].data) ;
				speed_set[set_index].tcon_speed_info[index].data = NULL ;

				printLog(PUSH, "((TCON SPEED)) SET_INDEX(%d) INDEX(%d) FREE\n", set_index, index) ;
			}

			speed_set[set_index].tcon_speed_info[index].num = onlyRecvInfoNum ;
			speed_set[set_index].tcon_speed_info[index].realSize = INT_LEN + INT_LEN + INT_LEN + onlyRecvInfoNum ;

			if(speed_set[set_index].tcon_speed_info[index].realSize > PACKET_SIZE) {
				speed_set[set_index].tcon_speed_info[index].compFlag = 1 ;

				if((speed_set[set_index].tcon_speed_info[index].data =
							(char *) malloc (speed_set[set_index].tcon_speed_info[index].realSize)) == NULL) {
					printLog(PUSH, "ERR: Mamory Alloc Fail=>Program Exit\n") ;
					exit_handler() ;
				}
				memset(speed_set[set_index].tcon_speed_info[index].data, 0, 
						speed_set[set_index].tcon_speed_info[index].realSize) ;

				speed_set[set_index].tcon_speed_info[index].compSize = 
					speed_set[set_index].tcon_speed_info[index].realSize ;
				ret = compress(speed_set[set_index].tcon_speed_info[index].data,
						(long *)&(speed_set[set_index].tcon_speed_info[index].compSize),
						onlyRecvInfo, speed_set[set_index].tcon_speed_info[index].realSize) ;

				printLog(PUSH, "compress() : ret(%d) set_index(%d) index(%d) compFlag(%d) compSize(%d) realSize(%d)\n",
						ret, set_index, index, speed_set[set_index].tcon_speed_info[index].compFlag,
						speed_set[set_index].tcon_speed_info[index].compSize,
						speed_set[set_index].tcon_speed_info[index].realSize) ;

			}
			else {
				speed_set[set_index].tcon_speed_info[index].compFlag = 0 ;
				if((speed_set[set_index].tcon_speed_info[index].data =
							(char *) malloc (speed_set[set_index].tcon_speed_info[index].realSize)) == NULL) {
					printLog(PUSH, "ERR: Mamory Alloc Fail=>Program Exit\n") ;
					exit_handler() ;
				}
				memset(speed_set[set_index].tcon_speed_info[index].data, 0, 
						speed_set[set_index].tcon_speed_info[index].realSize) ;
				memcpy(speed_set[set_index].tcon_speed_info[index].data,
						onlyRecvInfo, speed_set[set_index].tcon_speed_info[index].realSize) ;

				speed_set[set_index].tcon_speed_info[index].compSize = 
					speed_set[set_index].tcon_speed_info[index].realSize ;
			}

			if(onlyRecvInfo != NULL) free(onlyRecvInfo) ;
			onlyRecvInfo = NULL ;

			printLog(PUSH, "((ROTIS SPEED)) SET_INDEX(%d) INDEX(%d) - NUM(%d) CF(%d) CS(%d) RS(%d) CREATE\n",
					set_index, index,
					speed_set[set_index].tcon_speed_info[index].num, 
					speed_set[set_index].tcon_speed_info[index].compFlag,
					speed_set[set_index].tcon_speed_info[index].compSize, 
					speed_set[set_index].tcon_speed_info[index].realSize) ;

			DataToFile(speed_set[set_index].version*10, &(speed_set[set_index].tcon_speed_info[index])) ;
			printLog(PUSH, "DataToFile() - speed_set(%d).tcon_speed_info(%d)END\n", set_index, index) ;
		}
	}   // END OF FOR

	if(type == TYPE_TCON_SPEED_INFO) {
		pthread_mutex_lock(&tc_lock) ;
		g_tcon_speed_flag = index ;
		pthread_mutex_unlock(&tc_lock) ;
	}

error_exit :
	if(info != NULL) free (info) ;
	info = NULL ;
	close(sockfd) ;

	printLog(PUSH, "===GET_SPEED_INFO(%d) END===\n", type) ;
	return ret ;

}
Example #3
0
int _tmain(int argc, _TCHAR* argv[])
{
	_tsetlocale(LC_ALL, _T("")); // fixes VS11DP quirk

	// open csv file

	RCSVFileRO file;

	if (argc == 2)
	{
		if (!file.Open(CorrectPath(argv[1])))
			{_putts(_T("Unable to open file: ") + CorrectPath(argv[1])); PAUSERETURN(-1);}
	}
	else if (argc == 1)
	{
		if (!file.Open(CorrectPath(_T("strings.csv"))))
			{_putts(_T("Please supply the name of CSV-file.")); PAUSERETURN(-2);}
	}
	else
		{_putts(_T("Invalid argument count.")); PAUSERETURN(-3);}

	if (file.GetLineCount() == 0)
		{_putts(_T("Empty file.")); PAUSERETURN(1);}

	if (file.GetLineCount() < 2)
		{_putts(_T("File must contain at least two lines.")); PAUSERETURN(-4);}

	if (file.GetFieldCount() < 2)
		{_putts(_T("File must contain at least two columns.")); PAUSERETURN(-5);}

	// generate header file contents

	RString str;
	str += _T("// strings.h : Defines the strings to be used throughout the application.\r\n");
	str += _T("//\r\n");
	str += _T("\r\n");

	int n = 1000;
	
	int i, j;
	for (i = 1; i < file.GetLineCount(); i++)
		if (_tcscmp(file.GetField(i, 0), _T("")) != 0)
			str += RString(_T("#define ")) + file.GetField(i, 0) + _T(" ") + NumberToString(n++) + _T("\r\n");

	str += _T("\r\n");
	str += _T("inline void LoadStrings()\r\n");
	str += _T("{\r\n");
	str += _T("\tINT_PTR nLanguage;\r\n");

	for (i = 1; i < file.GetFieldCount(); i++)
	{
		str += _T("\r\n");
		str += (RString)_T("\tnLanguage = GetLangMgr()->GetLanguage(_T(\"") + file.GetField(0, i) + _T("\"));\r\n");
		str += (RString)_T("\tif (nLanguage == -1)\r\n");
		str += (RString)_T("\t\tnLanguage = GetLangMgr()->AddLanguage(_T(\"") + file.GetField(0, i) + _T("\"), _T(\"") + file.GetField(1, i)
				+ _T("\"), _T(\"\"));\r\n\r\n");

		for (j = 1; j < file.GetLineCount(); j++)
		{
			if (_tcscmp(file.GetField(j, 0), _T("")) == 0)
				continue; // skip empty ids

			str += (RString)_T("\tGetLangMgr()->SetString(nLanguage, ") + NumberToString(j-1) + _T(", _T(\"") +
					file.GetField(j, i) + _T("\"), false);\r\n");
		}
	}

	str += _T("}\r\n");

	// write to file

	RString strFilePath = CorrectPath(argc == 2 ? argv[1] : _T("strings.csv"));
	strFilePath = strFilePath.Left(strFilePath.ReverseFind(_T('\\'))+1) + _T("strings.h");

	RArray<BYTE> data = StringToData(str, CHARSET_ANSI);
	if (!DataToFile(data, strFilePath))
		{_tprintf(_T("Failed to open %s for writing.\n"), (LPCTSTR)strFilePath); PAUSERETURN(-6);}

	_tprintf(_T("Created %s succesfully.\n"), (LPCTSTR)strFilePath);

	PAUSERETURN(0);
}