Esempio n. 1
0
void MethodBlock::load_const(Location& loc, DexString* value) {
  always_assert(!loc.is_wide());
  DexInstruction* load = new DexOpcodeString(OPCODE_CONST_STRING, value);
  load->set_dest(reg_num(loc));
  loc.type = get_string_type();
  push_instruction(load);
}
Esempio n. 2
0
int main(int argc, char **argv) {

  umqtt_ret ret = UMQTT_SUCCESS;

  /* initialise packet */
  struct mqtt_packet *pkt = NULL;

  if (argv[1]) {
     pkt = construct_packet_headers(get_string_type(argv[1]));
  }

  if (!pkt) {
    log_std(LOG_ERROR, "Constructing headers: Packet creation failed");
    ret = UMQTT_ERROR;
    goto free;
  } else {
    switch (pkt->fixed->generic.type) {
      case CONNECT:
        ret = build_connect_pkt_getopts(argc, argv, pkt);
        break;

      case PUBLISH:
        ret = build_publish_pkt_getopts(argc, argv, pkt);
        break;

      case SUBSCRIBE:
      case UNSUBSCRIBE:
        ret = build_un_subscribe_pkt_getopts(argc, argv, pkt);
        break;

      default:
        ret = build_generic_pkt_getopts(argc, argv, pkt);
        break;
    }
  }

  if (ret) {
    log_std(LOG_ERROR, "Building packet: Packet creation failed");
    goto free;
  }

  /* Cleanup packet */
  finalise_packet(pkt);

  /* print */
  print_packet_detailed_info(pkt);
  print_packet_hex_debug(pkt);
  print_packet_raw_debug(pkt);

free:
  if (pkt) {
    free_packet(pkt);
  }
  return ret;
}
Esempio n. 3
0
void MethodBlock::load_const(Location& loc, DexString* value) {
  always_assert(!loc.is_wide());
  IRInstruction* load = new IRInstruction(OPCODE_CONST_STRING);
  load->set_string(value);
  push_instruction(load);
  IRInstruction* move_result_pseudo =
      new IRInstruction(IOPCODE_MOVE_RESULT_PSEUDO_OBJECT);
  loc.type = get_string_type();
  move_result_pseudo->set_dest(loc.get_reg());
  push_instruction(move_result_pseudo);
}
Esempio n. 4
0
/* 对各种类型的文件buffer抽取出来的中文字符串进行集中处理 */
int
string_process(char* pBuffer, int nStrLen, int bError){
	int 		nStrType, nRet, nRet2;
	char		szTranslate[MAX_TRANS_LEN];
	char		cOld1, cOld2, *pChineseStr, *pTemp;
	int         	nHaveChinese = 0;
	int		nStrLen2;

	if ( pBuffer == NULL || *pBuffer == '\0' )
		return 1;

	memset(szTranslate, 0, MAX_TRANS_LEN);
	cOld1 = pBuffer[nStrLen];
	cOld2 = '\0';
 	pBuffer[nStrLen] = '\0';
	nRet = nStrLen+1;

	pChineseStr = pBuffer;
	nStrLen2 = nStrLen;
	if ( bError == 1 ){
		/* if this string is a error string, judge
		   there is chinese string it, if have then
		   write record to file or not;
		*/
		nStrType = STR_ERROR;
		pTemp = pBuffer;
		while ( *(pTemp+1) != '\0' ){
			if ( is_gbk_chinese(*pTemp, *(pTemp+1)) ){
				nHaveChinese = 1;
				break;
			}
			pTemp++;
		}
		if ( nHaveChinese == 0 )
			goto exit;
	}
	else{
		nStrType = get_string_type(pBuffer, nStrLen);
	}		

	if ( nStrType != STR_NORMAL ) {
		/*在抽取字符串时,非需要翻译的字符串直接记录在对应的文件里即可 */
		if ( g_nTranslate == 0 )
			record_string(nStrType, pChineseStr, nStrLen2);
		goto exit;
	}

	/* 对于需要翻译的中文字符串,先去除前后的非关键字符 */
	pChineseStr = strip_ignore_sign(pBuffer, &nStrLen2);
	cOld2= pChineseStr[nStrLen2];
	pChineseStr[nStrLen2] = '\0';

	if (pChineseStr[0] == '\0')
		goto exit;

	if ( g_nTranslate == 0 ){
		/* 如果不需要翻译,那么将这个字符串插入到字典数据库中 */
		nRet2 = insert_notrans_to_db(pChineseStr);
		if ( nRet2 == 1 ){
			/* 返回值为1,则这个字符串字典中尚不存在需要翻译,那么记录下来 */
			record_string(nStrType, pChineseStr, nStrLen2);
			g_nRightCount ++;
		}
		else if ( nRet2 == 0 ) /* 查找字典时出错 */
			g_nWrongCount ++;
		else if ( nRet2 == 2) /* 字典中已存在 */
			g_nRepeatCount ++;
	}
	else{
		nRet2 = get_trans_from_db(pChineseStr,
					  szTranslate, MAX_TRANS_LEN);
		if ( nRet2 == 0 ){
			g_nWrongCount ++;
			record_string(nStrType, pChineseStr, nStrLen2);
			goto exit;
		}
		else if ( nRet2 == 1 )
			g_nRightCount ++;

		nRet = (int)strlen(szTranslate) + 1;
		if ( (nStrLen != nStrLen2) && (cOld2 != '\0') ){
			szTranslate[nRet-1] = cOld2;
			if ( *(pChineseStr+nStrLen2+1) != '\0' )
				memcpy(szTranslate + nRet, pChineseStr + nStrLen2 + 1,
				       (int)strlen(pChineseStr + nStrLen2 + 1));
			nRet = (int)strlen(szTranslate) + 1;
		}
			
		szTranslate[nRet - 1] = cOld1;
		if ( cOld1 != '\0' )
			memcpy(szTranslate + nRet, pBuffer + nStrLen + 1,
			       (int)strlen(pBuffer + nStrLen + 1));

		strcpy(pChineseStr, szTranslate);
		nRet += (int)(pChineseStr-pBuffer);	
		goto exit2;
	}
exit:	
	pBuffer[nRet-1] = cOld1;
	if ( cOld2 != '\0' )
		pChineseStr[nStrLen2] = cOld2;
 exit2:	
	return nRet;
}