示例#1
0
void print_injection_indexes()
{
	print_char('I');print_char(' ');
	print_byte(lowRPMindexInj);print_char(' ');
	print_byte(highRPMindexInj);
	new_line();
}
示例#2
0
void print_ignition_indexes()
{
	print_char('S');print_char(' ');
	print_byte(lowRPMindexIgn);print_char(' ');
	print_byte(highRPMindexIgn);
	new_line();
}
示例#3
0
void print_load_indexes()
{
	print_char('L');print_char(' ');
	print_byte(lowMAPindex);print_char(' ');
	print_byte(highMAPindex);
	new_line();
}
示例#4
0
文件: tag_test.c 项目: haderer/IDV3v2
/* helper to print byte */
void print_byte_int(int x){
   int hi, lo;
   hi=(x>>8) & 0xff;
   lo=x&0xff;
   print_byte(hi);
   printf(" ");
   print_byte(lo);
}
示例#5
0
void print_interpolation()
{
	print_char('P');print_char(' ');
	print_byte(p_inj);print_char(' ');
	print_byte(p_ign);print_char(' ');
	print_byte(q);
	new_line();
}
示例#6
0
void print_Analog_2()
{
	print_char('a');print_char(' ');
	print_byte(sensor_reading[CLT_PIN]);print_char(' ');
	print_byte(sensor_reading[MAP2_PIN]);print_char(' ');
	//print_byte(sensor_reading[OT_PIN]);print_char(' ');
	print_byte(engine_MAP);
	new_line();
}
示例#7
0
void print_Analog_1()
{
	print_char('A');print_char(' ');
	print_byte(sensor_reading[WB_PIN]);print_char(' ');
	//print_byte(sensor_reading[IAT_PIN]);print_char(' ');
	print_byte(engine_iat);print_char(' ');
	print_byte(sensor_reading[TPS_PIN]);
	new_line();
}
示例#8
0
void print_state(state_t *state){
	printf("\nWHAT\t   0 1 2 3 4 5 6 7\n");
	printf("DATA\t  ");
	print_byte(state->data);

	printf("STAT\t  ");
	print_byte(state->state);

	printf("CTRL\t  ");
	print_byte(state->control);
}
示例#9
0
int main(int argc, char **argv) {

  if (argc < 2) {
    printHelpMessage();
    return -1;
  }

  MP4Container_t *container = new_mp4_container(argv[1]);

  AVCCAtom_t *avc = get_video_info(container);
  if (avc == NULL) {
    printf("FAILED: Didn't find the avcC atom\n");
    return -1;
  }

  printf("\n avcC atom @ %d - length: %d", avc->position, avc->length);
  print_buffer_data(avc->bytes, avc->size);
  printf("\n");

  for (size_t i = 0; i < avc->number_of_sps_nalus; i++) {
    SPS_t *sps = avc->sps_array[i];
    printf(" SPS #%ld - size: %d", i + 1, sps->size);
    print_buffer_data(sps->bytes, sps->size);
    printf("\n");
  }

  for (size_t i = 0; i < avc->number_of_pps_nalus; i++) {
    PPS_t *pps = avc->pps_array[i];
    printf(" PPS #%ld - size %d", i + 1, pps->size);
    print_buffer_data(pps->bytes, pps->size);
    printf("\n");
  }

  printf(" version: %d\n", avc->version);
  printf(" profile: %d\n", avc->profile);
  printf(" compatibility: %d\n", avc->compatibility);
  printf(" level: %d\n", avc->level);

  printf(" reserved: %d\n           ", avc->reserved);
  print_byte(avc->reserved);
  printf("\n");

  printf(" nalu_length_minus_one: %d\n", avc->nalu_length_minus_one);

  printf(" reserved: ");
  print_byte(avc->reserved_after_length_minus_one);
  printf("\n");

  printf(" number_of_sps_nalus: %d\n", avc->number_of_sps_nalus);
  printf(" number_of_pps_nalus: %d\n", avc->number_of_pps_nalus);

  close_mp4_container(container);
}
示例#10
0
static void print_rds_group(const struct v4l2_rds_group *rds_group)
{
	printf("\nComplete RDS data group received \n");
	printf("PI: %04x\n", rds_group->pi);
	printf("Group: %u%c \n", rds_group->group_id, rds_group->group_version);
	printf("Data B:");
	print_byte(rds_group->data_b_lsb, true);
	printf("Data C:");
	print_byte(rds_group->data_c_msb, false);
	print_byte(rds_group->data_c_lsb, true);
	printf("Data D:");
	print_byte(rds_group->data_d_msb, false);
	print_byte(rds_group->data_d_lsb, true);
	printf("\n");
}
示例#11
0
void		ft_print_memory(const void *addr, size_t size)
{
	size_t			k;
	size_t			l;
	unsigned char	*str;

	k = -1;
	str = (unsigned char *)addr;
	l = (size % 16 == 0) ? size : size + (16 - (size % 16));
	while (++k < l)
	{
		if (k < size)
			print_byte(str[k]);
		else
			write(1, "  ", 2);
		if (((k + 1) % 2) == 0)
			ft_putchar(' ');
		if ((k + 1) % 16 == 0)
		{
			(k < size) ? print_dots(str, k - 16, k) \
				: print_dots(str, (size - (size % 16) - 1), size - 1);
			ft_putchar('\n');
		}
	}
}
示例#12
0
static int print_string( ctl* control, SSHORT offset)
{
	SSHORT n = print_byte(control);
	while (--n >= 0)
		print_char(control, offset);

	PUT_BYTE(' ');
	return 0;
}
示例#13
0
static void dump_bytes(uint8_t *bytes, size_t len)
{
    for (size_t ii = 0; ii < len; ++ii) {
        if (ii % 4 == 0) {
            printf("\n    +---------------+---------------+---------------+---------------+\n");
            printf(" %3zu|", ii);
        }
        print_byte(bytes[ii]);
    }
}
示例#14
0
int PRETTY_print_cdb( UCHAR* blr, FPTR_PRINT_CALLBACK routine, void* user_arg, SSHORT language)
{

	ctl ctl_buffer;
	ctl* control = &ctl_buffer;

	if (!routine)
	{
		routine = gds__default_printer;
		user_arg = NULL;
	}

	control->ctl_routine = routine;
	control->ctl_user_arg = user_arg;
	control->ctl_blr = control->ctl_blr_start = blr;
	control->ctl_ptr = control->ctl_buffer;
	control->ctl_language = language;

	SSHORT level = 0;
	indent(control, level);
	const SSHORT i = BLR_BYTE;

	SCHAR temp[32];
	if (*control->ctl_blr)
		sprintf(temp, "gds__dpb_version%d, ", i);
	else
		sprintf(temp, "gds__dpb_version%d", i);
	blr_format(control, temp);

	SSHORT offset = 0;
	print_line(control, offset);

	SSHORT parameter;
	while (parameter = BLR_BYTE)
	{
		const char* p;
		if (parameter > FB_NELEM(cdb_table) || !(p = cdb_table[parameter]))
		{
			return error(control, 0, "*** cdb parameter %d is undefined ***\n", parameter);
		}
		indent(control, level);
		blr_format(control, p);
		PUT_BYTE(',');
		int length = print_byte(control);
		if (length)
		{
			do {
				print_char(control, offset);
			} while (--length);
		}
		print_line(control, offset);
	}

	return 0;
}
void encode(int argc, char**argv)
{
    int fin = 0; //stdin
    int fout = 1; //stdout

    if(argc > 1) {
        int tmp = open(argv[1], O_RDONLY);
        if(tmp < 0)
            printf("encode:Can not open file %s\n", argv[1]);
        else {
            fin = tmp;
            std::string s(argv[1]);
            s += ".out";
            int tmp2 = creat(s.c_str(), S_IRUSR | S_IWUSR);
            if(tmp2 < 0)
                printf("encode:Can not open file for writing %s\n", s.c_str());
            else
                fout = tmp2;
        }
    }

    uint8_t buf;
    uint8_t chmap[R] = {0};
    for(int i =0 ; i < R ; i++) {
        chmap[i] = i;
    }

    while(read(fin, &buf, 1) > 0) 
    {
        out("buf=");
        print_byte(buf);

        uint8_t prev = chmap[0]; //save prev
        for(int i = 0; i < R; i++) {
            out("i%d%d",i,chmap[i]);
            if(chmap[i] == buf) {
                swap(chmap[i], prev);
                write(fout, &i, 1); 
                chmap[0] = buf;
                out("found at %d\n",i);
                break;
            }
            swap(chmap[i], prev);
        }
    }
    /*
    0 1 2 ... a b c
    a 0 1 2.... b c
    b a 0 1 2.... c
    */

    close(fin);
    close(fout);
}
示例#16
0
文件: output.c 项目: k6s/yaod
void			print_addr(WINDOW *win, size_t var_len, size_t x, size_t y,
							   char *reg, int colors)
{
  size_t		idx;

  wmove(win, y, x);
  idx = 0;
  while (idx < var_len)
    print_byte(win, *(reg + idx++));
  wmove(win, y, x);
  wchgat(win, var_len * 2, COLOR_PAIR(colors), colors, 0);
}
示例#17
0
文件: printer.hpp 项目: Jiish/prophy
inline std::ostream& operator<<(std::ostream& out, std::pair<const uint8_t*, size_t> bytes)
{
    out << '\'';
    while (bytes.second)
    {
        print_byte(out, *bytes.first);
        ++bytes.first;
        --bytes.second;
    }
    out << '\'';
    return out;
}
示例#18
0
文件: NN_0.c 项目: Chuphay/school
int main(){

  print_byte(and_net(39,121));

  print_byte(39&121);

  print_byte(or_net(89,31));
  print_byte(89|31);
  print_byte(not_net(7,or_net(89,31)));
  print_byte(~(89|31));
  print_byte(xor_net(88,113));
  print_byte(88^113);
  return 0;
}
示例#19
0
void main(void)										
{
	byte xdata *ptr;
	init_lcd();
	clear_screen();

	ptr=900;
	print_byte(0x55,ptr);

	for(;;)
	{	
		_nop_();
	}
}
void decode(int argc, char**argv)
{
    int fin = 0; //stdin
    int fout = 1; //stdout

    if(argc < 2) {
        return;
    }

    int tmp = open(argv[1], O_RDONLY);
    out("\nDecoding: %s\n",argv[1]);

    if(tmp < 0) {
        printf("decode:Can not open file %s\n", argv[1]);
        return;
    }
    else {
        fin = tmp;
        std::string s(argv[1]);
        s += ".verif";
        int tmp2 = creat(s.c_str(), S_IRUSR | S_IWUSR);
        if(tmp2 < 0) {
            printf("decode:Can not open file for writing %s\n", s.c_str());
            return;
        }
        else
            fout = tmp2;
    }

    uint8_t buf;
    uint8_t chmap[R] = {0};
    for(int i =0 ; i < R ; i++) {
        chmap[i] = i;
    }

    while(read(fin, &buf, 1) > 0) 
    {
        out("buf=");
        print_byte(buf);

        write(fout, &chmap[buf], 1); //0 of the other type (ex zeros)
        int tmp = chmap[buf];
        for(int i = buf; i != 0; i--) {
            chmap[i] = chmap[i-1];
        }
        chmap[0] = tmp;
    }

}
示例#21
0
int main(){



	int fd = spi_open("/dev/spidev0.0");
	spi_mode(fd, SPI_MODE_1);
	// spi_mode(fd,  SPI_NO_CS | SPI_MODE_2);
	spi_speed(fd, MHZ_32);
	dumpstat("SPI device 0: ",fd);

	// uint16_t command = MCP3208_START_BIT | MCP3208_SINGLE_ENDED

	printf("size %d\n", sizeof(MCP_CHAN_7));

	// uint32_t foo = MCP_CHAN_7;
	// uint32_t mcp_tx = ((uint32_t)MCP_CHAN_7) << 14;
	// uint32_t mcp_rx = 0;

	uint8_t tx[] = {1,8 + 0 << 4,0,0};
	uint8_t rx[4] = {0}; 


	struct spi_ioc_transfer mcp_tr ={
		.tx_buf = (unsigned long)&tx,
		.rx_buf = (unsigned long)&rx,
		.len = 4,
		.delay_usecs = 0,
		.speed_hz = KHZ_500,
		.bits_per_word = 8,
	};


	while(1){
		spi_transfer(fd, &mcp_tr, 1);

		// printf ("B "BYTETOBINARYPATTERN" ", BYTETOBINARY(mcp_tx >> 24));
		// printf (""BYTETOBINARYPATTERN" ", BYTETOBINARY(mcp_tx >> 16));
		// printf (""BYTETOBINARYPATTERN" ", BYTETOBINARY(mcp_tx >> 8));
		// printf (""BYTETOBINARYPATTERN" ", BYTETOBINARY(mcp_tx));
		// printf("\tbuf_tx: %u\n", mcp_tx);

		// mcp_rx |= 0xff000000;
		// mcp_rx &= 0x00ffffff;
		// mcp_rx = mcp_rx >> 0;

		uint32_t ret = 0;
		ret |= (uint32_t)rx[3];
		ret |= (uint32_t)rx[2] << 8;
		ret |= (uint32_t)rx[1] << 16;
		// ret |= (uint32_t)rx[0] << 24;

		print_byte(rx[0]);
		print_byte(rx[1]);
		print_byte(rx[2]);
		print_byte(rx[3]);
		printf(" rx %d", ret >> 6);
		printf("\n");

		// printf("%d\n", rx);

		// printf ("\nA "BYTETOBINARYPATTERN" ", BYTETOBINARY(mcp_rx >> 24));
		// printf (""BYTETOBINARYPATTERN" ", BYTETOBINARY(mcp_rx >> 16));
		// printf (""BYTETOBINARYPATTERN" ", BYTETOBINARY(mcp_rx >> 8));
		// printf (""BYTETOBINARYPATTERN" ", BYTETOBINARY(mcp_rx));
		// printf("\tbuf_rx: %u\n", mcp_rx);

		nanosleep(&requested,&remaining);
	}

	// uint16_t command = get_mcp_channel_command(0);
	// printf ("Byte 00 "BYTETOBINARYPATTERN"\n", BYTETOBINARY((uint8_t)command));
	// printf ("Byte 01 "BYTETOBINARYPATTERN"\n", BYTETOBINARY((uint8_t)command >> 8));

	// printf ("Byte 00 "BYTETOBINARYPATTERN"\n", BYTETOBINARY((uint8_t)0x8));
	// printf ("Byte 01 "BYTETOBINARYPATTERN"\n", BYTETOBINARY((uint8_t)0x10));
	// printf("command %d %s\n", command, &buf);

	// dumpstat("SPI device 0: ",fd);

	spi_close(fd);

}

static void print_byte(uint8_t byte){
	printf (""BYTETOBINARYPATTERN" ", BYTETOBINARY(byte));
} 
示例#22
0
void vbprintf(string s, string fmt, va_list ap)
{
    character i;
    int state = 0;
    int base = 0;
    int pad;
    int count = 0;

    string_foreach(fmt, i) {
        switch (state){
        case 2:
            for (int j = 0; j < count; j++)
                string_insert(s, i);
            state = 0;
            break;

        case 0:
            base = 10;
            pad = 0;
            if (i == '%') state = 3;
            else string_insert(s, i);
            break;

        case 1:
            if ((i >= '0') && (i <= '9')) {
                pad = pad * 10 + digit_of(i);
                break;
            } else {
                state = 3;
            }

        case 3:
            switch (i) {
            case '0':
                state = 1;
                break;

            case '%':
                string_insert(s, '\%');
                break;

            case 't':
                print_time(s, va_arg(ap, ticks));
                break;

            case 'b':
                string_concat(s, (va_arg(ap, string)));
                break;

            case 'n':
                count = va_arg(ap, unsigned int);
                state = 2;
                break;

            case 'c':
                string_insert(s, va_arg(ap, int));
                break;

            case 's':
                {
                    char *c = va_arg(ap, char *);
                    if (!c) c = (char *)"(null)";
                    int len = cstring_length(c);
                    for (int i =0 ; i < pad; i++)
                        string_insert(s, ' ');
                    pad = 0;
                    for (; *c; c++)
                        string_insert(s, *c);
                }
                break;

            case 'S':
                {
                    unsigned int x = va_arg(ap, unsigned int);
                    for (int i =0 ; i < x; i++) string_insert(s, ' ');
                    break;
                }

            case 'p':
                pad = 16;
                unsigned long x = va_arg(ap, unsigned long);
                format_number(s, x, 16, pad?pad:1);
                break;

            case 'l':
                pad = 0;
                unsigned long z = va_arg(ap, unsigned long);
                format_number(s, z, 10, pad?pad:1);
                break;

            case 'x':
                base=16;

            case 'o':
                if (base == 10) base=8;
            case 'u':
                {
                    unsigned int x = va_arg(ap, unsigned int);
                    format_number(s, x, base, pad?pad:1);
                    break;
                }

             // xxx - layer violation..meh
             // also generalize string pad support
            case 'v':
                if (pad) {
                    // xxx  transient or resizable stack head
                    buffer b = allocate_string(s->h);
                    print_value(b, va_arg(ap, void *));
                    // xxx utf token length
                    for (int i =0 ; i < (pad-buffer_length(b)); i++) string_insert(s, ' ');
                    buffer_append(s, bref(b, 0), buffer_length(b));
                    pad = 0;
                    state = 0;
                } else print_value(s, va_arg(ap, void *));
                break;

            case 'r':
                if (pad) {
                    // xxx  transient or resizable stack head
                    buffer b = allocate_string(s->h);
                    print_value_raw(b, va_arg(ap, void *));
                    // xxx utf token length
                    for (int i =0 ; i < (pad-buffer_length(b)); i++) string_insert(s, ' ');
                    buffer_append(s, bref(b, 0), buffer_length(b));
                    pad = 0;
                    state = 0;
                } else print_value_raw(s, va_arg(ap, void *));
                break;

            case 'V':
                print_value_vector(s, va_arg(ap, void *));
                break;

            case 'X':
                // xxx - utf8 will break this
                 {
                  buffer xx = va_arg(ap, buffer);
                  string_foreach(xx, i){
                     print_byte(s, i);
                  }
                 }
                break;

            case 'd': case 'i':
                {
                    int x = va_arg(ap, int);
                    if (x <0){
                        string_insert(s, '-');
                        x = -x;
                    }
                    format_number(s, (unsigned int)x, base, pad?pad:1);
                    break;
                }
            default:
                break;
            }
            // badness
            if (state == 3)
                state = 0;
            break;
        }
    }
示例#23
0
static int print_blr_dtype(ctl* control, bool print_object)
{
	const char* string = NULL;
	SSHORT length = -1;

	const USHORT dtype = BLR_BYTE;

	// Special case blob (261) to keep down the size of the
	// jump table

	switch (dtype)
	{
	case blr_short:
		string = "short";
		length = 2;
		break;

	case blr_long:
		string = "long";
		length = 4;
		break;

	case blr_quad:
		string = "quad";
		length = 8;
		break;

	// Begin date/time/timestamp
	case blr_sql_date:
		string = "sql_date";
		length = sizeof(ISC_DATE);
		break;

	case blr_sql_time:
		string = "sql_time";
		length = sizeof(ISC_TIME);
		break;

	case blr_timestamp:
		string = "timestamp";
		length = sizeof(ISC_TIMESTAMP);
		break;
	// End date/time/timestamp

	case blr_int64:
		string = "int64";
		length = sizeof(ISC_INT64);
		break;

	case blr_float:
		string = "float";
		length = 4;
		break;

	case blr_double:
		string = "double";
		length = 8;
		break;

	case blr_d_float:
		string = "d_float";
		length = 8;
		break;

	case blr_text:
		string = "text";
		break;

	case blr_cstring:
		string = "cstring";
		break;

	case blr_varying:
		string = "varying";
		break;

	case blr_text2:
		string = "text2";
		break;

	case blr_cstring2:
		string = "cstring2";
		break;

	case blr_varying2:
		string = "varying2";
		break;

	case blr_blob_id:
		string = "blob_id";
		length = 8;
		break;

	default:
		error(control, 0, "*** invalid data type ***", 0);
	}

	blr_format(control, "blr_%s, ", string);

	if (!print_object)
		return length;

	switch (dtype)
	{
	case blr_text:
		length = print_word(control);
		break;

	case blr_varying:
		length = print_word(control) + 2;
		break;

	case blr_text2:
		print_word(control);
		length = print_word(control);
		break;

	case blr_varying2:
		print_word(control);
		length = print_word(control) + 2;
		break;

	case blr_short:
	case blr_long:
	case blr_int64:
	case blr_quad:
		print_byte(control);
		break;

	case blr_blob_id:
		print_word(control);
		break;

	default:
		if (dtype == blr_cstring)
			length = print_word(control);
		else if (dtype == blr_cstring2)
		{
			print_word(control);
			length = print_word(control);
		}
		break;
	}

	return length;
}
示例#24
0
static int print_dyn_verb( ctl* control, SSHORT level)
{
	const SSHORT offset = control->ctl_blr - control->ctl_blr_start;
	const UCHAR dyn_operator = BLR_BYTE;

    const char* p;
	const int size = FB_NELEM(dyn_table);
	if (dyn_operator > size || dyn_operator <= 0 || !(p = dyn_table[dyn_operator])) {
		return error(control, offset, "*** dyn operator %d is undefined ***\n", (int) dyn_operator);
	}

	indent(control, level);
	blr_format(control, p);
	PUT_BYTE(',');
	PUT_BYTE(' ');
	++level;

	int length;

	switch (dyn_operator)
	{
	case isc_dyn_drop_difference:
	case isc_dyn_begin_backup:
	case isc_dyn_end_backup:
		return 0;
	case isc_dyn_begin:
	case isc_dyn_mod_database:
		print_line(control, offset);
		while (NEXT_BYTE != isc_dyn_end)
			PRINT_DYN_VERB;
		PRINT_DYN_VERB;
		return 0;

	case isc_dyn_view_blr:
	case isc_dyn_fld_validation_blr:
	case isc_dyn_fld_computed_blr:
	case isc_dyn_trg_blr:
	case isc_dyn_fld_missing_value:
	case isc_dyn_prc_blr:
	case isc_dyn_fld_default_value:
		length = print_word(control);
		print_line(control, offset);
		if (length)
		{
			control->ctl_level = level;
			fb_print_blr(control->ctl_blr, length, print_blr_line, control, control->ctl_language);
			control->ctl_blr += length;
		}
		return 0;

	case isc_dyn_scl_acl:
//	case isc_dyn_log_check_point_length:
//	case isc_dyn_log_num_of_buffers:
//	case isc_dyn_log_buffer_size:
//	case isc_dyn_log_group_commit_wait:
	case isc_dyn_idx_inactive:
		length = print_word(control);
		while (length--)
			print_byte(control);
		print_line(control, offset);
		return 0;

	case isc_dyn_view_source:
	case isc_dyn_fld_validation_source:
	case isc_dyn_fld_computed_source:
	case isc_dyn_description:
	case isc_dyn_prc_source:
	case isc_dyn_fld_default_source:
		length = print_word(control);
		while (length--)
			print_char(control, offset);
		print_line(control, offset);
		return 0;

	case isc_dyn_del_exception:
		if (length = print_word(control))
			do {
				print_char(control, offset);
			} while (--length);
		return 0;

	case isc_dyn_fld_not_null:
	case isc_dyn_sql_object:
//	case isc_dyn_drop_log:
//	case isc_dyn_drop_cache:
//	case isc_dyn_def_default_log:
//	case isc_dyn_log_file_serial:
//	case isc_dyn_log_file_raw:
//	case isc_dyn_log_file_overflow:
	case isc_dyn_single_validation:
	case isc_dyn_del_computed:
	case isc_dyn_del_default:
	case isc_dyn_del_validation:
	case isc_dyn_idx_statistic:
	case isc_dyn_foreign_key_delete:
	case isc_dyn_foreign_key_update:
	case isc_dyn_foreign_key_cascade:
	case isc_dyn_foreign_key_default:
	case isc_dyn_foreign_key_null:
	case isc_dyn_foreign_key_none:

		print_line(control, offset);
		return 0;

	case isc_dyn_end:
		print_line(control, offset);
		return 0;
	}

	if (length = print_word(control))
		do {
			print_char(control, offset);
		} while (--length);

	print_line(control, offset);

	switch (dyn_operator)
	{
	case isc_dyn_def_database:
	case isc_dyn_def_dimension:
	case isc_dyn_def_exception:
	case isc_dyn_def_file:
//	case isc_dyn_def_log_file:
//	case isc_dyn_def_cache_file:
	case isc_dyn_def_filter:
	case isc_dyn_def_function:
	case isc_dyn_def_function_arg:
	case isc_dyn_def_generator:
	case isc_dyn_def_global_fld:
	case isc_dyn_def_idx:
	case isc_dyn_def_local_fld:
	case isc_dyn_def_rel:
	case isc_dyn_def_procedure:
	case isc_dyn_def_parameter:
	case isc_dyn_def_security_class:
	case isc_dyn_def_shadow:
	case isc_dyn_def_sql_fld:
	case isc_dyn_def_trigger:
	case isc_dyn_def_trigger_msg:
	case isc_dyn_def_view:
	case isc_dyn_delete_database:
	case isc_dyn_delete_dimensions:
	case isc_dyn_delete_filter:
	case isc_dyn_delete_function:
	case isc_dyn_delete_global_fld:
	case isc_dyn_delete_idx:
	case isc_dyn_delete_local_fld:
	case isc_dyn_delete_rel:
	case isc_dyn_delete_procedure:
	case isc_dyn_delete_parameter:
	case isc_dyn_delete_security_class:
	case isc_dyn_delete_trigger:
	case isc_dyn_delete_trigger_msg:
	case isc_dyn_delete_shadow:
	case isc_dyn_mod_exception:
	case isc_dyn_mod_global_fld:
	case isc_dyn_mod_idx:
	case isc_dyn_mod_local_fld:
	case isc_dyn_mod_procedure:
	case isc_dyn_mod_rel:
	case isc_dyn_mod_security_class:
	case isc_dyn_mod_trigger:
	case isc_dyn_mod_trigger_msg:
	case isc_dyn_rel_constraint:
	case isc_dyn_mod_view:
	case isc_dyn_grant:
	case isc_dyn_revoke:
	case isc_dyn_view_relation:
	case isc_dyn_def_sql_role:
		while (NEXT_BYTE != isc_dyn_end)
			PRINT_DYN_VERB;
		PRINT_DYN_VERB;
		return 0;
	}

	return 0;
}
示例#25
0
static int print_sdl_verb( ctl* control, SSHORT level)
{
	const char* p;

	SSHORT offset = control->ctl_blr - control->ctl_blr_start;
	const UCHAR sdl_operator = BLR_BYTE;

	if (sdl_operator > FB_NELEM(sdl_table) || sdl_operator <= 0 || !(p = sdl_table[sdl_operator]))
	{
		return error(control, offset, "*** SDL operator %d is undefined ***\n", (int) sdl_operator);
	}

	indent(control, level);
	blr_format(control, p);
	PUT_BYTE(',');
	PUT_BYTE(' ');
	++level;
	int n = 0;

	switch (sdl_operator)
	{
	case isc_sdl_begin:
		print_line(control, offset);
		while (NEXT_BYTE != isc_sdl_end)
			PRINT_SDL_VERB;
		PRINT_SDL_VERB;
		return 0;

	case isc_sdl_struct:
		n = print_byte(control);
		while (n--)
		{
			print_line(control, offset);
			indent(control, level + 1);
			offset = control->ctl_blr - control->ctl_blr_start;
			print_blr_dtype(control, true);
		}
		break;

	case isc_sdl_scalar:
		print_byte(control);

	case isc_sdl_element:
		n = print_byte(control);
		print_line(control, offset);
		while (n--)
			PRINT_SDL_VERB;
		return 0;

	case isc_sdl_field:
	case isc_sdl_relation:
		print_string(control, offset);
		break;

	case isc_sdl_fid:
	case isc_sdl_rid:
	case isc_sdl_short_integer:
		print_word(control);
		break;

	case isc_sdl_variable:
	case isc_sdl_tiny_integer:
		print_byte(control);
		break;

	case isc_sdl_long_integer:
		print_long(control);
		break;

	case isc_sdl_add:
	case isc_sdl_subtract:
	case isc_sdl_multiply:
	case isc_sdl_divide:
		print_line(control, offset);
		PRINT_SDL_VERB;
		PRINT_SDL_VERB;
		return 0;

	case isc_sdl_negate:
		print_line(control, offset);
		PRINT_SDL_VERB;
		return 0;

	case isc_sdl_do3:
		n++;
	case isc_sdl_do2:
		n++;
	case isc_sdl_do1:
		n += 2;
		print_byte(control);
		print_line(control, offset);
		while (n--)
			PRINT_SDL_VERB;
		return 0;
	}

	print_line(control, offset);

	return 0;
}
示例#26
0
int
main()
{
        MyPacket        Pkt,Pkt2;
        u8              buf[MAXPKTSIZE];
        int             i;
 
        /*
         * Fill in a packet
         */
 
        for (i = 0; i < INTARRAYSIZE; i++)
                Pkt.myInts[i] = i * 11 + 5;
 
        /*
         * Set the first, second and 4th bits
         */
 
        Pkt.myFlags = 0;
        Pkt.myFlags |= (1 << 0);
        Pkt.myFlags |= (1 << 1);
        Pkt.myFlags |= (1 << 3);
 
        /*
         * Set the myName string
         */
 
        Pkt.myName = calloc(1, 256);
        strcpy(Pkt.myName, "Mister Z");
 
        /*
         * Encode Pkt into DER
         */
 
        i = Encode_DER_Packet(&Pkt, buf);
 
        /*
         * Decode DER data to Pkt2
         */
 
        i = Decode_DER_Packet(buf,&Pkt2);
 
        /*
         * Display contents of Pkt2
         */
 
        printf("\n\nStructure Pkt2: \n");
        printf("\nMyFlags : ");
        print_byte(Pkt2.myFlags);
        printf("\nMyName  : %s", Pkt2.myName);
        printf("\nMyInts  : ");
        for (i=0;i<INTARRAYSIZE;i++)
                printf("%d ",Pkt2.myInts[i]);
 
        printf("\n");
 
        if (Pkt.myName)
          free (Pkt.myName);
 
        if (Pkt2.myName)
          free (Pkt2.myName);
 
        return 0;
}
void wav2c(FILE *in, FILE *out, FILE *outh)
{
	uint32_t header[5];
	int16_t format, channels, bits;
	uint32_t rate;
	uint32_t i, length, padlength=0, arraylen;
	int32_t audio=0;

	// read the WAV file's header
	for (i=0; i<5; i++) {
		header[i] = read_uint32(in);
	}
	if (header[0] != 0x46464952 || header[2] != 0x45564157
	  || header[3] != 0x20746D66 || header[4] != 0x00000010) {
		 die("error in format of file %s", filename);
	}

	// read the audio format parameters
	format = read_int16(in);
	channels = read_int16(in);
	rate = read_uint32(in);
	read_uint32(in); // ignore byterate
	read_int16(in);  // ignore blockalign
	bits = read_int16(in);
	//printf("format: %d, channels: %d, rate: %d, bits %d\n", format, channels, rate, bits);
	if (format != 1)
		die("file %s is compressed, only uncompressed supported", filename);
	if (rate != 44100 && rate != 22050 && rate != 11025 /*&& rate != 8000*/ )
		die("sample rate %d in %s is unsupported\n"
		  "Only 44100, 22050, 11025 work", rate, filename);
	if (channels != 1 && channels != 2)
		die("file %s has %d channels, but only 1 & 2 are supported", filename, channels);
	if (bits != 16)
		die("file %s has %d bit format, but only 16 is supported", filename, bits);

	// read the data header, skip non-audio data
	while (1) {
		header[0] = read_uint32(in);
		length = read_uint32(in);
		if (header[0] == 0x61746164) break; // beginning of actual audio data
		// skip over non-audio data
		for (i=0; i < length; i++) {
			read_uint8(in);
		}
	}

	// the length must be a multiple of the data size
	if (channels == 2) {
		if (length % 4) die("file %s data length is not a multiple of 4", filename);
		length = length / 4;
	}
	if (channels == 1) {
		if (length % 1) die("file %s data length is not a multiple of 2", filename);
		length = length / 2;
	}
	if (length > 0xFFFFFF) die("file %s data length is too long", filename);
	bcount = 0;

	// AudioPlayMemory requires padding to 2.9 ms boundary (128 samples @ 44100)
	if (rate == 44100) {
		padlength = padding(length, 128);
		format = 1;
	} else if (rate == 22050) {
		padlength = padding(length, 64);
		format = 2;
	} else if (rate == 11025) {
		padlength = padding(length, 32);
		format = 3;
	}
	if (pcm_mode) {
		arraylen = ((length + padlength) * 2 + 3) / 4 + 1;
		format |= 0x80;
	} else {
		arraylen = (length + padlength + 3) / 4 + 1;
	}
	total_length += arraylen;

	// output a minimal header, just the length, #bits and sample rate
	fprintf(outh, "extern const unsigned int AudioSample%s[%d];\n", samplename, arraylen);
	fprintf(out, "// Converted from %s, using %d Hz, %s encoding\n", filename, rate,
	  (pcm_mode ? "16 bit PCM" : "u-law"));
	fprintf(out, "const unsigned int AudioSample%s[%d] = {\n", samplename, arraylen);
	fprintf(out, "0x%08X,", length | (format << 24));
	wcount = 1;

	// finally, read the audio data
	while (length > 0) {
		if (channels == 1) {
			audio = read_int16(in);
		} else {
			audio = read_int16(in);
			audio += read_int16(in);
			audio /= 2;
		}
		if (pcm_mode) {
			print_byte(out, audio);
			print_byte(out, audio >> 8);
		} else {
			print_byte(out, ulaw_encode(audio));
		}
		length--;
	}