/* * Check for zip drive. */ int is_zip(hd_t *hd) { if( hd->base_class.id == bc_storage_device && ( hd->sub_class.id == sc_sdev_disk || hd->sub_class.id == sc_sdev_floppy ) ) { if( ( contains_word(hd->vendor.name, "IOMEGA") || contains_word(hd->sub_vendor.name, "IOMEGA") || contains_word(hd->device.name, "IOMEGA") || contains_word(hd->sub_device.name, "IOMEGA") ) && ( contains_word(hd->device.name, "ZIP") || contains_word(hd->sub_device.name, "ZIP") ) ) { return 1; } } return 0; }
bool two_argument( const char*& argument, const char* word, char* arg ) { int i; if( ( i = count( argument ) ) < 2 ) return FALSE; if( i == 2 ) { argument = one_argument( argument, arg ); return TRUE; } return( contains_word( argument, word, arg ) && *argument != '\0' && *arg != '\0' ); }
void handle_input(int connfd, char* ptr){ char sendBuff[5000]; printf("ptr on %s", ptr); if(contains_word(ptr, "send")){ printf("User wants to send something \n"); int bytes = get_bytes(ptr, 5); snprintf(sendBuff, sizeof(sendBuff), "Please send %d bytes data now.\n", bytes); write(connfd, sendBuff, strlen(sendBuff)); char* datapointer = malloc(bytes); read_data(connfd, bytes, datapointer); } else { printf("Not defined command\n"); } }
void do_label( char_data* ch, char* argument ) { char arg [ MAX_INPUT_LENGTH ]; obj_data* obj; char* label; bool remove; remove = !contains_word( argument, "as", arg ); if( *argument == '\0' || ( !remove && *arg == '\0' ) ) { send( ch, "Label what item and as what?\r\n" ); return; } if( ( obj = one_object( ch, remove ? argument : arg, "label", &ch->contents ) ) == NULL ) return; if( remove ) { if( obj->label == empty_string ) { send( ch, "%s isn't labeled.\r\n", obj ); return; } free_string( obj->label, MEM_OBJECT ); obj->label = empty_string; send( ch, "You remove the label from %s.\r\n", obj ); return; } if( obj->pIndexData->item_type != ITEM_CONTAINER ) { send( ch, "You may only label containers.\r\n" ); return; } if( ( label = obj->label ) != empty_string ) { obj->label = empty_string; send( ch, "%s is already labeled as '%s'.\r\n", obj, label ); obj->label = label; return; } if( !valid_label( ch, argument ) ) return; if( obj->number > 1 ) { obj->number--; obj = duplicate( obj ); } if( obj->label == empty_string ) { send( ch, "You label %s '%s'.\r\n", obj, argument ); } else { free_string( obj->label, MEM_OBJECT ); obj->label = empty_string; fsend( ch, "You remove the old label from %s and replace it with '%s'.\r\n", obj, argument ); } obj->label = alloc_string( argument, MEM_OBJECT ); if( obj->array == NULL ) obj->To( ch ); consolidate( obj ); }