Exemplo n.º 1
0
void chk_cltab(char *classasc, CLASSTAB *clstab)
{
	int32_t i;
	char *ptr1, *saveptr1 = NULL;
	CLASSTAB newclstab;
	memset(&newclstab, 0, sizeof(newclstab));
	newclstab.an = newclstab.bn = 0;
	for(i = 0, ptr1 = strtok_r(classasc, ",", &saveptr1); (i < CS_MAXCAIDTAB) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1))
	{
		ptr1 = trim(ptr1);
		if(ptr1[0] == '!')
			{ newclstab.bclass[newclstab.bn++] = (uchar)a2i(ptr1 + 1, 2); }
		else
			{ newclstab.aclass[newclstab.an++] = (uchar)a2i(ptr1, 2); }
	}
	memcpy(clstab, &newclstab, sizeof(CLASSTAB));
}
Exemplo n.º 2
0
void chk_ecm_hdr_whitelist(char *value, ECM_HDR_WHITELIST *ecm_hdr_whitelist)
{
	ecm_hdr_whitelist_clear(ecm_hdr_whitelist);
	char *ptr, *saveptr = NULL;
	for(ptr = strtok_r(value, ";", &saveptr); ptr; ptr = strtok_r(NULL, ";", &saveptr))
	{
		ECM_HDR_WHITELIST_DATA d;
		memset(&d, 0, sizeof(d));
		char *caid_end_ptr = strchr(ptr, ':'); // caid_end_ptr + 1 -> headers
		char *provid_ptr = strchr(ptr, '@'); // provid_ptr + 1 -> provid
		char *headers = ptr;
		if(caid_end_ptr)
		{
			caid_end_ptr[0] = '\0';
			if (provid_ptr)
			{
				provid_ptr[0] = '\0';
				provid_ptr++;
				d.provid = a2i(provid_ptr, 6);
			}
			d.caid = dyn_word_atob(ptr);
			headers = caid_end_ptr + 1; // -> headers
		} else if(provid_ptr) {
			provid_ptr[0] = '\0';
			d.provid = a2i(provid_ptr, 6);
		}
		if (d.caid == 0xffff) d.caid = 0;
		if (d.provid == 0xffff) d.provid = 0;
		char *hdr_ptr, *savehdr_ptr = NULL;
		for(hdr_ptr = strtok_r(headers, ",", &savehdr_ptr); hdr_ptr; hdr_ptr = strtok_r(NULL, ",", &savehdr_ptr))
		{
			hdr_ptr = trim(hdr_ptr);
			d.len = strlen(hdr_ptr);
			if (d.len / 2 > sizeof(d.header))
				d.len = sizeof(d.header) * 2;
			if (d.len > 1)
			{
				key_atob_l(hdr_ptr, d.header, d.len);
				ecm_hdr_whitelist_add(ecm_hdr_whitelist, &d);
			}
		}
	}
}
Exemplo n.º 3
0
void chk_cacheex_hitvaluetab(char *lbrlt, CECSPVALUETAB *tab)
{
	//[caid][&mask][@provid][$servid]
	int32_t i;
	char *ptr = NULL, *saveptr1 = NULL;
	cecspvaluetab_clear(tab);

	for(i = 0, ptr = strtok_r(lbrlt, ",", &saveptr1); (ptr); ptr = strtok_r(NULL, ",", &saveptr1), i++)
	{
		CECSPVALUETAB_DATA d;
		memset(&d, 0, sizeof(d));

		int32_t caid = -1, cmask = -1, srvid = -1;
		int32_t provid = -1;
		char *ptr1 = NULL, *ptr2 = NULL, *ptr3 = NULL;

		if((ptr3 = strchr(trim(ptr), '$')))
		{
			*ptr3++ = '\0';
			srvid = a2i(ptr3, 4);
		}
		if((ptr2 = strchr(trim(ptr), '@')))
		{
			*ptr2++ = '\0';
			provid = a2i(ptr2, 6);
		}
		if((ptr1 = strchr(ptr, '&')))
		{
			*ptr1++ = '\0';
			cmask = a2i(ptr1, -2);
		}
		caid = a2i(ptr, 2);
		if(caid > 0)
		{
			d.caid = caid;
			d.cmask = cmask;
			d.prid = provid;
			d.srvid = srvid;
			cecspvaluetab_add(tab, &d);
		}
	}

}
Exemplo n.º 4
0
int
main(int argc, char **argv)
{
  decode_table *rules;
  if (argc != 3)
    error("Usage: decode <decode-file> <hi-bit-nr>\n");
  rules = load_decode_table(argv[1], a2i(argv[2]));
  dump_decode_rules(rules, 0);
  return 0;
}
Exemplo n.º 5
0
void format ( int server, int channel, char *fmt, va_list va ) {
	char bf[12];
	char ch, lz;
	int w;

	
	while ( ( ch = *(fmt++) ) ) {
		if ( ch != '%' )
			Putc( server, channel, ch );
		else {
			lz = 0; w = 0;
			ch = *(fmt++);
			switch ( ch ) {
			case '0':
				lz = 1; ch = *(fmt++);
				break;
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				ch = a2i( ch, &fmt, 10, &w );
				break;
			}
			switch( ch ) {
			case 0: return;
			case 'c':
				Putc( server, channel, va_arg( va, char ) );
				break;
			case 's':
				putw( server, channel, w, 0, va_arg( va, char* ) );
				break;
			case 'u':
				ui2a( va_arg( va, unsigned int ), 10, bf );
				bwputw( channel, w, lz, bf );
				break;
			case 'd':
				i2a( va_arg( va, int ), bf );
				putw( server, channel, w, lz, bf );
				break;
			case 'x':
				ui2a( va_arg( va, unsigned int ), 16, bf );
				putw( server, channel, w, lz, bf );
				break;
			case '%':
				Putc( server, channel, ch );
				break;
			}
		}
	}
}
Exemplo n.º 6
0
void chk_cacheex_hitvaluetab(char *lbrlt, CECSPVALUETAB *tab)
{
	//[caid][&mask][@provid][$servid]
	int32_t i;
	char *ptr = NULL, *saveptr1 = NULL;
	CECSPVALUETAB newtab;
	memset(&newtab, 0, sizeof(CECSPVALUETAB));

	for(i = 0, ptr = strtok_r(lbrlt, ",", &saveptr1); (i < CS_MAXCAIDTAB) && (ptr); ptr = strtok_r(NULL, ",", &saveptr1), i++)
	{
		int32_t caid = -1, cmask = -1, srvid = -1;
		int32_t provid = -1;
		char *ptr1 = NULL, *ptr2 = NULL, *ptr3 = NULL;

		if((ptr3 = strchr(trim(ptr), '$')))
		{
			*ptr3++ = '\0';
			srvid = a2i(ptr3, 4);
		}
		if((ptr2 = strchr(trim(ptr), '@')))
		{
			*ptr2++ = '\0';
			provid = a2i(ptr2, 6);
		}
		if((ptr1 = strchr(ptr, '&')))
		{
			*ptr1++ = '\0';
			cmask = a2i(ptr1, -2);
		}
		caid = a2i(ptr, 2);
		if(caid > 0)
		{
			newtab.caid[i] = caid;
			newtab.cmask[i] = cmask;
			newtab.prid[i] = provid;
			newtab.srvid[i] = srvid;
			newtab.n = i + 1;
		}

	}
	memcpy(tab, &newtab, sizeof(CECSPVALUETAB));
}
Exemplo n.º 7
0
static void boxid_fn(const char *token, char *value, void *setting, FILE *f) {
    struct s_reader *rdr = setting;
    if (value) {
        rdr->boxid = strlen(value) ? a2i(value, 4) : 0;
        return;
    }
    if (rdr->boxid)
        fprintf_conf(f, token, "%08X\n", rdr->boxid);
    else if (cfg.http_full_cfg)
        fprintf_conf(f, token, "\n");
}
Exemplo n.º 8
0
static int setup_index(
  const char *alpha					/* the alphabet */
)
{
  int i, a;

  /* flag unused letters */
  for (i=0; i<MAXASCII; i++) a2i(i) = -1;	/* illegal letters */

  /* set up the hashing and unhashing indices */
  for (i = 0; (a = alpha[i]); i++) {
    a = islower(a) ? toupper(a) : a;		/* convert to uppercase */
    a2i(a) = i;					/* position in alphabet */
    i2a(i) = a;
    if (isupper(a)) a2i(tolower(a)) = i;	/* set lowercase as well */
  }
  index_alen = i;				/* set global */

  return(i);
} /* setup_index */
Exemplo n.º 9
0
static void on_button_apply()
{
	extern unsigned int timeout;

	g_cfg.stdby_after = a2i(to_sec);

	/* apply new timeout */
	timeout = g_cfg.stdby_after * 1000;
	
	config_write();

	frame_config();
}
Exemplo n.º 10
0
void chk_ecm_whitelist(char *value, ECM_WHITELIST *ecm_whitelist)
{
	ecm_whitelist_clear(ecm_whitelist);
	char *ptr, *saveptr1 = NULL;
	for(ptr = strtok_r(value, ";", &saveptr1); ptr; ptr = strtok_r(NULL, ";", &saveptr1))
	{
		ECM_WHITELIST_DATA d;
		memset(&d, 0, sizeof(d));
		char *caid_end_ptr = strchr(ptr, ':'); // caid_end_ptr + 1 -> headers
		char *provid_ptr = strchr(ptr, '@'); // provid_ptr + 1 -> provid
		char *headers = ptr;
		if(caid_end_ptr)
		{
			caid_end_ptr[0] = '\0';
			if (provid_ptr)
			{
				provid_ptr[0] = '\0';
				provid_ptr++;
				d.ident = a2i(provid_ptr, 6);
			}
			d.caid = dyn_word_atob(ptr);
			headers = caid_end_ptr + 1; // -> headers
		} else if(provid_ptr) {
			provid_ptr[0] = '\0';
			d.ident = a2i(provid_ptr, 6);
		}
		if (d.caid == 0xffff) d.caid = 0;
		if (d.ident == 0xffff) d.ident = 0;
		char *len_ptr, *savelen_ptr = NULL;
		for(len_ptr = strtok_r(headers, ",", &savelen_ptr); len_ptr; len_ptr = strtok_r(NULL, ",", &savelen_ptr))
		{
			d.len = dyn_word_atob(len_ptr);
			if (d.len == 0xffff)
				continue;
			ecm_whitelist_add(ecm_whitelist, &d);
		}
	}
}
Exemplo n.º 11
0
static void dvbapi_caidtab_fn(const char *UNUSED(token), char *caidasc, void *UNUSED(setting), long cmd, FILE *UNUSED(f)) {
	char *ptr1, *ptr3, *saveptr1 = NULL;
	if (!caidasc)
		return;
	char type = (char)cmd;
	for (ptr1 = strtok_r(caidasc, ",", &saveptr1); (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1)) {
		uint32_t caid, prov;
		if ( (ptr3 = strchr(trim(ptr1), ':')) )
			*ptr3++ = '\0';
		else
			ptr3 = "";
		if ( ((caid = a2i(ptr1, 2)) | (prov = a2i(ptr3, 3))) ) {
			struct s_dvbapi_priority *entry;
			if (!cs_malloc(&entry, sizeof(struct s_dvbapi_priority)))
				return;
			entry->caid=caid;
			if (type == 'd') {
				char tmp1[5];
				snprintf(tmp1, sizeof(tmp1), "%04X", (uint)prov);
				int32_t cw_delay = strtol(tmp1, '\0', 10);
				entry->delay = cw_delay;
			} else {
				entry->provid = prov;
			}
			entry->type = type;
			entry->next = NULL;
			if (!dvbapi_priority) {
				dvbapi_priority = entry;
			} else {
				struct s_dvbapi_priority *p;
				for (p = dvbapi_priority; p->next != NULL; p = p->next)
					;
				p->next = entry;
			}
		}
	}
	// THIS OPTION IS NOT SAVED
}
Exemplo n.º 12
0
int Profile_GetInt(const TCHAR *Section, const TCHAR *Key, const int Default, const TCHAR *File)
{
	TCHAR *buf, *p;
	int SectionIndex;
	int KeyIndex;
	int ret;
	int len;

	//セクションの検索
	SectionIndex = FindSection(Section);
	if(SectionIndex == -1){
		return Default;
	}

	//キーの検索
	KeyIndex = FindKey((SectionInfo + SectionIndex), Key);
	if(KeyIndex == -1 || ((SectionInfo + SectionIndex)->KeyInfo + KeyIndex)->String == NULL){
		return Default;
	}

	//内容の取得
	buf = (TCHAR *)LocalAlloc(LMEM_FIXED, sizeof(TCHAR) * (lstrlen(((SectionInfo + SectionIndex)->KeyInfo + KeyIndex)->String) + 1));
	if(buf != NULL){
		lstrcpy(buf, ((SectionInfo + SectionIndex)->KeyInfo + KeyIndex)->String);
		Trim(buf);
		p = (*buf == TEXT('\"')) ? buf + 1 : buf;
		len = lstrlen(p);
		if(len > 0){
			if(*(p + len - 1) == TEXT('\"')) *(p + len - 1) = TEXT('\0');
		}
		ret = a2i(p);
		LocalFree(buf);
	}else{
		ret = a2i(((SectionInfo + SectionIndex)->KeyInfo + KeyIndex)->String);
	}
	return ret;
}
Exemplo n.º 13
0
extern int p2i(
  char *string,					/* the string to index */
  int w						// length of prefix
)
{

  int i, index;
  for (i=index=0; i<w; i++) {
    char a = string[i];
    if (a == '\0') return(-1);
    int j = a2i(a);				/* first charcter */
    if (j < 0) return(-1);
    index = index_alen*index + (j+1);
  }

  return(index-1);
} /* p2i */
Exemplo n.º 14
0
extern int s2i(
  char *string					/* the string to index */
)
{
  int i;
  char a;
  int index=0;					/* array index */

  /* complete the computation */
  while ((a = *(string++)) && a!='\0') {
    i = a2i(a);					/* first charcter */
    if (i < 0) return(-1);
    index = index_alen*index + (i+1);
  }

  return(index-1);
} /* s2i */
Exemplo n.º 15
0
int
main(int argc, char **argv)
{
  filter *filters = NULL;
  decode_table *decode_rules = NULL;
  insn_table *instructions = NULL;

  if (argc != 5)
    error("Usage: insn <filter> <hi-bit-nr> <decode-table> <insn-table>\n");

  filters = new_filter(argv[1], filters);
  hi_bit_nr = a2i(argv[2]);
  ASSERT(hi_bit_nr < insn_bit_size);
  decode_rules = load_decode_table(argv[3], hi_bit_nr);
  instructions = load_insn_table(argv[4], decode_rules, filters);
  insn_table_expand_insns(instructions);

  dump_insn_table(instructions, 0, -1);
  return 0;
}
Exemplo n.º 16
0
void chk_caidvaluetab(char *value, CAIDVALUETAB *caidvaluetab)
{
	caidvaluetab_clear(caidvaluetab);
	char *ptr, *saveptr1 = NULL;
	for(ptr = strtok_r(value, ",", &saveptr1); ptr; ptr = strtok_r(NULL, ",", &saveptr1))
	{
		CAIDVALUETAB_DATA d;
		memset(&d, 0, sizeof(d));
		char *caid_end_ptr = strchr(ptr, ':'); // caid_end_ptr + 1 -> value
		if(!caid_end_ptr)
			continue;
		*caid_end_ptr++ = '\0';
		errno = 0;
		d.caid = a2i(ptr, 2);
		if (errno == EINVAL)
			continue;
		d.value = atoi(caid_end_ptr);
		if (d.caid && d.value < 10000)
			caidvaluetab_add(caidvaluetab, &d);
	}
}
Exemplo n.º 17
0
static void gbox_password_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
{
	if (value)
	{
	    const char *s;
		s=value;
    	if (s[strspn(s, "0123456789abcdefABCDEF")] == 0)
		{
    		/* valid Hexa symbol */
			cfg.gbox_password = a2i(value, 8);
			return;
	 	}
	 	else
	 	{
	 		cfg.gbox_password = 0;
	 	}
	 }
	if (cfg.gbox_password != 0)
	{
		fprintf_conf(f, token, "%08X\n", cfg.gbox_password);
	}
}
Exemplo n.º 18
0
static void gbox_localcard_fn(const char *token, char *value, void *UNUSED(setting), FILE *f) {
	if (value) {
		char *ptr1, *saveptr1 = NULL;
		memset(cfg.gbox_card, 0, sizeof(cfg.gbox_card));
		int n = 0, i;
		for (i = 0, ptr1 = strtok_r(value, ",", &saveptr1); (i < CS_GBOX_MAX_LOCAL_CARDS) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1)) {
			cfg.gbox_card[n++] = a2i(ptr1, 8);
		}
		cfg.gbox_local_cards_num = n;
		return;
	}

	if (cfg.gbox_local_cards_num > 0) {
		int i;
		char *dot = "";
		fprintf_conf(f, token, " ");
		for (i = 0; i < cfg.gbox_local_cards_num; i++) {
			fprintf(f, "%s%08lX", dot, cfg.gbox_card[i]);
			dot = ",";
		}
		fprintf(f, "\n");
	}
}
Exemplo n.º 19
0
void chk_caidvaluetab(char *lbrlt, CAIDVALUETAB *tab, int32_t minvalue)
{
	int32_t i;
	char *ptr1, *ptr2, *saveptr1 = NULL;
	CAIDVALUETAB newtab;
	memset(&newtab, 0, sizeof(CAIDVALUETAB));

	for (i = 0, ptr1 = strtok_r(lbrlt, ",", &saveptr1); (i < CS_MAX_CAIDVALUETAB) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1)) {
		int32_t caid, value;

		if( (ptr2 = strchr(trim(ptr1), ':')) )
			*ptr2++ = '\0';
		else
			ptr2 = "";

		if (((caid = a2i(ptr1, 2)) < 0xFFFF) | ((value = atoi(ptr2)) < 10000)) {
			newtab.caid[i] = caid;
			if (value < minvalue) value = minvalue;
			newtab.value[i] = value;
			newtab.n = ++i;
		}
	}
	memcpy(tab, &newtab, sizeof(CAIDVALUETAB));
}
Exemplo n.º 20
0
static void gbox_dest_peers_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
{
	if (value)
	{
		char *ptr1, *saveptr1 = NULL;
		const char *s;
		memset(cfg.gbox_dest_peers, 0, sizeof(cfg.gbox_dest_peers));
		int n = 0;
		for (ptr1 = strtok_r(value, ",", &saveptr1); (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1))
		{
			s=trim(ptr1);
			if ((n < GBOX_MAX_DEST_PEERS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0))
			{ cfg.gbox_dest_peers[n++] = a2i(trim(ptr1), strlen(trim(ptr1))); }
		}
		cfg.gbox_dest_peers_num = n;
		return;
	}
	if ((cfg.gbox_dest_peers_num > 0) && cfg.gbox_save_gsms)
	{
		value = mk_t_gbox_dest_peers();
		fprintf_conf(f, token, "%s\n", value);
		free_mk_t(value);
	}
}
Exemplo n.º 21
0
static void gbox_ignored_peer_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
{
	if (value)
	{
		char *ptr1, *saveptr1 = NULL;
		const char *s;
		memset(cfg.gbox_ignored_peer, 0, sizeof(cfg.gbox_ignored_peer));
		int n = 0, i;
		for (i = 0, ptr1 = strtok_r(value, ",", &saveptr1); (i < 4) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1))
		{
			s=ptr1;
			if ((n < GBOX_MAX_IGNORED_PEERS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0))
			{ cfg.gbox_ignored_peer[n++] = a2i(ptr1, 4); }	
		}
		cfg.gbox_ignored_peer_num = n;
		return;
	}
	if (cfg.gbox_ignored_peer_num > 0)
	{
		value = mk_t_gbox_ignored_peer();
		fprintf_conf(f, token, "%s\n", value);
		free_mk_t(value);
	}
}
Exemplo n.º 22
0
void dvbapi_load_channel_cache(void)
{
	if (USE_OPENXCAS) // Why?
		return;

	char fname[256];
	char line[1024];
	FILE *file;
	struct s_channel_cache *c;

	get_config_filename(fname, sizeof(fname), "oscam.ccache");
	file = fopen(fname, "r");
	if(!file)
	{
		cs_log("dvbapi channelcache can't read from file %s", fname);
		return;
	}

	int32_t i = 1;
	int32_t valid = 0;
	char *ptr, *saveptr1 = NULL;
	char *split[6];

	memset(line, 0, sizeof(line));
	while(fgets(line, sizeof(line), file))
	{
		if(!line[0] || line[0] == '#' || line[0] == ';')
			{ continue; }

		for(i = 0, ptr = strtok_r(line, ",", &saveptr1); ptr && i < 6 ; ptr = strtok_r(NULL, ",", &saveptr1), i++)
		{
			split[i] = ptr;
		}

		valid = (i == 5);
		if(valid)
		{
			if(!cs_malloc(&c, sizeof(struct s_channel_cache)))
			{ continue; }
			c->caid = a2i(split[0], 4);
			c->prid = a2i(split[1], 6);
			c->srvid = a2i(split[2], 4);
			c->pid = a2i(split[3], 4);
			c->chid = a2i(split[4], 6);

			if(valid && c->caid != 0)
			{
				if(!channel_cache)
				{
					channel_cache = ll_create("channel cache");
				}

				ll_append(channel_cache, c);
			}
			else
			{
				NULLFREE(c);
			}
		}
	}
	fclose(file);
	cs_log("dvbapi channelcache loaded from %s", fname);
}
Exemplo n.º 23
0
void chk_port_tab(char *portasc, PTAB *ptab)
{
	int32_t i, j, nfilts, ifilt, iport;
	PTAB *newptab;
	char *ptr1, *ptr2, *ptr3, *saveptr1 = NULL;
	char *ptr[CS_MAXPORTS] = {0};
	int32_t port[CS_MAXPORTS] = {0};
	if(!cs_malloc(&newptab, sizeof(PTAB)))
		{ return; }

	for(nfilts = i = 0, ptr1 = strtok_r(portasc, ";", &saveptr1); (i < CS_MAXPORTS) && (ptr1); ptr1 = strtok_r(NULL, ";", &saveptr1), i++)
	{
		ptr[i] = ptr1;

		if(!newptab->ports[i].ncd && !cs_malloc(&newptab->ports[i].ncd, sizeof(struct ncd_port)))
			{ break; }

		if((ptr2 = strchr(trim(ptr1), '@')))
		{
			*ptr2++ = '\0';
			newptab->ports[i].s_port = atoi(ptr1);

			//checking for des key for port
			newptab->ports[i].ncd->ncd_key_is_set = false;
			if((ptr3 = strchr(trim(ptr1), '{')))
			{
				*ptr3++ = '\0';
				if(key_atob_l(ptr3, newptab->ports[i].ncd->ncd_key, sizeof(newptab->ports[i].ncd->ncd_key) * 2))
					{ fprintf(stderr, "newcamd: error in DES Key for port %s -> ignored\n", ptr1); }
				else
					{ newptab->ports[i].ncd->ncd_key_is_set = true; }
			}

			ptr[i] = ptr2;
			port[i] = newptab->ports[i].s_port;
			newptab->nports++;
		}
		nfilts++;
	}

	if(nfilts == 1 && strlen(portasc) < 6 && newptab->ports[0].s_port == 0)
	{
		newptab->ports[0].s_port = atoi(portasc);
		newptab->nports = 1;
	}

	iport = ifilt = 0;
	for(i = 0; i < nfilts; i++)
	{
		if(port[i] != 0)
			{ iport = i; }
		for(j = 0, ptr3 = strtok_r(ptr[i], ",", &saveptr1); (j < CS_MAXPROV) && (ptr3); ptr3 = strtok_r(NULL, ",", &saveptr1), j++)
		{
			if((ptr2 = strchr(trim(ptr3), ':')))
			{
				*ptr2++ = '\0';
				newptab->ports[iport].ncd->ncd_ftab.nfilts++;
				ifilt = newptab->ports[iport].ncd->ncd_ftab.nfilts - 1;
				newptab->ports[iport].ncd->ncd_ftab.filts[ifilt].caid = (uint16_t)a2i(ptr3, 4);
				newptab->ports[iport].ncd->ncd_ftab.filts[ifilt].prids[j] = a2i(ptr2, 6);
			}
			else
			{
				newptab->ports[iport].ncd->ncd_ftab.filts[ifilt].prids[j] = a2i(ptr3, 6);
			}
			newptab->ports[iport].ncd->ncd_ftab.filts[ifilt].nprids++;
		}
	}
	memcpy(ptab, newptab, sizeof(PTAB));
	free(newptab);
}
Exemplo n.º 24
0
void chk_cacheex_valuetab(char *lbrlt, CECSPVALUETAB *tab)
{
	//[caid][&mask][@provid][$servid][:awtime][:]dwtime
	int32_t i;
	char *ptr = NULL, *saveptr1 = NULL;
	CECSPVALUETAB newtab;
	memset(&newtab, 0, sizeof(CECSPVALUETAB));

	for(i = 0, ptr = strtok_r(lbrlt, ",", &saveptr1); (i < CS_MAXCAIDTAB) && (ptr); ptr = strtok_r(NULL, ",", &saveptr1), i++)
	{
		int32_t caid = -1, cmask = -1, srvid = -1;
		int32_t j, provid = -1;
		int16_t awtime = -1, dwtime = -1;
		char *ptr1 = NULL, *ptr2 = NULL, *ptr3 = NULL, *ptr4 = NULL, *ptr5 = NULL, *saveptr2 = NULL;

		if((ptr4 = strchr(trim(ptr), ':')))
		{
			//awtime & dwtime
			*ptr4++ = '\0';
			for(j = 0, ptr5 = strtok_r(ptr4, ":", &saveptr2); (j < 2) && ptr5; ptr5 = strtok_r(NULL, ":", &saveptr2), j++)
			{
				if(!j)
				{
					dwtime = atoi(ptr5);
				}
				if(j)
				{
					awtime = dwtime;
					dwtime = atoi(ptr5);
				}
			}
		}
		if((ptr3 = strchr(trim(ptr), '$')))
		{
			*ptr3++ = '\0';
			srvid = a2i(ptr3, 4);
		}
		if((ptr2 = strchr(trim(ptr), '@')))
		{
			*ptr2++ = '\0';
			provid = a2i(ptr2, 6);
		}
		if((ptr1 = strchr(ptr, '&')))
		{
			*ptr1++ = '\0';
			cmask = a2i(ptr1, -2);
		}
		if(!ptr1 && !ptr2 && !ptr3 && !ptr4)  //only dwtime
			{ dwtime = atoi(ptr); }
		else
			{ caid = a2i(ptr, 2); }
		if((i == 0 && (caid <= 0)) || (caid > 0))
		{
			newtab.caid[i] = caid;
			newtab.cmask[i] = cmask;
			newtab.prid[i] = provid;
			newtab.srvid[i] = srvid;
			newtab.awtime[i] = awtime;
			newtab.dwtime[i] = dwtime;
			newtab.n = i + 1;
		}

	}
	memcpy(tab, &newtab, sizeof(CECSPVALUETAB));
}
Exemplo n.º 25
0
void do_kicksay(COMMAND_ARGS)
{
	/*
	 *  on_msg checks: CARGS
	 */
	KickSay *kick;
	char	*channel,*mask;
	int	inum;

	channel = chop(&rest);
	if (!channel)
	{
		if (!current->kicklist)
		{
			to_user(from,"Kicksay list is empty");
			return;
		}

		if (dcc_only_command(from))
			return;

		table_buffer("\037channel\037\t\037action\037\t\037string\037\t\037kick reason\037");
		for(kick=current->kicklist;kick;kick=kick->next)
		{
			table_buffer("%s\t%s\t%s\t%s",kick->chan,ks_actions[kick->action],kick->mask,kick->reason);
		}
		table_send(from,2);
		return;
	}

	if (ischannel(channel) || *channel == '*')
	{

		if (get_useraccess(from,channel) < cmdaccess)
			return;

		inum = DEFAULT_KS_LEVEL;
		if (*rest != '"')
		{
			inum = a2i(chop(&rest));
			if (errno || inum < 0 || inum > MAX_KS_LEVEL)
				return;
		}

		mask = get_token(&rest,"\"");

		if (!mask || !*mask)
			goto usage;

		/*
		 *  check for previously existing kicks
		 */
		if ((kick = find_kicksay(mask,channel)) != NULL)
		{
			to_user(from,"I'm already kicking on \"%s\"",kick->mask);
			return;
		}

		/*
		 *  dig out the reason (the rest)
		 */
		while(rest && *rest == ' ')
			rest++;
		if (!*rest)
			goto usage;

		/*
		 *  add it to the list
		 */
		set_mallocdoer(do_kicksay);
		kick = (KickSay*)Calloc(sizeof(KickSay) + Strlen(channel,mask,rest,NULL));

		kick->next = current->kicklist;
		current->kicklist = kick;
		kick->action = inum;

		if (!matches("\\*?*\\*",mask))
			kick->chan = Strcpy(kick->mask,mask) + 1;
		else
		{
			kick->mask[0] = '*';
			Strcpy(kick->mask+1,mask);
			kick->chan = Strcat(kick->mask,MATCH_ALL) + 1;
		}
		kick->reason = Strcpy(kick->chan,channel) + 1;
				Strcpy(kick->reason,rest);

		to_user(from,"Now kicking on \"%s\" on %s",mask,channel);
		current->ul_save++;
		return;
	}
usage:
	usage(from);	/* usage for CurrentCmd->name */
}
Exemplo n.º 26
0
int32_t init_provid(void)
{
	FILE *fp = open_config_file(cs_provid);
	if(!fp)
		{ return 0; }

	int32_t nr;
	char *payload, *saveptr1 = NULL, *token;
	if(!cs_malloc(&token, MAXLINESIZE))
		{ return 0; }
	struct s_provid *provid_ptr = NULL;
	struct s_provid *new_cfg_provid = NULL, *last_provid;

	nr = 0;
	while(fgets(token, MAXLINESIZE, fp))
	{
		int32_t i, l;
		struct s_provid *new_provid = NULL;
		char *tmp, *ptr1;
		
		tmp = trim(token);

		if(tmp[0] == '#') { continue; }
		if((l = strlen(tmp)) < 11) { continue; }
		if(!(payload = strchr(token, '|'))) { continue; }

		*payload++ = '\0';
		
		if(!cs_malloc(&new_provid, sizeof(struct s_provid)))
		{
			NULLFREE(token);
			fclose(fp);
			return (1);
		}
				
		new_provid->nprovid = 0;
		for(i = 0, ptr1 = strtok_r(token, ":@", &saveptr1); ptr1; ptr1 = strtok_r(NULL, ":@", &saveptr1), i++)
		{
			if(i==0)
			{
				new_provid->caid = a2i(ptr1, 3);
				continue;	
			}
			
			new_provid->nprovid++;
		}

		if(!cs_malloc(&new_provid->provid, sizeof(uint32_t) * new_provid->nprovid))
		{
			NULLFREE(new_provid);
			NULLFREE(token);
			fclose(fp);
			return (1);
		}

		ptr1 = token + strlen(token) + 1;
		for(i = 0; i < new_provid->nprovid ; i++)
		{
			new_provid->provid[i] = a2i(ptr1, 3);
			
			ptr1 = ptr1 + strlen(ptr1) + 1;
		}
		
		for(i = 0, ptr1 = strtok_r(payload, "|", &saveptr1); ptr1; ptr1 = strtok_r(NULL, "|", &saveptr1), i++)
		{
			switch(i)
			{
			case 0:
				cs_strncpy(new_provid->prov, trim(ptr1), sizeof(new_provid->prov));
				break;
			case 1:
				cs_strncpy(new_provid->sat, trim(ptr1), sizeof(new_provid->sat));
				break;
			case 2:
				cs_strncpy(new_provid->lang, trim(ptr1), sizeof(new_provid->lang));
				break;
			}
		}
		
		if(strlen(new_provid->prov) == 0)
		{
			NULLFREE(new_provid->provid);
			NULLFREE(new_provid);
			continue;
		}
		
		nr++;
				
		if(provid_ptr)
		{
			provid_ptr->next = new_provid;
		}
		else
		{ 
			new_cfg_provid = new_provid;
		}	
		provid_ptr = new_provid;
	}
	
	NULLFREE(token);
	fclose(fp);
	
	if(nr > 0)
		{ cs_log("%d provid's loaded", nr); }
	
	if(new_cfg_provid == NULL)
	{
		if(!cs_malloc(&new_cfg_provid, sizeof(struct s_provid)))
		{
			return (1);
		}		
	}
	
	cs_writelock(__func__, &config_lock);
	
	//this allows reloading of provids, so cleanup of old data is needed:
	last_provid = cfg.provid; //old data
	cfg.provid = new_cfg_provid; //assign after loading, so everything is in memory

	cs_writeunlock(__func__, &config_lock);

	struct s_client *cl;
	for(cl = first_client->next; cl ; cl = cl->next)
		{ cl->last_providptr = NULL; }

	struct s_provid *ptr, *nptr;
	
	if(last_provid)
	{
		ptr = last_provid;
		while(ptr)    //cleanup old data:
		{
			add_garbage(ptr->provid);
			nptr = ptr->next;
			add_garbage(ptr);
			ptr = nptr;
		}
	}
			
	return (0);
}
Exemplo n.º 27
0
/* Parses a single AES_KEYS entry and assigns it to the given list.
   The expected format for value is caid1@ident1:key0,key1 */
void parse_aes_entry(AES_ENTRY **list, char *label, char *value)
{
	uint16_t caid, dummy;
	uint32_t ident;
	int32_t len;
	char *tmp;
	int32_t nb_keys, key_id;
	uchar aes_key[16];
	char *save = NULL;

	tmp = strtok_r(value, "@", &save);

	//if we got error caid
	len = strlen(tmp);
	if(len == 0 || len > 4) { return; }

	//if there is not value after @
	len = strlen(save);
	if(len == 0) { return; }

	caid = a2i(tmp, 2);
	tmp = strtok_r(NULL, ":", &save);

	//if we got error ident
	len = strlen(tmp);
	if(len == 0 || len > 6) { return; }

	ident = a2i(tmp, 3);

	// now we need to split the key and add the entry to the reader.
	nb_keys = 0;
	key_id = 0;
	while((tmp = strtok_r(NULL, ",", &save)))
	{
		dummy = 0;
		len = strlen(tmp);
		if(len != 32)
		{
			dummy = a2i(tmp, 1);
			// FF means the card will do the AES decrypt
			// 00 means we don't have the aes.
			if((dummy != 0xFF && dummy != 0x00) || len > 2)
			{
				key_id++;
				cs_log("AES key length error .. not adding");
				continue;
			}
			if(dummy == 0x00)
			{
				key_id++;
				continue;
			}
		}
		nb_keys++;
		if(dummy)
			{ memset(aes_key, 0xFF, 16); }
		else
			{ key_atob_l(tmp, aes_key, 32); }
		// now add the key to the reader... TBD
		add_aes_entry(list, caid, ident, key_id, aes_key);
		key_id++;
	}

	cs_log("%d AES key(s) added on reader %s for %04x:%06x", nb_keys, label, caid, ident);
}
Exemplo n.º 28
0
//=============================================================================
//
//=============================================================================
void MonitorOSD(BYTE wbits)
{
	BYTE i;
	WORD dat[10];
	BYTE duration=6, ch;

	for(i=0; i<argc; i++)
		dat[i] = a2i(argv[i+2]);	
	

#ifdef MODEL_TW88TEMP
	WriteTW88Page(OSD_PAGE);
#endif

	if( !stricmp(argv[1], "?") ) {
		MonOsdHelp();
	}
	//---------- Initialize ------------------
	else if( !stricmp(argv[1], "0") ) {
		OsdInit(0);
		OsdInit(1);
		OsdInit(4);
		
		OsdLoadDefaultLUT(0);
		OsdLoadDefaultLUT(1);

		OsdWinEnable(0, 1);
	}
	//---------- Block Fill -------------------
	else if( !stricmp(argv[1], "1") ) {
		if( argc<=2 ) {
			dat[0]=0; dat[1]=0; dat[2]=800; dat[3]=480; dat[4]=0;
		}
		Printf("\nOsdBlockFill(%04x %04x %04x %04x ", dat[0], dat[1], dat[2], dat[3]);
		Printf("%04x)", dat[4]);
		OsdWriteMode( BLOCKFILL | BLT_NO | CONV_DIS | wbits | SOURCE0 );
		OsdBlockFill( dat[0], dat[1], dat[2], dat[3], dat[4]);
	}
	//---------- Block Fill 16 -----------------
	else if( !stricmp(argv[1], "11") ) {
		Printf("\nOsdBlockFill(%04x %04x %04x %04x ", dat[0], dat[1], dat[2], dat[3]);
		Printf("%04x)", dat[4]);
		OsdWriteMode( BLOCKFILL | BLT_NO | CONV_DIS | wbits | SOURCE0 );
		OsdBlockFill( dat[0], dat[1], dat[2], dat[3], dat[4]);
	}
	//---------- Block Transfer ----------------
	else if( !stricmp(argv[1], "2") ) {
		Printf("\nOsdBlockTransfer (%04x %04x ", dat[0], dat[1]);
		Printf("%04x %04x %04x %04x)", dat[2], dat[3], dat[4], dat[5]);
		OsdWriteMode( BLOCKTRANS | BLT_NO | CONV_DIS | wbits | SOURCE0 );
		OsdBlockTransfer( dat[0], dat[1], dat[2], dat[3], dat[4], dat[5]);
	}
	//---------- Block Transfer Linear ---------
	else if( !stricmp(argv[1], "btl") ) {
		Printf("\nOsdBlockTransfer (%04x %04x ", dat[0], dat[1]);
		Printf("%04x %04x %04x %04x)", dat[2], dat[3], dat[4], dat[5]);
		OsdWriteMode( BLOCKTRANSL | BLT_NO | CONV_DIS | wbits | SOURCE0 );
		OsdBlockTransfer( dat[0], dat[1], dat[2], dat[3], dat[4], dat[5]);
	}
	//---------- Bitmap Test "Ford" ------------
	else if( !stricmp(argv[1], "ford") ) {
		WORD sx=0, sy=0;
		if( argc>=3 ) sx=dat[0];
		if( argc>=4 ) sy=dat[1];
		Printf("\nFord Logo Display");
//		OsdLoadBmpXY( wbits, fordlogo_half_Header, sx, sy );
//		OsdLoadLUT( 0, fordlogo_half_LUT );
	}
/*
	//---------- Bitmap Test "Pigeon" ----------

	else if( !stricmp(argv[1], "pigeon") ) {
		WORD sx=0, sy=0, d=4;
		if( argc>=3 ) sx=dat[0];
		if( argc>=4 ) sy=dat[1];
		if( argc>=5 ) d = dat[2];
//		MonOsdPigeon(sx,sy, d);
	}
	//---------- Bitmap Test "Pigeon Linear" ----------
	else if( !stricmp(argv[1], "pigeonL") ) {
		WORD sx=0, sy=0, d=4;
		if( argc>=3 ) sx=dat[0];
		if( argc>=4 ) sy=dat[1];
		if( argc>=5 ) d = dat[2];
		MonOsdPigeonLinear(sx,sy, d);
	}
*/
	//---------- Bitmap Test "Rose Linear from SPI" ----------
	else if( !stricmp(argv[1], "Rose") ) {
		//RoseDisplay();
	}

	//---------- Bitmap Test "Pigeon Linear from SPI" ----------
	else if( !stricmp(argv[1], "PigeonL") ) {
		//PigeonDisplay();
	}

	//---------- Load Font -----------------------------
	else if( !stricmp(argv[1], "Font") ) {

		OsdLoadFont(wbits);

	}

	//---------- Load Font -----------------------------
	else if( !stricmp(argv[1], "FontMV") ) {

		OsdLoadFontMV(wbits);

	}

	//---------- Load Font -----------------------------
	else if( !stricmp(argv[1], "FontTP") ) {			// transparent test

		OsdLoadFontTransparent(wbits);

	}

	//---------- Load 16bit expansion -----------------------------
	else if( !stricmp(argv[1], "EXP16") ) {			// transparent test

		Osd16bitTransparent(wbits);

	}

	//---------- Load Font -----------------------------
	else if( !stricmp(argv[1], "FontTest") ) {

		//OsdLoadTransBmpXYFromSPI(TestFont8bit_Header, OSDFONT8_SPI_START, 0, 0);

	}

	//---------- Load Font -----------------------------
	else if( !stricmp(argv[1], "TestAll") ) {
	/*
		DWORD ddraddr=HARRY_DDR_START, spiaddr=HARRY_SPI_START;
		WORD x=0, y=0;

		OsdInit(0);
		OsdInit(1);
		OsdInit(4);
		
		OsdLoadDefaultLUT(0);
		OsdLoadDefaultLUT(1);

		OsdWinEnable(0, 1);

		if( argc<=2 ) {
			dat[0]=0; dat[1]=0; dat[2]=800; dat[3]=480; dat[4]=0;
		}
		Printf("\nOsdBlockFill(%04x %04x %04x %04x ", dat[0], dat[1], dat[2], dat[3]);
		Printf("%04x)", dat[4]);
		OsdWriteMode( BLOCKFILL | BLT_NO | CONV_DIS | wbits | SOURCE0 );
		OsdBlockFill( dat[0], dat[1], dat[2], dat[3], dat[4]);

		//---------- Bitmap Test "Pigeon Linear from SPI" ----------
		PigeonDisplay();
		ch = 0;
	    //------------------------- TEST ROSE -----------------------------------------------------------------
		RoseDisplay();
		ch = 0;

	    //------------------------- TEST Harry 16bit -----------------------------------------------------------------

		//DWORD ddraddr=0L, spiaddr=0x100000L;

		if( argc>=3 ) x=a2h(argv[2]);
		if( argc>=4 ) y=a2h(argv[3]);
		//if( argc>=3 ) ddraddr=a2h(argv[2]);
		//if( argc>=4 ) spiaddr=a2h(argv[3]);
		
		OsdWriteMode( CPUWRITE | BLT_NO | CONV_DIS | PIXEL16 );
		OsdLoadBmpXYFromSPI(  Harry_Header, spiaddr, x, x );
//		OsdLoadBmpLinearFromSPI( Harry_Header, spiaddr, ddraddr);

//		OsdBltSourceMemoryW64( Harry_Header->w/64 );
//		OsdBltDestMemoryW64  ( Harry_Header->w/64 );

//		OsdWinBuffer( 4, ddraddr, Harry_Header->w/64, Harry_Header->h/64 + 1 );
		OsdWinEnable(0, 0);
		OsdWinEnable(1, 0);
		OsdWinEnable(4, 1);
		Osd16Format(OSD16_YCBCR422);		// 00=YCbCr422, 01=RGB565, 10=RGB4444, 11=RGB1444
		Printf("\nPress ESC to display 8bit to 16bit expansion with transparent");
		while(1) {
				if( RS_ready() ) {
					ch = RS_rx();
					if ( ch == 27 ) break;
				}
		}


		Osd16bitTransparent(wbits);

		Printf("\nPress ESC to display LUT16");
		while(1) {
				if( RS_ready() ) {
					ch = RS_rx();
					if ( ch == 27 ) break;
				}
		}

		MonOsdLutTest16();
	*/
	}

#define COLOR_BLACK		0x00
#define COLOR_WHITE		0xff
#define COLOR_RED		0xe0
#define COLOR_GREEN		0x18
#define COLOR_BLUE		0x07

	//---------- Display String ------------------------
	else if( !stricmp(argv[1], "S") ) {
		BYTE fore=COLOR_WHITE, back=COLOR_BLACK;
		WORD x=0, y=0;
		
		if( argc>=4 ) fore = a2h( argv[3] );
		if( argc>=5 ) back = a2h( argv[4] );
		if( argc>=6 ) x    = a2h( argv[5] );
		if( argc>=7 ) y    = a2h( argv[6] );

		OsdDisplayString( 0, x, y, argv[2], fore, back );
	}

	//---------- Display String ------------------------
	else if( !stricmp(argv[1], "ST") ) {
		BYTE fore=COLOR_WHITE, back=COLOR_BLACK;
		WORD x=0, y=0;
		
		if( argc>=4 ) fore = a2h( argv[3] );
		if( argc>=5 ) back = a2h( argv[4] );
		if( argc>=6 ) x    = a2h( argv[5] );
		if( argc>=7 ) y    = a2h( argv[6] );

		OsdDisplayStringT( 0, x, y, argv[2], fore );
	}

	//---------- Display String ------------------------
	else if( !stricmp(argv[1], "SMV") ) {
		BYTE fore=COLOR_WHITE, back=COLOR_BLACK;
		WORD x=0, y=0;
		
		if( argc>=4 ) fore = a2h( argv[3] );
		if( argc>=5 ) back = a2h( argv[4] );
		if( argc>=6 ) x    = a2h( argv[5] );
		if( argc>=7 ) y    = a2h( argv[6] );

		OsdDisplayStringLinear( x, y, argv[2], fore, back );
	}

	//---------- Display String ------------------------
	else if( !stricmp(argv[1], "STMV") ) {
		BYTE fore=COLOR_WHITE, back=COLOR_BLACK;
		WORD x=0, y=0;
		
		if( argc>=4 ) fore = a2h( argv[3] );
		if( argc>=5 ) back = a2h( argv[4] );
		if( argc>=6 ) x    = a2h( argv[5] );
		if( argc>=7 ) y    = a2h( argv[6] );

		OsdDisplayStringTLinear( x, y, argv[2], fore );
	}

	//---------- Bitmap Test "Harry(OSD422(YCb YCr)) from SPI" ----------
	else if( !stricmp(argv[1], "Harry") ) {	
	/*				 			
		//DWORD ddraddr=0L, spiaddr=0x100000L;
		DWORD ddraddr=HARRY_DDR_START, spiaddr=HARRY_SPI_START;
		WORD x=0, y=0;

		if( argc>=3 ) x=a2h(argv[2]);
		if( argc>=4 ) y=a2h(argv[3]);
		//if( argc>=3 ) ddraddr=a2h(argv[2]);
		//if( argc>=4 ) spiaddr=a2h(argv[3]);
		
		OsdWriteMode( CPUWRITE | BLT_NO | CONV_DIS | PIXEL16 );
		OsdLoadBmpXYFromSPI(  Harry_Header, spiaddr, x, x );
//		OsdLoadBmpLinearFromSPI( Harry_Header, spiaddr, ddraddr);

//		OsdBltSourceMemoryW64( Harry_Header->w/64 );
//		OsdBltDestMemoryW64  ( Harry_Header->w/64 );

//		OsdWinBuffer( 4, ddraddr, Harry_Header->w/64, Harry_Header->h/64 + 1 );
		OsdWinEnable(0, 0);
		OsdWinEnable(1, 0);
		OsdWinEnable(4, 1);
		Osd16Format(OSD16_YCBCR422);		// 00=YCbCr422, 01=RGB565, 10=RGB4444, 11=RGB1444
	*/
	}
	/*
	//---------- Bitmap Test "OSD444(YCbCr:655) from SPI" ----------
	else if( !stricmp(argv[1], "OSD444") ) {
		//DWORD ddraddr=0L, spiaddr=0x100000L;
		DWORD ddraddr=OSD444_DDR_START, spiaddr=OSD444_SPI_START;
		if( argc>=3 ) ddraddr=a2h(argv[2]);
		if( argc>=4 ) spiaddr=a2h(argv[3]);
		
		OsdWriteMode( CPUWRITE | BLT_NO | CONV_DIS | PIXEL16 );
		OsdLoadBmpLinearFromSPI( Harry_Header, spiaddr, ddraddr);

		OsdBltSourceMemoryW64( OSD444_Header->w/64 );
		OsdBltDestMemoryW64  ( OSD444_Header->w/64 );

		OsdWinBuffer( 4, ddraddr, OSD444_Header->w/64, OSD444_Header->h/64 + 1 );
		OsdWinEnable(0, 0);
		OsdWinEnable(1, 0);
		OsdWinEnable(4, 1);
		Osd16Format(OSD16_YCBCR422);		// 00=YCbCr422, 01=RGB565, 10=RGB4444, 11=RGB1444

	}
	*/
	//---------- Bitmap Test "OSDRGB(565) from SPI" ----------
	/*
	else if( !stricmp(argv[1], "RGBn") ) {
		//DWORD ddraddr=0L, spiaddr=0x100000L;
		DWORD ddraddr=OSDRGBn_DDR_START, spiaddr=OSDRGBn_SPI_START;
		WORD x=0, y=0;

		if( argc>=3 ) x=a2h(argv[2]);
		if( argc>=4 ) y=a2h(argv[3]);
		
		OsdWriteMode( CPUWRITE | BLT_NO | CONV_DIS | PIXEL16 );
		OsdLoadBmpXYFromSPI( osdRGBn_Header, spiaddr, x, y );

		OsdWinEnable(0, 0);
		OsdWinEnable(1, 0);
		OsdWinEnable(4, 1);
		Osd16Format(OSD16_RGB565);		// 00=YCbCr422, 01=RGB565, 10=RGB4444, 11=RGB1444

	}
	//---------- Bitmap Test "OSDRGB(565) from SPI" ----------
	else if( !stricmp(argv[1], "RGB") ) {
		//DWORD ddraddr=0L, spiaddr=0x100000L;
		DWORD ddraddr=OSDRGB_DDR_START, spiaddr=OSDRGB_SPI_START;
		WORD x=0, y=0;

		if( argc>=3 ) x=a2h(argv[2]);
		if( argc>=4 ) y=a2h(argv[3]);
		
		OsdWriteMode( CPUWRITE | BLT_NO | CONV_DIS | PIXEL16 );
		OsdLoadBmpXYFromSPI( osdRGB_Header, spiaddr, x, y );

		OsdWinEnable(0, 0);
		OsdWinEnable(1, 0);
		OsdWinEnable(4, 1);
		Osd16Format(OSD16_RGB565);		// 00=YCbCr422, 01=RGB565, 10=RGB4444, 11=RGB1444

	}
	//---------- Bitmap Test "OSDaRGB(4444) from SPI" ----------
	else if( !stricmp(argv[1], "aRGBn") ) {
		//DWORD ddraddr=0L, spiaddr=0x100000L;
		DWORD ddraddr=OSDaRGBn_DDR_START, spiaddr=OSDaRGBn_SPI_START;
		WORD x=0, y=0;

		if( argc>=3 ) x=a2h(argv[2]);
		if( argc>=4 ) y=a2h(argv[3]);
		
		OsdWriteMode( CPUWRITE | BLT_NO | CONV_DIS | PIXEL16 );
		OsdLoadBmpXYFromSPI( osdaRGBn_Header, spiaddr, x, y );

		OsdWinEnable(0, 0);
		OsdWinEnable(1, 0);
		OsdWinEnable(4, 1);
		Osd16Format(OSD16_RGB4444);		// 00=YCbCr422, 01=RGB565, 10=RGB4444, 11=RGB1444

	}
	else if( !stricmp(argv[1], "aRGB") ) {
		//DWORD ddraddr=0L, spiaddr=0x100000L;
		DWORD ddraddr=OSDaRGB_DDR_START, spiaddr=OSDaRGB_SPI_START;
		WORD x=0, y=0;

		if( argc>=3 ) x=a2h(argv[2]);
		if( argc>=4 ) y=a2h(argv[3]);
		
		OsdWriteMode( CPUWRITE | BLT_NO | CONV_DIS | PIXEL16 );
		OsdLoadBmpXYFromSPI( osdaRGB_Header, spiaddr, x, y );

		OsdWinEnable(0, 0);
		OsdWinEnable(1, 0);
		OsdWinEnable(4, 1);
		Osd16Format(OSD16_RGB4444);		// 00=YCbCr422, 01=RGB565, 10=RGB4444, 11=RGB1444

	}
	//---------- Bitmap Test "OSDbRGB(1555) from SPI" ----------
	else if( !stricmp(argv[1], "bRGBn") ) {
		//DWORD ddraddr=0L, spiaddr=0x100000L;
		DWORD ddraddr=OSDbRGBn_DDR_START, spiaddr=OSDbRGBn_SPI_START;
		WORD x=0, y=0;

		if( argc>=3 ) x=a2h(argv[2]);
		if( argc>=4 ) y=a2h(argv[3]);
		
		OsdWriteMode( CPUWRITE | BLT_NO | CONV_DIS | PIXEL16 );
		OsdLoadBmpXYFromSPI( osdbRGBn_Header, spiaddr, x, y );

		OsdWinEnable(0, 0);
		OsdWinEnable(1, 0);
		OsdWinEnable(4, 1);
		Osd16Format(OSD16_RGB1555);		// 00=YCbCr422, 01=RGB565, 10=RGB4444, 11=RGB1444

	}
	else if( !stricmp(argv[1], "bRGB") ) {
		//DWORD ddraddr=0L, spiaddr=0x100000L;
		DWORD ddraddr=OSDbRGB_DDR_START, spiaddr=OSDbRGB_SPI_START;
		WORD x=0, y=0;

		if( argc>=3 ) x=a2h(argv[2]);
		if( argc>=4 ) y=a2h(argv[3]);
		
		OsdWriteMode( CPUWRITE | BLT_NO | CONV_DIS | PIXEL16 );
		OsdLoadBmpXYFromSPI( osdbRGB_Header, spiaddr, x, y );

		OsdWinEnable(0, 0);
		OsdWinEnable(1, 0);
		OsdWinEnable(4, 1);
		Osd16Format(OSD16_RGB1555);		// 00=YCbCr422, 01=RGB565, 10=RGB4444, 11=RGB1444

	}
	*/
	//---------- Animation ---------------------
	else if( !stricmp(argv[1], "ani") ) {
		BYTE en=0;
		if( argc>=3 ) en=dat[0];
		if( en ) {
//			AnimationPigeon();
			AnimationON=1;
		}
		else {
			for(en=0; en<MAX_ANIMATION; en++) AnimationData[en].active = 0;
			AnimationON=0;
		}
	}



	//---------- LUT Test-----------------------
	else if( !stricmp(argv[1], "ATTR") ) {
		Printf("\nChange Attribute in LUT: Window %d = %02x", dat[0], dat[1]);
		MonOsdChangeAttr(dat[0], dat[1]);
	}
	//---------- LUT Test-----------------------
	else if( !stricmp(argv[1], "LUTx") ) {
		Printf("\nset Transparent LUT: Window %d, R:%d, G:%d, B:%d", dat[0], dat[1], dat[2], dat[3]);
		OsdLoadTranparentLUT( dat[0], dat[1], dat[2], dat[3] );
	}
	//---------- LUT Test-----------------------
	else if( !stricmp(argv[1], "LUT") ) {
		BYTE xcnt=16, size=10;
		WORD sx=0, sy=0;
		if( argc>=3 ) size=dat[0];
		if( argc>=4 ) xcnt=dat[1];
		if( argc>=5 ) sx=dat[2];
		if( argc>=6 ) sy=dat[3];
		Printf("\nMonOsdLutTest");
		MonOsdLutTest(size, xcnt, sx, sy);
	}
	//---------- LUT Test 16 -------------------
	else if( !stricmp(argv[1], "LUT16") ) {
		Printf("\nMonOsdLutTest16");
		MonOsdLutTest16();
	}
	//---------- LUT Test 565 -------------------
	else if( !stricmp(argv[1], "LUT565") ) {
		Printf("\nMonOsdLutTestRGB");
		MonOsdLutTest565();
		MonOsdLutTest565_2();
	}
	//---------- LUT Test 555 -------------------
	else if( !stricmp(argv[1], "LUT555") ) {
		Printf("\nMonOsdLutTestbRGB");
		MonOsdLutTest555();
		MonOsdLutTest555_2();
	}
	//---------- LUT Test 444 -------------------
	else if( !stricmp(argv[1], "LUT444") ) {
		Printf("\nMonOsdLutTestaRGB");
		MonOsdLutTest444();
	}
	//---------- LUT Test YCbYCr -------------------
	else if( !stricmp(argv[1], "LUTYUV") ) {
		Printf("\nMonOsdLutTestYCbYCr");
		MonOsdLutTestYUV();
	}
	//---------- DDR  Test ---------------------
	else if( !stricmp(argv[1], "t") ) {
		Printf("\nMonOsdTestDDR");
		MonOsdTestDDR();
	}
	else {
		Printf("\nInvalid command...");
	}
}
Exemplo n.º 29
0
int
main(int argc,
     char **argv,
     char **envp)
{
  cache_table *cache_rules = NULL;
  lf_file_references file_references = lf_include_references;
  decode_table *decode_rules = NULL;
  filter *filters = NULL;
  insn_table *instructions = NULL;
  table_include *includes = NULL;
  char *real_file_name = NULL;
  int is_header = 0;
  int ch;

  if (argc == 1) {
    printf("Usage:\n");
    printf("  igen <config-opts> ... <input-opts>... <output-opts>...\n");
    printf("Config options:\n");
    printf("  -F <filter-out-flag>  eg -F 64 to skip 64bit instructions\n");
    printf("  -E                    Expand (duplicate) semantic functions\n");
    printf("  -I <icache-size>      Generate cracking cache version\n");
    printf("  -C                    Include semantics in cache functions\n");
    printf("  -S                    Include insn (instruction) in icache\n");
    printf("  -R                    Use defines to reference cache vars\n");
    printf("  -L                    Supress line numbering in output files\n");
    printf("  -B <bit-size>         Set the number of bits in an instruction\n");
    printf("  -H <high-bit>         Set the nr of the high (msb bit)\n");
    printf("  -N <nr-cpus>          Specify the max number of cpus the simulation will support\n");
    printf("  -J                    Use jumps instead of function calls\n");
    printf("  -T <mechanism>        Override the mechanism used to decode an instruction\n");
    printf("                        using <mechanism> instead of what was specified in the\n");
    printf("                        decode-rules input file\n");
    printf("\n");
    printf("Input options (ucase version also dumps loaded table):\n");
    printf("  -o <decode-rules>\n");
    printf("  -k <cache-rules>\n");
    printf("  -i <instruction-table>\n");
    printf("\n");
    printf("Output options:\n");
    printf("  -n <real-name>        Specify the real name of for the next output file\n"); 
    printf("  -h 		    Generate header file\n");
    printf("  -c <output-file>      output icache\n");
    printf("  -d <output-file>      output idecode\n");
    printf("  -m <output-file>      output model\n");
    printf("  -s <output-file>      output schematic\n");
    printf("  -t <output-file>      output itable\n");
    printf("  -f <output-file>      output support functions\n");
  }

  while ((ch = getopt(argc, argv,
		      "F:EI:RSLJT:CB:H:N:o:k:i:n:hc:d:m:s:t:f:"))
	 != -1) {
    fprintf(stderr, "\t-%c %s\n", ch, (optarg ? optarg : ""));
    switch(ch) {
    case 'C':
      code |= generate_with_icache;
      code |= generate_with_semantic_icache;
      break;
    case 'S':
      code |= generate_with_icache;
      code |= generate_with_insn_in_icache;
      break;
    case 'L':
      file_references = lf_omit_references;
      break;
    case 'E':
      generate_expanded_instructions = 1;
      break;
    case 'G':
      {
	int enable_p;
	char *argp;
	if (strncmp (optarg, "no-", strlen ("no-")) == 0)
	  {
	    argp = optarg + strlen ("no-");
	    enable_p = 0;
	  }
	else if (strncmp (optarg, "!", strlen ("!")) == 0)
	  {
	    argp = optarg + strlen ("no-");
	    enable_p = 0;
	  }
	else
	  {
	    argp = optarg;
	    enable_p = 1;
	  }
        if (strncmp (argp, "gen-icache", strlen ("gen-icache")) == 0)
          {
            switch (argp[strlen ("gen-icache")])
              {
              case '=':
	        icache_size = atoi (argp + strlen ("gen-icache") + 1);
	        code |= generate_with_icache;
                break;
              case '\0':
	        code |= generate_with_icache;
                break;
              default:
                error (NULL, "Expecting -Ggen-icache or -Ggen-icache=<N>\n");
              }
          }
	}
    case 'I':
      {
	table_include **dir = &includes;
	while ((*dir) != NULL)
	  dir = &(*dir)->next;
	(*dir) = ZALLOC (table_include);
	(*dir)->dir = strdup (optarg);
      }
      break;
    case 'N':
      generate_smp = a2i(optarg);
      break;
    case 'R':
      code |= generate_with_direct_access;
      break;
    case 'B':
      insn_bit_size = a2i(optarg);
      ASSERT(insn_bit_size > 0 && insn_bit_size <= max_insn_bit_size
	     && (hi_bit_nr == insn_bit_size-1 || hi_bit_nr == 0));
      break;
    case 'H':
      hi_bit_nr = a2i(optarg);
      ASSERT(hi_bit_nr == insn_bit_size-1 || hi_bit_nr == 0);
      break;
    case 'F':
      filters = new_filter(optarg, filters);
      break;
    case 'J':
      code &= ~generate_calls;
      code |= generate_jumps;
      break;
    case 'T':
      force_decode_gen_type(optarg);
      break;
    case 'i':
      if (decode_rules == NULL) {
	fprintf(stderr, "Must specify decode tables\n");
	exit (1);
      }
      instructions = load_insn_table(optarg, decode_rules, filters, includes,
				     &cache_rules);
      fprintf(stderr, "\texpanding ...\n");
      insn_table_expand_insns(instructions);
      break;
    case 'o':
      decode_rules = load_decode_table(optarg, hi_bit_nr);
      break;
    case 'k':
      cache_rules = load_cache_table(optarg, hi_bit_nr);
      break;
    case 'n':
      real_file_name = strdup(optarg);
      break;
    case 'h':
      is_header = 1;
      break;
    case 's':
    case 'd':
    case 'm':
    case 't':
    case 'f':
    case 'c':
      {
	lf *file = lf_open(optarg, real_file_name, file_references,
			   (is_header ? lf_is_h : lf_is_c),
			   argv[0]);
	lf_print__file_start(file);
	ASSERT(instructions != NULL);
	switch (ch) {
	case 's':
	  if(is_header)
	    gen_semantics_h(instructions, file, code);
	  else
	    gen_semantics_c(instructions, cache_rules, file, code);
	  break;
	case 'd':
	  if (is_header)
	    gen_idecode_h(file, instructions, cache_rules);
	  else
	    gen_idecode_c(file, instructions, cache_rules);
	  break;
	case 'm':
	  if (is_header)
	    gen_model_h(instructions, file);
	  else
	    gen_model_c(instructions, file);
	  break;
	case 't':
	  if (is_header)
	    gen_itable_h(instructions, file);
	  else
	    gen_itable_c(instructions, file);
	  break;
	case 'f':
	  if (is_header)
	    gen_support_h(instructions, file);
	  else
	    gen_support_c(instructions, file);
	  break;
	case 'c':
	  if (is_header)
	    gen_icache_h(instructions, file, code);
	  else
	    gen_icache_c(instructions, cache_rules, file, code);
	  break;
	}
	lf_print__file_finish(file);
	lf_close(file);
	is_header = 0;
      }
      real_file_name = NULL;
      break;
    default:
      error("unknown option\n");
    }
  }
  return 0;
}
Exemplo n.º 30
0
static void ecmwhitelist_fn(const char *token, char *value, void *setting, FILE *f) {
    struct s_reader *rdr = setting;
    if (value) {
        char *ptr, *ptr2, *ptr3, *saveptr1 = NULL;
        struct s_ecmWhitelist *tmp, *last;
        struct s_ecmWhitelistIdent *tmpIdent, *lastIdent;
        struct s_ecmWhitelistLen *tmpLen, *lastLen;
        for(tmp = rdr->ecmWhitelist; tmp; tmp=tmp->next) {
            for(tmpIdent = tmp->idents; tmpIdent; tmpIdent=tmpIdent->next) {
                for(tmpLen = tmpIdent->lengths; tmpLen; tmpLen=tmpLen->next) {
                    add_garbage(tmpLen);
                }
                add_garbage(tmpIdent);
            }
            add_garbage(tmp);
        }
        rdr->ecmWhitelist = NULL;
        if(strlen(value) > 0) {
            saveptr1 = NULL;
            char *saveptr2 = NULL;
            for (ptr = strtok_r(value, ";", &saveptr1); ptr; ptr = strtok_r(NULL, ";", &saveptr1)) {
                int16_t caid = 0, len;
                uint32_t ident = 0;
                ptr2=strchr(ptr,':');
                if(ptr2 != NULL) {
                    ptr2[0] = '\0';
                    ++ptr2;
                    ptr3=strchr(ptr,'@');
                    if(ptr3 != NULL) {
                        ptr3[0] = '\0';
                        ++ptr3;
                        ident = (uint32_t)a2i(ptr3, 6);
                    }
                    caid = (int16_t)dyn_word_atob(ptr);
                } else ptr2 = ptr;
                for (ptr2 = strtok_r(ptr2, ",", &saveptr2); ptr2; ptr2 = strtok_r(NULL, ",", &saveptr2)) {
                    len = (int16_t)dyn_word_atob(ptr2);
                    last = NULL, tmpIdent = NULL, lastIdent = NULL, tmpLen = NULL, lastLen = NULL;
                    for(tmp = rdr->ecmWhitelist; tmp; tmp=tmp->next) {
                        last = tmp;
                        if(tmp->caid == caid) {
                            for(tmpIdent = tmp->idents; tmpIdent; tmpIdent=tmpIdent->next) {
                                lastIdent = tmpIdent;
                                if(tmpIdent->ident == ident) {
                                    for(tmpLen = tmpIdent->lengths; tmpLen; tmpLen=tmpLen->next) {
                                        lastLen = tmpLen;
                                        if(tmpLen->len == len) break;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    if(tmp == NULL) {
                        if (cs_malloc(&tmp, sizeof(struct s_ecmWhitelist))) {
                            tmp->caid = caid;
                            tmp->idents = NULL;
                            tmp->next = NULL;
                            if(last == NULL) {
                                rdr->ecmWhitelist = tmp;
                            } else {
                                last->next = tmp;
                            }
                        }
                    }
                    if(tmp != NULL && tmpIdent == NULL) {
                        if (cs_malloc(&tmpIdent, sizeof(struct s_ecmWhitelistIdent))) {
                            tmpIdent->ident = ident;
                            tmpIdent->lengths = NULL;
                            tmpIdent->next = NULL;
                            if(lastIdent == NULL) {
                                tmp->idents = tmpIdent;
                            } else {
                                lastIdent->next = tmpIdent;
                            }
                        }
                    }
                    if(tmp != NULL && tmpIdent != NULL && tmpLen == NULL) {
                        if (cs_malloc(&tmpLen, sizeof(struct s_ecmWhitelistLen))) {
                            tmpLen->len = len;
                            tmpLen->next = NULL;
                            if(lastLen == NULL) {
                                tmpIdent->lengths = tmpLen;
                            } else {
                                lastLen->next = tmpLen;
                            }
                        }
                    }
                }
            }
        }
        return;
    }

    value = mk_t_ecmwhitelist(rdr->ecmWhitelist);
    if (strlen(value) > 0 || cfg.http_full_cfg)
        fprintf_conf(f, token, "%s\n", value);
    free_mk_t(value);
}