예제 #1
0
krb5_error_code KRB5_CALLCONV
krb5int_accessor(krb5int_access *internals, krb5_int32 version)
{
    if (version == KRB5INT_ACCESS_VERSION) {
#if DESIGNATED_INITIALIZERS
#define S(FIELD, VAL)   .FIELD = VAL
#if defined __GNUC__ && __STDC_VERSION__ < 199901L
	__extension__
#endif
	static const krb5int_access internals_temp = {
#else
#define S(FIELD, VAL)   internals_temp.FIELD = VAL
	    krb5int_access internals_temp;
#endif
	    S (free_addrlist, krb5int_free_addrlist),
	    S (krb5_hmac, krb5_hmac),
	    S (krb5_auth_con_get_subkey_enctype, krb5_auth_con_get_subkey_enctype),
	    S (md5_hash_provider, &krb5int_hash_md5),
	    S (arcfour_enc_provider, &krb5int_enc_arcfour),
	    S (sendto_udp, &krb5int_sendto),
	    S (add_host_to_list, krb5int_add_host_to_list),

#ifdef KRB5_DNS_LOOKUP
#define SC(FIELD, VAL)	S(FIELD, VAL)
#else /* disable */
#define SC(FIELD, VAL)	S(FIELD, 0)
#endif
	    SC (make_srv_query_realm, krb5int_make_srv_query_realm),
	    SC (free_srv_dns_data, krb5int_free_srv_dns_data),
	    SC (use_dns_kdc, _krb5_use_dns_kdc),
#undef SC
	    S (clean_hostname, krb5int_clean_hostname),

	    S (krb_life_to_time, 0),
	    S (krb_time_to_life, 0),
	    S (krb524_encode_v4tkt, 0),

	    S (krb5int_c_mandatory_cksumtype, krb5int_c_mandatory_cksumtype),
#ifndef LEAN_CLIENT
#define SC(FIELD, VAL)	S(FIELD, VAL)
#else /* disable */
#define SC(FIELD, VAL)	S(FIELD, 0)
#endif
	    SC (krb5_ser_pack_int64, krb5_ser_pack_int64),
	    SC (krb5_ser_unpack_int64, krb5_ser_unpack_int64),
#undef SC

#ifdef ENABLE_LDAP
#define SC(FIELD, VAL)	S(FIELD, VAL)
#else
#define SC(FIELD, VAL)	S(FIELD, 0)
#endif
	    SC (asn1_ldap_encode_sequence_of_keys, krb5int_ldap_encode_sequence_of_keys),
	    SC (asn1_ldap_decode_sequence_of_keys, krb5int_ldap_decode_sequence_of_keys),
#undef SC

#ifndef DISABLE_PKINIT
#define SC(FIELD, VAL)	S(FIELD, VAL)
#else /* disable */
#define SC(FIELD, VAL)	S(FIELD, 0)
#endif
	    SC (encode_krb5_pa_pk_as_req, encode_krb5_pa_pk_as_req),
	    SC (encode_krb5_pa_pk_as_req_draft9, encode_krb5_pa_pk_as_req_draft9),
            SC (encode_krb5_pa_pk_as_rep, encode_krb5_pa_pk_as_rep),
	    SC (encode_krb5_pa_pk_as_rep_draft9, encode_krb5_pa_pk_as_rep_draft9),
	    SC (encode_krb5_auth_pack, encode_krb5_auth_pack),
	    SC (encode_krb5_auth_pack_draft9, encode_krb5_auth_pack_draft9),
	    SC (encode_krb5_kdc_dh_key_info, encode_krb5_kdc_dh_key_info),
	    SC (encode_krb5_reply_key_pack, encode_krb5_reply_key_pack),
	    SC (encode_krb5_reply_key_pack_draft9, encode_krb5_reply_key_pack_draft9),
	    SC (encode_krb5_typed_data, encode_krb5_typed_data),
	    SC (encode_krb5_td_trusted_certifiers, encode_krb5_td_trusted_certifiers),
	    SC (encode_krb5_td_dh_parameters, encode_krb5_td_dh_parameters),
	    SC (decode_krb5_pa_pk_as_req, decode_krb5_pa_pk_as_req),
	    SC (decode_krb5_pa_pk_as_req_draft9, decode_krb5_pa_pk_as_req_draft9),
	    SC (decode_krb5_pa_pk_as_rep, decode_krb5_pa_pk_as_rep),
	    SC (decode_krb5_pa_pk_as_rep_draft9, decode_krb5_pa_pk_as_rep_draft9),
	    SC (decode_krb5_auth_pack, decode_krb5_auth_pack),
	    SC (decode_krb5_auth_pack_draft9, decode_krb5_auth_pack_draft9),
	    SC (decode_krb5_kdc_dh_key_info, decode_krb5_kdc_dh_key_info),
	    SC (decode_krb5_principal_name, decode_krb5_principal_name),
	    SC (decode_krb5_reply_key_pack, decode_krb5_reply_key_pack),
	    SC (decode_krb5_reply_key_pack_draft9, decode_krb5_reply_key_pack_draft9),
	    SC (decode_krb5_typed_data, decode_krb5_typed_data),
	    SC (decode_krb5_td_trusted_certifiers, decode_krb5_td_trusted_certifiers),
	    SC (decode_krb5_td_dh_parameters, decode_krb5_td_dh_parameters),
	    SC (decode_krb5_as_req, decode_krb5_as_req),
	    SC (encode_krb5_kdc_req_body, encode_krb5_kdc_req_body),
	    SC (krb5_free_kdc_req, krb5_free_kdc_req),
	    SC (krb5int_set_prompt_types, krb5int_set_prompt_types),
	    SC (encode_krb5_authdata_elt, encode_krb5_authdata_elt),
#undef SC

	    S (encode_krb5_sam_response_2, encode_krb5_sam_response_2),
	    S (encode_krb5_enc_sam_response_enc_2, encode_krb5_enc_sam_response_enc_2),
	    S (encode_enc_ts, encode_krb5_pa_enc_ts),
	    S (decode_enc_ts, decode_krb5_pa_enc_ts),
	    S (encode_enc_data, encode_krb5_enc_data),
	    S(decode_enc_data, decode_krb5_enc_data),
	    S(free_enc_ts, krb5_free_pa_enc_ts),
	    S(free_enc_data, krb5_free_enc_data),
	    S(encrypt_helper, krb5_encrypt_helper),

#if DESIGNATED_INITIALIZERS
	};
#else
	0;
#endif
	*internals = internals_temp;
	return 0;
    }
예제 #2
0
std::string mtype_to_string(MType type)
{
    static const mtype_str_table_t mtype_str_table = mtype_str_table_init();
    return mtype_str_table[SC(type)];
}
예제 #3
0
static inline char * DESCRIBE_RAM(char *s, UINT8 ramControl, UINT32 gprContents) {
	return s + sprintf(s, es5510_device::RAM_CONTROL[ramControl].description, SC(gprContents));
}
예제 #4
0
파일: ymf278b.c 프로젝트: vgmrips/vgmplay
	0, 8, 16, 24, 32, 40, 48, 256, 256,   0,  0,  0,  0,  0,  0, 0
};
const INT32 pan_right[16] = {
	0, 0,  0,  0,  0,  0,  0,   0, 256, 256, 48, 40, 32, 24, 16, 8
};

// Mixing levels, units are -3dB, and add some marging to avoid clipping
const INT32 mix_level[8] = {
	8, 16, 24, 32, 40, 48, 56, 256+8
};

// decay level table (3dB per step)
// 0 - 15: 0, 3, 6, 9,12,15,18,21,24,27,30,33,36,39,42,93 (dB)
#define SC(db) (db * (2.0 / ENV_STEP))
const UINT32 dl_tab[16] = {
 SC( 0), SC( 1), SC( 2), SC(3 ), SC(4 ), SC(5 ), SC(6 ), SC( 7),
 SC( 8), SC( 9), SC(10), SC(11), SC(12), SC(13), SC(14), SC(31)
};
#undef SC

#define RATE_STEPS	8
const UINT8 eg_inc[15 * RATE_STEPS] = {
//cycle:0  1   2  3   4  5   6  7
	0, 1,  0, 1,  0, 1,  0, 1, //  0  rates 00..12 0 (increment by 0 or 1)
	0, 1,  0, 1,  1, 1,  0, 1, //  1  rates 00..12 1
	0, 1,  1, 1,  0, 1,  1, 1, //  2  rates 00..12 2
	0, 1,  1, 1,  1, 1,  1, 1, //  3  rates 00..12 3

	1, 1,  1, 1,  1, 1,  1, 1, //  4  rate 13 0 (increment by 1)
	1, 1,  1, 2,  1, 1,  1, 2, //  5  rate 13 1
	1, 2,  1, 2,  1, 2,  1, 2, //  6  rate 13 2
예제 #5
0
quint32 QPCSCReader::connectEx(Connect connect, Mode mode)
{
	LONG err = SC(Connect, d->d->context, d->state.szReader, connect, mode, &d->card, &d->proto);
	updateState();
	return quint32(err);
}
int parse_pko_config_command(token_list_t *list)
{
	int intf_index = -1;
	int queue_cnt = -1;
	int port_cnt = -1;
	int tok_offset = 0;
	int interfaces[CVMX_HELPER_MAX_IFACE];
	int intf_cnt, i;

	if (SC(TK[1],"command_queue") == 0)
		return (parse_fpa_config_command(list, &pko_fpa_cfg, "pko command queue pool"));
	if  ( (SC(TK[0],"pko") != 0) || (SC(TK[1],"interface") != 0) ||
	      (SC(TK[2],"=") != 0) || (list->token_index < 9) ) {
		cvmx_dprintf("ERROR: invalid pko command :");
		return -1;
		//show_token_list(list);
	}
	intf_cnt = parse_interface_name(TK[3], interfaces,
					CVMX_HELPER_MAX_IFACE);

	if (intf_cnt < 0) {
		cvmx_dprintf("ERROR: invalid interface name = %s \n", TK[3]);
		return -1;
	}

	if (SC(TK[4],"interface_index") == 0)
	{
		if (intf_cnt != 1) {
			cvmx_dprintf("ERROR: cannot specify interface_index"
				     " when using wild card for specifying"
				     " interface name\n");
			return -1;
		}
		if (SC(TK[5],"=") != 0) {
			cvmx_dprintf("ERROR: invalid pko config command : no "
				     "equal sign after interface_index \n");
			return -1;
		}
		tok_offset = 3;
		intf_index = ST(TK[6], 0, 10);
		if ((intf_index >= CVMX_HELPER_CFG_MAX_PORT_PER_IFACE) ||
			(intf_index < 0)) {
			cvmx_dprintf("ERROR: invalid intf_index=%d max=%d\n",
				     intf_index,
				     CVMX_HELPER_CFG_MAX_PORT_PER_IFACE-1);
			return -1;
		}
	}

	if ( (SC(TK[tok_offset + 4],"internal_port_cnt") != 0) ||
	     (SC(TK[tok_offset + 5],"=") != 0) ) {
		cvmx_dprintf("ERROR: invalid pko config command  while looking"
			     "for internal_port_cnt \n");
		return -1;
	}
	if ( (SC(TK[tok_offset+7],"queues_per_internal_port") != 0) ||
	     (SC(TK[tok_offset+8],"=") != 0) )  {
		cvmx_dprintf("ERROR: invalid pko config command while looking"
			     "for queues_per_internal_port\n");
		return -1;
	}
#define PKO_CFG __cvmx_pko_config

	port_cnt = (int) ST(TK[tok_offset+6], 0, 10);
	queue_cnt  = (int) ST(TK[tok_offset+9], 0, 10);

	for(i=0; i<intf_cnt; i++) {
		int intf_num = interfaces[i];
		if (intf_num == -1)
			continue;
		if ( (is_interface_disabled(intf_num) == 1)  && dbg_parse) {
			cvmx_dprintf("skipping config interace_num=%d :",
				     intf_num);
			show_token_list(list);
		}
		if (intf_index != -1) {
			//cvmx_dprintf("%d:%d %d %d \n", intf_num, intf_index, port_cnt, queue_cnt);
			PKO_CFG[intf_num][intf_index].internal_port_cnt = port_cnt;
			PKO_CFG[intf_num][intf_index].queues_per_internal_port = queue_cnt;
		} else {
			int index;
			int port_max = __cvmx_helper_early_ports_on_interface(intf_num);
			for(index=0; index<port_max; index++) {
				PKO_CFG[intf_num][index].internal_port_cnt = port_cnt;
				PKO_CFG[intf_num][index].queues_per_internal_port = queue_cnt;
			}
		}
		if(dbg_parse)
			cvmx_dprintf("interface=%d interface_index=%d queue_cnt"
				     "=%d port_cnt=%d\n", intf_num, intf_index,
				     queue_cnt, port_cnt);
	}
#undef PKO_CFG
	return 0;
}
int parse_ilk_config_command(token_list_t *list)
{
	int interface;
	unsigned int mode;
	unsigned char channels;
	unsigned char mask;

	if(dbg_parse)
		cvmx_dprintf("parsing llm_config\n");
	if (list->token_index < 7) {
		cvmx_dprintf("ERROR: Invalid index=%d ilk config command\n", list->token_index);
		return -1;
	}
	if((SC(TK[1], "interface") == 0) &&  (SC(TK[2], "=") == 0))  {
		interface = ST(TK[3], (char**)NULL, 10);
		if(interface >= CVMX_NUM_ILK_INTF || interface < 0) {
			cvmx_dprintf("ERROR: Invalid interface=%d in ilk config command\n",
				     interface);
			return -1;
		}
		if((SC(TK[4], "enable_look_aside_mode") == 0) &&
			(SC(TK[5], "=") == 0)) {
			if(SC(TK[6],"yes") == 0)
				mode = 1;
			else
				mode = 0;
			cvmx_ilk_config_set_LA_mode(interface, mode);
		}
		else if((SC(TK[4], "enable_rx_calendar_in_look_aside_mode") == 0) &&
		       (SC(TK[5], "=") == 0)) {
			if(SC(TK[6],"yes") == 0)
				mode = 1;
			else
				mode = 0;
			cvmx_ilk_config_set_LA_mode_cal(interface, mode);
		}
		else if((SC(TK[4], "max_number_of_channels") == 0) &&
				       (SC(TK[5], "=") == 0)) {
			channels = ST(TK[6], (char**)NULL, 10);
			if(dbg_parse)
				cvmx_dprintf("ilk interface=%d channels=%d\n",(int)interface,
				     (int)channels);
			cvmx_ilk_config_set_max_channels(interface, channels);
		}
		else if((SC(TK[4], "lane_mask") == 0) &&
				       (SC(TK[5], "=") == 0)) {
			mask = ST(TK[6], (char**)NULL, 16);
			if(dbg_parse)
				cvmx_dprintf("ilk interface=%d lane_mask=0x%x\n",(int)interface,
				     (int)mask);
			cvmx_ilk_config_set_lane_mask(interface, mask);
		}
		else {
		       cvmx_dprintf("ERROR: Invalid ilk config command %s\n",TK[4] );
		       return -1;
	       }
	}
	else {
		cvmx_dprintf("ERROR: Invalid ilk config command %s\n",TK[1] );
		return -1;
	}
	return 0;
}
예제 #8
0
파일: scriplib.c 프로젝트: jonof/jfmact
boolean SCRIPT_GetDoubleString( int32 scripthandle, const char * sectionname, const char * entryname, char * dest1, char * dest2, size_t dest1len, size_t dest2len )
{
	ScriptSectionType *s;
	ScriptEntryType *e;
	const char *p;
    char ch, done;
	size_t c;

	if (!SC(scripthandle)) return 1;
	if (!SCRIPT(scripthandle,script)) return 1;

	s = SCRIPT_SectionExists(scripthandle, sectionname);
	e = SCRIPT_EntryExists(s, entryname);
	
	if (!e) return 1;
	if (dest1len < 1) return 1;
	if (dest2len < 1) return 1;

	// Deduct the terminating nulls.
	dest1len--;
	dest2len--;

	p = e->value;
	c = 0;
	done = 0;
		
	if (*p == '\"') {
		// quoted string
		p++;
		while (!done && (ch = *(p++))) {
			switch (ch) {
				case '\\':
					ch = *(p++);
					if (ch == 0) {
						done = 1;
					} else if (c < dest1len) {
						switch (ch) {
							case 'n': dest1[c++] = '\n'; break;
							case 'r': dest1[c++] = '\r'; break;
							case 't': dest1[c++] = '\t'; break;
							default:  dest1[c++] = ch; break;
						}
					}
					break;
				case '\"':
					done = 1;
					break;
				default:
					if (c < dest1len) {
						dest1[c++] = ch;
					}
					break;
			}
		}
	} else {
		while ((ch = *(p++))) {
			if (ch == ' ' || ch == '\t') {
				break;
			} else if (c < dest1len) {
				dest1[c++] = ch;
			}
		}
	}

	dest1[c] = 0;

	while (*p == ' ' || *p == '\t') p++;
	if (*p == 0) return 0;

	c = 0;
	done = 0;
		
	if (*p == '\"') {
		// quoted string
		p++;
		while (!done && (ch = *(p++))) {
			switch (ch) {
				case '\\':
					ch = *(p++);
					if (ch == 0) {
						done = 1;
					} else if (c < dest2len) {
						switch (ch) {
							case 'n': dest2[c++] = '\n'; break;
							case 'r': dest2[c++] = '\r'; break;
							case 't': dest2[c++] = '\t'; break;
							default:  dest2[c++] = ch; break;
						}
					}
					break;
				case '\"':
					done = 1;
					break;
				default:
					if (c < dest2len) {
						dest2[c++] = ch;
					}
					break;
			}
		}
	} else {
		while ((ch = *(p++))) {
			if (ch == ' ' || ch == '\t') {
				break;
			} else if (c < dest2len) {
				dest2[c++] = ch;
			}
		}
	}

	dest2[c] = 0;

	return 0;
}
예제 #9
0
	static_cast<UINT32>(12.000/DV),static_cast<UINT32>(13.125/DV),static_cast<UINT32>(13.875/DV),static_cast<UINT32>(14.625/DV),
	static_cast<UINT32>(15.000/DV),static_cast<UINT32>(15.750/DV),static_cast<UINT32>(16.125/DV),static_cast<UINT32>(16.500/DV),
	static_cast<UINT32>(16.875/DV),static_cast<UINT32>(17.250/DV),static_cast<UINT32>(17.625/DV),static_cast<UINT32>(18.000/DV),
	/* OCT 7 */
	 static_cast<UINT32>(0.000/DV), static_cast<UINT32>(9.000/DV),static_cast<UINT32>(12.000/DV),static_cast<UINT32>(13.875/DV),
	static_cast<UINT32>(15.000/DV),static_cast<UINT32>(16.125/DV),static_cast<UINT32>(16.875/DV),static_cast<UINT32>(17.625/DV),
	static_cast<UINT32>(18.000/DV),static_cast<UINT32>(18.750/DV),static_cast<UINT32>(19.125/DV),static_cast<UINT32>(19.500/DV),
	static_cast<UINT32>(19.875/DV),static_cast<UINT32>(20.250/DV),static_cast<UINT32>(20.625/DV),static_cast<UINT32>(21.000/DV)
};
#undef DV

/* sustain level table (3db per step) */
/* 0 - 15: 0, 3, 6, 9,12,15,18,21,24,27,30,33,36,39,42,93 (dB)*/
#define SC(db) (db*((3/EG_STEP)*(1<<ENV_BITS)))+EG_DST
static const INT32 SL_TABLE[16]={
 static_cast<INT32>(SC( 0)),static_cast<INT32>(SC( 1)),static_cast<INT32>(SC( 2)),static_cast<INT32>(SC(3 )),static_cast<INT32>(SC(4 )),static_cast<INT32>(SC(5 )),static_cast<INT32>(SC(6 )),static_cast<INT32>(SC( 7)),
 static_cast<INT32>(SC( 8)),static_cast<INT32>(SC( 9)),static_cast<INT32>(SC(10)),static_cast<INT32>(SC(11)),static_cast<INT32>(SC(12)),static_cast<INT32>(SC(13)),static_cast<INT32>(SC(14)),static_cast<INT32>(SC(31))
};
#undef SC

#define TL_MAX (EG_ENT*2) /* limit(tl + ksr + envelope) + sinwave */
/* TotalLevel : 48 24 12  6  3 1.5 0.75 (dB) */
/* TL_TABLE[ 0      to TL_MAX          ] : plus  section */
/* TL_TABLE[ TL_MAX to TL_MAX+TL_MAX-1 ] : minus section */
static INT32 *TL_TABLE;

/* pointers to TL_TABLE with sinwave output offset */
static INT32 **SIN_TABLE;

/* LFO table */
static INT32 *AMS_TABLE;
예제 #10
0
/*Change attribute of uppercases*/
void cAAttribute(int y, int x)
{
    int aChar = board[y][x] - 48;
    if (strcmp(mapName, "menu") == 0)
    {
        switch (aChar)
        {
        case 1:
            attributeMap[y][x] = 2;
            break;
        case 2:
            attributeMap[y][x] = 2;
            break;
        case 3:
            attributeMap[y][x] = 2;
            break;
        case 4:
            attributeMap[y][x] = 2;
            break;
        default:
            attributeMap[y][x] = 1;
            break;
        }
    }
    else if (strcmp(mapName, "sorting") == 0)
    {
        switch (aChar)
        {
        case A:
            attributeMap[y][x] = 2;
            break;
        case C:
            attributeMap[y][x] = 2;
            break;
        default:
            attributeMap[y][x] = 0;
            break;
        }
    }
    else if (strcmp(mapName, "filtering") == 0)
    {
        switch (aChar)
        {
            break;
        case 1:
            attributeMap[y][x] = 2;
            break;
        case 2:
            attributeMap[y][x] = 0;
            break;
        case 3:
            attributeMap[y][x] = 2;
            break;
        case 6:
            attributeMap[y][x] = 0;
            break;
        case 7:
            attributeMap[y][x] = 3;
            break;
        case 8:
            attributeMap[y][x] = 3;
            break;
        case Z:
            attributeMap[y][x] = 0;
            break;
        case X:
            attributeMap[y][x] = 0;
            break;
        case C:
            attributeMap[y][x] = 0;
            break;
        case V:
            attributeMap[y][x] = 0;
            break;
        case B:
            attributeMap[y][x] = 0;
            break;
        case 9:
            attributeMap[y][x] = 0;
            break;
        case O:
            attributeMap[y][x] = 0;
            break;
        default:
            attributeMap[y][x] = 1;
            break;
        }
    }
    else
    {
        perror ("'mapName' out of speck");
        SC(mapName);
        assert(!TRUE);
    }

}
예제 #11
0
/*If you want to change e.g. appearance or attribute of a character automatically when loading the map, change it here*/
void cAAppearance(int y, int x)
{
    int aChar = board[y][x] - 48;
    if (strcmp(mapName, "menu") == 0)
    {
        switch (aChar)
        {
        /*Appearance don't need to be changed*/
        default:
            break;
        }
    }
    else if (strcmp(mapName, "sorting") == 0)
    {
        switch (aChar)
        {
        case A:
            visibleMap[y][x] = '^';
            break;
        case B:
            visibleMap[y][x] = ' ';
            break;
        case C:
            visibleMap[y][x] = 'v';
            break;
        case D:
            visibleMap[y][x] = 'I';
            break;
        case X:
            visibleMap[y][x] = 64-48;
            break;
        /*Appearance don't need to be changed*/
        default:
            break;
        }
    }
    else if (strcmp(mapName, "filtering") == 0)
    {
        switch (aChar)
        {
        case 6:
            visibleMap[y][x] = ' ';
            break;
        case 7:
            visibleMap[y][x] = ' ';
            break;
        case 8:
            visibleMap[y][x] = ' ';
            break;
        case U:
            visibleMap[y][x] = ' ';
            break;
        case I:
            visibleMap[y][x] = ' ';
            break;
        case Z:
            visibleMap[y][x] = '1';
            break;
        case X:
            visibleMap[y][x] = '2';
            break;
        case C:
            visibleMap[y][x] = '3';
            break;
        case V:
            visibleMap[y][x] = '4';
            break;
        case B:
            visibleMap[y][x] = '5';
            break;
        case 1:
            visibleMap[y][x] = '^';
            break;
        case 2:
            visibleMap[y][x] = ' ';
            break;
        case 3:
            visibleMap[y][x] = 'v';
            break;
        case Q:
            visibleMap[y][x] = '-';
            break;
        case W:
            visibleMap[y][x] = '-';
            break;
        case E:
            visibleMap[y][x] = '|';
            break;
        case R:
            visibleMap[y][x] = '|';
            break;
        case T:
            visibleMap[y][x] = '|';
            break;
        case Y:
            visibleMap[y][x] = '|';
            break;
        default:
            break;
        }
    }
    else
    {
        perror ("'mapName' out of speck");
        SC(mapName);
        assert(!TRUE);
    }
}
예제 #12
0
/*What will happen when pressed ENTER while standing on chosen area*/
void pMAction(int aChar)
{
    if (strcmp(mapName, "menu") == 0)
    {
        switch (aChar)
        {
        case 1:
            break;
        case 0:
            useDoor(E, UP);
            useDoor(F, DOWN);
            useDoor(H, LEFT);
            useDoor(G, RIGHT);
            break;
        }
    }
    else if (strcmp(mapName, "sorting") == 0)
    {
        switch (aChar)
        {
        case 1:
            sortData(1, v_order);
            break;
        case 2:
            sortData(2, v_order);
            break;
        case 3:
            sortData(3, v_order);
            break;
        case 4:
            sortData(4, v_order);
            break;
        case 5:
            sortData(5, v_order);
            break;
        case O:
            initializeData();
            break;
        case U:
            v_order = UP;
            break;
        case D:
            v_order = DOWN;
            break;
            /*@*/
        case (64-48):
            switchMap("menu");
            break;
        }
    }
    else if (strcmp(mapName, "filtering") == 0)
    {
        switch (aChar)
        {
        case O:
            loadGlobalActions(mapName);
            activateDatabase(movies_database);
            initializeData();
            cMAppearance(U, 0, 0, ' ');
            cMAppearance(I, 0, 0, ' ');
            break;
        case Z:
            if (action1 == 1 && action2 == FALSE)
                break;
            if (action1 != FALSE)
            {
                passValue(column1, &action2);
                teleport (U);
                openDoor(Q, DOWN);
                if (action2 != FALSE)
                    cMAppearance(U, 0, 0, '*');
            }
            else
            {
                passValue(column1, &action1);
                teleport (I);
                openDoor(W, UP);
                if (action1 != FALSE)
                    cMAppearance(I, 0, 0, '*');
            }
            break;
        case X:
            if (action1 == 2 && action2 == FALSE)
                break;
            if (action1 != FALSE)
            {
                passValue(column2, &action2);
                teleport (U);
                openDoor(Q, DOWN);
                if (action2 != FALSE)
                    cMAppearance(U, 0, 0, '*');
            }
            else
            {
                passValue(column2, &action1);
                teleport (I);
                openDoor(W, UP);
                if (action1 != FALSE)
                    cMAppearance(I, 0, 0, '*');
            }
            break;
        case C:
            if (action1 == 3 && action2 == FALSE)
                break;
            if (action1 != FALSE)
            {
                passValue(column3, &action2);
                teleport (U);
                openDoor(Q, DOWN);
                if (action2 != FALSE)
                    cMAppearance(U, 0, 0, '*');
            }
            else
            {
                passValue(column3, &action1);
                teleport (I);
                openDoor(W, UP);
                if (action1 != FALSE)
                    cMAppearance(I, 0, 0, '*');
            }
            break;
        case V:
            if (action1 == 4 && action2 == FALSE)
                break;
            if (action1 == TRUE)
            {
                passValue(column4, &action2);
                teleport (U);
                openDoor(Q, DOWN);
                if (action2 != FALSE)
                    cMAppearance(U, 0, 0, '*');
            }
            else
            {
                passValue(column4, &action1);
                teleport (I);
                openDoor(W, UP);
                if (action1 != FALSE)
                    cMAppearance(I, 0, 0, '*');
            }
            break;
        case B:
            if (action1 == 5 && action2 == FALSE)
                break;
            if (action1 != FALSE)
            {
                passValue(column5, &action2);
                teleport (U);
                openDoor(Q, DOWN);
                if (action2 != FALSE)
                    cMAppearance(U, 0, 0, '*');
            }
            else
            {
                passValue(column5, &action1);
                teleport (I);
                openDoor(W, UP);
                if (action1 != FALSE)
                    cMAppearance(I, 0, 0, '*');
            }
            break;
        case 6:
            useDoor(E, RIGHT);
            break;
        case 9:
            switch (action1)
            {
            case 1:
                switch (action2)
                {
                case 2:
                    filterData(action1, v_column1, action2, v_column2);
                    break;
                case 3:
                    filterData(action1, v_column1, action2, v_column3);
                    break;
                case 4:
                    filterData(action1, v_column1, action2, v_column4);
                    break;
                case 5:
                    filterData(action1, v_column1, action2, v_column5);
                    break;
                }
                break;
            case 2:
                switch (action2)
                {
                case 1:
                    filterData(action1, v_column2, action2, v_column1);
                    break;
                case 3:
                    filterData(action1, v_column2, action2, v_column3);
                    break;
                case 4:
                    filterData(action1, v_column2, action2, v_column4);
                    break;
                case 5:
                    filterData(action1, v_column2, action2, v_column5);
                    break;
                }
                break;
            case 3:
                switch (action2)
                {
                case 1:
                    filterData(action1, v_column3, action2, v_column1);
                    break;
                case 2:
                    filterData(action1, v_column3, action2, v_column2);
                    break;
                case 4:
                    filterData(action1, v_column3, action2, v_column4);
                    break;
                case 5:
                    filterData(action1, v_column3, action2, v_column5);
                    break;
                }
                break;
            case 4:
                switch (action2)
                {
                case 1:
                    filterData(action1, v_column4, action2, v_column1);
                    break;
                case 2:
                    filterData(action1, v_column4, action2, v_column2);
                    break;
                case 3:
                    filterData(action1, v_column4, action2, v_column3);
                    break;
                case 5:
                    filterData(action1, v_column4, action2, v_column5);
                    break;
                }
                break;
            case 5:
                switch (action2)
                {
                case 1:
                    filterData(action1, v_column5, action2, v_column1);
                    break;
                case 2:
                    filterData(action1, v_column5, action2, v_column2);
                    break;
                case 3:
                    filterData(action1, v_column5, action2, v_column3);
                    break;
                case 4:
                    filterData(action1, v_column5, action2, v_column4);
                    break;
                }
                break;
            }
            break;
            /*@*/
        case (64-48):
            switchMap("menu");
            break;
        }
    }
    else
    {
        perror ("'mapName' out of speck");
        SC(mapName);
        assert(!TRUE);
    }
    mapConditions();
}
예제 #13
0
/*Define here what the action characters on the map will do when entered on their area*/
void pAAction(int aChar)
{
    if (strcmp(mapName, "menu") == 0)
    {
        switch (aChar)
        {
        case 1:
            initializeSort();
            switchMap("filtering");
            break;
        case 2:
            initializeSort();
            switchMap("sorting");
            break;
        case 3:
            teleport(aChar);
            break;
        case 4:
            closeProg();
            break;
        }
    }
    else if (strcmp(mapName, "sorting") == 0)
    {
        switch (aChar)
        {
        case A:
            teleport(B);
            scrollData(UP);
            break;
        case C:
            teleport(B);
            scrollData(DOWN);
            break;
        }
    }
    else if (strcmp(mapName, "filtering") == 0)
    {
        switch (aChar)
        {
        case 1:
            teleport(2);
            scrollData(UP);
            break;
        case 3:
            teleport(2);
            scrollData(DOWN);
            break;
        case 7:
            closeDoor(Q, DOWN);
            break;
        case 8:
            closeDoor(W, UP);
            break;
        }
    }
    else
    {
        perror ("'mapName' out of speck");
        SC(mapName);
        assert(!TRUE);
    }
}
예제 #14
0
void SongDatabase::GetSongInformation7K(int ID, VSRG::Song* Out)
{
    int ret;
    SC(sqlite3_bind_int(st_GetSongInfo, 1, ID));
    ret = sqlite3_step(st_GetSongInfo);

    if (ret != SQLITE_ROW)
    {
        Log::Printf("SongDatabase::GetSongInformation7K: Chart %d does not exist.\n", ID);
        return;
    }

    // Main metadata is up in this query.

    Out->SongName = (char*)sqlite3_column_text(st_GetSongInfo, 0);
    Out->SongAuthor = (char*)sqlite3_column_text(st_GetSongInfo, 1);
    Out->SongFilename = _T(sqlite3_column_text(st_GetSongInfo, 2));
    Out->Subtitle = (char*)sqlite3_column_text(st_GetSongInfo, 3);
    Out->BackgroundFilename = _T(sqlite3_column_text(st_GetSongInfo, 4));
    Out->ID = ID;
    int mode = sqlite3_column_int(st_GetSongInfo, 5);
    Out->PreviewTime = sqlite3_column_double(st_GetSongInfo, 6);

    SC(sqlite3_reset(st_GetSongInfo));

    if (mode != MODE_VSRG)
        return; // Sowwy.

    // Now, difficulty information.
    SC(sqlite3_bind_int(st_GetDiffInfo, 1, ID));
    while (sqlite3_step(st_GetDiffInfo) != SQLITE_DONE)
    {
        std::shared_ptr<VSRG::Difficulty> Diff(new VSRG::Difficulty);

        // diffid associated data
        Diff->ID = sqlite3_column_int(st_GetDiffInfo, 0);
        Diff->Name = (char*)sqlite3_column_text(st_GetDiffInfo, 1);
        Diff->TotalObjects = sqlite3_column_int(st_GetDiffInfo, 2);
        Diff->TotalScoringObjects = sqlite3_column_int(st_GetDiffInfo, 3);
        Diff->TotalHolds = sqlite3_column_int(st_GetDiffInfo, 4);
        Diff->TotalNotes = sqlite3_column_int(st_GetDiffInfo, 5);
        Diff->Duration = sqlite3_column_double(st_GetDiffInfo, 6);
        Diff->IsVirtual = (sqlite3_column_int(st_GetDiffInfo, 7) == 1);
        Diff->Channels = sqlite3_column_int(st_GetDiffInfo, 8);

        int colInt = sqlite3_column_int(st_GetDiffInfo, 10);
        Diff->BPMType = (VSRG::Difficulty::ETimingType)colInt;

        // We don't include author information to force querying it from the database.
        // Diff->Author
        Diff->Level = sqlite3_column_int(st_GetDiffInfo, 11);

        // File ID associated data
        int FileID = sqlite3_column_int(st_GetDiffInfo, 9);

        SC(sqlite3_bind_int(st_GetFileInfo, 1, FileID));
        sqlite3_step(st_GetFileInfo);

		// This copy is dangerous, so we should reset the info _before_ we try to copy.
		std::string s = (char*)sqlite3_column_text(st_GetFileInfo, 0);
		
		// There's a case where a string could cause operator= to throw
		// if it tries encoding from u8 into the internal ::path representation and it fails!
		try {
#ifdef _WIN32
			Diff->Filename = Utility::Widen(s);
#else
			Diff->Filename = s;
#endif
		}
		catch (std::exception &e) {
			// We failed copying this thing - clean up and rethrow.
			SC(sqlite3_reset(st_GetFileInfo));
			SC(sqlite3_reset(st_GetDiffInfo));
			throw e;
		}

		SC(sqlite3_reset(st_GetFileInfo));
        Out->Difficulties.push_back(Diff);
    }

    SC(sqlite3_reset(st_GetDiffInfo));
}
예제 #15
0
SongDatabase::SongDatabase(GString Database)
{
	int ret = sqlite3_open_v2(Database.c_str(), &db, SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);

	if (ret != SQLITE_OK)
		Log::Printf("Unable to open song database file.");
	else
	{
		char* err; // Do the "create tables" query.
		const char* tail;
		SC(sqlite3_exec(db, DatabaseQuery, NULL, NULL, &err));

		// And not just that, also the statements.
		SC(sqlite3_prepare_v2(db, InsertSongQuery, strlen(InsertSongQuery), &st_SngInsertQuery, &tail));
		SC(sqlite3_prepare_v2(db, InsertDifficultyQuery, strlen(InsertDifficultyQuery), &st_DiffInsertQuery, &tail));
		SC(sqlite3_prepare_v2(db, GetFilenameIDQuery, strlen(GetFilenameIDQuery), &st_FilenameQuery, &tail));
		SC(sqlite3_prepare_v2(db, InsertFilenameQuery, strlen(InsertFilenameQuery), &st_FilenameInsertQuery, &tail));
		SC(sqlite3_prepare_v2(db, GetLMTQuery, strlen(GetLMTQuery), &st_LMTQuery, &tail));
		SC(sqlite3_prepare_v2(db, GetSongInfo, strlen(GetSongInfo), &st_GetSongInfo, &tail));
		SC(sqlite3_prepare_v2(db, GetDiffInfo, strlen(GetDiffInfo), &st_GetDiffInfo, &tail));
		SC(sqlite3_prepare_v2(db, GetFileInfo, strlen(GetFileInfo), &st_GetFileInfo, &tail));
		SC(sqlite3_prepare_v2(db, UpdateLMT, strlen(UpdateLMT), &st_UpdateLMT, &tail));
		SC(sqlite3_prepare_v2(db, GetDiffIDFileID, strlen(GetDiffIDFileID), &st_GetDiffIDFile, &tail));
		SC(sqlite3_prepare_v2(db, UpdateDiff, strlen(UpdateDiff), &st_DiffUpdateQuery, &tail));
		SC(sqlite3_prepare_v2(db, GetDiffFilename, strlen(GetDiffFilename), &st_GetDiffFilename, &tail));
		SC(sqlite3_prepare_v2(db, GetSongIDFromFilename, strlen(GetSongIDFromFilename), &st_GetSIDFromFilename, &tail));
		SC(sqlite3_prepare_v2(db, GetLatestSongID, strlen(GetLatestSongID), &st_GetLastSongID, &tail));
		SC(sqlite3_prepare_v2(db, GetAuthorOfDifficulty, strlen(GetAuthorOfDifficulty), &st_GetDiffAuthor, &tail));
		SC(sqlite3_prepare_v2(db, GetPreviewOfSong, strlen(GetPreviewOfSong), &st_GetPreviewInfo, &tail));
		SC(sqlite3_prepare_v2(db, sGetStageFile, strlen(sGetStageFile), &st_GetStageFile, &tail));
	}
}
예제 #16
0
/* Return a pointer to a string which is the printed representation
   of CHARACTER if it were printed at HPOS. */
char *
printed_representation (const char *character, size_t len, size_t hpos,
			/* Return: */
			size_t *plen)
{
  const unsigned char *cp = (const unsigned char *) character;
  register int i = 0;
  int printable_limit = ISO_Latin_p ? 255 : 127;
#define REPSPACE(s)                                            \
  do                                                           \
    {                                                          \
      while (the_rep_size < s) 			               \
	{						       \
	  if (the_rep_size == 0)			       \
	    the_rep_size = 8; /* Initial allocation */	       \
	  the_rep = x2realloc (the_rep, &the_rep_size);	       \
	}						       \
    }                                                          \
  while (0)
    
#define SC(c)                                                  \
  do                                                           \
    {                                                          \
      REPSPACE(i + 1);                                         \
      the_rep[i++] = c;                                        \
    }                                                          \
  while (0)
  
  for (; len > 0; cp++, len--)
    {
      if (raw_escapes_p && *cp == '\033')
	SC(*cp);
      /* Show CTRL-x as ^X.  */
      else if (iscntrl (*cp) && *cp < 127)
	{
	  switch (*cp)
	    {
	    case '\r':
	    case '\n':
	      SC(*cp);
	      break;

	    case '\t':
	      {
		int tw;

		tw = ((hpos + 8) & 0xf8) - hpos;
		while (i < tw)
		  SC(' ');
		break;
	      }
	      
	    default:
	      SC('^');
	      SC(*cp | 0x40);
	    }
	}
      /* Show META-x as 0370.  */
      else if (*cp > printable_limit)
	{
	  REPSPACE (i + 5);
	  sprintf (the_rep + i, "\\%0o", *cp);
	  i = strlen (the_rep);
	}
      else if (*cp == DEL)
	{
	  SC('^');
	  SC('?');
	}
      else
	SC(*cp);
    }
  
  SC(0);
  *plen = i - 1;
  return the_rep;
}
int parse_interface_name(char *name, int interfaces[], int max_interface_cnt)
{

	token_list_t *list;
	list = init_token_list(30, 128);

	get_interface_name_token_list(list, name);
	//show_token_list(list);
	if (list->token_index < 3 ) {
		cvmx_dprintf("invalid interface name :%s token_cnt=%d \n",
			     name, list->token_index);
		show_token_list(list);
		return -1;
	}

	/* Looking for something like type:n */
	if ( (list->token_index == 3 ) && (SC(TK[1],":") == 0) ) {
		int interface_num = ST(TK[2], 0, 10);
		int type_index = cvmx_get_interface_type_index(TK[0]);

		//cvmx_dprintf("type_index=%d num=%d \n", type_index, interface_num);
		if (type_index < 0) {
			cvmx_dprintf("invalid interface type:%s\n", TK[0]);
			return -1;
		}

		if (interface_num >= cvmx_interface_types[type_index].max_cnt ) {
			cvmx_dprintf("invalid interface index=%d for type=%s\n",
				     interface_num, TK[0]);
			return -1;
		}
		interfaces[0] = cvmx_get_interface_number(type_index, interface_num);
		//cvmx_dprintf("interface=%d \n", interfaces[0]);
		return 1;
	}
	/* Looking for something like type:[n..n] */
	if ( (list->token_index == 8 ) && (SC(TK[2],"[") == 0)  &&
	     (SC(TK[4],".") == 0) && (SC(TK[5],".") == 0) &&
	     (SC(TK[7],"]") == 0) ) {
		int intf_start = ST(TK[3], 0, 10);
		int intf_end   = ST(TK[6], 0, 10);
		int type_index = cvmx_get_interface_type_index(TK[0]);
		int i,j;

		if (type_index < 0) {
			cvmx_dprintf("invalid interface type:%s\n", TK[0]);
			return -1;
		}
		if ((intf_end <= intf_start) || (intf_start < 0) ||
		    intf_end >= cvmx_interface_types[type_index].max_cnt) {
			cvmx_dprintf("invalid interface range %d..%d max=%d\n",
				     intf_start, intf_start,
				     cvmx_interface_types[type_index].max_cnt);
			return -1;
		}
		j=0;
		for(i=intf_start; i<=intf_end; i++) {
			int inum = cvmx_get_interface_number(type_index, i);
			if (inum != -1)
				interfaces[j++] = inum;
		}
		return j;
	}
	//cvmx_dprintf("%s:%d Here... %s %s \n", __FUNCTION__, __LINE__,
	//	     TK[2], TK[list->token_index -1]);
	/* Looking for something like type:[n,*,n] * is repetitions of ,n*/
	if ( (SC(TK[2],"[") == 0) && (SC(TK[list->token_index-1], "]") == 0) ) {
		int type_index = cvmx_get_interface_type_index(TK[0]);
		int i,j;

		//cvmx_dprintf("%s:%d Here..\n", __FUNCTION__, __LINE__);
		if (type_index < 0) {
			cvmx_dprintf("invalid interface type:%s\n", TK[0]);
			return -1;
		}
		for(i=4; i < (list->token_index-1); i+=2) {
			if (SC(TK[i],",") != 0) {
				cvmx_dprintf("invalid seperator i=%d\n",i);
				return -1;
			}
		}
		j = 0;
		for(i=3; i < (list->token_index-1); i++) {
			int num = ST(TK[i], 0, 10);
			int inum;

			if (num >  cvmx_interface_types[type_index].max_cnt) {
				cvmx_dprintf("invalid index %d for type=%s\n", num,
					     cvmx_interface_types[type_index].name);
			}
			inum = cvmx_get_interface_number(type_index, i);
			if (inum != -1)
				interfaces[j++] = inum;
			if (j >= max_interface_cnt) {
				cvmx_dprintf("too many interface numbers=%d\n", j);
				return -1;
			}
		}
		return j;
	}
	return -1;

}
예제 #18
0

/* SVR4 (aka the full official iBCS) is the base mapping - no exceptions,
 * other than the RESTART* values.
 */
struct map_segment svr4_err_map[] = {
        { 0,    0+sizeof(SVR4_err_table)-1,     SVR4_err_table },
        { 512,  512+sizeof(LNX_err_table)-1,    LNX_err_table },
        { -1 }
};

EXPORT_SYMBOL(svr4_err_map);

ABI_func svr4_generic_funcs[] = {
   { abi_syscall,	Fast	ITR(0, "syscall",	"")	}, /*    0 */
   { SC(exit),		-1	ITR(0, "exit",		"d")	}, /*    1 */
   { abi_fork,		Spl	ITR(0, "fork",		"")	}, /*    2 */
   { abi_read,		3	ITR(0, "read",		"dpd")	}, /*    3 */
   { SC(write),		-3	ITR(0, "write",		"dpd")	}, /*    4 */
   { svr4_open,		3	ITR(0, "open",		"soo")	}, /*    5 */
   { SC(close),		-1	ITR(0, "close",		"d")	}, /*    6 */
   { abi_wait,		Spl	ITR(0, "wait",		"xxx")	}, /*    7 */
   { SC(creat),		-2	ITR(0, "creat",		"so")	}, /*    8 */
   { SC(link),		-2	ITR(0, "link",		"ss")	}, /*    9 */
   { SC(unlink),	-1	ITR(0, "unlink",	"s")	}, /*   10 */
   { abi_exec,		Spl	ITR(0, "exec",		"sxx")	}, /*   11 */
   { SC(chdir),		-1	ITR(0, "chdir",		"s")	}, /*   12 */
   { abi_time,		0	ITR(0, "time",		"")	}, /*   13 */
   { abi_mknod,	3	ITR(0, "mknod",		"soo")	}, /*   14 */
   { SC(chmod),		-2	ITR(0, "chmod",		"so")	}, /*   15 */
   { SC(chown),		-3	ITR(0, "chown",		"sdd")	}, /*   16 */
int parse_ipd_config_command(token_list_t *list, cvmx_ipd_config_t* ipd_config)
{
	int token_index;

	if(dbg_parse)
		cvmx_dprintf("parsing ipd_config\n");
	if (list->token_index < 4) {
		cvmx_dprintf("ERROR: Invalid index=%d IPD config command\n", list->token_index);
		return -1;
	}
	if((SC(TK[1], "packet_pool") == 0) && (list->token_index == 5))
		return (parse_fpa_config_command(list, &ipd_config->packet_pool, "packet pool"));
	else if((SC(TK[1], "wqe_pool")) == 0 && (list->token_index == 5))
		return (parse_fpa_config_command(list, &ipd_config->wqe_pool, "wqe pool"));
	else if((SC(TK[1], "first_mbuf_skip") == 0) && (SC(TK[2], "=") == 0))
		ipd_config->first_mbuf_skip = ST(TK[3], (char**)NULL, 10);
	else if((SC(TK[1], "not_first_mbuf_skip") == 0) && (SC(TK[2], "=") == 0))
		ipd_config->not_first_mbuf_skip = ST(TK[3], (char**)NULL, 10);
	else if((SC(TK[1], "cache_mode") == 0) && (SC(TK[2], "=") == 0))
		ipd_config->cache_mode = ST(TK[3], (char**)NULL, 10);
	else if((SC(TK[1], "enable_ipd_in_helper_init") == 0) && (SC(TK[2], "=") == 0))
		ipd_config->ipd_enable = ST(TK[3], (char**)NULL, 10);
	else if((SC(TK[1], "enable_len_M8_fix") == 0) && (SC(TK[2], "=") == 0))
		ipd_config->enable_len_M8_fix = ST(TK[3], (char**)NULL, 10);
	else if( list->token_index == 10) {
		if((SC(TK[7], "parse_mode") == 0) && (SC(TK[8], "=") == 0)) {
			if(SC(TK[9], "skip_L2") == 0)
				ipd_config->port_config.parse_mode = CVMX_PIP_PORT_CFG_MODE_SKIPL2;
			else if(SC(TK[9], "skip_IP") == 0)
				ipd_config->port_config.parse_mode = CVMX_PIP_PORT_CFG_MODE_SKIPIP;
			else
				ipd_config->port_config.parse_mode = CVMX_PIP_PORT_CFG_MODE_NONE;
		}
		else if((SC(TK[7], "tag_type") == 0) && (SC(TK[8], "=") == 0)) {
			if(SC(TK[9], "ordered") == 0)
				ipd_config->port_config.tag_type = CVMX_POW_TAG_TYPE_ORDERED;
			else if(SC(TK[9], "atomic") == 0)
				ipd_config->port_config.tag_type = CVMX_POW_TAG_TYPE_ATOMIC;
			else if(SC(TK[9], "null") == 0)
				ipd_config->port_config.tag_type = CVMX_POW_TAG_TYPE_NULL;
			else if(SC(TK[9], "null_null") == 0)
				ipd_config->port_config.tag_type = CVMX_POW_TAG_TYPE_NULL_NULL;
			else {
				cvmx_dprintf("ERROR: Invalid tag_type %s in ipd config\n",TK[9]);
				return -1;
			}

		}
		else if((SC(TK[7], "tag_mode") == 0) && (SC(TK[8], "=") == 0)) {
			if(SC(TK[9], "tuple_tag") == 0)
				ipd_config->port_config.tag_mode = CVMX_PIP_TAG_MODE_TUPLE;
			else if(SC(TK[9], "mask_tag") == 0)
				ipd_config->port_config.tag_mode = CVMX_PIP_TAG_MODE_MASK;
			else if(SC(TK[9], "ip_or_mask_tag") == 0)
				ipd_config->port_config.tag_mode = CVMX_PIP_TAG_MODE_IP_OR_MASK;
			else if(SC(TK[9], "tuple_xor_mask_tag") == 0)
				ipd_config->port_config.tag_mode = CVMX_PIP_TAG_MODE_TUPLE_XOR_MASK;
			else {
				cvmx_dprintf("ERROR: Invalid tag_mode %s in ipd config\n",TK[9]);
				return -1;
			}
		}
		else {
			cvmx_dprintf("ERROR: Invalid IPD config %s\n",TK[7] );
			return -1;
		}
	}
	else if((SC(TK[7], "include_in_tag_tuple") == 0) && list->token_index >= 8 ) {
		token_index = 8;
		while (token_index < list->token_index) {
			//cvmx_dprintf("\ntag tuple include %s",list->tokens[token_index]);
			if(SC(TK[token_index], "ipv6_src_ip") == 0)
				ipd_config->port_config.tag_fields.ipv6_src_ip = 1;
			else if(SC(TK[token_index], "ipv6_dst_ip") == 0)
				ipd_config->port_config.tag_fields.ipv6_dst_ip = 1;
			else if(SC(TK[token_index], "ipv6_src_port") == 0)
				ipd_config->port_config.tag_fields.ipv6_src_port = 1;
			else if(SC(TK[token_index], "ipv6_dst_port") == 0)
				ipd_config->port_config.tag_fields.ipv6_dst_port = 1;
			else if(SC(TK[token_index], "ipv6_next_header") == 0)
				ipd_config->port_config.tag_fields.ipv6_next_header = 1;
			else if(SC(TK[token_index], "ipv4_src_ip") == 0)
				ipd_config->port_config.tag_fields.ipv4_src_ip = 1;
			else if(SC(TK[token_index], "ipv4_dst_ip") == 0)
				ipd_config->port_config.tag_fields.ipv4_dst_ip = 1;
			else if(SC(TK[token_index], "ipv4_src_port") == 0)
				ipd_config->port_config.tag_fields.ipv4_src_port = 1;
			else if(SC(TK[token_index], "ipv4_dst_port") == 0)
				ipd_config->port_config.tag_fields.ipv4_dst_port = 1;
			else if(SC(TK[token_index], "ipv4_protocol") == 0)
				ipd_config->port_config.tag_fields.ipv4_protocol = 1;
			else if (SC(TK[token_index], "input_port") == 0)
				ipd_config->port_config.tag_fields.input_port = 1;
			else {
				cvmx_dprintf("ERROR: Invalid tag_tuple_include config %s\n",
					     TK[token_index]);
				return -1;
			}
			token_index += 1;
		}
	}
	else {
		cvmx_dprintf("ERROR: Invalid IPD config command\n");
		return -1;
	}
	return 0;
}
예제 #20
0
파일: symify.c 프로젝트: amagnasco/rhide
int
main(int argc, char *argv[])
{
  char *function, *file;
  int lineno;
#ifdef __DJGPP__
  int r, c;
  short *sc;
  char buf[1024];
  int i;
#endif
  int diff = 0;
  unsigned v;
  FILE *ofile = 0;
  FILE *ifile = 0;

  if (argc < 2)
  {
    fprintf(stderr,
            "Usage: gsymify [-o <outfile>] [-i <tracefile>] [-a <adjust>] <program>\n");
    fprintf(stderr,
            "This program adds debug information to DJGPP program call frame tracebacks\n");
    return 1;
  }
  while (argv[1][0] == '-')
  {
    if ((strcmp(argv[1], "-a") == 0) && (argc > 3))
    {
      diff = atoi(argv[2]);
      argc -= 2;
      argv += 2;
    }
    if ((strcmp(argv[1], "-o") == 0) && (argc > 3))
    {
      ofile = fopen(argv[2], "w");
      if (ofile == 0)
        fprintf(stderr, "Error: unable to open file %s\n", argv[2]);
      argc -= 2;
      argv += 2;
    }
    if ((strcmp(argv[1], "-i") == 0) && (argc > 3))
    {
      ifile = fopen(argv[2], "r");
      if (ifile == 0)
        fprintf(stderr, "Error: unable to open file %s\n", argv[2]);
      argc -= 2;
      argv += 2;
    }
  }
  progname = argv[1];
  _GetProgName = GetProgName;
  InitRHGDB();

  if (!isatty(0) && !ifile)
    ifile = stdin;

  if (!isatty(1) && !ofile)
    ofile = stdout;

  if (ifile)
  {
    char line[1000];

    if (ofile == 0)
      ofile = stdout;
    while (fgets(line, 1000, ifile))
    {
      if (strncmp(line, "  0x", 4) == 0)
      {
        sscanf(line + 4, "%x", &v);
        symify(line + 4, &function, &file, &lineno, diff);
        fprintf(ofile, "  0x%08x", v);
        if (function)
        {
          fprintf(ofile, " %s", function);
          free(function);
          if (file)
          {
            fprintf(ofile, ", line %d of %s", lineno, file);
            free(file);
          }
        }
        fprintf(ofile, "\n");
      }
      else
        fputs(line, ofile);
    }
    fclose(ifile);
    fclose(ofile);
    return 0;
  }
#ifdef __DJGPP__
  sc = (short *) malloc(ScreenRows() * ScreenCols() * 2);

  ScreenRetrieve(sc);

  for (r = 0; r < ScreenRows(); r++)
  {
    if (SC(r, 0) == ' ' && SC(r, 1) == ' ' && SC(r, 2) == '0'
        && SC(r, 3) == 'x')
    {
      buf[8] = 0;
      for (i = 0; i < 8; i++)
        buf[i] = SC(r, i + 4);
      sscanf(buf, "%x", &v);
      symify(buf, &function, &file, &lineno, diff);

      buf[0] = 0;
      if (function)
      {
        strcpy(buf, function);
        free(function);
      }
      if (file)
      {
        if (buf[0])
          strcat(buf, ", ");
        sprintf(buf + strlen(buf), "line %d of %s", lineno, file);
        free(file);
      }
      if (buf[0])
        for (i = 0; buf[i]; i++)
          SW(r, 15 + i) = 0x0f00 + buf[i];
    }
  }

  if (ofile)
  {
    for (r = 0; r < ScreenRows(); r++)
    {
      c = 0;
      for (i = 0; i < ScreenCols(); i++)
        if (SC(r, i) != ' ')
          c = i;
      for (i = 0; i <= c; i++)
        fputc(SC(r, i), ofile);
      fputc('\n', ofile);
    }
    fclose(ofile);
  }
  else
    ScreenUpdate(sc);
#endif
  return 0;
}
int cvmx_parse_config()
{
	token_list_t *list;
	int start_index=0;
        int rv;
	cvmx_ipd_config_t ipd_config;
	cvmx_dma_config_t dma_config;
	cvmx_tim_config_t timer_config;
	cvmx_dfa_app_config_t dfa_config;
	cvmx_zip_config_t zip_config;
	cvmx_raid_config_t raid_config;
	cvmx_bch_app_config_t bch_config;

	if (cvmx_app_config_str == 0)
		cvmx_dprintf("ERROR: application config string is not set\n");
	if(dbg_parse)
		cvmx_dprintf("Parsing config string.\n");

	list = init_token_list(30, 128);
	cvmx_ipd_get_config(&ipd_config);
	cvmx_dma_get_cmd_que_pool_config(&dma_config.command_queue_pool);
	cvmx_pko_get_cmd_que_pool_config(&pko_fpa_cfg);
	cvmx_tim_get_fpa_pool_config(&timer_config.timer_pool);
	cvmx_dfa_get_fpa_pool_config(&dfa_config.dfa_pool);
	cvmx_zip_get_fpa_pool_config(&zip_config.zip_pool);
	cvmx_raid_get_cmd_que_pool_config(&raid_config.command_queue_pool);
	cvmx_bch_get_cmd_que_pool_config(&bch_config.command_queue_pool);

	while (1) {
		/* Parsing the config string line by line, each call to get_token_list()
		   returns the tokens on the next line */
		start_index = get_token_list(list, cvmx_app_config_str, start_index);
		//show_token_list(list);
		if (list->token_index >= 1) {
			if (SC(TK[0],"pko") == 0)  {
				rv = parse_pko_config_command(list);
				if (rv != 0) {
					cvmx_dprintf("ERROR: in parsing pko commands\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"ipd") == 0) {
				if((rv = parse_ipd_config_command(list, &ipd_config))) {
					cvmx_dprintf("ERROR: in parsing IPD command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"rgmii") == 0) {
				if((rv = parse_rgmii_config_command(list))) {
					cvmx_dprintf("ERROR: in parsing rgmii command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"dma") == 0) {
				if((rv = parse_dma_config_command(list, &dma_config ))) {
					cvmx_dprintf("ERROR: in parsing dma command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"timer") == 0) {
				if((rv = parse_timer_config_command(list, &timer_config ))) {
					cvmx_dprintf("ERROR: in parsing timer command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"dfa") == 0) {
				if((rv = parse_dfa_config_command(list, &dfa_config ))) {
					cvmx_dprintf("ERROR: in parsing dfa command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"zip") == 0) {
				if((rv = parse_zip_config_command(list, &zip_config ))) {
					cvmx_dprintf("ERROR: in parsing zip command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0], "bch") == 0) {
				if ((rv = parse_bch_config_command(list, &bch_config))) {
					cvmx_dprintf("ERROR: in parsing bch command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"raid") == 0) {
				if((rv = parse_raid_config_command(list, &raid_config ))) {
					cvmx_dprintf("ERROR: in parsing raid command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"llm") == 0) {
				if((rv = parse_llm_config_command(list))) {
					cvmx_dprintf("ERROR: in parsing llm command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"spi") == 0) {
				if((rv = parse_spi_config_command(list))) {
					cvmx_dprintf("ERROR: in parsing spi command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"ilk") == 0) {
				if((rv = parse_ilk_config_command(list))) {
					cvmx_dprintf("ERROR: in parsing ilk command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"npi") == 0) {
				if((rv = parse_npi_config_command(list))) {
					cvmx_dprintf("ERROR: in parsing npi command\n");
					show_token_list(list);
				}
			}
			else if (SC(TK[0],"pki") == 0) {
				if(OCTEON_IS_MODEL(OCTEON_CN78XX)) {
					if((rv = parse_pki_config_command(list))) {
						cvmx_dprintf("ERROR: in parsing pki command\n");
						show_token_list(list);
					}
				}
			}
		}
		if (cvmx_app_config_str[start_index] == '\0') {
			cvmx_ipd_set_config(ipd_config);
			cvmx_pko_set_cmd_que_pool_config(pko_fpa_cfg.pool_num,
					pko_fpa_cfg.buffer_size, pko_fpa_cfg.buffer_count);
			cvmx_zip_set_fpa_pool_config(zip_config.zip_pool.pool_num,
					zip_config.zip_pool.buffer_size, zip_config.zip_pool.buffer_count);
			cvmx_tim_set_fpa_pool_config(timer_config.timer_pool.pool_num,
					timer_config.timer_pool.buffer_size, timer_config.timer_pool.buffer_count);
			cvmx_dfa_set_fpa_pool_config(dfa_config.dfa_pool.pool_num,
					dfa_config.dfa_pool.buffer_size, dfa_config.dfa_pool.buffer_count);
			cvmx_dma_set_cmd_que_pool_config(dma_config.command_queue_pool.pool_num,
					dma_config.command_queue_pool.buffer_size, dma_config.command_queue_pool.buffer_count);
			cvmx_raid_set_cmd_que_pool_config(raid_config.command_queue_pool.pool_num,
					raid_config.command_queue_pool.buffer_size, raid_config.command_queue_pool.buffer_count);
			cvmx_bch_set_cmd_que_pool_config(bch_config.command_queue_pool.pool_num,
					bch_config.command_queue_pool.buffer_size,
					bch_config.command_queue_pool.buffer_count);
			break;
		}
		start_index++;
		reset_token_index(list);
	}
	return 0;
}
예제 #22
0
#define SC( weight )	( 1024 / weight )	/* Scale factor */
#define SC_0			16384	/* SC( SC_0 ) evalutes to 0 */

static struct RI {
    const char *path;		/* Path to check for existence of source */
    const char *arg;		/* Args for source */
    const int usefulness;	/* Usefulness of source */
    FILE *pipe; 		/* Pipe to source as FILE * */
    int pipeFD; 		/* Pipe to source as FD */
    pid_t pid;			/* pid of child for waitpid() */
    int length; 		/* Quantity of output produced */
    const int hasAlternative;	    /* Whether source has alt.location */
} dataSources[] = {

    {	"/bin/vmstat", "-s", SC(-3), NULL, 0, 0, 0, 1    },
    {	"/usr/bin/vmstat", "-s", SC(-3), NULL, 0, 0, 0, 0},
    {	"/bin/vmstat", "-c", SC(-3), NULL, 0, 0, 0, 1     },
    {	"/usr/bin/vmstat", "-c", SC(-3), NULL, 0, 0, 0, 0},
    {	"/usr/bin/pfstat", NULL, SC(-2), NULL, 0, 0, 0, 0},
    {	"/bin/vmstat", "-i", SC(-2), NULL, 0, 0, 0, 1     },
    {	"/usr/bin/vmstat", "-i", SC(-2), NULL, 0, 0, 0, 0},
    {	"/usr/ucb/netstat", "-s", SC(2), NULL, 0, 0, 0, 1 },
    {	"/usr/bin/netstat", "-s", SC(2), NULL, 0, 0, 0, 1 },
    {	"/usr/sbin/netstat", "-s", SC(2), NULL, 0, 0, 0, 1},
    {	"/usr/etc/netstat", "-s", SC(2), NULL, 0, 0, 0, 0},
    {	"/usr/bin/nfsstat", NULL, SC(2), NULL, 0, 0, 0, 0},
    {	"/usr/ucb/netstat", "-m", SC(-1), NULL, 0, 0, 0, 1  },
    {	"/usr/bin/netstat", "-m", SC(-1), NULL, 0, 0, 0, 1  },
    {	"/usr/sbin/netstat", "-m", SC(-1), NULL, 0, 0, 0, 1 },
    {	"/usr/etc/netstat", "-m", SC(-1), NULL, 0, 0, 0, 0 },
예제 #23
0
bool QPCSCReader::beginTransaction()
{
	return d->isTransacted = SC(BeginTransaction, d->card) == SCARD_S_SUCCESS;
}
예제 #24
0
// Inserts a filename, if it already exists, updates it.
// Returns the ID of the filename.
int SongDatabase::InsertFilename(Directory Fn)
{
	int ret;
	int idOut;
	int lmt;
	SC(sqlite3_bind_text(st_FilenameQuery, 1, Fn.c_path(), Fn.path().length(), SQLITE_STATIC));

	if (sqlite3_step(st_FilenameQuery) == SQLITE_ROW)
	{
		idOut = sqlite3_column_int(st_FilenameQuery, 0);
		lmt = sqlite3_column_int(st_FilenameQuery, 1);

		int lastLmt = Utility::GetLMT(Fn.path());

		// Update the last-modified-time of this file, and its hash if it has changed.
		if (lmt != lastLmt)
		{
			GString Hash = Utility::GetSha256ForFile(Fn);
			SC(sqlite3_bind_int(st_UpdateLMT, 1, lastLmt));
			SC(sqlite3_bind_text(st_UpdateLMT, 2, Hash.c_str(), Hash.length(), SQLITE_STATIC));
			SC(sqlite3_bind_text(st_UpdateLMT, 3, Fn.c_path(), Fn.path().length(), SQLITE_STATIC));
			SCS(sqlite3_step(st_UpdateLMT));
			SC(sqlite3_reset(st_UpdateLMT));
		}
	}else
	{
		GString Hash = Utility::GetSha256ForFile(Fn);

		// There's no entry, got to insert it.
		SC(sqlite3_bind_text(st_FilenameInsertQuery, 1, Fn.c_path(), Fn.path().length(), SQLITE_STATIC));
		SC(sqlite3_bind_int(st_FilenameInsertQuery, 2, Utility::GetLMT(Fn.path())));
		SC(sqlite3_bind_text(st_FilenameInsertQuery, 3, Hash.c_str(), Hash.length(), SQLITE_STATIC));
		SCS(sqlite3_step(st_FilenameInsertQuery)); // This should not fail. Otherwise, there are bigger problems to worry about...
		SC(sqlite3_reset(st_FilenameInsertQuery));

		// okay, then return the ID.
		SC(sqlite3_reset(st_FilenameQuery));
		SC(sqlite3_bind_text(st_FilenameQuery, 1, Fn.c_path(), Fn.path().length(), SQLITE_STATIC));
		sqlite3_step(st_FilenameQuery);
		idOut = sqlite3_column_int(st_FilenameQuery, 0);
	}

	SC(sqlite3_reset(st_FilenameQuery));
	return idOut;
}
예제 #25
0
QPCSCReader::Result QPCSCReader::transferCTL(const QByteArray &apdu, bool verify,
	quint16 lang, quint8 minlen, quint8 newPINOffset, bool requestCurrentPIN) const
{
	bool display = false;
	QHash<DRIVER_FEATURES,quint32> features = d->features();
	if( DWORD ioctl = features.value(FEATURE_IFD_PIN_PROPERTIES) )
	{
		DWORD size = 0;
		BYTE recv[256];
		LONG rv = SC(Control, d->card, ioctl, nullptr, 0u, recv, DWORD(sizeof(recv)), &size);
		if( rv == SCARD_S_SUCCESS )
		{
			PIN_PROPERTIES_STRUCTURE *caps = (PIN_PROPERTIES_STRUCTURE *)recv;
			display = caps->wLcdLayout > 0;
		}
	}

	quint8 PINFrameOffset = 0, PINLengthOffset = 0;
	#define SET() \
		data->bTimerOut = 30; \
		data->bTimerOut2 = 30; \
		data->bmFormatString = FormatASCII|AlignLeft|quint8(PINFrameOffset << 4)|PINFrameOffsetUnitBits; \
		data->bmPINBlockString = PINLengthNone << 5|PINFrameSizeAuto; \
		data->bmPINLengthFormat = PINLengthOffsetUnitBits|PINLengthOffset; \
		data->wPINMaxExtraDigit = quint16(minlen << 8) | 12; \
		data->bEntryValidationCondition = ValidOnKeyPressed; \
		data->wLangId = lang; \
		data->bTeoPrologue[0] = 0x00; \
		data->bTeoPrologue[1] = 0x00; \
		data->bTeoPrologue[2] = 0x00; \
		data->ulDataLength = quint32(apdu.size())

	QByteArray cmd( 255, 0 );
	if( verify )
	{
		PIN_VERIFY_STRUCTURE *data = (PIN_VERIFY_STRUCTURE*)cmd.data();
		SET();
		data->bNumberMessage = display ? CCIDDefaultInvitationMessage : NoInvitationMessage;
		data->bMsgIndex = NoInvitationMessage;
		cmd.resize( sizeof(PIN_VERIFY_STRUCTURE) - 1 );
	}
	else
	{
		PIN_MODIFY_STRUCTURE *data = (PIN_MODIFY_STRUCTURE*)cmd.data();
		SET();
		data->bNumberMessage = display ? ThreeInvitationMessage : NoInvitationMessage;
		data->bInsertionOffsetOld = 0x00;
		data->bInsertionOffsetNew = newPINOffset;
		data->bConfirmPIN = ConfirmNewPin;
		if(requestCurrentPIN)
		{
			data->bConfirmPIN |= RequestCurrentPin;
			data->bMsgIndex1 = NoInvitationMessage;
			data->bMsgIndex2 = OneInvitationMessage;
			data->bMsgIndex3 = TwoInvitationMessage;
		}
		else
		{
			data->bMsgIndex1 = OneInvitationMessage;
			data->bMsgIndex2 = TwoInvitationMessage;
			data->bMsgIndex3 = ThreeInvitationMessage;
		}
		cmd.resize( sizeof(PIN_MODIFY_STRUCTURE) - 1 );
	}
	cmd += apdu;

	DWORD ioctl = features.value( verify ? FEATURE_VERIFY_PIN_START : FEATURE_MODIFY_PIN_START );
	if( !ioctl )
		ioctl = features.value( verify ? FEATURE_VERIFY_PIN_DIRECT : FEATURE_MODIFY_PIN_DIRECT );

	qCDebug(APDU).nospace() << 'T' << d->proto - 1 << "> " << apdu.toHex().constData();
	qCDebug(APDU).nospace() << "CTL" << "> " << cmd.toHex().constData();
	QByteArray data( 255 + 3, 0 );
	DWORD size = DWORD(data.size());
	LONG err = SC(Control, d->card, ioctl, cmd.constData(), DWORD(cmd.size()), LPVOID(data.data()), DWORD(data.size()), &size);

	if( DWORD finish = features.value( verify ? FEATURE_VERIFY_PIN_FINISH : FEATURE_MODIFY_PIN_FINISH ) )
	{
		size = DWORD(data.size());
		err = SC(Control, d->card, finish, nullptr, 0u, LPVOID(data.data()), DWORD(data.size()), &size);
	}

	Result result = { data.mid(int(size - 2), 2), data.left(int(size - 2)), quint32(err) };
	qCDebug(APDU).nospace() << 'T' << d->proto - 1 << "< " << result.SW.toHex().constData();
	if(!result.data.isEmpty()) qCDebug(APDU).nospace() << data.left(int(size)).toHex().constData();
	return result;
}
예제 #26
0
// Adds a difficulty to the database, or updates it if it already exists.
void SongDatabase::AddDifficulty(int SongID, Directory Filename, Game::Song::Difficulty* Diff, int Mode)
{
	int FileID = InsertFilename(Filename);
	int DiffID;
	int ret;

	if (!DifficultyExists(FileID, Diff->Name, &DiffID))
	{
		SC(sqlite3_bind_int(st_DiffInsertQuery, 1, SongID));
		SC(sqlite3_bind_int(st_DiffInsertQuery, 2, FileID));
		SC(sqlite3_bind_text(st_DiffInsertQuery, 3, Diff->Name.c_str(), Diff->Name.length(), SQLITE_STATIC));
		SC(sqlite3_bind_int(st_DiffInsertQuery, 4, Diff->TotalObjects));
		SC(sqlite3_bind_int(st_DiffInsertQuery, 5, Diff->TotalScoringObjects));
		SC(sqlite3_bind_int(st_DiffInsertQuery, 6, Diff->TotalHolds));
		SC(sqlite3_bind_int(st_DiffInsertQuery, 7, Diff->TotalNotes));
		SC(sqlite3_bind_double(st_DiffInsertQuery, 8, Diff->Duration));

		if (Mode == MODE_VSRG)
		{
			VSRG::Difficulty *VDiff = static_cast<VSRG::Difficulty*>(Diff);

			SC(sqlite3_bind_int(st_DiffInsertQuery, 9, VDiff->IsVirtual));
			SC(sqlite3_bind_int(st_DiffInsertQuery, 10, VDiff->Channels));
			SC(sqlite3_bind_int(st_DiffInsertQuery, 11, VDiff->BPMType));
			SC(sqlite3_bind_int(st_DiffInsertQuery, 12, VDiff->Level));
			SC(sqlite3_bind_text(st_DiffInsertQuery, 13, VDiff->Author.c_str(), VDiff->Author.length(), SQLITE_STATIC));
			SC(sqlite3_bind_text(st_DiffInsertQuery, 14, VDiff->Data->StageFile.c_str(), VDiff->Data->StageFile.length(), SQLITE_STATIC));
		}else if (Mode == MODE_DOTCUR)
		{
			SC(sqlite3_bind_int(st_DiffInsertQuery, 9, 0));
			SC(sqlite3_bind_int(st_DiffInsertQuery, 10, 0));
			SC(sqlite3_bind_int(st_DiffInsertQuery, 11, 0));
			SC(sqlite3_bind_int(st_DiffInsertQuery, 12, 0));
			SC(sqlite3_bind_text(st_DiffInsertQuery, 13, Diff->Author.c_str(), Diff->Author.length(), SQLITE_STATIC));
		}

		SCS(sqlite3_step(st_DiffInsertQuery));
		SC(sqlite3_reset(st_DiffInsertQuery));

	}else
	{
		SC(sqlite3_bind_text(st_DiffUpdateQuery, 1, Diff->Name.c_str(), Diff->Name.length(), SQLITE_STATIC));
		SC(sqlite3_bind_int(st_DiffUpdateQuery, 2, Diff->TotalObjects));
		SC(sqlite3_bind_int(st_DiffUpdateQuery, 3, Diff->TotalScoringObjects));
		SC(sqlite3_bind_int(st_DiffUpdateQuery, 4, Diff->TotalHolds));
		SC(sqlite3_bind_int(st_DiffUpdateQuery, 5, Diff->TotalNotes));
		SC(sqlite3_bind_double(st_DiffUpdateQuery, 6, Diff->Duration));

		if (Mode == MODE_VSRG)
		{
			VSRG::Difficulty *VDiff = static_cast<VSRG::Difficulty*>(Diff);
			assert(VDiff->Data != NULL);
		
			SC(sqlite3_bind_int(st_DiffUpdateQuery, 7, VDiff->IsVirtual));
			SC(sqlite3_bind_int(st_DiffUpdateQuery, 8, VDiff->Channels));
			SC(sqlite3_bind_int(st_DiffUpdateQuery, 9, VDiff->BPMType));
			SC(sqlite3_bind_int(st_DiffUpdateQuery, 10, VDiff->Level));
			SC(sqlite3_bind_text(st_DiffUpdateQuery, 11, VDiff->Author.c_str(), VDiff->Author.length(), SQLITE_STATIC));
			SC(sqlite3_bind_text(st_DiffUpdateQuery, 12, VDiff->Data->StageFile.c_str(), VDiff->Data->StageFile.length(), SQLITE_STATIC));
		}else if (Mode == MODE_DOTCUR)
		{
			SC(sqlite3_bind_int(st_DiffUpdateQuery, 7, 0));
			SC(sqlite3_bind_int(st_DiffUpdateQuery, 8, 0));
			SC(sqlite3_bind_int(st_DiffUpdateQuery, 9, 0));

			SC(sqlite3_bind_int(st_DiffUpdateQuery, 10, 0));
			SC(sqlite3_bind_text(st_DiffUpdateQuery, 11, Diff->Author.c_str(), Diff->Author.length(), SQLITE_STATIC));
			SC(sqlite3_bind_text(st_DiffUpdateQuery, 12, "", 0, SQLITE_STATIC));
		}

		SC(sqlite3_bind_int(st_DiffUpdateQuery, 12, DiffID));
		SCS(sqlite3_step(st_DiffUpdateQuery));
		SC(sqlite3_reset(st_DiffUpdateQuery));
	}

	if (DiffID == 0)
	{
		if (!DifficultyExists (FileID, Diff->Name, &DiffID))
			Utility::DebugBreak();
		if(DiffID == 0)
			Utility::DebugBreak();
	}

	Diff->ID = DiffID;
}
예제 #27
0
파일: wmf.cpp 프로젝트: montsuqi/monpe
static void
set_font(DiaRenderer *self, DiaFont *font, real height)
{
    WmfRenderer *renderer = WMF_RENDERER (self);

    W32::LPCTSTR sFace;
    W32::DWORD dwItalic = 0;
    W32::DWORD dwWeight = FW_DONTCARE;
    DiaFontStyle style = dia_font_get_style(font);
    real font_size = dia_font_get_size (font) * (height / dia_font_get_height (font));


    DIAG_NOTE(renderer, "set_font %s %f\n", 
              dia_font_get_family (font), height);
    if (renderer->hFont) {
	W32::DeleteObject(renderer->hFont);
	renderer->hFont = NULL;
    }
    if (renderer->pango_context) {
        g_object_unref (renderer->pango_context);
	renderer->pango_context = NULL;
    }
    
    if (renderer->use_pango) {
#ifdef __PANGOWIN32_H__ /* with the pangowin32 backend there is a better way */
	if (!renderer->pango_context)
	    renderer->pango_context = pango_win32_get_context ();

	PangoFont* pf = pango_context_load_font (renderer->pango_context, dia_font_get_description (font));
	if (pf)
	{
	    W32::LOGFONT* lf = pango_win32_font_logfont (pf);
	    /* .93 : sligthly smaller looks much better */
	    lf->lfHeight = -SC(height*.93);
	    lf->lfHeight = -SC(font_size);
	    renderer->hFont = (W32::HFONT)W32::CreateFontIndirect (lf);
	    g_free (lf);
	    g_object_unref (pf);
	}
	else
	{
	    gchar *desc = pango_font_description_to_string (dia_font_get_description (font));
	    message_warning (_("Can not render unknown font:\n%s"), desc);
	    g_free (desc);
	}
#else
	g_assert_not_reached();
#endif
    } else {
	sFace = dia_font_get_family (font);
	dwItalic = DIA_FONT_STYLE_GET_SLANT(style) != DIA_FONT_NORMAL;

	/* although there is a known algorithm avoid it for cleanness */
	switch (DIA_FONT_STYLE_GET_WEIGHT(style)) {
	case DIA_FONT_ULTRALIGHT    : dwWeight = FW_ULTRALIGHT; break;
	case DIA_FONT_LIGHT         : dwWeight = FW_LIGHT; break;
	case DIA_FONT_MEDIUM        : dwWeight = FW_MEDIUM; break;
	case DIA_FONT_DEMIBOLD      : dwWeight = FW_DEMIBOLD; break;
	case DIA_FONT_BOLD          : dwWeight = FW_BOLD; break;
	case DIA_FONT_ULTRABOLD     : dwWeight = FW_ULTRABOLD; break;
	case DIA_FONT_HEAVY         : dwWeight = FW_HEAVY; break;
	default : dwWeight = FW_NORMAL; break;
	}
	//Hack to get BYTE out of namespace W32
#       ifndef BYTE
#       define BYTE unsigned char
#       endif

	renderer->hFont = (W32::HFONT)W32::CreateFont( 
		- SC (font_size),  // logical height of font 
		0,		// logical average character width 
		0,		// angle of escapement
		0,		// base-line orientation angle 
		dwWeight,	// font weight
		dwItalic,	// italic attribute flag
		0,		// underline attribute flag
		0,		// strikeout attribute flag
		DEFAULT_CHARSET,	// character set identifier 
		OUT_TT_PRECIS, 	// output precision 
		CLIP_DEFAULT_PRECIS,	// clipping precision
		PROOF_QUALITY,		// output quality 
		DEFAULT_PITCH,		// pitch and family
		sFace);		// pointer to typeface name string
    }
}
예제 #28
0
void SongDatabase::GetSongInformation7K (int ID, VSRG::Song* Out)
{
	int ret;
	SC(sqlite3_bind_int(st_GetSongInfo, 1, ID));
	ret = sqlite3_step(st_GetSongInfo);

	if (ret != SQLITE_ROW)
	{
		Log::Printf("SongDatabase::GetSongInformation7K: Chart %d does not exist.\n", ID);
		return;
	}

	// Main metadata is up in this query.

	Out->SongName = (char*)sqlite3_column_text(st_GetSongInfo, 0);
	Out->SongAuthor = (char*)sqlite3_column_text(st_GetSongInfo, 1);
	Out->SongFilename = (char*)sqlite3_column_text(st_GetSongInfo, 2);
	Out->Subtitle = (char*)sqlite3_column_text(st_GetSongInfo, 3);
	Out->BackgroundFilename = (char*)sqlite3_column_text(st_GetSongInfo, 4);
	Out->ID = ID;
	int mode = sqlite3_column_int(st_GetSongInfo, 5);
	Out->PreviewTime = sqlite3_column_double(st_GetSongInfo, 6);

	SC(sqlite3_reset(st_GetSongInfo));

	if (mode != MODE_VSRG)
		return; // Sowwy.

	// Now, difficulty information.
	SC(sqlite3_bind_int(st_GetDiffInfo, 1, ID));
	while (sqlite3_step(st_GetDiffInfo) != SQLITE_DONE)
	{
		std::shared_ptr<VSRG::Difficulty> Diff (new VSRG::Difficulty);

		// diffid associated data
		Diff->ID = sqlite3_column_int(st_GetDiffInfo, 0);
		Diff->Name = (char*)sqlite3_column_text(st_GetDiffInfo, 1);
		Diff->TotalObjects = sqlite3_column_int(st_GetDiffInfo, 2);
		Diff->TotalScoringObjects = sqlite3_column_int(st_GetDiffInfo, 3);
		Diff->TotalHolds = sqlite3_column_int(st_GetDiffInfo, 4);
		Diff->TotalNotes = sqlite3_column_int(st_GetDiffInfo, 5);
		Diff->Duration = sqlite3_column_double(st_GetDiffInfo, 6);
		Diff->IsVirtual = (sqlite3_column_int(st_GetDiffInfo, 7) == 1);
		Diff->Channels = sqlite3_column_int(st_GetDiffInfo, 8);

		int colInt = sqlite3_column_int(st_GetDiffInfo, 10);
		Diff->BPMType = (VSRG::Difficulty::ETimingType)colInt;

		// We don't include author information to force querying it from the database.
		// Diff->Author
		Diff->Level = sqlite3_column_int(st_GetDiffInfo, 11);

		// File ID associated data
		int FileID = sqlite3_column_int(st_GetDiffInfo, 9);

		SC(sqlite3_bind_int(st_GetFileInfo, 1, FileID));
		sqlite3_step(st_GetFileInfo);
		Diff->Filename = (char*)sqlite3_column_text(st_GetFileInfo, 0);
		SC(sqlite3_reset(st_GetFileInfo));

		Out->Difficulties.push_back(Diff);
	}

	SC(sqlite3_reset(st_GetDiffInfo));
}
예제 #29
0
    /* 6 */ 1,2, 1,2, 1,2, 1,2, /* rate 13 2 */
    /* 7 */ 1,2, 2,2, 1,2, 2,2, /* rate 13 3 */

    /* 8 */ 2,2, 2,2, 2,2, 2,2, /* rate 14 0 (increment by 2) */
    /* 9 */ 2,2, 2,4, 2,2, 2,4, /* rate 14 1 */
    /*10 */ 2,4, 2,4, 2,4, 2,4, /* rate 14 2 */
    /*11 */ 2,4, 4,4, 2,4, 4,4, /* rate 14 3 */

    /*12 */ 4,4, 4,4, 4,4, 4,4, /* rates 15 0, 15 1, 15 2, 15 3 (increment by 4) */
    /*13 */ 8,8, 8,8, 8,8, 8,8, /* rates 15 2, 15 3 for attack */
    /*14 */ 0,0, 0,0, 0,0, 0,0, /* infinity rates for attack and decay(s) */
};

#define SC(db) (u32) ( db * (1.0/ENV_STEP) )
const u32 YM2413CORE::sl_tab[16] = {
    SC( 0),SC( 1),SC( 2),SC(3 ),SC(4 ),SC(5 ),SC(6 ),SC( 7),
    SC( 8),SC( 9),SC(10),SC(11),SC(12),SC(13),SC(14),SC(15)
};
#undef SC

/* multiple table */
#define ML 2
const double YM2413CORE::mul_tab[16] = {
/* 1/2, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,10,12,12,15,15 */
   0.50*ML, 1.00*ML, 2.00*ML, 3.00*ML, 4.00*ML, 5.00*ML, 6.00*ML, 7.00*ML,
   8.00*ML, 9.00*ML,10.00*ML,10.00*ML,12.00*ML,12.00*ML,15.00*ML,15.00*ML
};
#undef ML

void YM2413CORE::initTlTable() {
    signed int n;
예제 #30
0
krb5_error_code KRB5_CALLCONV
krb5int_accessor(krb5int_access *internals, krb5_int32 version)
{
    if (version == KRB5INT_ACCESS_VERSION) {
#if DESIGNATED_INITIALIZERS
#define S(FIELD, VAL)   .FIELD = VAL
#if defined __GNUC__ && __STDC_VERSION__ < 199901L
        __extension__
#endif
            static const krb5int_access internals_temp = {
#else
#define S(FIELD, VAL)   internals_temp.FIELD = VAL
            krb5int_access internals_temp;
#endif
            S (arcfour_gsscrypt, krb5int_arcfour_gsscrypt),
            S (auth_con_get_subkey_enctype, krb5_auth_con_get_subkey_enctype),

            S (clean_hostname, krb5int_clean_hostname),

            S (mandatory_cksumtype, krb5int_c_mandatory_cksumtype),
#ifndef LEAN_CLIENT
#define SC(FIELD, VAL)  S(FIELD, VAL)
#else /* disable */
#define SC(FIELD, VAL)  S(FIELD, 0)
#endif
            SC (ser_pack_int64, krb5_ser_pack_int64),
            SC (ser_unpack_int64, krb5_ser_unpack_int64),
#undef SC

#ifdef ENABLE_LDAP
#define SC(FIELD, VAL)  S(FIELD, VAL)
#else
#define SC(FIELD, VAL)  S(FIELD, 0)
#endif
            SC (asn1_ldap_encode_sequence_of_keys, krb5int_ldap_encode_sequence_of_keys),
            SC (asn1_ldap_decode_sequence_of_keys, krb5int_ldap_decode_sequence_of_keys),
#undef SC

#ifndef DISABLE_PKINIT
#define SC(FIELD, VAL)  S(FIELD, VAL)
#else /* disable */
#define SC(FIELD, VAL)  S(FIELD, 0)
#endif
            SC (encode_krb5_pa_pk_as_req, encode_krb5_pa_pk_as_req),
            SC (encode_krb5_pa_pk_as_req_draft9, encode_krb5_pa_pk_as_req_draft9),
            SC (encode_krb5_pa_pk_as_rep, encode_krb5_pa_pk_as_rep),
            SC (encode_krb5_pa_pk_as_rep_draft9, encode_krb5_pa_pk_as_rep_draft9),
            SC (encode_krb5_auth_pack, encode_krb5_auth_pack),
            SC (encode_krb5_auth_pack_draft9, encode_krb5_auth_pack_draft9),
            SC (encode_krb5_kdc_dh_key_info, encode_krb5_kdc_dh_key_info),
            SC (encode_krb5_reply_key_pack, encode_krb5_reply_key_pack),
            SC (encode_krb5_reply_key_pack_draft9, encode_krb5_reply_key_pack_draft9),
            SC (encode_krb5_typed_data, encode_krb5_typed_data),
            SC (encode_krb5_td_trusted_certifiers, encode_krb5_td_trusted_certifiers),
            SC (encode_krb5_td_dh_parameters, encode_krb5_td_dh_parameters),
            SC (decode_krb5_pa_pk_as_req, decode_krb5_pa_pk_as_req),
            SC (decode_krb5_pa_pk_as_req_draft9, decode_krb5_pa_pk_as_req_draft9),
            SC (decode_krb5_pa_pk_as_rep, decode_krb5_pa_pk_as_rep),
            SC (decode_krb5_pa_pk_as_rep_draft9, decode_krb5_pa_pk_as_rep_draft9),
            SC (decode_krb5_auth_pack, decode_krb5_auth_pack),
            SC (decode_krb5_auth_pack_draft9, decode_krb5_auth_pack_draft9),
            SC (decode_krb5_kdc_dh_key_info, decode_krb5_kdc_dh_key_info),
            SC (decode_krb5_principal_name, decode_krb5_principal_name),
            SC (decode_krb5_reply_key_pack, decode_krb5_reply_key_pack),
            SC (decode_krb5_reply_key_pack_draft9, decode_krb5_reply_key_pack_draft9),
            SC (decode_krb5_typed_data, decode_krb5_typed_data),
            SC (decode_krb5_td_trusted_certifiers, decode_krb5_td_trusted_certifiers),
            SC (decode_krb5_td_dh_parameters, decode_krb5_td_dh_parameters),
            SC (decode_krb5_as_req, decode_krb5_as_req),
            SC (encode_krb5_kdc_req_body, encode_krb5_kdc_req_body),
            SC (free_kdc_req, krb5_free_kdc_req),
            SC (set_prompt_types, krb5int_set_prompt_types),
            SC (encode_krb5_authdata_elt, encode_krb5_authdata_elt),
#undef SC

            S (encode_krb5_sam_response_2, encode_krb5_sam_response_2),
            S (encode_krb5_enc_sam_response_enc_2, encode_krb5_enc_sam_response_enc_2),

#if DESIGNATED_INITIALIZERS
        };
#else
        0;
#endif
        *internals = internals_temp;
        return 0;
    }