示例#1
0
static void display_iface(struct ifreq *ifreq)
{
    int ret;

    ioctl(netdev_fd, SIOCGIFINDEX, ifreq);
    printf("%s: ", ifreq->ifr_name);

    ret = ioctl(netdev_fd, SIOCGIFFLAGS, ifreq);
    if (!ret)
        display_flags(ifreq->ifr_flags);

    ret = ioctl(netdev_fd, SIOCGIFADDR, ifreq);
    if (!ret)
        display_addr(&ifreq->ifr_addr);

    ret = ioctl(netdev_fd, SIOCGIFNETMASK, ifreq);
    if (!ret)
        display_netmask(&ifreq->ifr_netmask);

    ret = ioctl(netdev_fd, SIOCGIFHWADDR, ifreq);
    if (!ret)
        display_hwaddr(&ifreq->ifr_hwaddr);

    printf("\n");
}
示例#2
0
int main(int argc, char *argv[]) {
    display_flags("O_RDONLY\t\t", O_RDONLY);
    display_flags("O_WRONLY\t\t", O_WRONLY);
    display_flags("O_RDWR\t\t\t", O_RDWR);
    printf("\n");
    display_flags("O_APPEND\t\t", O_APPEND);
    display_flags("O_TRUNC\t\t\t", O_TRUNC);
    display_flags("O_CREAT\t\t\t", O_CREAT);
    printf("\n");
    display_flags("O_WRONLY|O_APPEND|O_CREAT", O_WRONLY|O_APPEND|O_CREAT);
}
示例#3
0
void do_dflag( char_data* ch, char* argument )
{
  wizard_data*   imm  = (wizard_data*) ch; 
  exit_data*    exit;
  exit_data*    back;
  int          flags;

  if( !get_flags( ch, argument, &flags, "1", "dflag" ) )
    return;

  if( ( exit = imm->exit_edit ) == NULL ) {
    send( ch, "Use dedit to specify direction.\n\r" );
    return;
    }

  if( *argument == '\0' ) {
    display_flags( "Door Flags", &dflag_name[0], &dflag_name[1],
      &exit->exit_info, MAX_DFLAG, ch );
    return;
    }

  if( !can_edit( ch, ch->in_room ) ) 
    return;

  ch->in_room->area->modified = TRUE;

  for( int i = 0; i < MAX_DFLAG; i++ ) 
    if( fmatches( argument, dflag_name[i] ) ) {
      switch_bit( &exit->exit_info, i );
      if( ( back = reverse( exit ) ) != NULL
        && !is_set( &flags, 0 ) )
        assign_bit( &back->exit_info, i, is_set( &exit->exit_info,i ) );
      send( ch, "%s set %s on %sthe %s exit.\n\r",
        dflag_name[i], true_false( &exit->exit_info, i ),
        back != NULL && !is_set( &flags, 0 ) ? "both sides of " : "",
        dir_table[ exit->direction ].name );
      return;
      }

  send( ch, "Unknown flag - see dflag with no arguments for list.\n\r" );
}