void i2a( int num, char *bf ) { if( num < 0 ) { num = -num; *bf++ = '-'; } ui2a( num, 10, bf ); }
static void i2a(long long int num, struct param *p) { if (num < 0) { num = -num; p->sign = 1; } ui2a(num, p); }
static void i2a(int num, struct param *p) { if(num < 0) { num = -num; p->sign = '-'; } ui2a(num, p); }
void switches_init() { int i; for (i = 0; i < NUM_SWITCHES + NUM_AUXILLARY_SWITCHES; ++i) { switches[i] = 0; } char command[1024]; char *pos = &command[0]; pos += sprintf(pos, "\0337\033[%u;%uH", SWITCH_TABLE_HEIGHT, 1); pos += sprintf(pos, "Switches: "); pos += sprintf(pos, "\033[%u;%uH", SWITCH_TABLE_HEIGHT + 1, 1); // Draw Regular Switches. for (i = 0; i < NUM_SWITCHES; ++i) { char num[4]; ui2a(i + 1, 10, num); pos += sputw(pos, 4, ' ', num); } // Draw Auxillary Switches. for (i = 0; i < AUXILLARY_SWITCH_COUNT; ++i) { char num[4]; ui2a(AUXILLARY_SWITCH_BASE + i, 10, num); pos += sputw(pos, 4, ' ', num); } pos += sprintf(pos, "\033[%u;%uH", SWITCH_TABLE_HEIGHT + 2, 1); // Draw States. for (i = 0; i < NUM_SWITCHES + AUXILLARY_SWITCH_COUNT; ++i) { pos += sputw(pos, 4, ' ', "?"); } pos += sprintf(pos, "\0338"); Write(COM2, command, pos - command); }