示例#1
0
void do_cmdline(int ac, char *av[])
{
    int i;

    for (i=1;i<ac;i++)
        {
        if (valid_drive((av[i])=strupr(av[i])))
            {
            if (*Drive == '?')
                {
                *Drive = *av[i];        /* Save the drive letter. */
                } /* end if. */
            else
                {
                myprintf("There were multiple drives mentioned.\r\n",0);
                myprintf("Please select one drive to label at a time.\r\n",0);
                exit(26);
                } /* end if. */

            /* See if the drive letter is the first parameter. */
            if (i != 1)
                DriveNotFirst = 1;

            /* See if the label is tacked right onto the drive letter. */
            /* Verify label if it is. */
            if (valid_label(av[i]))
                return;

            } /* end if. */
        else
            {
            if (check_label(av[i]))
                return;
            else
                save_label(av[i]);

            } /* end else. */

        } /* end for. */

    if (check_quotes())
        {
        strcpy(Label,"");
        myprintf("Invalid label\r\n",0);
        return;
        } /* end if. */

} /* end process_cmdline. */
示例#2
0
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 );
}