Example #1
0
boost::any ConfigOptionsGroup::config_value(std::string opt_key, int opt_index, bool deserialize){

	if (deserialize) {
		// Want to edit a vector value(currently only multi - strings) in a single edit box.
		// Aggregate the strings the old way.
		// Currently used for the post_process config value only.
		if (opt_index != -1)
			throw std::out_of_range("Can't deserialize option indexed value");
// 		return join(';', m_config->get(opt_key)});
		return get_config_value(*m_config, opt_key);
	}
	else {
//		return opt_index == -1 ? m_config->get(opt_key) : m_config->get_at(opt_key, opt_index);
		return get_config_value(*m_config, opt_key, opt_index);
	}
}
Example #2
0
void Pcap(TQueueItem* start, TQueueItem* stop, TQueueCallbackArgs args)
{
	char* pcap_filename = get_config_value("pcap_filename");
	if(pcap_filename==NULL)
		return;
	open_pcap(pcap_filename);

	TQueueItem* item = start;

    while(item != NULL)
    {
        TPacket* packet = item->packet;

        uint8_t* packet_l2_start;
        uint32_t packet_l2_length;

        onep_dpss_pkt_get_l2_start((onep_dpss_paktype_t*)packet, &packet_l2_start, &packet_l2_length);


		pcap_pkthdr_t x = {{(uint32_t)item->timestamp.tv_sec, (uint32_t)item->timestamp.tv_nsec / 1000}, packet_l2_length, packet_l2_length};


		pcap_dump((u_char*)pcap_dumpfile, &x, packet_l2_start);		

        item = GetNextItem(item, stop);
    }
    pcap_dump_flush(pcap_dumpfile);

}
Example #3
0
int write_tdq(char* tdq, int level, char* fmt, ...)
{
	int	len;
	int	ret;
	ulong	resp;
	va_list	args;
	char	msg[ MESSAGE_LENGTH ];
	char	message[ MESSAGE_LENGTH ];

	/* 取配置文件内容,如果失败,重置日志等级 -2 */
	if (base_level < 0) {
		ret = get_config_value(CONFIG_FILE_NAME, LOG_LEVEL, message);
		if (ret != 0) { 
			if (base_level != -2)
				fprintf(stderr, 
					"-->Get config file [%s] error [%s]!\n",
					CONFIG_FILE_NAME, strerror(errno));
			base_level = -2;
		}
		else
			base_level = atoi(message);
	}

	/* 生成日志记录内容 */
	va_start(args, fmt);
	vsprintf(msg, fmt, args);
	va_end(args);
	sprintf(message, "-->Netbank : %s", msg);

	/* 如果无法取出配置文件中的日志等级,将信息输出到标准错误上 */
	if (base_level < 0) {
		/* fprintf(stderr, "%s\n", message); */
		fprintf(stderr, "-->>Netbank : 无法写日志文件");
		return 0;
	}

	/* 对日志级别进行比较 */
	if (level > base_level)
		return 0;

	/* 将日志内容记录到TDQ中 */
	len = strlen(message);
	/* EXEC CICS WRITEQ TD QUEUE (tdq) FROM (message) LENGTH (len) RESP (resp); */ \
    { \
	cics_api_strncpy(CicsArgs.ArgData[9].StringValue, tdq, (short)4); \
	CicsArgs.ArgData[4].DataArea = message; \
	CicsArgs.ArgData[2].ShortValue = len; \
	CicsArgs.ArgMask = 0x20000214; \
	CicsArgs.FnCode = 106; \
	CicsArgs.DebugLine = -1; \
	cics_api_exec_c(&CicsArgs); \
	resp = dfheiptr->eibresp; \
    }

	return check_respcode(resp);
}
Example #4
0
/******************************************************************************
 * get_control_sock - see net.h
 *****************************************************************************/
int get_control_sock (void)
{
  //The socket that will listen for control connections from the client.
  int csfd;

  //Variables used to collect the IPv4 address of the server.
  char *interfaceSetting = "INTERFACE_CONFIG"; //ftp.conf setting
  char *interfaceResult;                       //value of the ftp.conf setting
  char interfaceAddr[INET_ADDRSTRLEN];

  //Variables used to collect the default port.
  char *portSetting = "DEFAULT_PORT_CONFIG"; //ftp.conf setting
  char *portResult;

  //Read the config file for the default port.
  if ((portResult = get_config_value (portSetting, FTP_CONFIG_FILE)) == NULL) {
    return -1;
  }

  //Read the config file to find which interface to use to make the socket.
  if ((interfaceResult = get_config_value (interfaceSetting,
					    FTP_CONFIG_FILE)) == NULL) {
    return -1;
  }

  /* Get the IPv4 address for the interface that was set in the configuration
   * file.*/
  if (get_interface_address (interfaceResult, &interfaceAddr) == -1) {
    free (interfaceResult);
    free (portResult);
    return -1;
  }
  free (interfaceResult);

  /* Create a control connection socket that is ready to accept a connection
   * from the client. */
  if ((csfd = get_pasv_sock (interfaceAddr, portResult)) == -1) {
    return -1;
  }
  free (portResult);
  
  return csfd;
}
Example #5
0
int main(int argc, char *argv[]) {
	if (argc != 2) {
		printf("Invalid argument count, should pass json file to "
			"parse.\n");
	}

	tst_info_t test_info = parse_test_file(argv[1]);
	printf("Successfully parsed.\n");
	printf("config_value: 0x%08X\n", get_config_value(test_info));
	return 0;
}
Example #6
0
static bool create_loader(struct LoaderInterface* loader) {
    char* wmloader_key = get_config_value("config.ini", "WMLoader", "Key");
    bool created = true;

    if (wmloader_key != NULL) {
        *loader = create_wm_loader(wmloader_key);

        free(wmloader_key);
    } else {
        created = false;
    }

    char *config_return_size = get_config_value("config.ini", "GeoNamesLoader", "ReturnSize");
    if (config_return_size != NULL) {
        return_size = atoi(config_return_size);
        free(config_return_size);
    }


    return created;
}
Example #7
0
void
init_time(void)
{
	char *freeptr, *lsm, *mon;
	uint8_t i, m;

	summermonth = (uint8_t)strtol(get_config_value("summermonth"), NULL, 10);
	if (summermonth < 1 || summermonth > 12)
		summermonth = 0;
	wintermonth = (uint8_t)strtol(get_config_value("wintermonth"), NULL, 10);
	if (wintermonth < 1 || wintermonth > 12)
		wintermonth = 0;

	freeptr = lsm = strdup(get_config_value("leapsecmonths"));
	num_leapsecmonths = 0;
	for (i = 0; (mon = strsep(&lsm, ",")) != NULL; i++) {
		m = (uint8_t)strtol(mon, NULL, 10);
		if (m >= 1 && m <= 12) {
			leapsecmonths[i] = m;
			num_leapsecmonths++;
		}
	}
	free(freeptr);
}
Example #8
0
 /**	函数名:	get_config_value  int 的项值
   *	功能描述:	初始化配置文件项变量的值
   *	参数列表:  无
   *    返回值:	无	 
   */
void conf_init()
{
	g_max_thread_num = get_config_value(MAX_THREAD_NUM);
	g_min_thread_num = get_config_value(MIN_THREAD_NUM);
	g_def_thread_num = get_config_value(DEF_THREAD_NUM);
	g_manage_adjust_interval = get_config_value(MANAGE_ADJUST_INTERVAL);
	g_thread_worker_high_ratio = get_config_value(THREAD_WORKER_HIGH_RATIO);
	g_thread_worker_low_ratio = get_config_value(THREAD_WORKER_LOW_RATIO);

}
Example #9
0
/*
 * Open the library
 */
int nvm_open_lib()
{
	int rc = NVM_SUCCESS;

	// initialize the connection to the database
	if (!open_default_lib_store())
	{
		rc = NVM_ERR_UNKNOWN;
	}
	else
	{
		char sim_path[CONFIG_VALUE_LEN];
		// attempt to open a default simulator
		if (get_config_value(SQL_KEY_DEFAULT_SIMULATOR, sim_path) == COMMON_SUCCESS)
		{
			// don't care about failures. sim_adapter will log any
			// errors to the config database. other adapters will just
			// return not supported
			COMMON_LOG_DEBUG_F("Opening default simulator %s", sim_path);
			nvm_add_simulator(sim_path, s_strnlen(sim_path, CONFIG_VALUE_LEN));
		}

		// initialize the event monitor lock
		// event monitoring is per process so no need to be cross-process safe
		// thus no name on the mutex
		if (!mutex_init((OS_MUTEX*)&g_eventmonitor_lock, NULL))
		{
			rc = NVM_ERR_UNKNOWN;
		}

		// initialize the context lock
		// context is per proces so no need to be cross-process safe
		// thus no name on the mutex
		if (!mutex_init((OS_MUTEX*)&g_context_lock, NULL))
		{
			rc = NVM_ERR_UNKNOWN;
		}
	}
	return rc;
}
Example #10
0
int  load_config(ocConfig *conf)
{
    if (conf == NULL)
        return -1;
    if (get_config_value("wake_min_freq", conf->wake_min_freq) == -1)
        return -1;
    if (get_config_value("wake_max_freq", conf->wake_max_freq) == -1)
        return -1;
    if (get_config_value("wake_governor", conf->wake_governor) == -1)
        return -1;

    if (get_config_value("sleep_min_freq", conf->sleep_min_freq) == -1)
        return -1;
    if (get_config_value("sleep_max_freq", conf->sleep_max_freq) == -1)
        return -1;
    if (get_config_value("sleep_governor", conf->sleep_governor) == -1)
        return -1;
    return 0;
}
Example #11
0
static void
parse_config(const char *path)
{
  int fd;
  ssize_t n;
  char *p = NULL;
  char buf[BUFSIZ + 1];
  struct stat *st = g_malloc0(sizeof(struct stat));

  if(stat(path, st) == -1) {
    fprintf(stderr, "%s: missing configuration file %s\n",
        stormfs.progname, path);
    exit(EXIT_FAILURE);
  }

  validate_config_perms(st);

  if((fd = open(path, O_RDONLY)) == -1) {
    free(st);
    perror("open");
    fprintf(stderr, "%s: unable to open configuration file %s\n",
        stormfs.progname, path);
    exit(EXIT_FAILURE);
    return;
  }

  while((n = read(fd, buf, BUFSIZ)) > 0)
    buf[n] = '\0';

  p = strtok(buf, "\n");
  while(p != NULL) {
    while(*p == ' ')
      p++;

    if(*p == '#') {
      p = strtok(NULL, "\n");
      continue;
    }

    if(strstr(p, "access_key") != NULL)
      stormfs.access_key = get_config_value(strstr(p, "=") + 1);
    if(strstr(p, "secret_key") != NULL)
      stormfs.secret_key = get_config_value(strstr(p, "=") + 1);
    if(strstr(p, "url") != NULL)
      stormfs.url = get_config_value(strstr(p, "=") + 1);
    if(strstr(p, "acl") != NULL)
      stormfs.acl = get_config_value(strstr(p, "=") + 1);
    if(strstr(p, "expires") != NULL)
      stormfs.expires = get_config_value(strstr(p, "=") + 1);
    if(strstr(p, "use_ssl") != NULL)
      stormfs.ssl = true;
    if(strstr(p, "no_verify_ssl") != NULL)
      stormfs.verify_ssl = 0;
    if(strstr(p, "use_rrs") != NULL)
      stormfs.rrs = true;
    if(strstr(p, "encryption") != NULL)
      stormfs.encryption = true;
    if(strstr(p, "mime_path") != NULL)
      stormfs.mime_path = get_config_value(strstr(p, "=") + 1);
    if(strstr(p, "cache_path") != NULL)
      stormfs.cache_path = get_config_value(strstr(p, "=") + 1);

    p = strtok(NULL, "\n");
  }

  g_free(st);
  return;
}
Example #12
0
int ics_proc_482999(char *send_buff,char *recv_buff)
{
  /*说明:send_buff-上传报文;
          recv_buff-下传报文;
          ics_send_buff-与后台通讯的发送串;
          ics_recv_buff-与后台通讯的接收串;
 */

  int     i;
  int     len;
  int     ret;
  int     offset;
  int     i_biz_id;

  ICS_DEF_TIA   *pICS_TIA;
  ICS_DEF_TOA   *pICS_TOA;
  ICS_DEF_482999_I  *pICS_482999_I;
  ICS_DEF_482999_N  *pICS_482999_N;
  ICS_DEF_482999_E  *pICS_482999_E;

  char      ics_send_buff[LEN_ICS_PROC_BUF];
  char      ics_recv_buff[LEN_ICS_PROC_BUF];
  char      ics_482999i_buff[20];
  char      ics_482999n_buff[334];
  char      ics_482999e_buff[71];
  char      ics_tia_buff[171];
  char      ics_toa_buff[114];
  char      tmp_val_str[LEN_TMP_VAL_STR];
  char      tmp_val_str2[LEN_TMP_VAL_STR];
  char      display_str[LEN_ICS_PROC_BUF];
  char      display_log_str[LEN_ICS_PROC_BUF];
  char      tmpvalue[256];  /*从上传报文中取得的某项值*/

  char      sLen[8];
  char      sLeft[14];
  char      sRight[3];
  char      sTranNo[16];
  char      sTranDate[11];
  char      sTellerNo[8];
  char      sErrMsg[64];
  char      ics_port[6];
  char      sTxnCnl[32];
	char  Reserve_Code[13];							/*服务商*/	
	char  Product_Name[201];      			/*预定内容*/
	char  Provide_Name[31];      				/*服务商*/
	char  Trans_Toal_Amount[15];      	/*总金额*/
	char  Paid_Amount[15];      				/*已付金额*/	
	char  Arrearage_Amount[15];      		/*欠费金额*/	
	char  Return_Code[4];      					/*处理结果*/		
	char  PB_Return_Code_Msg[51];      	/*处理结果信息*/	

  time_t    cur_time;

  struct tm   *my_tm;

  FILE      *fp;

/*
  void *pComplibhandle; * Handle to shared lib file *
  int (*pCompfunchandle)(); * Pointer to loaded routine */

  /*-------------------STEP1:通讯前处理-组成上传串--------------------*/

  /* STEP1-1:清理结构和变量 */

  memset(ics_send_buff,'\0',sizeof(ics_send_buff));
  memset(ics_recv_buff,'\0',sizeof(ics_recv_buff));
  memset(ics_482999i_buff,'\0',sizeof(ics_482999i_buff));
  memset(ics_482999n_buff,'\0',sizeof(ics_482999n_buff));
  memset(ics_482999e_buff,'\0',sizeof(ics_482999e_buff));
  memset(ics_tia_buff,'\0',sizeof(ics_tia_buff));
  memset(ics_toa_buff,'\0',sizeof(ics_toa_buff));

  pICS_482999_I=(ICS_DEF_482999_I *)ics_482999i_buff;
  pICS_482999_N=(ICS_DEF_482999_N *)ics_482999n_buff;
  pICS_482999_E=(ICS_DEF_482999_E *)ics_482999e_buff;
  pICS_TIA=(ICS_DEF_TIA *)ics_tia_buff;
  pICS_TOA=(ICS_DEF_TOA *)ics_toa_buff;

  memset(tmp_val_str,'\0',sizeof(tmp_val_str));
  memset(tmp_val_str2,'\0',sizeof(tmp_val_str2));
  memset(display_str,'\0',sizeof(display_str));
  memset(display_log_str,'\0',sizeof(display_log_str));
  memset(tmpvalue,'\0',sizeof(tmpvalue));
  memset(sTranNo,'\0',sizeof(sTranNo));
  memset(sTranDate,'\0',sizeof(sTranDate));
  memset(sErrMsg,'\0',sizeof(sErrMsg));
  memset(sTellerNo,'\0',sizeof(sTellerNo));
  memset( sErrMsg, '\0', sizeof( sErrMsg ) ) ;

  flog( STEP_LEVEL,"--482999 接收[%s]------------------------------",send_buff);

  /* STEP1-2:填上传串的固定头 */
  strcpy(pICS_TIA->CCSCod,"TLU6");
	strcpy(pICS_TIA->TTxnCd,"482999");
  strcpy(pICS_TIA->FeCod,"482999");

  strcpy(pICS_TIA->TrmNo,"DVID");
  
  /*将终端的交易渠道赋值进来*/
  /* 如果TXNSRC值没有上送,默认使用WE441 */
  memset(sTxnCnl, '\0', sizeof(sTxnCnl));
  if(strstr(send_buff,"TXNSRC")){
    getValueOfStr(send_buff,"TXNSRC", sTxnCnl); /*交易渠道*/
  }else{
    strcpy(sTxnCnl, "WE441");
  }
  strcpy(pICS_TIA->TxnSrc, sTxnCnl);

  time(&cur_time);
  my_tm = localtime(&cur_time);
  sprintf(sTranNo,"%d%d%d%d%d%d11", my_tm->tm_year+1900, my_tm->tm_mon+1, my_tm->tm_mday, my_tm->tm_hour, my_tm->tm_min, my_tm->tm_sec);
  sprintf(sTranDate,"%d-%d-%d",my_tm->tm_year+1900,my_tm->tm_mon+1,my_tm->tm_mday);

  strcpy(pICS_TIA->NodTrc,sTranNo);

  ret = get_config_value(CONFIG_FILE_NAME, "TELLER_NO", sTellerNo);
  if (ret != RETURN_OK)
  return ret;

  strcpy(pICS_TIA->TlrId,sTellerNo);
  strcpy(pICS_TIA->TIATyp,"T");
  strcpy(pICS_TIA->AthLvl,"00");
  strcpy(pICS_TIA->Sup1Id," ");
  strcpy(pICS_TIA->Sup2Id," ");
  strcpy(pICS_TIA->Sup1Pw," ");
  strcpy(pICS_TIA->Sup2Pw," ");
  strcpy(pICS_TIA->Sup1Dv," ");
  strcpy(pICS_TIA->Sup2Dv," ");
  strcpy(pICS_TIA->AthTbl," ");
  strcpy(pICS_TIA->AthLog," ");
  strcpy(pICS_TIA->HLogNo," ");
  strcpy(pICS_TIA->CprInd,"0");
  strcpy(pICS_TIA->EnpInd,"0");
  strcpy(pICS_TIA->NodNo,"441200");
  strcpy(pICS_TIA->OprLvl," ");
  strcpy(pICS_TIA->TrmVer,"v0000001");
  strcpy(pICS_TIA->OutSys," ");
  strcpy(pICS_TIA->Fil," ");

  /* STEP1-3: 填上传串的元素值*/
  memset(Reserve_Code, 0, sizeof(Reserve_Code));
  trim(Reserve_Code);
  getValueOfStr(send_buff,"Reserve_Code", Reserve_Code);   /* 定单号 */
  strcpy(pICS_482999_I->Reserve_Code, Reserve_Code);


  /*发往ICS需加8位报文长度*/
  offset=0;
  offset=offset+8;

  /*STEP1-4:把结构中的结束符替换为空格,上传串末尾加结束符.*/
  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
    if(ics_tia_buff[i]==0)
      ics_tia_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_tia_buff,len);
  offset=offset+sizeof(ICS_DEF_TIA);

  len=sizeof(ICS_DEF_482999_I);
  for(i=0;i<len;i++)
  {
    if(ics_482999i_buff[i]==0)
      ics_482999i_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_482999i_buff,len);
  offset=offset+sizeof(ICS_DEF_482999_I);

  /*发往ICS需加8位报文长度在头*/
  memcpy(sLen,'\0',8);
  sprintf(sLen,"%08d",offset-8);
  memcpy(ics_send_buff,sLen,8);

  ics_send_buff[offset] = '\0';

    /* 与ICS通讯 */
  memset(ics_port,'\0',sizeof(ics_port));

  ret = get_config_value(CONFIG_FILE_NAME, "ICS_PORT_YLT", ics_port);
  if (ret != RETURN_OK)
        return ret;

  flog( STEP_LEVEL,"TO ICS: [%s]",ics_send_buff);

  /*
  ret=clientics( ics_send_buff, ics_recv_buff, atoi(ics_port) );
  if(ret != RETURN_OK)
    return(-1);
  */
  		setValueOfStr(recv_buff, "Reserve_Code", "898966");
			setValueOfStr(recv_buff, "Product_Name", "hao");
      /*
      setValueOfStr(recv_buff, "Provide_Name", Provide_Name);
      setValueOfStr(recv_buff, "Trans_Toal_Amount", Trans_Toal_Amount);
      setValueOfStr(recv_buff, "Paid_Amount", Paid_Amount);
      setValueOfStr(recv_buff, "Arrearage_Amount", Arrearage_Amount);
      */
  return 0;
  flog( STEP_LEVEL,"FROM ICS: [%s]",ics_recv_buff);

  /*--------------------通讯后处理:组成回传报文------------------*/

  memcpy(ics_toa_buff,ics_recv_buff,sizeof(ics_toa_buff));

RETURN:

  if(memcmp(pICS_TOA->RspCod,"000000",sizeof(pICS_TOA->RspCod))==0)/*成功*/
  {
  /* STEP3-1处理页面显示要素: 在这里填写的字段,就是在页面上显示的字段 */
  /* 注意,<br>是页面显示的换行符号 */

      memcpy(ics_482999n_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_482999n_buff));

      memset(Product_Name, 0, sizeof(Product_Name));
      memset(Provide_Name, 0, sizeof(Provide_Name));
      memset(Trans_Toal_Amount, 0, sizeof(Trans_Toal_Amount));
      memset(Paid_Amount, 0, sizeof(Paid_Amount));
      memset(Arrearage_Amount, 0, sizeof(Arrearage_Amount));

      memcpy(Product_Name,pICS_482999_N->Product_Name,sizeof(pICS_482999_N->Product_Name));
      trim(Product_Name);
      sprintf(tmp_val_str,"预定内容: %s  <br>", Product_Name);
      strcat(display_str,tmp_val_str);

      memcpy(Provide_Name,pICS_482999_N->Provide_Name,sizeof(pICS_482999_N->Provide_Name));
      trim(Provide_Name);
      sprintf(tmp_val_str,"服务商: %s  <br>", Provide_Name);
      strcat(display_str,tmp_val_str);

      memcpy(Trans_Toal_Amount,pICS_482999_N->Trans_Toal_Amount,sizeof(pICS_482999_N->Trans_Toal_Amount));
      trim(Trans_Toal_Amount);
      memset(sLeft,0,sizeof(sLeft));
      memset(sRight,0,sizeof(sRight));
      memcpy(sLeft,Trans_Toal_Amount,12);
      memcpy(sRight,Trans_Toal_Amount+12,2);      
      sprintf(tmp_val_str,"总金额: %d.%s  <br>",atoi(sLeft),sRight);
      strcat(display_str,tmp_val_str);

      memcpy(Paid_Amount,pICS_482999_N->Paid_Amount,sizeof(pICS_482999_N->Paid_Amount));
      trim(Paid_Amount);
      memset(sLeft,0,sizeof(sLeft));
      memset(sRight,0,sizeof(sRight));
      memcpy(sLeft,Paid_Amount,12);
      memcpy(sRight,Paid_Amount+12,2);      
      sprintf(tmp_val_str,"已付金额: %d.%s  <br>",atoi(sLeft),sRight);      
      strcat(display_str,tmp_val_str);

      memcpy(Arrearage_Amount,pICS_482999_N->Arrearage_Amount,sizeof(pICS_482999_N->Arrearage_Amount));
      trim(Arrearage_Amount);
      memset(sLeft,0,sizeof(sLeft));
      memset(sRight,0,sizeof(sRight));
      memcpy(sLeft,Arrearage_Amount,12);
      memcpy(sRight,Arrearage_Amount+12,2);      
      sprintf(tmp_val_str,"欠费金额: %d.%s  <br>",atoi(sLeft),sRight);      
      strcat(display_str,tmp_val_str);
                              
      setValueOfStr(recv_buff,"display_zone",display_str);

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
      setValueOfStr(recv_buff, "MGID", tmp_val_str);/*返回码*/


			setValueOfStr(recv_buff, "Reserve_Code", Reserve_Code);
			setValueOfStr(recv_buff, "Product_Name", Product_Name);
      setValueOfStr(recv_buff, "Provide_Name", Provide_Name);
      setValueOfStr(recv_buff, "Trans_Toal_Amount", Trans_Toal_Amount);
      setValueOfStr(recv_buff, "Paid_Amount", Paid_Amount);
      setValueOfStr(recv_buff, "Arrearage_Amount", Arrearage_Amount);
  }
  else if(memcmp(pICS_TOA->RspCod,"482199",sizeof(pICS_TOA->RspCod))==0)/*订单号已缴清*/
  	{
  		memcpy( sErrMsg, pICS_TOA->RspCod, 6 ) ;

      memcpy(ics_482999e_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_482999e_buff));

      strcpy(tmp_val_str,"<font color=ff0000><b>--->订单号已缴清!<br>--->如有疑问或问题请咨询银旅通客户服务热线:4008-960-168</b></font><br>");
      strcat(display_str,tmp_val_str);

      setValueOfStr(recv_buff,"display_zone",display_str);

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
      setValueOfStr(recv_buff,"MGID",tmp_val_str);/*返回码*/
  	}
  else
  { /*失败*/

      memcpy( sErrMsg, pICS_TOA->RspCod, 6 ) ;

      memcpy(ics_482999e_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_482999e_buff));

      strcpy(tmp_val_str,"<font color=ff0000><b>--->定单查询失败!<br>--->如有疑问,请及时与开户银行联系!</b></font><br>");
      strcat(display_str,tmp_val_str);

      sprintf(tmp_val_str,"--->失败原因:[%s] <br>",sErrMsg);
      strcat(display_str,tmp_val_str);

      setValueOfStr(recv_buff,"display_zone",display_str);

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
      setValueOfStr(recv_buff,"MGID",tmp_val_str);/*返回码*/
  }

  flog( STEP_LEVEL,"**482999 返回[%s]******************************",recv_buff);

  return 0;
}
Example #13
0
/******************************************************************************
 * main
 *****************************************************************************/
int main (int argc, char *argv[])
{
  int listenSfd;        // Listen for control connections on this sfd.
  int *csfd;            // An accepted control socket file descriptor.
  pthread_t thread;     // The handle for a new thread.
  pthread_attr_t attr;  // pthread attribute, to set detached state on creation.
  
  char *rootTemp;

  //Retrieve the name of the root directory from the config file.
  if ((rootTemp = get_config_value ("ROOT_PATH_CONFIG", FTP_CONFIG_FILE)) == NULL)
    return -1;

  /* Append the relative path from the server executable to the server root directory
   * to the absolute path of the server executable. */
  if ((rootdir = get_config_path (rootTemp)) == NULL) {
    free (rootTemp);
    return -1;
  }
  free (rootTemp);

  rootTemp = rootdir;
  /* Canonicalize the path to the server root directory 
   * (eg. resolve all "..", ".", excessive "/" and symbolic links). */
  if ((rootdir = canonicalize_file_name (rootTemp)) == NULL) {
    fprintf (stderr, "%s: canonicalize_file_name: %s\n", __FUNCTION__, strerror (errno));
  }
  free (rootTemp);

  //Initialize the pthread attributes.
  if (pthread_attr_init (&attr) != 0) {
    fprintf (stderr, "%s: pthread_attr_init: %s\n", __FUNCTION__, strerror (errno));
    return -1;
  }

  //Set the detach state attribute.
  if (pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) != 0) {
    fprintf (stderr, "%s: pthread_attr_init: %s\n", __FUNCTION__, strerror (errno));
    return -1;
  }

  //Create a socket to listen for control connections.
  if ((listenSfd = get_control_sock ()) == -1)
    return -1;

  //Display usage instructions to the server operator, and connection information.
  if (welcome_message() == -1) {
    return -1;
  }

  /* This loop does the following:
   *   -Accepts a control connection from a client.
   *   -Starts a thread for the accepted control connection.
   *   OR
   *   -Read a command from stdin entered on the server console.
   *   -Call server_cmd_handler to perform the command.
   *
   * This loop will exit when:
   *    -malloc cannot allocate memory for an integer.
   *    -The functions pthread_mutex_lock or pthread_mutex_unlock return error.
   *    -The command "shutdown" is entered on the server console. */ 
  while (1) {
    if ((csfd = malloc (sizeof(*csfd))) == NULL) {
      fprintf (stderr, "%s: malloc of %lu bytes failed\n", __FUNCTION__, sizeof(*csfd));
      break;
    }

    //Accept a connection from the client, or read a server command on stdin.
    if ((*csfd = accept_connection (listenSfd, ACCEPT_CONTROL, NULL)) == -1) {
      free (csfd);
      continue;
    } else if (*csfd == STDIN_READY) {   //There is something to read on stdin.
      if (read_server_cmd () == SHUTDOWN_SERVER) {
	shutdownServer = true;
	free (csfd);
	break;
      } else {
	free (csfd);
	continue;
      }
    }

    //Create a new thread for this control connection.
    if (pthread_create (&thread, &attr, &control_thread, csfd) != 0) {
      fprintf (stderr, "%s: pthread_create: %s\n", __FUNCTION__, strerror (errno));
      free (csfd);
      continue;
    }

    //Increment the control connection thread count.
    if (modify_cthread_count (1) == -1)
      break;
  }

  free (rootdir);

  if (activeControlThreads > 0)
    printf ("waiting on threads to resolve...\n");

  //Wait for the control threads to shutdown.
  while (activeControlThreads > 0) {
    sleep (1);
  }

  if (pthread_attr_destroy (&attr) == -1)
    fprintf (stderr, "%s: pthread_attr_destroy: %s\n", __FUNCTION__, strerror (errno));

  printf ("All threads have terminated, exiting the program.\n");
  return 0;
}
Example #14
0
int
set_mode_live(void)
{
#if defined(NOLIVE)
	fprintf(stderr, "No GPIO interface available, "
	    "disabling live decoding\n");
	cleanup();
	return -1;
#else
#if defined(__FreeBSD__)
	struct gpio_pin pin;
#endif
	char buf[64];
	int res;

	if (filemode == 2) {
		fprintf(stderr, "Already initialized to file mode.\n");
		cleanup();
		return -1;
	}
	/* fill hardware structure and initialize hardware */
	hw.pin = (unsigned)strtol(get_config_value("pin"), NULL, 10);
	hw.active_high = (bool)strtol(get_config_value("activehigh"), NULL, 10);
	hw.freq = (unsigned)strtol(get_config_value("freq"), NULL, 10);
	if (hw.freq < 10 || hw.freq > 155000 || (hw.freq & 1) == 1) {
		fprintf(stderr, "hw.freq must be an even number between 10 "
		    "and 155000 inclusive\n");
		cleanup();
		return -1;
	}
	bit.signal = malloc(hw.freq / 2);
#if defined(__FreeBSD__)
	hw.iodev = (unsigned)strtol(get_config_value("iodev"), NULL, 10);
	res = snprintf(buf, sizeof(buf), "/dev/gpioc%u", hw.iodev);
	if (res < 0 || res >= sizeof(buf)) {
		fprintf(stderr, "hw.iodev too high? (%i)\n", res);
		cleanup();
		return -1;
	}
	fd = open(buf, O_RDONLY);
	if (fd < 0) {
		fprintf(stderr, "open %s: ", buf);
		perror(NULL);
		cleanup();
		return errno;
	}

	pin.gp_pin = hw.pin;
	if (ioctl(fd, GPIOGETCONFIG, &pin) < 0) {
		perror("ioctl(GPIOGETCONFIG)");
		cleanup();
		return errno;
	}
#elif defined(__linux__)
	fd = open("/sys/class/gpio/export", O_WRONLY);
	if (fd < 0) {
		perror("open (/sys/class/gpio/export)");
		cleanup();
		return errno;
	}
	res = snprintf(buf, sizeof(buf), "%u", hw.pin);
	if (res < 0 || res >= sizeof(buf)) {
		fprintf(stderr, "hw.pin too high? (%i)\n", res);
		cleanup();
		return -1;
	}
	if (write(fd, buf, res) < 0) {
		perror("write(export)");
		cleanup();
		if (errno != EBUSY)
			return errno; /* EBUSY -> pin already exported ? */
	}
	if (close(fd) == -1) {
		perror("close(export)");
		cleanup();
		return errno;
	}
	res = snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%u/direction", hw.pin);
	if (res < 0 || res >= sizeof(buf)) {
		fprintf(stderr, "hw.pin too high? (%i)\n", res);
		cleanup();
		return -1;
	}
	fd = open(buf, O_WRONLY);
	if (fd < 0) {
		perror("open (direction)");
		cleanup();
		return errno;
	}
	if (write(fd, "in", 3) < 0) {
		perror("write(in)");
		cleanup();
		return errno;
	}
	if (close(fd) == -1) {
		perror("close(direction)");
		cleanup();
		return errno;
	}
	res = snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%u/value", hw.pin);
	if (res < 0 || res >= sizeof(buf)) {
		fprintf(stderr, "hw.pin too high? (%i)\n", res);
		cleanup();
		return -1;
	}
	fd = open(buf, O_RDONLY | O_NONBLOCK);
	if (fd < 0) {
		perror("open (value)");
		cleanup();
		return errno;
	}
#endif
	filemode = 1;
	return 0;
#endif
}
Example #15
0
int
main(void)
{
  asteroids.lives         = START_LIVES;
  asteroids.display       = NULL;
  asteroids.timer         = NULL;
  asteroids.event_queue   = NULL;
  SHIP *ship;

  bool redraw = true;
  bool quit   = false;
  bool key[7] = { false };

  seed_rand();
  atexit(shutdown);

  if(!init())
    exit(EXIT_FAILURE);

  if((asteroids.high_score = get_config_value("high_score")) == NULL)
    asteroids.high_score = "0";

  asteroids.level = level_create(0, 0);

  if(!(ship = ship_create()))
    exit(EXIT_FAILURE);

  al_flip_display();
  al_start_timer(asteroids.timer);

  while(!quit) {
    ALLEGRO_EVENT ev;
    al_wait_for_event(asteroids.event_queue, &ev);

    if(ev.type == ALLEGRO_EVENT_TIMER) {
      /* start game */
      if(asteroids.level->number == 0 && key[KEY_S]) {
        start();
        continue;
      }

      /* are we out of asteroids to destroy? */
      if(list_length(asteroids.level->asteroids) == 0)
        asteroids.level = level_next(asteroids.level);

      /* update objects */
      ship = ship_update(ship, key, asteroids.timer);
      explosions_update();
      asteroids.level = level_update(asteroids.level, ship, key, asteroids.timer);

      /* ship->asteroid collisions. */
      check_ship_asteroid_collisions(ship, asteroids.level->asteroids);

      /* ship[missile] -> asteroid collisions. */
      check_ship_missile_asteroid_collisions(asteroids.level, ship);

      /* ship[missile] -> saucer collisions. */
      check_ship_missile_saucer_collisions(asteroids.level, ship);

      /* saucer[missile] -> ship collisions. */
      check_saucer_missile_ship_collisions(asteroids.level, ship);

      /* saucer[missile] -> asteroid collisions. */
      check_saucer_missile_asteroids_collisions(asteroids.level);

      /* saucer->asteroid collisions. */
      check_saucer_asteroid_collisions(asteroids.level);

      redraw = true;
    } else if(ev.type == ALLEGRO_EVENT_KEY_DOWN) {
      keydown(ev, key);
      quit = key[KEY_ESCAPE];
    } else if(ev.type == ALLEGRO_EVENT_KEY_UP) {
      keyup(ev, key);
      ship->fire_debounce  = key[KEY_SPACE];
      ship->hyper_debounce = key[KEY_LCONTROL];
    }

    if(redraw && al_is_event_queue_empty(asteroids.event_queue)) {
      redraw = false;
      al_clear_to_color(al_map_rgb(BLACK));

      level_draw(asteroids.level);
      draw_lives();
      draw_high_score();
      animation_draw_list(asteroids.explosions);

      if(asteroids.level->number == 0) {
        draw_home();
        al_flip_display();
        continue;
      }

      if(asteroids.lives > 0) {
        ship_draw(ship, key[KEY_UP]);
        missile_draw_list(ship->missiles);
      } else {
        if(ship->explosion)
          ship_draw(ship, false);
        draw_gameover();
      }

      al_flip_display();
    }
  };

  /* FIXME: cleanup */
  if(asteroids.timer != NULL)
    al_destroy_timer(asteroids.timer);
  if(asteroids.event_queue != NULL)
    al_destroy_event_queue(asteroids.event_queue);
  if(asteroids.display != NULL)
    al_destroy_display(asteroids.display);

  LIST *head = list_first(asteroids.level->asteroids);
  while(head != NULL) {
    ASTEROID *rock = (ASTEROID *) head->data;
    asteroid_free(rock);
    head = head->next;
  }
  ship_free(ship);

  al_destroy_bitmap(asteroids.lives_sprite);
  ship_shutdown();
  missile_shutdown();
  asteroid_shutdown();
  explosion_shutdown();

  al_uninstall_keyboard();

  exit(EXIT_SUCCESS);
}
Example #16
0
int ics_proc_482133(char *send_buff,char *recv_buff)
{
  /*说明:send_buff-上传报文;
          recv_buff-下传报文;
          ics_send_buff-与后台通讯的发送串;
          ics_recv_buff-与后台通讯的接收串;
 */

  int     i;
  int     len;
  int     ret;
  int     offset;
  int     i_biz_id;

  ICS_DEF_TIA   *pICS_TIA;
  ICS_DEF_TOA   *pICS_TOA;
  ICS_DEF_482133_I  *pICS_482133_I;
  ICS_DEF_482133_N  *pICS_482133_N;
  ICS_DEF_482133_E  *pICS_482133_E;

  char      ics_send_buff[LEN_ICS_PROC_BUF];
  char      ics_recv_buff[LEN_ICS_PROC_BUF];
  char      ics_482133i_buff[6];
  char      ics_482133n_buff[21];
  char      ics_482133e_buff[71];
  char      ics_tia_buff[171];
  char      ics_toa_buff[114];
  char      tmp_val_str[LEN_TMP_VAL_STR];
  char      tmp_val_str2[LEN_TMP_VAL_STR];
  char      display_str[LEN_ICS_PROC_BUF];
  char      display_log_str[LEN_ICS_PROC_BUF];
  char      tmpvalue[256];  /*从上传报文中取得的某项值*/
  char      ics_482133o_buff[4096];

  char      sLen[8];
  char      sLeft[14];
  char      sRight[3];
  char      sTranNo[16];
  char      sTranDate[11];
  char      sTellerNo[8];
  char      sErrMsg[64];
  char      ics_port[6];

  char			sSTxnAmt[32];
  char			sTCusNm[32];
  char			sLoSeq[32];
  char      sCarType[32];
  char      sCarNo[32];
  char      sTxnCnl[32];
  time_t    cur_time;

  struct tm   *my_tm;

  FILE      *fp;

/*
  void *pComplibhandle; * Handle to shared lib file *
  int (*pCompfunchandle)(); * Pointer to loaded routine */

  /*-------------------STEP1:通讯前处理-组成上传串--------------------*/

  /* STEP1-1:清理结构和变量 */

  memset(ics_send_buff,'\0',sizeof(ics_send_buff));
  memset(ics_recv_buff,'\0',sizeof(ics_recv_buff));
  memset(ics_482133i_buff,'\0',sizeof(ics_482133i_buff));
  memset(ics_482133n_buff,'\0',sizeof(ics_482133n_buff));
  memset(ics_482133e_buff,'\0',sizeof(ics_482133e_buff));
  memset(ics_tia_buff,'\0',sizeof(ics_tia_buff));
  memset(ics_toa_buff,'\0',sizeof(ics_toa_buff));
  memset(ics_482133o_buff, 0, sizeof(ics_482133o_buff));

  pICS_482133_I=(ICS_DEF_482133_I *)ics_482133i_buff;
  pICS_482133_N=(ICS_DEF_482133_N *)ics_482133n_buff;
  pICS_482133_E=(ICS_DEF_482133_E *)ics_482133e_buff;
  pICS_TIA=(ICS_DEF_TIA *)ics_tia_buff;
  pICS_TOA=(ICS_DEF_TOA *)ics_toa_buff;

  memset(tmp_val_str,'\0',sizeof(tmp_val_str));
  memset(tmp_val_str2,'\0',sizeof(tmp_val_str2));
  memset(display_str,'\0',sizeof(display_str));
  memset(display_log_str,'\0',sizeof(display_log_str));
  memset(tmpvalue,'\0',sizeof(tmpvalue));
  memset(sTranNo,'\0',sizeof(sTranNo));
  memset(sTranDate,'\0',sizeof(sTranDate));
  memset(sErrMsg,'\0',sizeof(sErrMsg));
  memset(sTellerNo,'\0',sizeof(sTellerNo));
  memset( sErrMsg, '\0', sizeof( sErrMsg ) ) ;

  flog( STEP_LEVEL,"--482133 接收[%s]------------------------------",send_buff);
  


  /* STEP1-2:填上传串的固定头 */
  strcpy(pICS_TIA->CCSCod,"TLU6");
	strcpy(pICS_TIA->TTxnCd,"482133");
  strcpy(pICS_TIA->FeCod,"482133");

  strcpy(pICS_TIA->TrmNo,"DVID");
  
  /*将终端的交易渠道赋值进来*/
  /* 如果TXNSRC值没有上送,默认使用WE441 */
  memset(sTxnCnl, '\0', sizeof(sTxnCnl));
  if(strstr(send_buff,"TXNSRC")){
    getValueOfStr(send_buff,"TXNSRC", sTxnCnl); /*交易渠道*/
  }else{
    strcpy(sTxnCnl, "WE441");
  }
  strcpy(pICS_TIA->TxnSrc, sTxnCnl);

  time(&cur_time);
  my_tm = localtime(&cur_time);
  sprintf(sTranNo,"%d%d%d%d%d%d11", my_tm->tm_year+1900, my_tm->tm_mon+1, my_tm->tm_mday, my_tm->tm_hour, my_tm->tm_min, my_tm->tm_sec);
  sprintf(sTranDate,"%d-%d-%d",my_tm->tm_year+1900,my_tm->tm_mon+1,my_tm->tm_mday);

  strcpy(pICS_TIA->NodTrc,sTranNo);

  ret = get_config_value(CONFIG_FILE_NAME, "TELLER_NO", sTellerNo);
  if (ret != RETURN_OK)
  return ret;

  strcpy(pICS_TIA->TlrId,sTellerNo);
  strcpy(pICS_TIA->TIATyp,"T");
  strcpy(pICS_TIA->AthLvl,"00");
  strcpy(pICS_TIA->Sup1Id," ");
  strcpy(pICS_TIA->Sup2Id," ");
  strcpy(pICS_TIA->Sup1Pw," ");
  strcpy(pICS_TIA->Sup2Pw," ");
  strcpy(pICS_TIA->Sup1Dv," ");
  strcpy(pICS_TIA->Sup2Dv," ");
  strcpy(pICS_TIA->AthTbl," ");
  strcpy(pICS_TIA->AthLog," ");
  strcpy(pICS_TIA->HLogNo," ");
  strcpy(pICS_TIA->CprInd,"0");
  strcpy(pICS_TIA->EnpInd,"0");
  strcpy(pICS_TIA->NodNo,"441200");
  strcpy(pICS_TIA->OprLvl," ");
  strcpy(pICS_TIA->TrmVer,"v0000001");
  strcpy(pICS_TIA->OutSys," ");
  strcpy(pICS_TIA->Fil," ");

  /*发往ICS需加8位报文长度*/
  offset=0;
  offset=offset+8;

  /*STEP1-4:把结构中的结束符替换为空格,上传串末尾加结束符.*/
  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
    if(ics_tia_buff[i]==0)
      ics_tia_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_tia_buff,len);
  offset=offset+sizeof(ICS_DEF_TIA);
  
  
  len=sizeof(ICS_DEF_482133_I);
  strcpy(pICS_482133_I->PagIdx, "000001");
  memcpy(ics_send_buff+offset, ics_482133i_buff, len);
  offset=offset+len;


  /*发往ICS需加8位报文长度在头*/
  memcpy(sLen,'\0',8);
  sprintf(sLen,"%08d",offset-8);
  memcpy(ics_send_buff,sLen,8);

  ics_send_buff[offset] = '\0';

    /* 与ICS通讯 */
  memset(ics_port,'\0',sizeof(ics_port));

  ret = get_config_value(CONFIG_FILE_NAME, "ICS_PORT_YLT", ics_port);
  if (ret != RETURN_OK)
        return ret;

	flog( STEP_LEVEL,"TO ICS_PORT: [%s]",ics_send_buff);
  flog( STEP_LEVEL,"TO ICS: [%s]",ics_send_buff);

  ret=clientics( ics_send_buff, ics_recv_buff, atoi(ics_port) );
  if(ret != RETURN_OK)
    return(-1);

  flog( STEP_LEVEL,"FROM ICS: [%s]",ics_recv_buff);
  
  /*--------------------通讯后处理:组成回传报文------------------*/

  memcpy(ics_toa_buff,ics_recv_buff,sizeof(ics_toa_buff));

RETURN:

  if(memcmp(pICS_TOA->RspCod,"000000",sizeof(pICS_TOA->RspCod))==0)/*成功*/
  {
  /* STEP3-1处理页面显示要素: 在这里填写的字段,就是在页面上显示的字段 */
  /* 注意,<br>是页面显示的换行符号 */

      memcpy(ics_482133n_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_482133n_buff));

			memcpy(ics_482133o_buff, ics_recv_buff+sizeof(ics_toa_buff)+sizeof(ics_482133n_buff),  sizeof(ics_recv_buff)-sizeof(ics_toa_buff)-sizeof(ics_482133n_buff));

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
      setValueOfStr(recv_buff, "MGID", tmp_val_str);/*返回码*/
      
      memset(tmp_val_str,'\0',sizeof(tmp_val_str));      
      strcpy(tmp_val_str, ics_482133o_buff);
			flog( STEP_LEVEL,"TO ICS: [%s]",ics_send_buff);
			ics_send_buff[184] = '2';
			
			memset(ics_recv_buff, 0, sizeof(ics_recv_buff));
			memset(ics_toa_buff, 0, sizeof(ics_toa_buff));
			memset(ics_482133n_buff, 0, sizeof(ics_482133n_buff));
			memset(ics_482133o_buff, 0, sizeof(ics_482133o_buff));
		  ret = get_config_value(CONFIG_FILE_NAME, "ICS_PORT_YLT", ics_port);
		  if (ret != RETURN_OK)
		        return ret;			
  		ret=clientics( ics_send_buff, ics_recv_buff, atoi(ics_port) );
  		if(ret != RETURN_OK)
    		return(-1);

  		flog( STEP_LEVEL,"FROM ICS: [%s]",ics_recv_buff);
  
  		memcpy(ics_toa_buff,ics_recv_buff,sizeof(ics_toa_buff));
			if(memcmp(pICS_TOA->RspCod,"000000",sizeof(pICS_TOA->RspCod))==0)/*成功*/{
	      memcpy(ics_482133n_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_482133n_buff));
				memcpy(ics_482133o_buff, ics_recv_buff+sizeof(ics_toa_buff)+sizeof(ics_482133n_buff),  sizeof(ics_recv_buff)-sizeof(ics_toa_buff)-sizeof(ics_482133n_buff));				
				strcat(tmp_val_str, ics_482133o_buff);
			}
			
      setValueOfStr(recv_buff,"display_zone","");
      
      setValueOfStr(recv_buff,"jingquxingxi", tmp_val_str);

  }
  else
  { /*失败*/

      memcpy( sErrMsg, pICS_TOA->RspCod, 6 ) ;

      memcpy(ics_482133e_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_482133e_buff));

      strcpy(tmp_val_str,"<font color=ff0000><b>--->查询景点信息查询失败!<br>--->如有疑问,请及时与开户银行联系!</b></font><br>");
      strcat(display_str,tmp_val_str);

      sprintf(tmp_val_str,"--->失败原因:[%s] <br>",sErrMsg);
      strcat(display_str,tmp_val_str);

      setValueOfStr(recv_buff,"display_zone",display_str);

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
      setValueOfStr(recv_buff,"MGID",tmp_val_str);/*返回码*/
  }

  flog( STEP_LEVEL,"**482133 返回[%s]******************************",recv_buff);

  return 0;
}
Example #17
0
void test()
{
    bool result;
    const uint8_t* filename = (const uint8_t*)"/home/user/test.conf";
    uint8_t buffer[64];
    config_parser_t cfg;

    for(;;)
    {
        toggle_led(LED2);

        log_info(&log, "remove file %s", filename);

        // delete the file
        unlink((const char*)filename);

        // check the file is not present
        if(open_config_file(&cfg, buffer, sizeof(buffer), filename))
        {
            while(get_next_config(&cfg))
            	log_info(&log, "read %s=%s", get_config_key(&cfg), get_config_value(&cfg));
            close_config_file(&cfg);
        }
        else
            log_info(&log, "file %s removed successfully", filename);

        // add to a new file
        result = add_config_entry(buffer, sizeof(buffer),
        							filename,
									(const uint8_t*)"testkey",
									(const uint8_t*)"testvalue");
        log_info(&log, "wrote %s=%s to %s, result=%d", "testkey", "testvalue", filename, result);

        result = add_config_entry(buffer, sizeof(buffer),
        							filename,
									(const uint8_t*)"testkey1",
									(const uint8_t*)"testvalue1");
        log_info(&log, "wrote %s=%s to %s, result=%d", "testkey1", "testvalue1", filename, result);

        // check the file is now present with
        if(open_config_file(&cfg, buffer, sizeof(buffer), filename))
        {
            while(get_next_config(&cfg))
            	log_info(&log, "read %s=%s", get_config_key(&cfg), get_config_value(&cfg));
            close_config_file(&cfg);
        }

        // edit within file
        result = edit_config_entry(buffer, sizeof(buffer),
                                    filename,
                                    (const uint8_t*)"testkey",
                                    (const uint8_t*)"newtestvalue");
        log_info(&log, "wrote %s=%s to %s, result=%d", "testkey", "testvalue", filename, result);

        result = edit_config_entry(buffer, sizeof(buffer),
                                    filename,
                                    (const uint8_t*)"testkey1",
                                    (const uint8_t*)"newtestvalue1");
        log_info(&log, "wrote %s=%s to %s, result=%d", "testkey1", "testvalue1", filename, result);

        // check the file is now present with new values
        if(open_config_file(&cfg, buffer, sizeof(buffer), filename))
        {
            while(get_next_config(&cfg))
                log_info(&log, "read %s=%s", get_config_key(&cfg), get_config_value(&cfg));
            close_config_file(&cfg);
        }

        sleep(10);
    }

	pthread_exit(0);
}
Example #18
0
void config_lua_table::get_values(augs::lua_state_raii& lua) {
	auto set = [&](auto& c, const std::string& ss) { 
		get_config_value(lua, replace_all(ss, ".", "_"), c); 
	};

	set(NVP(launch_mode));
	set(NVP(input_recording_mode));

	set(NVP(recording_replay_speed));

	set(NVP(determinism_test_cloned_cosmoi_count));
	
	set(NVP(enable_hrtf));
	set(NVP(sound_effects_volume));
	set(NVP(music_volume));

	set(NVP(debug_disable_cursor_clipping));

	set(NVP(mouse_sensitivity));

	set(NVP(connect_address));
	set(NVP(connect_port));
	set(NVP(server_port));
	set(NVP(alternative_port));

	set(NVP(nickname));
	set(NVP(debug_second_nickname));

	set(NVP(tickrate));

	set(NVP(jitter_buffer_ms));
	set(NVP(client_commands_jitter_buffer_ms));

	set(NVP(interpolation_speed));
	set(NVP(misprediction_smoothing_multiplier));
	
	set(NVP(debug_var));
	set(NVP(debug_randomize_entropies_in_client_setup));
	set(NVP(debug_randomize_entropies_in_client_setup_once_every_steps));

	set(NVP(server_launch_http_daemon));
	set(NVP(server_http_daemon_port));
	set(NVP(server_http_daemon_html_file_path));

	set(NVP(db_path));
	set(NVP(survey_num_file_path));
	set(NVP(post_data_file_path));
	set(NVP(last_session_update_link));

	set(NVP(director_scenario_filename));
	set(NVP(menu_intro_scenario_filename));

	set(NVP(menu_theme_filename));

	set(NVP(rewind_intro_scene_by_secs));
	set(NVP(start_menu_music_at_secs));

	set(NVP(skip_credits));
	set(NVP(latest_news_url));
	
	set(NVP(hotbar.increase_inside_alpha_when_selected));
	set(NVP(hotbar.colorize_inside_when_selected));
		
	set(NVP(hotbar.primary_selected_color));
	set(NVP(hotbar.secondary_selected_color)); 

}
Example #19
0
int load_config(ocConfig *conf)
{      
  if (conf == NULL)
    return -1;

  if (configFile == 1)
	__android_log_write(ANDROID_LOG_INFO, APPNAME, "Reading config from system partition.");
  else
    __android_log_write(ANDROID_LOG_INFO, APPNAME, "Reading config from SD card.");
	
  if (get_config_value("wake_min_freq=", conf->wake_min_freq) == -1)
    return -1;
  if (get_config_value("wake_max_freq=", conf->wake_max_freq) == -1)
    return -1;
  if (get_config_value("wake_governor=", conf->wake_governor) == -1)
    return -1;
	
   if (get_config_value("wake_min_freq=", conf->wake_min_freq) == -1)
    return -1;
  if (get_config_value("wake_max_freq=", conf->wake_max_freq) == -1)
    return -1;
  if (get_config_value("wake_governor=", conf->wake_governor) == -1)
    return -1;

  if (get_config_value("sleep_min_freq=", conf->sleep_min_freq) == -1)
    return -1;
  if (get_config_value("sleep_max_freq=", conf->sleep_max_freq) == -1)
    return -1;
  if (get_config_value("sleep_governor=", conf->sleep_governor) == -1)
    return -1;
	
  if (get_config_value("battery_temp=", conf->battery_temp) == -1)
    return -1;
  if (get_config_value("battery_temp_min_freq=", conf->battery_temp_min_freq) == -1)
    return -1;
  if (get_config_value("battery_temp_max_freq=", conf->battery_temp_max_freq) == -1)
    return -1;
  if (get_config_value("battery_temp_governor=", conf->battery_temp_governor) == -1)
    return -1;
	
  if (get_config_value("battery_cap=", conf->battery_cap) == -1)
    return -1;
  if (get_config_value("battery_cap_min_freq=", conf->battery_cap_min_freq) == -1)
    return -1;
  if (get_config_value("battery_cap_max_freq=", conf->battery_cap_max_freq) == -1)
    return -1;
  if (get_config_value("battery_cap_governor=", conf->battery_cap_governor) == -1)
    return -1;
	
  if (get_config_value("charge_min_freq=", conf->charge_min_freq) == -1)
    return -1;
  if (get_config_value("charge_max_freq=", conf->charge_max_freq) == -1)
    return -1;
  if (get_config_value("charge_governor=", conf->charge_governor) == -1)
    return -1;

  return 0;
}
int ics_proc_460501_mob(char *send_buff,char *recv_buff)
{
  /*说明:send_buff-上传报文;
          recv_buff-下传报文;
          ics_send_buff-与后台通讯的发送串;
          ics_recv_buff-与后台通讯的接收串;
 */

  int     i;  
  int     len;
  int     ret;
  int     offset;
  int     i_biz_id;

  ICS_DEF_TIA       *pICS_TIA;
  ICS_DEF_TOA       *pICS_TOA;
  ICS_DEF_460501_I_MOB  *pICS_460501_I;
  ICS_DEF_460501_N_MOB  *pICS_460501_N;
  ICS_DEF_460501_E_MOB  *pICS_460501_E;

  char      ics_send_buff[LEN_ICS_PROC_BUF];
  char      ics_recv_buff[LEN_ICS_PROC_BUF];
  char      ics_460501i_buff[185];
  char      ics_460501n_buff[79];
  char      ics_460501e_buff[75];

  char      ics_tia_buff[171];
  char      ics_toa_buff[114];
  char      tmp_val_str[LEN_TMP_VAL_STR];
  char      tmp_val_str2[LEN_TMP_VAL_STR];
  char      tmp_val_str3[LEN_TMP_VAL_STR];
  char      display_str[LEN_ICS_PROC_BUF];
  char      tmpvalue[200];   /*从上传报文中取得的某项值*/

  char			s_CDNO[LEN_CDNO]; /* 卡号 */
  char			s_PSWD[20]; /* 密码 */

  char      sLen[8];
  char      sLeft[14];
  char      sRight[3];
  char      sTranNo[16];
  char      sTranDate[11];
  char      ics_port[6];
  char      sTxnCnl[32];
  char      sErrMsg[64];
  char      sTellerNo[8];
  time_t    cur_time;
  struct tm   *my_tm;

  /*-------------------STEP1:通讯前处理-组成上传串--------------------*/

  /* STEP1-1:清理结构和变量 */

  pICS_460501_I=(ICS_DEF_460501_I_MOB *)ics_460501i_buff;
  pICS_460501_N=(ICS_DEF_460501_N_MOB *)ics_460501n_buff;
  pICS_460501_E=(ICS_DEF_460501_E_MOB *)ics_460501e_buff;
  pICS_TIA=(ICS_DEF_TIA *)ics_tia_buff;
  pICS_TOA=(ICS_DEF_TOA *)ics_toa_buff;

  memset(ics_send_buff,'\0',sizeof(ics_send_buff));
  memset(ics_recv_buff,'\0',sizeof(ics_recv_buff));
  memset(ics_460501i_buff,'\0',sizeof(ics_460501i_buff));
  memset(ics_460501n_buff,'\0',sizeof(ics_460501n_buff));
  memset(ics_460501e_buff,'\0',sizeof(ics_460501e_buff));
  memset(ics_tia_buff,'\0',sizeof(ics_tia_buff));
  memset(ics_toa_buff,'\0',sizeof(ics_toa_buff));

  memset(tmp_val_str,'\0',sizeof(tmp_val_str));
  memset(tmp_val_str2,'\0',sizeof(tmp_val_str2));
  memset(tmp_val_str3,'\0',sizeof(tmp_val_str3));
  memset(display_str,'\0',sizeof(display_str));
  memset(tmpvalue,'\0',sizeof(tmpvalue));
  memset(sTranNo,'\0',sizeof(sTranNo));
	memset(s_CDNO, '\0', sizeof(s_CDNO));
	memset(s_PSWD, '\0', sizeof(s_PSWD));
  memset(sTxnCnl, '\0', sizeof(sTxnCnl));
  memset(sTellerNo,'\0',sizeof(sTellerNo));
  memset(sTranDate,'\0',sizeof(sTranDate));

  flog( STEP_LEVEL,"--460501 接收[%s]-------------------------------",send_buff);

 /* 注意:填充数据最好按照结构定义先后顺序,以免出现数据覆盖问题 */
  /* STEP1-2:填上传串的固定头 */
  strcpy(pICS_TIA->CCSCod,"TLU6");            /* CICS交易代码 */
  strcpy(pICS_TIA->TTxnCd,"460501");
  strcpy(pICS_TIA->FeCod,"460501");
  strcpy(pICS_TIA->TrmNo,"DVID");

  /*将终端的交易渠道赋值进来*/
  /* 如果TXNSRC值没有上送,默认使用WE441 */
  memset(sTxnCnl, '\0', sizeof(sTxnCnl));
  if(strstr(send_buff,"TXNSRC")){
    getValueOfStr(send_buff,"TXNSRC", sTxnCnl); /*交易渠道*/
  }else{
    strcpy(sTxnCnl, "WE441");
  }
  strcpy(pICS_TIA->TxnSrc, sTxnCnl);

  time(&cur_time);
  my_tm = localtime(&cur_time);
  sprintf(sTranNo,"%d%d%d%d%d%d11", my_tm->tm_year+1900, my_tm->tm_mon+1, my_tm->tm_mday, my_tm->tm_hour, my_tm->tm_min, my_tm->tm_sec);
  sprintf(sTranDate,"%d-%d-%d",my_tm->tm_year+1900,my_tm->tm_mon+1,my_tm->tm_mday);

  strcpy(pICS_TIA->NodTrc,sTranNo);           /*柜员号*/

  ret = get_config_value(CONFIG_FILE_NAME, "TELLER_NO", sTellerNo);
  if (ret != RETURN_OK)
    return ret;

  strcpy(pICS_TIA->TlrId,sTellerNo);          /*柜员号*/
  strcpy(pICS_TIA->TIATyp,"T");
  strcpy(pICS_TIA->AthLvl,"00");
  strcpy(pICS_TIA->Sup1Id," ");
  strcpy(pICS_TIA->Sup2Id," ");
  strcpy(pICS_TIA->Sup1Pw," ");
  strcpy(pICS_TIA->Sup2Pw," ");
  strcpy(pICS_TIA->Sup1Dv," ");
  strcpy(pICS_TIA->Sup2Dv," ");
  strcpy(pICS_TIA->AthTbl," ");
  strcpy(pICS_TIA->AthLog," ");
  strcpy(pICS_TIA->HLogNo," ");
  strcpy(pICS_TIA->CprInd,"0");
  strcpy(pICS_TIA->EnpInd,"0");
  strcpy(pICS_TIA->NodNo,"441200");
  strcpy(pICS_TIA->OprLvl," ");
  strcpy(pICS_TIA->TrmVer,"v0000001");
  strcpy(pICS_TIA->OutSys," ");
  strcpy(pICS_TIA->Fil," ");

  /* STEP1-3: 填上传串中的固定元素值*/
  /* 格式: strcpy(pICS_460501_I->RsFld1,"P001"); 第三方交易码(查询)*/

  /* STEP1-4: 从上传报文中获得其余值-用getValueOf函数*/
  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"SigTyp",tmpvalue);  /* 签约类型 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->SigTyp,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"VchNO",tmpvalue);  /* 凭证号 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->VchNO,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"ActTyp",tmpvalue);  /* 账号类型 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->ActTyp,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"ActNo",tmpvalue);  /* 银行账号 */
  trim(tmpvalue);
  strcpy(s_CDNO, tmpvalue);
  strcpy(pICS_460501_I->ActNo,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"ActNam",tmpvalue);  /* 银行账号名称 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->ActNam,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"IdTyp",tmpvalue);  /* 证件类型 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->IdTyp,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"IdNo",tmpvalue);  /* 证件号码 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->IdNo,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"CusNam",tmpvalue);  /* 客户姓名 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->CusNam,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"MstTel",tmpvalue);  /* 主手机号码 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->MstTel,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"SigTel",tmpvalue);  /* 签约手机号码 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->SigTel,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"SigFlg",tmpvalue);  /* 签约标记 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->SigFlg,tmpvalue);

  memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"PINDat",tmpvalue);  /* 银行交易密码 */
  trim(tmpvalue);
  strcpy(pICS_460501_I->PINDat,tmpvalue);

  /*STEP1-4:把结构中的结束符替换为空格,上传串末尾加结束符.*/
  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
    if(ics_tia_buff[i]==0)
      ics_tia_buff[i]=' ';
  }

  /* 校验密码 */
  /*flog( STEP_LEVEL,"----校验密码----\n");
  ret = ics_proc_928460( "1", s_CDNO, "1", s_PSWD, pICS_TOA->RspCod ) ;
  if ( ret < 0 )
  {
		flog( STEP_LEVEL,"CALL 928460 Fail [%d]",ret);
		sprintf( sErrMsg, "密码校验失败![%d]", ret );
		goto RETURN;
  }
  if( memcmp( pICS_TOA->RspCod, "000000", 6 ) != 0 )
  {
		flog( STEP_LEVEL,"928460 return [%s]", pICS_TOA->RspCod ) ;
		goto RETURN;
  }*/

  /*发往ICS需加8位报文长度*/
  offset=0;
  offset=offset+8;

  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
    if(ics_tia_buff[i]==0)
      ics_tia_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_tia_buff,len);
  offset=offset+sizeof(ICS_DEF_TIA);

  len=sizeof(ICS_DEF_460501_I_MOB);
  for(i=0;i<len;i++)
  {
    if(ics_460501i_buff[i]==0)
      ics_460501i_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_460501i_buff,len);
  offset=offset+sizeof(ICS_DEF_460501_I_MOB);

  /*发往ICS需加8位报文长度在头*/
  memcpy(sLen,'\0',8);
  sprintf(sLen,"%08d",offset-8);
  memcpy(ics_send_buff,sLen,8);

  ics_send_buff[offset] = '\0';  

  /*----------------------STEP2:与中间业务前置机通讯-----------------*/
   /* 与ICS通讯 */
   memset(ics_port,'\0',sizeof(ics_port));

   ret = get_config_value(CONFIG_FILE_NAME, "ICS_PORT_MOBIL", ics_port);

   if (ret != RETURN_OK)
   {
       return -2;
   }
   /*-- 打印发送报文与端口 --*/
   flog( STEP_LEVEL,"--发送ics报文--[%s][%s]",ics_send_buff,ics_port);
   /*-- 发送交易到ICS,并接受返回 --*/
   ret=clientics( ics_send_buff,ics_recv_buff, atoi(ics_port) );

   if(ret != RETURN_OK)
       return -1;

    memcpy(pICS_TOA,ics_recv_buff,sizeof(ICS_DEF_TOA));

RETURN:

  /*--------------------STEP3:通讯后处理:组成回传报文------------------*/

  if(memcmp(pICS_TOA->RspCod,"000000",sizeof(pICS_TOA->RspCod))==0
     ||memcmp(pICS_TOA->RspCod,"SC0000",sizeof(pICS_TOA->RspCod))==0)/*成功*/
  {
    /* STEP3-1处理页面显示要素: 在这里填写的字段,就是在页面上显示的字段 */
    /* 注意,<br>是页面显示的换行符号 */
  
    memcpy(pICS_460501_N,ics_recv_buff+sizeof(ICS_DEF_TOA),sizeof(ICS_DEF_460501_N_MOB));
  
    /* 调用setValueOf函数填充 */
      /*格式:setValueOfStr(recv_buff,"display_zone",display_str);*/

      setValueOfStr(recv_buff,"MGID","000000");  /*返回码*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_460501_N->TmpDat,sizeof(pICS_460501_N->TmpDat));
      setValueOfStr(recv_buff,"TmpDat",tmp_val_str);/*包体长度*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_460501_N->ApCode,sizeof(pICS_460501_N->ApCode));
      setValueOfStr(recv_buff,"ApCode",tmp_val_str);/*格式码'SC'*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_460501_N->OFmtCd,sizeof(pICS_460501_N->OFmtCd));
      setValueOfStr(recv_buff,"OFmtCd",tmp_val_str);/*格式码'D04'*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_460501_N->MstTel,sizeof(pICS_460501_N->MstTel));
      setValueOfStr(recv_buff,"MstTel",tmp_val_str);/* 主手机号码 */

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_460501_N->SigTel,sizeof(pICS_460501_N->SigTel));
      setValueOfStr(recv_buff,"SigTel",tmp_val_str);/* 签约手机号码 */

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_460501_N->LogNo,sizeof(pICS_460501_N->LogNo));
      setValueOfStr(recv_buff,"LogNo",tmp_val_str);/* 移动返回流水号 */

    /* STEP3-2 处理页面隐含要素: 这里填写的字段,就是在页面作为隐含input的要素 */
    /* 注意,1.这里设置参数的顺序必须和数据库中参数的顺序一致,否则回出错! 
            2.返回码字段名定义注意与WEB上一致*/ 

  }
  else
  { /*失败*/
      /*获得错误返回包*/
      memcpy(pICS_460501_E,ics_recv_buff+sizeof(ICS_DEF_TOA),sizeof(ICS_DEF_460501_E_MOB));
  
      /* 调用setValueOf函数填充 */
      /*格式:setValueOfStr(recv_buff,"display_zone",display_str);*/
      /*memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_460501_E->RspCod,sizeof(pICS_460501_E->RspCod));
      setValueOfStr(recv_buff,"RspCod",tmp_val_str);*//*返回码       */

      /* 手机银行返回参数 */
      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
      setValueOfStr(recv_buff,"RspCod",tmp_val_str);  /*返回码*/ 

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
      setValueOfStr(recv_buff,"MGID",tmp_val_str);/*返回码*/

      /* 手机银行返回参数 */
      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_460501_E->RspMsg,sizeof(pICS_460501_E->RspMsg));
      setValueOfStr(recv_buff,"RspMsg",tmp_val_str);/*返回码       */

      /* 个人网银返回参数 */
      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_460501_E->RspMsg,sizeof(pICS_460501_E->RspMsg));
      setValueOfStr(recv_buff,"PB_Return_Code_Msg",tmp_val_str);/*返回码       */
  }
  flog( STEP_LEVEL,"**460501 返回[%s]******************************",recv_buff);
  return 0;

}
Example #21
0
int main ( int argc, char const *const *argv )
{
    if ( argc != 3 )
    {
        printf ( "usage: %s CFG_FILE LOG_FILE\n", argv[0] );

        return -1;
    }

    const char *log_filename = argv[2];
    int flags = O_CREAT | O_APPEND | O_RDWR;
    mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
    int log_fd = open ( log_filename, flags, mode );

    if ( log_fd < 0 )
    {
        fprintf ( stderr, "ERROR: Falied to open the log file '%s'\n", log_filename );

        exit ( 1 );
    }

    /* Read the configuration file. */
    struct lcfg *cfg = lcfg_new ( argv[1] );

    if ( lcfg_parse ( cfg ) != lcfg_status_ok )
    {
        printf ( "lcfg error: %s\n", lcfg_error_get ( cfg ) );

        return -1;
    }

    /* Read all the configuration parameters. */
    fprintf ( stdout, "Starting Murano agent with the following configuration:\n\n" );

    const char *host = get_config_value ( cfg, "RABBITMQ_HOST" , 1 );
    int port = atoi ( get_config_value ( cfg, "RABBITMQ_PORT" , 1 ) );
    const char *vhost = get_config_value ( cfg, "RABBITMQ_VHOST"  , 1 );
    const char *username = get_config_value ( cfg, "RABBITMQ_USERNAME"  , 1 );
    const char *password = get_config_value ( cfg, "RABBITMQ_PASSWORD"  , 1 );
    const char *queuename = get_config_value ( cfg, "RABBITMQ_INPUT_QUEUE"  , 1 );
    const char *result_routing_key = get_config_value ( cfg, "RABBITMQ_RESULT_ROUTING_KEY", 1 );

    amqp_connection_state_t conn = amqp_new_connection();
    amqp_socket_t *socket = NULL;
    amqp_bytes_t queuename_bytes = amqp_cstring_bytes ( queuename );

    socket = amqp_tcp_socket_new ( conn );
    if ( !socket )
    {
        die ( "creating TCP socket" );
    }

    if ( amqp_socket_open ( socket, host, port ) )
    {
        die ( "opening TCP socket" );
    }

    die_on_amqp_error ( amqp_login ( conn, vhost, 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, username, password ),
                        "Logging in" );
    amqp_channel_open ( conn, 1 );
    die_on_amqp_error ( amqp_get_rpc_reply ( conn ), "Opening channel" );

    amqp_basic_consume ( conn, 1, queuename_bytes, amqp_empty_bytes, 0, 1, 0, amqp_empty_table );
    die_on_amqp_error ( amqp_get_rpc_reply ( conn ), "Consuming" );

    puts ( "\nSuccessfully connected to Rabbit MQ server! Ready for messages..." );

    run ( conn, log_fd , result_routing_key );

    close ( log_fd );
    lcfg_delete ( cfg );

    die_on_amqp_error ( amqp_channel_close ( conn, 1, AMQP_REPLY_SUCCESS ), "Closing channel" );
    die_on_amqp_error ( amqp_connection_close ( conn, AMQP_REPLY_SUCCESS ), "Closing connection" );
    die_on_error ( amqp_destroy_connection ( conn ), "Ending connection" );

    return 0;
}
Example #22
0
/******************************************************************************
 * cmd_pasv - see net.h
 *****************************************************************************/
int cmd_pasv (session_info_t *si)
{
  //The setting to be searched for in the config file.
  char *interfaceSetting = "INTERFACE_CONFIG";
  //The value for the setting that was searched for in the config file.
  char *interfaceResult;
  //The IPv4 address of the configuration file interface.
  char interfaceAddr[INET_ADDRSTRLEN];

  int csfd = si->csfd;

  //Ensure the client has logged in.
  if (!si->loggedin) {
    send_mesg_530 (csfd, REPLY_530_REQUEST);
    return -1;
  }

  /* The server "MUST" close the data connection port when:
   * "The port specification is changed by a command from the user".
   * Source: RFC 959 page 19 */
  if (si->dsfd > 0) {
    if (close (si->dsfd) == -1)
      fprintf (stderr, "%s: close: %s\n", __FUNCTION__, strerror (errno));
    si->dsfd = 0;
  }

  //Read the config file to find which interface to use to make the socket.
  if ((interfaceResult = get_config_value (interfaceSetting,
					    FTP_CONFIG_FILE)) == NULL) {
    return -1;
  }

  /* Get the IPv4 address for the interface specified in the configuration
   * file. Free the interface string, it is no longer required. */
  if (get_interface_address (interfaceResult, &interfaceAddr) == -1) {
    free (interfaceResult);
    return -1;
  }
  free (interfaceResult);


  //Create a socket that will listen for a data connection from a client.
  if ((si->dsfd = get_pasv_sock (interfaceAddr, NULL)) == -1) {
    return -1;
  }

  //Send the data connection address information to the control socket.
  if (send_mesg_227 (csfd, si->dsfd) == -1) {
    close (si->dsfd);
    si->dsfd = 0;
    return -1;
  }
 
  //Accept a connection from the client on the listening socket.
  if ((si->dsfd = accept_connection (si->dsfd, ACCEPT_PASV, si)) == -1) {
  si->dsfd = 0;
  return -1;
  }

  return si->dsfd;
}
Example #23
0
int ics_proc_482135(char *send_buff,char *recv_buff)
{
  /*说明:send_buff-上传报文;
          recv_buff-下传报文;
          ics_send_buff-与后台通讯的发送串;
          ics_recv_buff-与后台通讯的接收串;
 */

  int     i;
  int     len;
  int     ret;
  int     offset;
  int     i_biz_id;

  ICS_DEF_TIA   *pICS_TIA;
  ICS_DEF_TOA   *pICS_TOA;
  ICS_DEF_482135_I  *pICS_482135_I;
  ICS_DEF_482135_N  *pICS_482135_N;
  ICS_DEF_482135_E  *pICS_482135_E;

  char      ics_send_buff[LEN_ICS_PROC_BUF];
  char      ics_recv_buff[LEN_ICS_PROC_BUF];
  char      ics_482135i_buff[556];
  char      ics_482135n_buff[257];
  char      ics_482135e_buff[71];
  char      ics_tia_buff[171];
  char      ics_toa_buff[114];
  char      tmp_val_str[LEN_TMP_VAL_STR];
  char      tmp_val_str2[LEN_TMP_VAL_STR];
  char      display_str[LEN_ICS_PROC_BUF];
  char      display_log_str[LEN_ICS_PROC_BUF];
  char      tmpvalue[256];  /*从上传报文中取得的某项值*/

  char			s_CDNO[LEN_CDNO]; /* 卡号 */
  char			s_PSWD[21]; /* 密码 */

  char      sLen[8];
  char      sLeft[14];
  char      sRight[3];
  char      sTranNo[16];
  char      sTranDate[11];
  char      sTellerNo[8];
  char      sErrMsg[64];
  char      ics_port[6];

	char  Product_Code[13]; 			  /*门票代码*/
	char  Retail_Price1[15]; 			  /*门市价*/
	char  E_Discount_Price1[15]; 	  /*电子优惠价*/
	char  Reserve_Amoun[5];         /*预订产品数量*/
	char  Mobile_Phone_Number[12];  /*手机号码*/
	char  Begin_Date[9];            /*使用日期*/
	char  Message_Type[3];          /*短信类型*/
	char  Amount1[15];              /*总金额*/
	char  Scence_Code[13];         	/*景区代码*/
	char  Scence_Name[61];         	/*景区名称*/
	char  Product_Name[51];         /*门票名称*/
  char  Remark1[161];             /*备注*/
	char  Valid_Days[4];            /*有效天数*/

	char  TCUSNM[13];               /*订单编号*/
	char  ThdKey[19];               /*银行交易流水号*/
	char  TXNAMT[15];               /**/
	char  Return_Code[4];           /*处理结果*/
	char  PB_Return_Code_Msg[31];   /*处理结果信息*/
	char  TckNo[12];                /*会计流水*/
	char 	sTxnCnl[32];

  time_t    cur_time;

  struct tm   *my_tm;

  FILE      *fp;

/*
  void *pComplibhandle; * Handle to shared lib file *
  int (*pCompfunchandle)(); * Pointer to loaded routine */

  /*-------------------STEP1:通讯前处理-组成上传串--------------------*/

  /* STEP1-1:清理结构和变量 */

  memset(ics_send_buff,'\0',sizeof(ics_send_buff));
  memset(ics_recv_buff,'\0',sizeof(ics_recv_buff));
  memset(ics_482135i_buff,'\0',sizeof(ics_482135i_buff));
  memset(ics_482135n_buff,'\0',sizeof(ics_482135n_buff));
  memset(ics_482135e_buff,'\0',sizeof(ics_482135e_buff));
  memset(ics_tia_buff,'\0',sizeof(ics_tia_buff));
  memset(ics_toa_buff,'\0',sizeof(ics_toa_buff));

  pICS_482135_I=(ICS_DEF_482135_I *)ics_482135i_buff;
  pICS_482135_N=(ICS_DEF_482135_N *)ics_482135n_buff;
  pICS_482135_E=(ICS_DEF_482135_E *)ics_482135e_buff;
  pICS_TIA=(ICS_DEF_TIA *)ics_tia_buff;
  pICS_TOA=(ICS_DEF_TOA *)ics_toa_buff;

  memset(tmp_val_str,'\0',sizeof(tmp_val_str));
  memset(tmp_val_str2,'\0',sizeof(tmp_val_str2));
  memset(display_str,'\0',sizeof(display_str));
  memset(display_log_str,'\0',sizeof(display_log_str));
  memset(tmpvalue,'\0',sizeof(tmpvalue));
  memset(sTranNo,'\0',sizeof(sTranNo));
  memset(sErrMsg,'\0',sizeof(sErrMsg));
  memset(sTranDate,'\0',sizeof(sTranDate));
  memset(sTellerNo,'\0',sizeof(sTellerNo));
  memset(sErrMsg, '\0', sizeof( sErrMsg ) ) ;
	memset(s_CDNO, '\0', sizeof(s_CDNO));
	memset(s_PSWD, '\0', sizeof(s_PSWD));
	memset(sTxnCnl, '\0', sizeof(sTxnCnl));

flog( STEP_LEVEL,"--482135 接收[%s]------------------------------",send_buff);

  /* STEP1-2:填上传串的固定头 */
  strcpy(pICS_TIA->CCSCod,"TLU6");
  strcpy(pICS_TIA->TTxnCd,"482135");
  strcpy(pICS_TIA->FeCod,"482135");
  strcpy(pICS_TIA->TrmNo,"DVID");
  
  /*将终端的交易渠道赋值进来*/
  /* 如果TXNSRC值没有上送,默认使用WE441 */
  memset(sTxnCnl, '\0', sizeof(sTxnCnl));
  if(strstr(send_buff,"TXNSRC")){
    getValueOfStr(send_buff,"TXNSRC", sTxnCnl); /*交易渠道*/
  }else{
    strcpy(sTxnCnl, "WE441");
  }
  strcpy(pICS_TIA->TxnSrc, sTxnCnl);

  time(&cur_time);
  my_tm = localtime(&cur_time);
  sprintf(sTranNo,"%d%d%d%d%d%d11", my_tm->tm_year+1900, my_tm->tm_mon+1, my_tm->tm_mday, my_tm->tm_hour, my_tm->tm_min, my_tm->tm_sec);
  sprintf(sTranDate,"%d-%d-%d",my_tm->tm_year+1900,my_tm->tm_mon+1,my_tm->tm_mday);

  strcpy(pICS_TIA->NodTrc,sTranNo);

  ret = get_config_value(CONFIG_FILE_NAME, "TELLER_NO", sTellerNo);
  if (ret != RETURN_OK)
    return ret;

  strcpy(pICS_TIA->TlrId,sTellerNo);
  strcpy(pICS_TIA->TIATyp,"T");
  strcpy(pICS_TIA->AthLvl,"00");
  strcpy(pICS_TIA->Sup1Id," ");
  strcpy(pICS_TIA->Sup2Id," ");
  strcpy(pICS_TIA->Sup1Pw," ");
  strcpy(pICS_TIA->Sup2Pw," ");
  strcpy(pICS_TIA->Sup1Dv," ");
  strcpy(pICS_TIA->Sup2Dv," ");
  strcpy(pICS_TIA->AthTbl," ");
  strcpy(pICS_TIA->AthLog," ");
  strcpy(pICS_TIA->HLogNo," ");
  strcpy(pICS_TIA->CprInd,"0");
  strcpy(pICS_TIA->EnpInd,"0");
  strcpy(pICS_TIA->NodNo,"441200");
  strcpy(pICS_TIA->OprLvl," ");
  strcpy(pICS_TIA->TrmVer,"v0000001");
  strcpy(pICS_TIA->OutSys," ");
  strcpy(pICS_TIA->Fil," ");

  /* STEP1-3: 填上传串的元素值*/

  strcpy(pICS_482135_I->ActTyp,"4");	/*帐号类型*/

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"CDNO", tmpvalue); /*代扣帐号*/
  trim(tmpvalue);
  strcpy(s_CDNO, tmpvalue);
  strcpy(pICS_482135_I->ActNo, tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"PSWD",tmpvalue); /*密码*/
  trim(tmpvalue);
  strcpy(s_PSWD,tmpvalue);
  strcpy(pICS_482135_I->PinBlk,tmpvalue);

	memset(Product_Code, 0, sizeof(Product_Code));
	memset(Retail_Price1, 0, sizeof(Retail_Price1));
	memset(E_Discount_Price1, 0, sizeof(E_Discount_Price1));
	memset(Reserve_Amoun, 0, sizeof(Reserve_Amoun));
	memset(Mobile_Phone_Number, 0, sizeof(Mobile_Phone_Number));
	memset(Begin_Date, 0, sizeof(Begin_Date));
	memset(Message_Type, 0, sizeof(Message_Type));
	memset(Amount1, 0, sizeof(Amount1));
	memset(Scence_Code, 0, sizeof(Scence_Code));
	memset(Scence_Name, 0, sizeof(Scence_Name));
	memset(Product_Name, 0, sizeof(Product_Name));
	memset(Remark1, 0, sizeof(Remark1));
	memset(Valid_Days, 0, sizeof(Valid_Days));

	getValueOfStr(send_buff,"Product_Code", Product_Code);

	memset(tmpvalue, 0, sizeof(tmpvalue));
	getValueOfStr(send_buff,"Retail_Price1", tmpvalue);
	sprintf(Retail_Price1, "%14.2f", atof(tmpvalue));

	memset(tmpvalue, 0, sizeof(tmpvalue));
	getValueOfStr(send_buff,"E_Discount_Price1", tmpvalue);
	sprintf(E_Discount_Price1, "%014.2f", atof(tmpvalue));

	getValueOfStr(send_buff,"Reserve_Amoun", Reserve_Amoun);
	getValueOfStr(send_buff,"Mobile_Phone_Number", Mobile_Phone_Number);

	memset(tmpvalue, 0, sizeof(tmpvalue));
	getValueOfStr(send_buff,"Begin_Date", tmpvalue);
	strncpy(Begin_Date, tmpvalue, 4);
	if(strlen(tmpvalue) == 10){
		strncpy(Begin_Date+4, tmpvalue+5, 2);
		strncpy(Begin_Date+6, tmpvalue+8, 2);
	}else{
		if(tmpvalue[6] == '-'){
			Begin_Date[4] = '0';
			Begin_Date[5] = tmpvalue[5];
			if(strlen(tmpvalue) == 9){
				strncpy(Begin_Date+6, tmpvalue+7, 2);
			}else{
				Begin_Date[6] = '0';
				Begin_Date[7] = tmpvalue[7];			
			}
		}else{
			strncpy(Begin_Date+4, tmpvalue+5, 2);
		}
	  if(tmpvalue[7] == '-'){
			Begin_Date[6] = '0';
			Begin_Date[7] = tmpvalue[8];
	  }
	}
	getValueOfStr(send_buff,"Message_Type", Message_Type);
	
	memset(tmpvalue, 0, sizeof(tmpvalue));
	getValueOfStr(send_buff,"Amount1", tmpvalue);
	sprintf(Amount1, "%014.2f", atof(tmpvalue));

	getValueOfStr(send_buff,"Scence_Code", Scence_Code);
	getValueOfStr(send_buff,"Scence_Name", Scence_Name);
	getValueOfStr(send_buff,"Product_Name", Product_Name);
	getValueOfStr(send_buff,"Remark1", Remark1);
	getValueOfStr(send_buff,"Valid_Days", Valid_Days);

	memcpy(pICS_482135_I->Product_Code, Product_Code, 12);
	memcpy(pICS_482135_I->Retail_Price1, Retail_Price1, 14);
	memcpy(pICS_482135_I->E_Discount_Price1, E_Discount_Price1, 14);
	memcpy(pICS_482135_I->Reserve_Amoun, Reserve_Amoun, 4);
	memcpy(pICS_482135_I->Mobile_Phone_Number, Mobile_Phone_Number, 11);
	memcpy(pICS_482135_I->Begin_Date, Begin_Date, 8);
	memcpy(pICS_482135_I->Message_Type, Message_Type, 2);
	memcpy(pICS_482135_I->Amount1, Amount1, 14);
	memcpy(pICS_482135_I->Scence_Code, Scence_Code, 12);
	memcpy(pICS_482135_I->Scence_Name, Scence_Name, 60);
	memcpy(pICS_482135_I->Product_Name, Product_Name, 50);
	memcpy(pICS_482135_I->Remark1, Remark1, 160);
	memcpy(pICS_482135_I->Valid_Days, Valid_Days, 3);

  flog( STEP_LEVEL,"----校验密码----\n");
  /* 校验密码 modify by ylw for 异地卡 20120211
  ret = ics_proc_928460( "1", s_CDNO, "1", s_PSWD, pICS_TOA->RspCod ) ;
  if ( ret < 0 )
  {
		flog( STEP_LEVEL,"CALL 928460 Fail [%d]",ret);
		sprintf( sErrMsg, "密码校验失败![%d]", ret );
		goto RETURN;
  }
  if( memcmp( pICS_TOA->RspCod, "000000", 6 ) != 0 )
  {
		flog( STEP_LEVEL,"928460 return [%s]", pICS_TOA->RspCod ) ;
		goto RETURN;
  }
*/

  flog( STEP_LEVEL,"----发往ICS-----\n");
  /*发往ICS需加8位报文长度*/
  offset=0;
  offset=offset+8;

  /*STEP1-4:把结构中的结束符替换为空格,上传串末尾加结束符.*/
  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
    if(ics_tia_buff[i]==0)
      ics_tia_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_tia_buff,len);
  offset=offset+sizeof(ICS_DEF_TIA);

  len=sizeof(ICS_DEF_482135_I);
  for(i=0;i<len;i++)
  {
    if(ics_482135i_buff[i]==0)
      ics_482135i_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_482135i_buff,len);
  offset=offset+sizeof(ICS_DEF_482135_I);

  /*发往ICS需加8位报文长度在头*/
  memcpy(sLen,'\0',8);
  sprintf(sLen,"%08d",offset-8);
  memcpy(ics_send_buff,sLen,8);

  ics_send_buff[offset] = '\0';

  /* 与ICS通讯 */
  memset(ics_port,'\0',sizeof(ics_port));

  ret = get_config_value(CONFIG_FILE_NAME, "ICS_PORT_YLT", ics_port);
  if (ret != RETURN_OK)
        return ret;

flog( STEP_LEVEL,"TO ICS: [%s]",ics_send_buff);

  ret=clientics( ics_send_buff, ics_recv_buff, atoi(ics_port) );
  if(ret != RETURN_OK)
    return(-1);

flog( STEP_LEVEL,"FROM ICS: [%s]",ics_recv_buff);

  /*--------------------通讯后处理:组成回传报文------------------*/

  memcpy(ics_toa_buff,ics_recv_buff,sizeof(ics_toa_buff));

RETURN:

  if(memcmp(pICS_TOA->RspCod,"000000",sizeof(pICS_TOA->RspCod))==0)/*成功*/
  {
    /* STEP3-1处理页面显示要素: 在这里填写的字段,就是在页面上显示的字段 */
    /* 注意,<br>是页面显示的换行符号 */

    memcpy(ics_482135n_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_482135n_buff));

		memset(TCUSNM, 0, sizeof(TCUSNM));
		memset(ThdKey, 0, sizeof(ThdKey));
		memset(TXNAMT, 0, sizeof(TXNAMT));
		memset(Return_Code, 0, sizeof(Return_Code));
		memset(PB_Return_Code_Msg, 0, sizeof(PB_Return_Code_Msg));
		memset(TckNo, 0, sizeof(TckNo));

		memcpy(TCUSNM, pICS_482135_N->TCUSNM, 12);
		memcpy(ThdKey, pICS_482135_N->ThdKey, 18);
		memcpy(TXNAMT, pICS_482135_N->TXNAMT, 14);
		memcpy(Return_Code, pICS_482135_N->Return_Code, 3);
		memcpy(PB_Return_Code_Msg, pICS_482135_N->PB_Return_Code_Msg, 30);
		memcpy(TckNo, pICS_482135_N->TckNo, 11);

	  trim(TCUSNM);
	  trim(ThdKey);
	  trim(TXNAMT);
	  trim(Return_Code);
	  trim(PB_Return_Code_Msg);
	  trim(TckNo);
    setValueOfStr(recv_buff,"TCUSNM",TCUSNM);
    setValueOfStr(recv_buff,"ThdKey",ThdKey);
    setValueOfStr(recv_buff,"TXNAMT",TXNAMT);
    setValueOfStr(recv_buff,"Return_Code",Return_Code);
    setValueOfStr(recv_buff,"PB_Return_Code_Msg",PB_Return_Code_Msg);
    setValueOfStr(recv_buff,"TckNo",TckNo);

    setValueOfStr(recv_buff,"display_zone",display_str);

    memset(tmp_val_str,'\0',sizeof(tmp_val_str));
    memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
    setValueOfStr(recv_buff,"MGID",tmp_val_str);/*返回码*/

  }
  else
  { /*失败*/
    memcpy(ics_482135e_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_482135e_buff));

    if( memcmp( pICS_TOA->RspCod, "PC5012", 6 ) == 0 )
        strcpy( sErrMsg, "密码不符" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "PD5012", 6 ) == 0 )
        strcpy( sErrMsg, "密码不符" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "PD5100", 6 ) == 0 )
        strcpy( sErrMsg, "借记卡可用余额不足" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "PC3254", 6 ) == 0 )
        strcpy( sErrMsg, "此交易不允许透支" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "PD5044", 6 ) == 0 )
       strcpy( sErrMsg, "密码错误次数超过限制" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "TC2051", 6 ) == 0 )
        strcpy( sErrMsg, "密码校验错" ) ;
    else
        /*memcpy( sErrMsg, pICS_TOA->RspCod, 6 ) ;*/
        strcpy(sErrMsg, pICS_482135_E->RspMsg);

		trim(sErrMsg);

    strcpy(tmp_val_str,"<font color=ff0000><b>--->交费失败!<br>--->如有疑问,请及时与开户银行联系!</b></font><br>");
    strcat(display_str,tmp_val_str);

    sprintf(tmp_val_str,"--->失败原因:[%s] <br>",sErrMsg);
    strcat(display_str,tmp_val_str);

    setValueOfStr(recv_buff,"display_zone",display_str);

    memset(tmp_val_str,'\0',sizeof(tmp_val_str));
    memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
    setValueOfStr(recv_buff,"MGID",tmp_val_str);/*返回码*/
    setValueOfStr(recv_buff,"PB_Return_Code_Msg",sErrMsg);
  }

flog( STEP_LEVEL,"**482135 返回[%s]******************************",recv_buff);

  return 0;
}
Example #24
0
int ics_proc_482184(char *send_buff,char *recv_buff)
{
  /*说明:send_buff-上传报文;
          recv_buff-下传报文;
          ics_send_buff-与后台通讯的发送串;
          ics_recv_buff-与后台通讯的接收串;
 */

  int			i;	
  int 		len;
  int     ret;
  int			offset;
  int			i_biz_id;

  ICS_DEF_TIA		*pICS_TIA;
  ICS_DEF_TOA		*pICS_TOA;
  ICS_DEF_482184_I	*pICS_482184_I;
  ICS_DEF_482184_N	*pICS_482184_N;
  ICS_DEF_482184_E	*pICS_482184_E;

  char			ics_send_buff[LEN_ICS_PROC_BUF];
  char			ics_recv_buff[LEN_ICS_PROC_BUF];
  char			ics_482184i_buff[38];
  char			ics_482184n_buff[118];
  char			ics_482184e_buff[75];
  char			ics_tia_buff[171];
  char			ics_toa_buff[114];
  char 			tmp_val_str[LEN_TMP_VAL_STR];
  char 			tmp_val_str2[LEN_TMP_VAL_STR];
  char 			tmp_val_str3[LEN_TMP_VAL_STR];
  char 			display_str[LEN_ICS_PROC_BUF];
  char      tmpvalue[40]; 	/*从上传报文中取得的某项值*/
  char			sLen[8];
  char			sLeft[14];
  char			sRight[3];
  char			ics_port[6];
  char      sTxnCnl[32];
 

  FILE 			*fp;

  /*-------------------STEP1:通讯前处理-组成上传串--------------------*/

  /* STEP1-1:清理结构和变量 */

	pICS_482184_I=(ICS_DEF_482184_I *)ics_482184i_buff;
	pICS_482184_N=(ICS_DEF_482184_N *)ics_482184n_buff;
	pICS_482184_E=(ICS_DEF_482184_E *)ics_482184e_buff;
	pICS_TIA=(ICS_DEF_TIA *)ics_tia_buff;
	pICS_TOA=(ICS_DEF_TOA *)ics_toa_buff;

	memset(ics_send_buff,'\0',sizeof(ics_send_buff));
	memset(ics_recv_buff,'\0',sizeof(ics_recv_buff));
	memset(ics_482184i_buff,'\0',sizeof(ics_482184i_buff));
	memset(ics_482184n_buff,'\0',sizeof(ics_482184n_buff));
	memset(ics_482184e_buff,'\0',sizeof(ics_482184e_buff));
	memset(ics_tia_buff,'\0',sizeof(ics_tia_buff));
	memset(ics_toa_buff,'\0',sizeof(ics_toa_buff));

	memset(tmp_val_str,'\0',sizeof(tmp_val_str));
	memset(tmp_val_str2,'\0',sizeof(tmp_val_str2));
	memset(tmp_val_str3,'\0',sizeof(tmp_val_str3));
	memset(display_str,'\0',sizeof(display_str));
	memset(tmpvalue,'\0',sizeof(tmpvalue));
  
flog( STEP_LEVEL,"--482184 接收[%s]-------------------------------",send_buff);

 /* 注意:填充数据最好按照结构定义先后顺序,以免出现数据覆盖问题 */
  /* STEP1-2:填上传串的固定头 */
  strcpy(pICS_TIA->CCSCod,"TLU6");   /* CICS交易代码 */
  strcpy(pICS_TIA->TTxnCd,"482184");
  strcpy(pICS_TIA->FeCod,"482184");
  strcpy(pICS_TIA->TrmNo,"DVID"); 
  strcpy(pICS_TIA->NodTrc,"200704100044191");
  strcpy(pICS_TIA->TlrId,"ABIA041");
  strcpy(pICS_TIA->TIATyp,"T");
  strcpy(pICS_TIA->AthLvl,"00");
  strcpy(pICS_TIA->Sup1Id,"       ");
  strcpy(pICS_TIA->Sup2Id,"       ");
  strcpy(pICS_TIA->Sup1Pw,"      ");
  strcpy(pICS_TIA->Sup2Pw,"      ");
  strcpy(pICS_TIA->Sup1Dv," ");
  strcpy(pICS_TIA->Sup2Dv," ");
  strcpy(pICS_TIA->AthTbl,"                                                            ");
  strcpy(pICS_TIA->AthLog," ");
  strcpy(pICS_TIA->HLogNo,"         ");
  strcpy(pICS_TIA->CprInd,"0");
  strcpy(pICS_TIA->EnpInd,"0");
  strcpy(pICS_TIA->NodNo,"441800");
  strcpy(pICS_TIA->OprLvl," ");
  strcpy(pICS_TIA->TrmVer,"v0000001");
  strcpy(pICS_TIA->OutSys," ");
  strcpy(pICS_TIA->Fil,"  ");
  
  /*将终端的交易渠道赋值进来*/
  /* 如果TXNSRC值没有上送,默认使用WE441 */
  memset(sTxnCnl, '\0', sizeof(sTxnCnl));
  if(strstr(send_buff,"TXNSRC")){
    getValueOfStr(send_buff,"TXNSRC", sTxnCnl); /*交易渠道*/
  }else{
    strcpy(sTxnCnl, "WE441");
  }
  strcpy(pICS_TIA->TxnSrc, sTxnCnl);

  /* STEP1-3: 填上传串中的固定元素值*/
  /*strcpy(pICS_482180_I->MsgType,"1129"); 消息类别(查询用户属性)*/

  /* STEP1-4: 从上传报文中获得其余值-用getValueOf函数*/
  getValueOfStr(send_buff,"biz_id",tmpvalue); /*第三方业务类型*/
  i_biz_id = atoi(tmpvalue);

  memset(tmpvalue,'\0',sizeof(tmpvalue));
  getValueOfStr(send_buff,"CTSQ",tmpvalue); /*缴费号码*/
  strcpy(pICS_482184_I->TCusID,tmpvalue);

  memset(tmpvalue,'\0',sizeof(tmpvalue));
  getValueOfStr(send_buff,"DestAttr",tmpvalue); /*被查询用户属性(0:固话 1:小灵通,2:移动,3:ADSL,4:智能公话,5:互联星空,6:付费易账户)*/
  strcpy(pICS_482184_I->DestAttr,tmpvalue);

  /*STEP1-4:把结构中的结束符替换为空格,上传串末尾加结束符.*/
  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
  	if(ics_tia_buff[i]==0)
   		ics_tia_buff[i]=' ';
  }

  /*发往ICS需加8位报文长度*/
  offset=0;
  offset=offset+8;

  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
    if(ics_tia_buff[i]==0)
      ics_tia_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_tia_buff,len);
  offset=offset+sizeof(ICS_DEF_TIA);

  len=sizeof(ICS_DEF_482184_I);
  for(i=0;i<len;i++)
  {
  	if(ics_482184i_buff[i]==0)
   		ics_482184i_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_482184i_buff,len);
  offset=offset+sizeof(ICS_DEF_482184_I);

  /*发往ICS需加8位报文长度在头*/
  memcpy(sLen,'\0',8);
  sprintf(sLen,"%08d",offset-8);
  memcpy(ics_send_buff,sLen,8);

  ics_send_buff[offset] = '\0';  

  /*----------------------STEP2:与中间业务前置机通讯-----------------*/
   /* 与ICS通讯 */
  memset(ics_port,'\0',sizeof(ics_port));

  ret = get_config_value(CONFIG_FILE_NAME, "ICS_PORT_DXCZ", ics_port);
  if (ret != RETURN_OK)
  {
		return -2;
  }

  ret=clientics( ics_send_buff,ics_recv_buff, atoi(ics_port) );
  if(ret != RETURN_OK)
		return -1;

  memcpy(pICS_TOA,ics_recv_buff,sizeof(ICS_DEF_TOA));

  /*--------------------STEP3:通讯后处理:组成回传报文------------------*/

  if(memcmp(pICS_TOA->RspCod,"000000",sizeof(pICS_TOA->RspCod))==0)/*成功*/
  {
  /* STEP3-1处理页面显示要素: 在这里填写的字段,就是在页面上显示的字段 */
  /* 注意,<br>是页面显示的换行符号 */

		memcpy(pICS_482184_N,ics_recv_buff+sizeof(ICS_DEF_TOA),sizeof(ICS_DEF_482184_N));

  	memset(tmp_val_str2,0,sizeof(tmp_val_str2));
		memcpy(tmp_val_str2,pICS_482184_N->Balance,sizeof(pICS_482184_N->Balance));
		memset(sLeft,0,sizeof(sLeft));
		memset(sRight,0,sizeof(sRight));
		memcpy(sLeft,tmp_val_str2,10);
		memcpy(sRight,tmp_val_str2+10,2);
		sprintf(tmp_val_str,"话费余额: %d.%s  <br>",atoi(sLeft),sRight);
		strcat(display_str,tmp_val_str);
  	
  	memset(tmp_val_str2,0,sizeof(tmp_val_str2));
		memcpy(tmp_val_str2,pICS_482184_N->EffTime,8);
		sprintf(tmp_val_str,"余额有效期开始时间: %s <br>",tmp_val_str2);
		strcat(display_str,tmp_val_str);
		
  	memset(tmp_val_str2,0,sizeof(tmp_val_str2));
		memcpy(tmp_val_str2,pICS_482184_N->ExpireTime,8);
		sprintf(tmp_val_str,"余额到期时间: %s <br>",tmp_val_str2);
		strcat(display_str,tmp_val_str);
  	
  	memset(tmp_val_str2,0,sizeof(tmp_val_str2));
		memcpy(tmp_val_str2,pICS_482184_N->DqCode,sizeof(pICS_482184_N->DqCode));
		sprintf(tmp_val_str,"号码归属地区号: %s <br>",tmp_val_str2);
		strcat(display_str,tmp_val_str);
  	
		/* 调用setValueOf函数填充 */
  	setValueOfStr(recv_buff,"display_zone",display_str);
  	
 		/* STEP3-2 处理页面隐含要素: 这里填写的字段,就是在页面作为隐含input的要素 */
 		/* 注意,1.这里设置参数的顺序必须和数据库中参数的顺序一致,否则回出错! 
  	        2.返回码字段名定义注意与WEB上一致*/ 
  	
		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
		setValueOfStr(recv_buff,"MGID",tmp_val_str); /*返回码*/ 

		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_482184_N->BalTyp,sizeof(pICS_482184_N->BalTyp));
		setValueOfStr(recv_buff,"BalTyp",tmp_val_str);/*余额类型*/ 
  	
		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_482184_N->Balance,sizeof(pICS_482184_N->Balance));
		setValueOfStr(recv_buff,"Balance",tmp_val_str);/*话费余额*/ 
  	
		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_482184_N->EffTime,sizeof(pICS_482184_N->EffTime));
		setValueOfStr(recv_buff,"EffTime",tmp_val_str);/*余额有效期开始时间*/ 
		
		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_482184_N->ExpireTime,sizeof(pICS_482184_N->ExpireTime));
		setValueOfStr(recv_buff,"ExpireTime",tmp_val_str);/*余额到期时间*/
  	
		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_482184_N->BillMode,sizeof(pICS_482184_N->BillMode));
		setValueOfStr(recv_buff,"BillMode",tmp_val_str);/*用户付费属性*/ 
  	
		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_482184_N->DestAttr,sizeof(pICS_482184_N->DestAttr));
		setValueOfStr(recv_buff,"DestAttr",tmp_val_str);/*用户属性*/ 
  	
		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_482184_N->DqCode,sizeof(pICS_482184_N->DqCode));
		setValueOfStr(recv_buff,"DqCode",tmp_val_str);/*号码归属地区号*/ 

		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_482184_N->objectHome,sizeof(pICS_482184_N->objectHome));
		setValueOfStr(recv_buff,"objectHome",tmp_val_str);/*号码归属平台*/ 
		
		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_482184_N->TCusID,sizeof(pICS_482184_N->TCusID));
		setValueOfStr(recv_buff,"CTSQ",tmp_val_str);/*被充值号码*/ 
		
  }
  else
  {	/*失败*/
		memcpy(pICS_482184_E,ics_recv_buff+sizeof(ICS_DEF_TOA),sizeof(ICS_DEF_482184_E));
		strcpy(tmp_val_str,"<font color=ff0000>--->交易失败</font><br>");
		strcat(display_str,tmp_val_str);
  	
  	memset(tmp_val_str2,0,sizeof(tmp_val_str2));
		memcpy(tmp_val_str2,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
		sprintf(tmp_val_str,"--->失败原因:[%s] ",tmp_val_str2);
		strcat(display_str,tmp_val_str);
  	
  	memset(tmp_val_str2,0,sizeof(tmp_val_str2));
		memcpy(tmp_val_str2,pICS_482184_E->RspMsg,sizeof(pICS_482184_E->RspMsg));
		sprintf(tmp_val_str,"[%s] <br>",tmp_val_str2);
		strcat(display_str,tmp_val_str);
  	
  	setValueOfStr(recv_buff,"display_zone",display_str);
  	
		memset(tmp_val_str,'\0',sizeof(tmp_val_str));
		memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
 		setValueOfStr(recv_buff,"MGID",tmp_val_str);/*返回码*/
  }
flog( STEP_LEVEL,"**482184 返回[%s]******************************",recv_buff);

  return 0;
}
int ics_proc_482101_tc(char *send_buff,char *recv_buff)
{
  /*说明:send_buff-上传报文;
          recv_buff-下传报文;
          ics_send_buff-与后台通讯的发送串;
          ics_recv_buff-与后台通讯的接收串;
 */

  int     i;  
  int     len;
  int     ret;
  int     offset;
  int     i_biz_id;

  ICS_DEF_TIA       *pICS_TIA;
  ICS_DEF_TOA       *pICS_TOA;
  ICS_DEF_482101_I_TC  *pICS_482101_I;
  ICS_DEF_482101_N_TC  *pICS_482101_N;
  ICS_DEF_482101_E_TC  *pICS_482101_E;

  char      ics_send_buff[LEN_ICS_PROC_BUF];
  char      ics_recv_buff[LEN_ICS_PROC_BUF];
  char      ics_482101i_buff[215];
  char      ics_482101n_buff[279];
  char      ics_482101e_buff[69];

  char      ics_tia_buff[171];
  char      ics_toa_buff[114];
  char      tmp_val_str[LEN_TMP_VAL_STR];
  char      tmp_val_str2[LEN_TMP_VAL_STR];
  char      tmp_val_str3[LEN_TMP_VAL_STR];
  char      display_str[LEN_ICS_PROC_BUF];
  char      tmpvalue[200];   /*从上传报文中取得的某项值*/

  char			s_CDNO[LEN_CDNO]; /* 卡号 */
  char			s_PSWD[20]; /* 密码 */

  char      sLen[8];
  char      sLeft[14];
  char      sRight[3];
  char      sTranNo[16];
  char      sTranDate[11];
  char      ics_port[6];
  char      sTxnCnl[32];
  char      sErrMsg[64];
  char      sTellerNo[8];
  time_t    cur_time;
  struct tm   *my_tm;

  /*-------------------STEP1:通讯前处理-组成上传串--------------------*/

  /* STEP1-1:清理结构和变量 */

  pICS_482101_I=(ICS_DEF_482101_I_TC *)ics_482101i_buff;
  pICS_482101_N=(ICS_DEF_482101_N_TC *)ics_482101n_buff;
  pICS_482101_E=(ICS_DEF_482101_E_TC *)ics_482101e_buff;
  pICS_TIA=(ICS_DEF_TIA *)ics_tia_buff;
  pICS_TOA=(ICS_DEF_TOA *)ics_toa_buff;

  memset(ics_send_buff,'\0',sizeof(ics_send_buff));
  memset(ics_recv_buff,'\0',sizeof(ics_recv_buff));
  memset(ics_482101i_buff,'\0',sizeof(ics_482101i_buff));
  memset(ics_482101n_buff,'\0',sizeof(ics_482101n_buff));
  memset(ics_482101e_buff,'\0',sizeof(ics_482101e_buff));
  memset(ics_tia_buff,'\0',sizeof(ics_tia_buff));
  memset(ics_toa_buff,'\0',sizeof(ics_toa_buff));

  memset(tmp_val_str,'\0',sizeof(tmp_val_str));
  memset(tmp_val_str2,'\0',sizeof(tmp_val_str2));
  memset(tmp_val_str3,'\0',sizeof(tmp_val_str3));
  memset(display_str,'\0',sizeof(display_str));
  memset(tmpvalue,'\0',sizeof(tmpvalue));
  memset(sTranNo,'\0',sizeof(sTranNo));
	memset(s_CDNO, '\0', sizeof(s_CDNO));
	memset(s_PSWD, '\0', sizeof(s_PSWD));
  memset(sTxnCnl, 0, sizeof(sTxnCnl));
  memset(sTellerNo,'\0',sizeof(sTellerNo));
  memset(sTranDate,'\0',sizeof(sTranDate));

flog( STEP_LEVEL,"--482101 接收[%s]-------------------------------",send_buff);

 /* 注意:填充数据最好按照结构定义先后顺序,以免出现数据覆盖问题 */
  /* STEP1-2:填上传串的固定头 */
  strcpy(pICS_TIA->CCSCod,"TLU6");            /* CICS交易代码 */
  strcpy(pICS_TIA->TTxnCd,"482101");
  strcpy(pICS_TIA->FeCod,"482101");
  strcpy(pICS_TIA->TrmNo,"DVID");

  getValueOfStr(send_buff,"TXNSRC", sTxnCnl); /*交易渠道*/
  strcpy(pICS_TIA->TxnSrc,sTxnCnl);

  time(&cur_time);
  my_tm = localtime(&cur_time);
  sprintf(sTranNo,"%d%d%d%d%d%d11", my_tm->tm_year+1900, my_tm->tm_mon+1, my_tm->tm_mday, my_tm->tm_hour, my_tm->tm_min, my_tm->tm_sec);
  sprintf(sTranDate,"%d-%d-%d",my_tm->tm_year+1900,my_tm->tm_mon+1,my_tm->tm_mday);

  strcpy(pICS_TIA->NodTrc,sTranNo);           /*柜员号*/

  ret = get_config_value(CONFIG_FILE_NAME, "TELLER_NO", sTellerNo);
  if (ret != RETURN_OK)
    return ret;

  strcpy(pICS_TIA->TlrId,sTellerNo);          /*柜员号*/
  strcpy(pICS_TIA->TIATyp,"T");
  strcpy(pICS_TIA->AthLvl,"00");
  strcpy(pICS_TIA->Sup1Id," ");
  strcpy(pICS_TIA->Sup2Id," ");
  strcpy(pICS_TIA->Sup1Pw," ");
  strcpy(pICS_TIA->Sup2Pw," ");
  strcpy(pICS_TIA->Sup1Dv," ");
  strcpy(pICS_TIA->Sup2Dv," ");
  strcpy(pICS_TIA->AthTbl," ");
  strcpy(pICS_TIA->AthLog," ");
  strcpy(pICS_TIA->HLogNo," ");
  strcpy(pICS_TIA->CprInd,"0");
  strcpy(pICS_TIA->EnpInd,"0");
  strcpy(pICS_TIA->NodNo,"441200");
  strcpy(pICS_TIA->OprLvl," ");
  strcpy(pICS_TIA->TrmVer,"v0000001");
  strcpy(pICS_TIA->OutSys," ");
  strcpy(pICS_TIA->Fil," ");

  /* STEP1-3: 填上传串中的固定元素值*/
  /* 格式: strcpy(pICS_482101_I->RsFld1,"P001"); 第三方交易码(查询)*/

  /* STEP1-4: 从上传报文中获得其余值-用getValueOf函数*/
	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"CrdNo",tmpvalue);  /*卡号          */
  trim(tmpvalue);
  strcpy(s_CDNO, tmpvalue);
  strcpy(pICS_482101_I->CrdNo,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"PSWD",tmpvalue);   /*密码          */
  trim(tmpvalue);
  strcpy(s_PSWD,tmpvalue);

  strcpy(pICS_482101_I->PinBlk,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"TxnAmt",tmpvalue); /*交易金额      */
  strcpy(pICS_482101_I->TxnAmt,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"TrmCod",tmpvalue); /*期号          */
  strcpy(pICS_482101_I->TrmCod,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"TikMod",tmpvalue); /*购票方式      */
  strcpy(pICS_482101_I->TikMod,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"LotTyp",tmpvalue); /*彩票类型      */
  strcpy(pICS_482101_I->LotTyp,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"SigDup",tmpvalue); /*单复式区分    */
  strcpy(pICS_482101_I->SigDup,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"NotNum",tmpvalue); /*注数          */
  strcpy(pICS_482101_I->NotNum,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"MulTip",tmpvalue); /*倍数          */
  strcpy(pICS_482101_I->MulTip,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"ExtNum",tmpvalue); /*扩展号码      */
  strcpy(pICS_482101_I->ExtNum,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
        memset(pICS_482101_I->LotNum, ' ', sizeof(pICS_482101_I->LotNum));
  getValueOfStr(send_buff,"LotNum",tmpvalue); /*投注号码      */
  strcpy(pICS_482101_I->LotNum,tmpvalue);

	memset(tmpvalue, 0, sizeof(tmpvalue));
  getValueOfStr(send_buff,"CntTel",tmpvalue); /*手机号码      */
  strcpy(pICS_482101_I->CntTel,tmpvalue);


  /*STEP1-4:把结构中的结束符替换为空格,上传串末尾加结束符.*/
  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
    if(ics_tia_buff[i]==0)
      ics_tia_buff[i]=' ';
  }

  /* 校验密码 */
  /*flog( STEP_LEVEL,"----校验密码----\n");
  ret = ics_proc_928460( "1", s_CDNO, "1", s_PSWD, pICS_TOA->RspCod ) ;
  if ( ret < 0 )
  {
		flog( STEP_LEVEL,"CALL 928460 Fail [%d]",ret);
		sprintf( sErrMsg, "密码校验失败![%d]", ret );
		goto RETURN;
  }
  if( memcmp( pICS_TOA->RspCod, "000000", 6 ) != 0 )
  {
		flog( STEP_LEVEL,"928460 return [%s]", pICS_TOA->RspCod ) ;
		goto RETURN;
  }*/

  /*发往ICS需加8位报文长度*/
  offset=0;
  offset=offset+8;

  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
        if(ics_tia_buff[i]==0)
                ics_tia_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_tia_buff,len);
  offset=offset+sizeof(ICS_DEF_TIA);

  len=sizeof(ICS_DEF_482101_I_TC);
  for(i=0;i<len;i++)
  {
    if(ics_482101i_buff[i]==0)
      ics_482101i_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_482101i_buff,len);
  offset=offset+sizeof(ICS_DEF_482101_I_TC);

  /*发往ICS需加8位报文长度在头*/
  memcpy(sLen,'\0',8);
  sprintf(sLen,"%08d",offset-8);
  memcpy(ics_send_buff,sLen,8);

  ics_send_buff[offset] = '\0';  

  /*----------------------STEP2:与中间业务前置机通讯-----------------*/
   /* 与ICS通讯 */
   memset(ics_port,'\0',sizeof(ics_port));

   ret = get_config_value(CONFIG_FILE_NAME, "ICS_PORT_TC", ics_port);

   if (ret != RETURN_OK)
   {
       return -2;
   }

   ret=clientics( ics_send_buff,ics_recv_buff, atoi(ics_port) );

   if(ret != RETURN_OK)
       return -1;

    memcpy(pICS_TOA,ics_recv_buff,sizeof(ICS_DEF_TOA));

RETURN:

  /*--------------------STEP3:通讯后处理:组成回传报文------------------*/

  if(memcmp(pICS_TOA->RspCod,"000000",sizeof(pICS_TOA->RspCod))==0)/*成功*/
  {
    /* STEP3-1处理页面显示要素: 在这里填写的字段,就是在页面上显示的字段 */
    /* 注意,<br>是页面显示的换行符号 */
  
    memcpy(pICS_482101_N,ics_recv_buff+sizeof(ICS_DEF_TOA),sizeof(ICS_DEF_482101_N_TC));
  
    /* 调用setValueOf函数填充 */
      /*格式:setValueOfStr(recv_buff,"display_zone",display_str);*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
      setValueOfStr(recv_buff,"MGID",tmp_val_str);  /*返回码*/ 

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->TmpDat,sizeof(pICS_482101_N->TmpDat));
      setValueOfStr(recv_buff,"TmpDat",tmp_val_str);/*包体长度*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->ApCode,sizeof(pICS_482101_N->ApCode));
      setValueOfStr(recv_buff,"ApCode",tmp_val_str);/*格式码'SC'*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->OFmtCd,sizeof(pICS_482101_N->OFmtCd));
      setValueOfStr(recv_buff,"OFmtCd",tmp_val_str);/*格式码'D04'*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->TRspCd,sizeof(pICS_482101_N->TRspCd));
      setValueOfStr(recv_buff,"TRspCd",tmp_val_str);/*状态       */

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->LogNo,sizeof(pICS_482101_N->LogNo));
      setValueOfStr(recv_buff,"LogNo",tmp_val_str);/*交行流水号 */

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->TLogNo,sizeof(pICS_482101_N->TLogNo));
      setValueOfStr(recv_buff,"TLogNo",tmp_val_str);/*购彩流水号 */

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->NotNum,sizeof(pICS_482101_N->NotNum));
      setValueOfStr(recv_buff,"NotNum",tmp_val_str);/*注数       */

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->LotNum1,sizeof(pICS_482101_N->LotNum1));
      setValueOfStr(recv_buff,"LotNum1",tmp_val_str);/*注1*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->LotNum2,sizeof(pICS_482101_N->LotNum2));
      setValueOfStr(recv_buff,"LotNum2",tmp_val_str);/*注2*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->LotNum3,sizeof(pICS_482101_N->LotNum3));
      setValueOfStr(recv_buff,"LotNum3",tmp_val_str);/*注3*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->LotNum4,sizeof(pICS_482101_N->LotNum4));
      setValueOfStr(recv_buff,"LotNum4",tmp_val_str);/*注4*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->LotNum5,sizeof(pICS_482101_N->LotNum5));
      setValueOfStr(recv_buff,"LotNum5",tmp_val_str);/*注5*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->LotNum6,sizeof(pICS_482101_N->LotNum6));
      setValueOfStr(recv_buff,"LotNum6",tmp_val_str);/*复试注注*/

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->MulTip,sizeof(pICS_482101_N->MulTip));
      setValueOfStr(recv_buff,"MulTip",tmp_val_str);/*倍数       */ 

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_N->TrmCod,sizeof(pICS_482101_N->TrmCod));
      setValueOfStr(recv_buff,"TrmCod",tmp_val_str);/*期号       */

    /* STEP3-2 处理页面隐含要素: 这里填写的字段,就是在页面作为隐含input的要素 */
    /* 注意,1.这里设置参数的顺序必须和数据库中参数的顺序一致,否则回出错! 
            2.返回码字段名定义注意与WEB上一致*/ 

  }
  else
  { /*失败*/
      /*获得错误返回包*/
      memcpy(pICS_482101_E,ics_recv_buff+sizeof(ICS_DEF_TOA),sizeof(ICS_DEF_482101_E_TC));
  
      /* 调用setValueOf函数填充 */
      /*格式:setValueOfStr(recv_buff,"display_zone",display_str);*/
      /*memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_E->RspCod,sizeof(pICS_482101_E->RspCod));
      setValueOfStr(recv_buff,"RspCod",tmp_val_str);*//*返回码       */

      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
      setValueOfStr(recv_buff,"RspCod",tmp_val_str);  /*返回码*/ 


      memset(tmp_val_str,'\0',sizeof(tmp_val_str));
      memcpy(tmp_val_str,pICS_482101_E->RspMsg,sizeof(pICS_482101_E->RspMsg));
      setValueOfStr(recv_buff,"RspMsg",tmp_val_str);/*返回码       */
  }
  flog( STEP_LEVEL,"**482101 返回[%s]******************************",recv_buff);
  return 0;

}
Example #26
0
int ics_proc_481143(char *send_buff,char *recv_buff)
{
  /*说明:send_buff-上传报文;
          recv_buff-下传报文;
          ics_send_buff-与后台通讯的发送串;
          ics_recv_buff-与后台通讯的接收串;
 */

  int     i;
  int     len;
  int     ret;
  int     offset;
  int     i_biz_id;

  ICS_DEF_TIA   *pICS_TIA;
  ICS_DEF_TOA   *pICS_TOA;
  ICS_DEF_481143_I  *pICS_481143_I;
  ICS_DEF_481143_N  *pICS_481143_N;
  ICS_DEF_481143_E  *pICS_481143_E;

  char      ics_send_buff[LEN_ICS_PROC_BUF];
  char      ics_recv_buff[LEN_ICS_PROC_BUF];
  char      ics_481143i_buff[235];
  char      ics_481143n_buff[241];
  char      ics_481143e_buff[71];
  char      ics_tia_buff[171];
  char      ics_toa_buff[114];
  char      tmp_val_str[LEN_TMP_VAL_STR];
  char      tmp_val_str2[LEN_TMP_VAL_STR];
  char      display_str[LEN_ICS_PROC_BUF];
  char      display_log_str[LEN_ICS_PROC_BUF];
  char      tmpvalue[256];  /*从上传报文中取得的某项值*/
  
  char			s_CDNO[LEN_CDNO]; /* 卡号 */
  char			s_PSWD[21]; /* 密码 */
  
  char      sLen[8];
  char      sLeft[14];
  char      sRight[3];
  char      sTranNo[16];
  char      sTranDate[11];
  char      sTellerNo[8];
  char      sErrMsg[64];
  char      ics_port[6];
  char      sTxnCnl[32];
	
  time_t    cur_time;

  struct tm   *my_tm;

  FILE      *fp;

/*
  void *pComplibhandle; * Handle to shared lib file *
  int (*pCompfunchandle)(); * Pointer to loaded routine */

  /*-------------------STEP1:通讯前处理-组成上传串--------------------*/

  /* STEP1-1:清理结构和变量 */

  memset(ics_send_buff,'\0',sizeof(ics_send_buff));
  memset(ics_recv_buff,'\0',sizeof(ics_recv_buff));
  memset(ics_481143i_buff,'\0',sizeof(ics_481143i_buff));
  memset(ics_481143n_buff,'\0',sizeof(ics_481143n_buff));
  memset(ics_481143e_buff,'\0',sizeof(ics_481143e_buff));
  memset(ics_tia_buff,'\0',sizeof(ics_tia_buff));
  memset(ics_toa_buff,'\0',sizeof(ics_toa_buff));

  pICS_481143_I=(ICS_DEF_481143_I *)ics_481143i_buff;
  pICS_481143_N=(ICS_DEF_481143_N *)ics_481143n_buff;
  pICS_481143_E=(ICS_DEF_481143_E *)ics_481143e_buff;
  pICS_TIA=(ICS_DEF_TIA *)ics_tia_buff;
  pICS_TOA=(ICS_DEF_TOA *)ics_toa_buff;

  memset(tmp_val_str,'\0',sizeof(tmp_val_str));
  memset(tmp_val_str2,'\0',sizeof(tmp_val_str2));
  memset(display_str,'\0',sizeof(display_str));
  memset(display_log_str,'\0',sizeof(display_log_str));
  memset(tmpvalue,'\0',sizeof(tmpvalue));
  memset(sTranNo,'\0',sizeof(sTranNo));
  memset(sErrMsg,'\0',sizeof(sErrMsg));
  memset(sTranDate,'\0',sizeof(sTranDate));
  memset(sTellerNo,'\0',sizeof(sTellerNo));
  memset(sErrMsg, '\0', sizeof( sErrMsg ) ) ;
	memset(s_CDNO, '\0', sizeof(s_CDNO));
	memset(s_PSWD, '\0', sizeof(s_PSWD));


flog( STEP_LEVEL,"--481143 接收[%s]------------------------------",send_buff);

  /* STEP1-2:填上传串的固定头 */
  strcpy(pICS_TIA->CCSCod,"TLU6");
  strcpy(pICS_TIA->TTxnCd,"481143");
  strcpy(pICS_TIA->FeCod,"481143");
  strcpy(pICS_TIA->TrmNo,"DVID");

  time(&cur_time);
  my_tm = localtime(&cur_time);
  sprintf(sTranNo,"%d%d%d%d%d%d11", my_tm->tm_year+1900, my_tm->tm_mon+1, my_tm->tm_mday, my_tm->tm_hour, my_tm->tm_min, my_tm->tm_sec);
  sprintf(sTranDate,"%d-%d-%d",my_tm->tm_year+1900,my_tm->tm_mon+1,my_tm->tm_mday);

  strcpy(pICS_TIA->NodTrc,sTranNo);

  ret = get_config_value(CONFIG_FILE_NAME, "TELLER_NO", sTellerNo);
  if (ret != RETURN_OK)
    return ret;

  strcpy(pICS_TIA->TlrId,sTellerNo);
  strcpy(pICS_TIA->TIATyp,"T");
  strcpy(pICS_TIA->AthLvl,"00");
  strcpy(pICS_TIA->Sup1Id," ");
  strcpy(pICS_TIA->Sup2Id," ");
  strcpy(pICS_TIA->Sup1Pw," ");
  strcpy(pICS_TIA->Sup2Pw," ");
  strcpy(pICS_TIA->Sup1Dv," ");
  strcpy(pICS_TIA->Sup2Dv," ");
  strcpy(pICS_TIA->AthTbl," ");
  strcpy(pICS_TIA->AthLog," ");
  strcpy(pICS_TIA->HLogNo," ");
  strcpy(pICS_TIA->CprInd,"0");
  strcpy(pICS_TIA->EnpInd,"0");
  strcpy(pICS_TIA->NodNo,"441200");
  strcpy(pICS_TIA->OprLvl," ");
  strcpy(pICS_TIA->TrmVer,"v0000001");
  strcpy(pICS_TIA->OutSys," ");
  strcpy(pICS_TIA->Fil," ");


  /*将终端的交易渠道赋值进来*/
  /* 如果TXNSRC值没有上送,默认使用WE441 */
  memset(sTxnCnl, '\0', sizeof(sTxnCnl));
  if(strstr(send_buff,"TXNSRC")){
    getValueOfStr(send_buff,"TXNSRC", sTxnCnl); /*交易渠道*/
  }else{
    strcpy(sTxnCnl, "WE441");
  }
  strcpy(pICS_TIA->TxnSrc, sTxnCnl);

  /* STEP1-3: 填上传串的元素值*/
  getValueOfStr(send_buff,"TxnDat", tmpvalue); /*日期*/
  strcpy(pICS_481143_I->TxnDat, tmpvalue);
	
	strcpy(pICS_481143_I->AbuTyp, "0002");        /*卡类*/
	
	getValueOfStr(send_buff,"BusNam", tmpvalue); /*卡种*/
  strcpy(pICS_481143_I->BusNam, tmpvalue);
  
  getValueOfStr(send_buff,"TxnAmt", tmpvalue); /*交易金额*/
  memset(tmp_val_str2, 0, sizeof(tmp_val_str2));
  strcpy(tmp_val_str2, "000");
  strcat(tmp_val_str2, tmpvalue);
  strcpy(pICS_481143_I->TxnAmt,tmp_val_str2);
  
  strcpy(pICS_481143_I->ActTyp,"4");	/*帐号类型*/

  getValueOfStr(send_buff,"CDNO", tmpvalue); /*代扣帐号*/
  strcpy(s_CDNO, tmpvalue);
  strcpy(pICS_481143_I->ActNo, tmpvalue);
  
  getValueOfStr(send_buff,"PSWD",tmpvalue); /*密码*/
  strcpy(s_PSWD,tmpvalue);
  strcpy(pICS_481143_I->PinBlk,tmpvalue);
  /* 校验密码 */
  ret = ics_proc_928460( "1", s_CDNO, "1", s_PSWD, pICS_TOA->RspCod ) ;
  if ( ret < 0 )
  {
		flog( STEP_LEVEL,"CALL 928460 Fail [%d]",ret);
		sprintf( sErrMsg, "密码校验失败![%d]", ret );
		goto RETURN;
  }
  if( memcmp( pICS_TOA->RspCod, "000000", 6 ) != 0 )
  {
		flog( STEP_LEVEL,"928460 return [%s]", pICS_TOA->RspCod ) ;
		goto RETURN;
  }
  
  /*发往ICS需加8位报文长度*/
  offset=0;
  offset=offset+8;

  /*STEP1-4:把结构中的结束符替换为空格,上传串末尾加结束符.*/
  len=sizeof(ICS_DEF_TIA);
  for(i=0;i<len;i++)
  {
    if(ics_tia_buff[i]==0)
      ics_tia_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_tia_buff,len);
  offset=offset+sizeof(ICS_DEF_TIA);

  len=sizeof(ICS_DEF_481143_I);
  for(i=0;i<len;i++)
  {
    if(ics_481143i_buff[i]==0)
      ics_481143i_buff[i]=' ';
  }
  memcpy(ics_send_buff+offset,ics_481143i_buff,len);
  offset=offset+sizeof(ICS_DEF_481143_I);

  /*发往ICS需加8位报文长度在头*/
  memcpy(sLen,'\0',8);
  sprintf(sLen,"%08d",offset-8);
  memcpy(ics_send_buff,sLen,8);

  ics_send_buff[offset] = '\0';

  /* 与ICS通讯 */
  memset(ics_port,'\0',sizeof(ics_port));

  ret = get_config_value(CONFIG_FILE_NAME, "ICS_PORT_TRANS", ics_port);
  if (ret != RETURN_OK)
        return ret;

flog( STEP_LEVEL,"TO ICS: [%s]",ics_send_buff);
/*
  ret=clientics( ics_send_buff, ics_recv_buff, atoi(ics_port) );
  if(ret != RETURN_OK)
    return(-1);
*/
flog( STEP_LEVEL,"FROM ICS: [%s]",ics_recv_buff);

  /*--------------------通讯后处理:组成回传报文------------------*/

	setValueOfStr(recv_buff,"MGID","000000");/*返回码*/
	setValueOfStr(recv_buff,"BossID", "AAAAAAAAAAAAAAAa");
	setValueOfStr(recv_buff,"TcusNm", "dfasdasdasdasdasdasdasdasdasd");
	setValueOfStr(recv_buff,"YXDate", "2009-12-31");
	setValueOfStr(recv_buff,"czFangFa", "1");
	
	return 0;

  memcpy(ics_toa_buff,ics_recv_buff,sizeof(ics_toa_buff));

RETURN:

  if(memcmp(pICS_TOA->RspCod,"000000",sizeof(pICS_TOA->RspCod))==0)/*成功*/
  {
    /* STEP3-1处理页面显示要素: 在这里填写的字段,就是在页面上显示的字段 */
    /* 注意,<br>是页面显示的换行符号 */

    memcpy(ics_481143n_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_481143n_buff));

    memset(tmp_val_str2,0,sizeof(tmp_val_str2));
    memcpy(tmp_val_str2,pICS_481143_N->BusNam,sizeof(pICS_481143_N->BusNam));
    sprintf(tmp_val_str,"卡种: %s  <br>", tmp_val_str2);
    strcat(display_str,tmp_val_str);

    memset(tmp_val_str2,0,sizeof(tmp_val_str2));
    memcpy(tmp_val_str2,pICS_481143_N->TxnAmt,sizeof(pICS_481143_N->TxnAmt));
    memset(sLeft,0,sizeof(sLeft));
    memset(sRight,0,sizeof(sRight));
    memcpy(sLeft,tmp_val_str2,13);
    memcpy(sRight,tmp_val_str2+13,2);
    sprintf(tmp_val_str,"卡面值: %d.%s  <br>",atoi(sLeft),sRight);
    strcat(display_str,tmp_val_str);

    memset(tmp_val_str2,0,sizeof(tmp_val_str2));
    memcpy(tmp_val_str2,pICS_481143_N->VchNo,sizeof(pICS_481143_N->VchNo));
    sprintf(tmp_val_str,"充值卡号: %s  <br>", tmp_val_str2);
    strcat(display_str,tmp_val_str);
    
    memset(tmp_val_str2,0,sizeof(tmp_val_str2));
    memcpy(tmp_val_str2,pICS_481143_N->EndDat,sizeof(pICS_481143_N->EndDat));
    sprintf(tmp_val_str,"有效日期: %s  <br>", tmp_val_str2);
    strcat(display_str,tmp_val_str);
    
    memset(tmp_val_str2,0,sizeof(tmp_val_str2));
    memcpy(tmp_val_str2,pICS_481143_N->BilRmk,sizeof(pICS_481143_N->BilRmk));
    sprintf(tmp_val_str,"充值方法: %s  <br>", tmp_val_str2);
    strcat(display_str,tmp_val_str);

    strcat(display_str,"<b>交费成功! 请及时查询结果。</b><br>");

    /* STEP3-1-1 在日志中记录有关数据备查 begin*/
    memset(tmp_val_str2,0,sizeof(tmp_val_str2));
    memcpy(tmp_val_str2,pICS_481143_N->VchNo,sizeof(pICS_481143_N->VchNo));
    sprintf(tmp_val_str,"充值卡号:[%s] ",tmp_val_str2);
    strcat(display_log_str,tmp_val_str);

    memset(tmp_val_str2,0,sizeof(tmp_val_str2));
    memcpy(tmp_val_str2,pICS_481143_N->TckNo,sizeof(pICS_481143_N->TckNo));
    sprintf(tmp_val_str,"会计流水:[%s] ",tmp_val_str2);
    strcat(display_log_str,tmp_val_str);

    memset(tmp_val_str2,0,sizeof(tmp_val_str2));
    memcpy(tmp_val_str2,pICS_481143_N->TxnAmt,sizeof(pICS_481143_N->TxnAmt));
    sprintf(tmp_val_str,"交费金额:[%s] ",tmp_val_str2);
    strcat(display_log_str,tmp_val_str);

    setValueOfStr(recv_buff,"display_zone",display_str);

    memset(tmp_val_str,'\0',sizeof(tmp_val_str));
    memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
    setValueOfStr(recv_buff,"MGID",tmp_val_str);/*返回码*/
  }
  else
  { /*失败*/
    if( memcmp( pICS_TOA->RspCod, "PC5012", 6 ) == 0 )
        strcpy( sErrMsg, "密码不符" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "PD5012", 6 ) == 0 )
        strcpy( sErrMsg, "密码不符" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "PD5100", 6 ) == 0 )
        strcpy( sErrMsg, "借记卡可用余额不足" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "PC3254", 6 ) == 0 )
        strcpy( sErrMsg, "此交易不允许透支" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "PD5044", 6 ) == 0 )
       strcpy( sErrMsg, "密码错误次数超过限制" ) ;
    else
    if( memcmp( pICS_TOA->RspCod, "TC2051", 6 ) == 0 )
        strcpy( sErrMsg, "密码校验错" ) ;
    else
        memcpy( sErrMsg, pICS_TOA->RspCod, 6 ) ;

    memcpy(ics_481143e_buff,ics_recv_buff+sizeof(ics_toa_buff),sizeof(ics_481143e_buff));

    strcpy(tmp_val_str,"<font color=ff0000><b>--->交费失败!<br>--->如有疑问,请及时与开户银行联系!</b></font><br>");
    strcat(display_str,tmp_val_str);

    sprintf(tmp_val_str,"--->失败原因:[%s] <br>",sErrMsg);
    strcat(display_str,tmp_val_str);

    setValueOfStr(recv_buff,"display_zone",display_str);

    memset(tmp_val_str,'\0',sizeof(tmp_val_str));
    memcpy(tmp_val_str,pICS_TOA->RspCod,sizeof(pICS_TOA->RspCod));
    setValueOfStr(recv_buff,"MGID",tmp_val_str);/*返回码*/
  }

flog( STEP_LEVEL,"**481143 返回[%s]******************************",recv_buff);

  return 0;
}