int InternalSendSetup( ibConf_t *conf, const Addr4882_t addressList[] ) { int i; ibBoard_t *board; uint8_t *cmd; int count; if( addressListIsValid( addressList ) == 0 || numAddresses( addressList ) == 0 ) { setIberr( EARG ); return -1; } if( conf->is_interface == 0 ) { setIberr( EDVR ); return -1; } board = interfaceBoard( conf ); if( is_cic( board ) == 0 ) { setIberr( ECIC ); return -1; } cmd = malloc( 16 + 2 * numAddresses( addressList ) ); if( cmd == NULL ) { setIberr( EDVR ); setIbcnt( ENOMEM ); return -1; } i = create_send_setup( board, addressList, cmd ); //XXX detect no listeners (EBUS) error count = my_ibcmd( conf, cmd, i ); free( cmd ); cmd = NULL; if(count != i) { return -1; } return 0; }
void PPollUnconfig( int boardID, const Addr4882_t addressList[] ) { ibConf_t *conf; int retval; conf = enter_library( boardID ); if( conf == NULL ) { exit_library( boardID, 1 ); return; } if( conf->is_interface == 0 ) { setIberr( EDVR ); exit_library( boardID, 1 ); return; } if( addressListIsValid( addressList ) == 0 ) { setIberr( EARG ); exit_library( boardID, 1 ); return; } if( numAddresses( addressList ) ) { retval = ppoll_configure_device( conf, addressList, PPD ); }else { uint8_t cmd = PPU; retval = my_ibcmd( conf, &cmd, 1 ); } if( retval < 0 ) { exit_library( boardID, 1 ); return; } exit_library( boardID, 0 ); }
int KMobileGnokii::readAddress( int index, KABC::Addressee &addr ) { PRINT_DEBUG << QString("############ GET ADDRESS #%1\n").arg(index); // index is zero-based, but in gnokii the first address starts at 1 if (index<0 || index>=numAddresses()) return KIO::ERR_DOES_NOT_EXIST; // now get our addressbook entry // do we have this entry in the cache already ? if (m_addrList.count() > (unsigned)index && !m_addrList[index].isEmpty()) { addr = m_addrList[index]; return 0; } gn_error err = read_phone_entry_highlevel(index+1, GN_MT_ME, &addr ); if (!err) m_addrList[index] = addr; return gn_error2kio_error(err); }
unsigned int create_send_setup( const ibBoard_t *board, const Addr4882_t addressList[], uint8_t *cmdString ) { unsigned int i, j; unsigned int board_pad; int board_sad; if( addressList == NULL ) { fprintf(stderr, "libgpib: bug! addressList NULL in create_send_setup()\n"); return 0; } if( addressListIsValid( addressList ) == 0 ) { fprintf(stderr, "libgpib: bug! bad address list\n"); return 0; } i = 0; /* controller's talk address */ if(query_pad(board, &board_pad) < 0) return 0; cmdString[i++] = MTA(board_pad); if(query_sad(board, &board_sad) < 0) return 0; if(board_sad >= 0 ) cmdString[i++] = MSA(board_sad); cmdString[ i++ ] = UNL; for( j = 0; j < numAddresses( addressList ); j++ ) { unsigned int pad; int sad; pad = extractPAD( addressList[ j ] ); sad = extractSAD( addressList[ j ] ); cmdString[ i++ ] = MLA( pad ); if( sad >= 0) cmdString[ i++ ] = MSA( sad ); } return i; }
int ppoll_configure_device( ibConf_t *conf, const Addr4882_t addressList[], int ppc_configuration ) { uint8_t *cmd; int i; int retval; if( is_cic( interfaceBoard( conf ) ) == 0 ) { setIberr( ECIC ); return -1; } cmd = malloc( 16 + 2 * numAddresses( addressList ) ); if( cmd == NULL ) { setIberr( EDVR ); setIbcnt( ENOMEM ); return -1; } i = create_send_setup( interfaceBoard( conf ), addressList, cmd ); cmd[ i++ ] = PPC; cmd[ i++ ] = ppc_configuration; retval = my_ibcmd( conf, cmd, i ); free( cmd ); cmd = NULL; if( retval < 0 ) { return -1; } return 0; }