static void printoptionnodestate(HashNode hn, int hadplus) { Optname on = (Optname) hn; int optno = on->optno; if (hadplus) { if (defset(on) != isset(optno)) printf("set -o %s%s\n", defset(on) ? "no" : "", on->nam); } else { if (defset(on)) printf("no%-19s %s\n", on->nam, isset(optno) ? "off" : "on"); else printf("%-21s %s\n", on->nam, isset(optno) ? "on" : "off"); } }
static void printoptionnode(HashNode hn, int set) { Optname on = (Optname) hn; int optno = on->optno; if (optno < 0) optno = -optno; if (isset(KSHOPTIONPRINT)) { if (defset(on, emulation)) printf("no%-19s %s\n", on->node.nam, isset(optno) ? "off" : "on"); else printf("%-21s %s\n", on->node.nam, isset(optno) ? "on" : "off"); } else if (set == (isset(optno) ^ defset(on, emulation))) { if (set ^ isset(optno)) fputs("no", stdout); puts(on->node.nam); } }
static void setemulate(HashNode hn, int fully) { Optname on = (Optname) hn; /* Set options: each non-special option is set according to the * * current emulation mode if either it is considered relevant * * to emulation or we are doing a full emulation (as indicated * * by the `fully' parameter). */ if (!(on->node.flags & OPT_ALIAS) && ((fully && !(on->node.flags & OPT_SPECIAL)) || (on->node.flags & OPT_EMULATE))) setemulate_opts[on->optno] = defset(on, setemulate_emulation); }
void emulate(const char *zsh_name, int fully) { int optno; /* Work out the new emulation mode */ if(!strcmp(zsh_name, "csh")) emulation = EMULATE_CSH; else if(!strcmp(zsh_name, "ksh")) emulation = EMULATE_KSH; else if(!strcmp(zsh_name, "sh")) emulation = EMULATE_SH; else emulation = EMULATE_ZSH; /* Set options: each non-special option is set according to the * * current emulation mode if either it is considered relevant * * to emulation or we are doing a full emulation (as indicated * * by the `fully' parameter). */ for(optno = OPT_SIZE; --optno; ) if((fully && !(optns[optno].flags & OPT_SPECIAL)) || (optns[optno].flags & OPT_EMULATE)) opts[optno] = defset(optno); }
int main(){ unsigned char messageBuf[TWI_BUFFER_SIZE]; unsigned char TWI_slaveAddress; // Own TWI slave address TWI_slaveAddress = 0x20; InitIO(); defset(); InitTimer(); OSCCAL=0xA8; // wdt_reset(); /* Write logical one to WDCE and WDE */ // WDTCR = (1<<WDCE) | (1<<WDE) | (2<<WDP0); // WDTCR = (1<<WDE) | (2<<WDP0); TIMING=eeprom_read_word(&EETIMING); TWI_Slave_Initialise( (unsigned char)((TWI_slaveAddress<<TWI_ADR_BITS) | (FALSE<<TWI_GEN_BIT) )); sei(); TWI_Start_Transceiver(); while (1){ // Check if the TWI Transceiver has completed an operation. if ( ! TWI_Transceiver_Busy() ) { // Check if the last operation was successful if ( TWI_statusReg.lastTransOK ) { // Check if the last operation was a reception if ( TWI_statusReg.RxDataInBuf ) { PORTB^=1<<PB3; TWI_Get_Data_From_Transceiver(messageBuf, 2); // Check if the last operation was a reception as General Call if ( TWI_statusReg.genAddressCall ) { // Put data received out to PORTB as an example. // PORTB = messageBuf[0]; } else // Ends up here if the last operation was a reception as Slave Address Match { // Example of how to interpret a command and respond. switch (messageBuf[0]){ case xval: OCR1A=255-messageBuf[1]; break; case yval: OCR1B=255-messageBuf[1]; break; // TWI_Start_Transceiver_With_Data( messageBuf, 1 ); } } } else // Ends up here if the last operation was a transmission { // __no_operation(); // Put own code here. } // Check if the TWI Transceiver has already been started. // If not then restart it to prepare it for new receptions. if ( ! TWI_Transceiver_Busy() ) { TWI_Start_Transceiver(); } } else // Ends up here if the last operation completed unsuccessfully { TWI_Act_On_Failure_In_Last_Transmission( TWI_Get_State_Info() ); } } } }