示例#1
0
void pr_encode_disable_encoding(void) {
#ifdef HAVE_ICONV_H
  pr_trace_msg(trace_channel, 8, "%s encoding disabled", encoding);
  (void) encode_free();
  encoding = NULL;
#endif
}
示例#2
0
文件: encode.c 项目: Nakor78/proftpd
static void tear_down(void) {
  if (getenv("TEST_VERBOSE") != NULL) {
    pr_trace_set_levels("encode", 0, 0);
  }

#ifdef PR_USE_NLS
  encode_free();
#endif /* PR_USE_NLS */

  if (p) {
    destroy_pool(p);
    p = permanent_pool = NULL;
  }
}
示例#3
0
int pr_encode_set_charset_encoding(const char *charset, const char *codeset) {
#ifdef HAVE_ICONV_H
  int res;

  if (charset == NULL ||
      codeset == NULL) {
    errno = EINVAL;
    return -1;
  }

  if (local_charset) {
    pr_trace_msg(trace_channel, 5,
      "attempting to switch local charset from %s to %s", local_charset,
      charset);

  } else {
    pr_trace_msg(trace_channel, 5, "attempting to use %s as local charset",
      charset);
  }

  if (encoding) {
    pr_trace_msg(trace_channel, 5,
      "attempting to switch encoding from %s to %s", encoding, codeset);

  } else {
    pr_trace_msg(trace_channel, 5, "attempting to use %s encoding", codeset);
  }

  (void) encode_free();

  local_charset = pstrdup(permanent_pool, charset);
  encoding = pstrdup(permanent_pool, codeset);

  res = encode_init();
  if (res < 0) {
    pr_trace_msg(trace_channel, 1,
      "failed to initialize encoding for local charset %s, encoding %s, "
      "disabling encoding", charset, codeset);
    local_charset = NULL;
    encoding = NULL;
  }

  return res;

#else
  errno = ENOSYS;
  return -1;
#endif /* !HAVE_ICONV_H */
}
示例#4
0
/* Enables runtime use of encoding using the specified character set (assuming
 * NLS is supported).  Note that "UTF8", "utf8", "utf-8", and "UTF-8" are
 * accepted "character set" designations.
 */
int pr_encode_enable_encoding(const char *codeset) {
#ifdef HAVE_ICONV_H
  int res;

  if (codeset == NULL) {
    errno = EINVAL;
    return -1;
  }

  if (encoding != NULL &&
      strcasecmp(encoding, codeset) == 0) {
    pr_trace_msg(trace_channel, 5, "'%s' encoding already being used", codeset);
    return 0;
  }

  if (encoding) {
    pr_trace_msg(trace_channel, 5,
      "attempting to switch encoding from %s to %s", encoding, codeset);

  } else {
    pr_trace_msg(trace_channel, 5, "attempting to enable %s encoding", codeset);
  }

  (void) encode_free();
  encoding = pstrdup(permanent_pool, codeset);

  res = encode_init();
  if (res < 0) {
    pr_trace_msg(trace_channel, 1,
      "failed to initialize encoding for %s, disabling encoding: %s", codeset,
      strerror(errno));
    encoding = NULL;
  }

  return res;

#else
  errno = ENOSYS;
  return -1;
#endif /* !HAVE_ICONV_H */
}
示例#5
0
static int read_cwdb(char *filename, char *gameid)
{
	int pos=0;
	char *p;
	char cw_buf[300];
	u32 address,val;
	t_mem_table	t;
	PspFile pf;

	if(openfile(filename, &pf)==0) return 1;
	
	if(gameid!=NULL){
		char codename[11];
		mips_memcpy(codename,gameid,10);
		codename[10]=0;
		do{
			pos=read_sect(pos,&pf);
			p=strstr(pf.buf,codename);
			if(p) break;
		}
		while(pos);
	}
	else{
		read_sect(pos,&pf);
		p=pf.buf;
		p=read_line(p,cw_buf);
	}
	
		if(p==0) {
			closefile(&pf);
			return 1;
		}

#ifdef BIG5_ENCODE_TEXT
	t_encodepack pack;
	char *big5buf = malloc(41688);
	if(big5buf==NULL) return 1;
	if(big5_init(big5buf,&pack)==0 && encode_init(&pack)==0)
	{
		charsets_big5_conv(p,&pack);
		encode_free(&pack);
	}
	free(big5buf);
#endif
	
	p=read_line(p,cw_buf);
	mips_memcpy(ui_get_gamename()+12,cw_buf+3,0x40);
	
	int repeat=0;
	int lock =0;
	char namebuf[80];
	char *namep;
	char nullcode=0;
	while(1){
	//金手指码部分	
		p=read_line(p,cw_buf);
		
		if(cw_buf[0]=='_'){
		if(cw_buf[1]=='C'){
			if(nullcode==1) {
			t.addr=0x8800000;
			t.value=0;
			t.type=0;
			t.lock=0;
			if(mem_table_add(&t)<0) goto READOUT;
			}
		repeat=0;
		namep = namebuf;
		mips_memcpy(namebuf,cw_buf+4,70);
		lock = strtoul(cw_buf+2,NULL,16);
		namep = read_name(namep, t.name, 10);
		mips_memcpy(t.name,namebuf,30);
		t.name[30]=0;
		t.name[31]=0;
		nullcode=1;
		}
		else if(cw_buf[1]=='L'){
			nullcode=0;
			if(repeat<5){
				if(repeat==0) {
				}
				else{
					t.name[0] = '+';
					namep = read_name(namep, t.name+1, 9);
				}
				repeat++;
			}
			else{//strcpy(t.name,"+");
				t.name[0]='+';
				t.name[1]=0;
			}
			char *tempptr;
			address=strtoul(cw_buf+2,&tempptr,16)+0x08800000;
			val=strtoul(tempptr,NULL,16);
			t.addr=address;
			t.value=val;
			t.type=0;
			t.lock=lock;
			if(mem_table_add(&t)<0) goto READOUT;
		}
		else if(cw_buf[1]=='S'){
			break;
		}
		}
		if(p==0) break;
		if(p[0]=='_' && p[1]=='S') break;
	}
	
READOUT:
	closefile(&pf);
	return 0;
}