Exemple #1
0
/*
 *  Reset USB Device Endpoint
 *    Parameters:      EPNum: Device Endpoint Number
 *                       EPNum.0..3: Address
 *                       EPNum.7:    Dir
 *    Return Value:    None
 */
void USBD_ResetEP (U32 EPNum)
{
    ep_buffer_t *desc = get_desc(EPNum);

    EPNum &= EPNUM_MASK;
    MXC_USB->ep[EPNum] |= MXC_F_USB_EP_DT;

    if (ep_info[EPNum].type == MXC_S_USB_EP_DIR_OUT) {
        // This is an OUT endpoint. Go ahead and register a request.
        desc = get_desc(EPNum);
        desc->buf0_address = (uint32_t)ep_buffer[EPNum];
        desc->buf0_desc = sizeof(ep_buffer[EPNum]);
        MXC_USB->out_owner = (1 << EPNum);
    }
}
Exemple #2
0
D*
mad_desc_newk(int nv, const ord_t var_ords[nv], const ord_t map_ords_[nv], str_t var_nam_[nv],
              int nk, const ord_t knb_ords[nk], ord_t dk)
{
  // input validation
  ensure(nv && var_ords);
  // ensure(nk && knb_ords);
  ensure(dk <= mad_mono_ord(nk,knb_ords));
  ensure(mad_mono_ord(nv,var_ords) + mad_mono_ord(nk,knb_ords) < desc_max_order);

  ord_t map_ords[nv];  // to parse optional param
  if (map_ords_) {
    for (int i = 0; i < nv; ++i)
      ensure(var_ords[i] <= map_ords_[i]);
    mad_mono_copy(nv,map_ords_,map_ords);
  }
  else {
    ord_t mo = mad_mono_max(nv,var_ords);
    mad_mono_fill(nv,map_ords,mo);
  }
  if (dk == 0) dk = mad_mono_max(nk,knb_ords);
  ensure(dk <= mad_mono_max(nv,map_ords));

  ord_t ords[nv+nk];
  int oidx = 0;
  for (int i = 0; i < nv; ++i)
    ords[oidx++] = var_ords[i];
  for (int i = 0; i < nk; ++i) {
    ensure(knb_ords[i] != 0);
    ords[oidx++] = knb_ords[i];
  }
  return get_desc(nv,map_ords,var_nam_, nv+nk,ords, dk);
}
Exemple #3
0
int blk_list_part(enum if_type if_type)
{
	struct blk_driver *drv;
	struct blk_desc *desc;
	int devnum, ok;
	bool first = true;

	drv = blk_driver_lookup_type(if_type);
	if (!drv)
		return -ENOSYS;
	for (ok = 0, devnum = 0; devnum < drv->max_devs; ++devnum) {
		if (get_desc(drv, devnum, &desc))
			continue;
		if (desc->part_type != PART_TYPE_UNKNOWN) {
			++ok;
			if (!first)
				putc('\n');
			part_print(desc);
			first = false;
		}
	}
	if (!ok)
		return -ENODEV;

	return 0;
}
Exemple #4
0
void
idntfy(void)
{
    short ch;
    object *obj;
    struct id *id_table;
    char desc[ROGUE_COLUMNS];
AGAIN:
    ch = pack_letter(mesg[260], ALL_OBJECTS);
    if (ch == CANCEL) {
	return;
    }
    if (!(obj = get_letter_object(ch))) {
	message(mesg[261], 0);
	message("", 0);
	check_message();
	goto AGAIN;
    }
    obj->identified = 1;
    if (obj->what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING)) {
	id_table = get_id_table(obj);
	id_table[obj->which_kind].id_status = IDENTIFIED;
    }
    get_desc(obj, desc, 1);
    message(desc, 0);
}
Exemple #5
0
int main() {
	srand(0); //seed generator with 0 for debugging
	dungeon *game = generate_dungeon(10, 20);

	tutorial(game);

	for(;;) {
		set_stage(game);
		get_desc(game);

		switch(input("", I_CHAR)) {
			case 'q': goto END_GAME;
			case 'n': move(game, D_NORTH); break;
			case 's': move(game, D_SOUTH); break;
			case 'e': move(game, D_EAST); break;
			case 'w': move(game, D_WEST); break;
			case 'i': action(game, A_INVENTORY); break;
			case 'd': action(game, A_DROP); break;
			case 'l': action(game, A_LOOT); break;
			case 'p': action(game, A_PUTON); break;
			case 'a': action(game, A_ARM); break;
			case 'c': action(game, A_CONSUME); break;
			case 'f': fight(game); break;
			case 'h': help(); break;
			case 'r': reflect(&(game->player)); break;
			case 'z': dump_dungeon(game); break;
			default: printf("Invalid Command!\n");
		}
	}
	END_GAME:
	return 0;
}
Exemple #6
0
void identify_item( short ichar )
{
	short ch = 0 ;
	object *obj;
	struct id *id_table;
	char desc[DCOLS];

	if( ichar ) ch = ichar ;

    while( !ch ) /* Until valid input is given...*/
    {
		ch = pack_letter( "What would you like to identify?", ALL_OBJECTS ) ;
 
		if( ch == ROGUE_KEY_CANCEL )
		{
			return ;
		}
		if( !(obj = get_letter_object(ch)) )
		{
			message( "No such item. Try again.", 0 ) ;
			message( "", 0 ) ;
			check_message() ;
			ch = 0 ;
		}
	}

	obj->identified = 1;
	if (obj->what_is & (SCROLL | POTION | WEAPON | ARMOR | WAND | RING))
	{
		id_table = get_id_table(obj);
		id_table[obj->which_kind].id_status = IDENTIFIED;
	}
	get_desc( obj, desc, 1 ) ;
	message(desc, 0);
}
size_t get_phys_addrs(
    pid_t target,
    unsigned long virt_addr_start,
    unsigned long virt_addr_end,
    unsigned long *phys_addr,
    size_t num_addr)
{
    FILE *pmap;
    size_t pagesize = getpagesize();
    unsigned long phys_page_num;
    unsigned long offset_in_page;
    uint64_t page_desc;
    unsigned long virt_addr;
    size_t count = 0;

    pmap = open_pagemap(target);
    if (!pmap) {
        perror("fopen");
        return 0;
    }

    virt_addr = virt_addr_start;
    while (virt_addr < virt_addr_end && count < num_addr) {
        offset_in_page = virt_addr % pagesize;
        page_desc = get_desc(pmap, pagesize, virt_addr);
        phys_page_num = page_desc & PFN_MASK;
        phys_addr[count++] = (phys_page_num * pagesize) + offset_in_page;
        virt_addr += pagesize;
    }


    fclose(pmap);
    return count;
}
Exemple #8
0
static void
idntfy(void)
{
	short ch;
	object *obj;
	struct id *id_table;
	char desc[DCOLS];
AGAIN:
	ch = pack_letter("what would you like to identify?", ALL_OBJECTS);

	if (ch == CANCEL) {
		return;
	}
	if (!(obj = get_letter_object(ch))) {
		message("no such item, try again", 0);
		message("", 0);
		check_message();
		goto AGAIN;
	}
	obj->identified = 1;
	if (obj->what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING)) {
		id_table = get_id_table(obj);
		id_table[obj->which_kind].id_status = IDENTIFIED;
	}
	get_desc(obj, desc);
	message(desc, 0);
}
/// Set the new value of the specified resource limit. This function does _not_ multiply the limit
// value by the multiplier constant used by the commandline ulimit.
static int set(int resource, int hard, int soft, rlim_t value, io_streams_t &streams) {
    struct rlimit ls;
    getrlimit(resource, &ls);

    if (hard) {
        ls.rlim_max = value;
    }

    if (soft) {
        ls.rlim_cur = value;

        // Do not attempt to set the soft limit higher than the hard limit.
        if ((value == RLIM_INFINITY && ls.rlim_max != RLIM_INFINITY) ||
            (value != RLIM_INFINITY && ls.rlim_max != RLIM_INFINITY && value > ls.rlim_max)) {
            ls.rlim_cur = ls.rlim_max;
        }
    }

    if (setrlimit(resource, &ls)) {
        if (errno == EPERM)
            streams.err.append_format(
                L"ulimit: Permission denied when changing resource of type '%ls'\n",
                get_desc(resource));
        else
            builtin_wperror(L"ulimit", streams);
        return 1;
    }
    return 0;
}
Exemple #10
0
static int pv_desc(sip_msg_t* msg, pv_param_t* param, pv_value_t* res)
{
	if (get_desc(&res->rs, msg) < 0) {
		return pv_get_null(msg, param, res);
	}
	res->flags = PV_VAL_STR;
	return 0;
}
Exemple #11
0
void input_context::display_help()
{
    // Shamelessly stolen from help.cpp
    WINDOW *w_help = newwin(FULL_SCREEN_HEIGHT - 2, FULL_SCREEN_WIDTH - 2,
                            1 + (int)((TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0),
                            1 + (int)((TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0));

    werase(w_help);

    // Draw win header and borders
    draw_border(w_help, c_white);
    mvwprintz(w_help, 0, (FULL_SCREEN_WIDTH - utf8_width(_("Keybindings"))) / 2 - 1,
              c_ltred, " %s ", _("Keybindings"));
    mvwprintz(w_help, 1, 51, c_ltred, _("Unbound keys"));
    mvwprintz(w_help, 2, 51, c_ltgreen, _("Keybinding active only"));
    mvwprintz(w_help, 3, 51, c_ltgreen, _("on this screen"));
    mvwprintz(w_help, 4, 51, c_ltgray, _("Keybinding active globally"));

    // Clear the lines. Don't touch borders
    for (int i = 1; i < FULL_SCREEN_HEIGHT - 3; i++) {
        mvwprintz(w_help, i, 1, c_black, "                                               ");
    }

    for (int i = 0; i < registered_actions.size(); i++) {
        const std::string &action_id = registered_actions[i];
        if(action_id == "ANY_INPUT") {
            continue;
        }

        bool overwrite_default;
        const std::vector<input_event> &input_events = inp_mngr.get_input_for_action(action_id, category,
                &overwrite_default);

        nc_color col = input_events.size() ? c_white : c_ltred;
        mvwprintz(w_help, i, 3, col, "%s: ", inp_mngr.get_action_name(action_id).c_str());

        if (!input_events.size()) {
            mvwprintz(w_help, i, 30, c_ltred, _("Unbound!"));
        } else {
            // The color depends on whether this input draws from context-local or from
            // default settings. Default will be ltgray, overwrite will be ltgreen.
            col = overwrite_default ? c_ltgreen : c_ltgray;

            mvwprintz(w_help, i, 30, col, "%s", get_desc(action_id).c_str());
        }
    }
    wrefresh(w_help);
    refresh();

    long ch = getch();
    while (ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE) {
        ch = getch();
    };

    werase(w_help);
    wrefresh(w_help);
    delwin(w_help);
}
Exemple #12
0
struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
{
	struct blk_driver *drv = blk_driver_lookup_type(if_type);
	struct blk_desc *desc;

	if (!drv)
		return NULL;

	if (get_desc(drv, devnum, &desc))
		return NULL;

	return desc;
}
Exemple #13
0
struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
{
	struct blk_driver *drv = blk_driver_lookup_typename(if_typename);
	struct blk_desc *desc;

	if (!drv)
		return NULL;

	if (get_desc(drv, devnum, &desc))
		return NULL;

	return desc;
}
Exemple #14
0
int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
{
	struct blk_driver *drv = blk_driver_lookup_type(if_type);
	struct blk_desc *desc;
	int ret;

	if (!drv)
		return -ENOSYS;
	ret = get_desc(drv, devnum, &desc);
	if (ret)
		return ret;
	return drv->select_hwpart(desc, hwpart);
}
Exemple #15
0
void net_get(nut_ctype_t *client, int numarg, const char **arg)
{
	if (numarg < 2) {
		send_err(client, NUT_ERR_INVALID_ARGUMENT);
		return;
	}

	/* GET NUMLOGINS UPS */
	if (!strcasecmp(arg[0], "NUMLOGINS")) {
		get_numlogins(client, arg[1]);
		return;
	}

	/* GET UPSDESC UPS */
	if (!strcasecmp(arg[0], "UPSDESC")) {
		get_upsdesc(client, arg[1]);
		return;
	}

	if (numarg < 3) {
		send_err(client, NUT_ERR_INVALID_ARGUMENT);
		return;
	}

	/* GET VAR UPS VARNAME */
	if (!strcasecmp(arg[0], "VAR")) {
		get_var(client, arg[1], arg[2]);
		return;
	}

	/* GET TYPE UPS VARNAME */
	if (!strcasecmp(arg[0], "TYPE")) {
		get_type(client, arg[1], arg[2]);
		return;
	}

	/* GET DESC UPS VARNAME */
	if (!strcasecmp(arg[0], "DESC")) {
		get_desc(client, arg[1], arg[2]);
		return;
	}

	/* GET CMDDESC UPS CMDNAME */
	if (!strcasecmp(arg[0], "CMDDESC")) {
		get_cmddesc(client, arg[1], arg[2]);
		return;
	}

	send_err(client, NUT_ERR_INVALID_ARGUMENT);
	return;
}
Exemple #16
0
ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
		       lbaint_t blkcnt, const void *buffer)
{
	struct blk_driver *drv = blk_driver_lookup_type(if_type);
	struct blk_desc *desc;
	int ret;

	if (!drv)
		return -ENOSYS;
	ret = get_desc(drv, devnum, &desc);
	if (ret)
		return ret;
	return desc->block_write(desc, start, blkcnt, buffer);
}
int
main (int argc, char *argv[])
{
  int i;
  OrcOpcodeSet *opcode_set;

  orc_init();
  orc_test_init();
  
  printf(
"<!-- generated by " __FILE__ " -->\n"
"<table frame=\"all\" id=\"table-basictypes\" xreflabel=\"Table of Opcodes\">\n"
"<title>Table of Opcodes</title>\n"
"<tgroup cols=\"3\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n"
"<thead>\n"
"<row>\n"
"<entry>opcode</entry>\n"
"<entry>destination size</entry>\n"
"<entry>source 1 size</entry>\n"
"<entry>source 2 size</entry>\n"
"<entry>description</entry>\n"
"<entry>pseudo code</entry>\n"
"</row>\n"
"</thead>\n"
"<tbody valign=\"top\">\n");

  opcode_set = orc_opcode_set_get ("sys");

  for(i=0;i<opcode_set->n_opcodes;i++){
    printf("<row>\n");
    printf("<entry>%s</entry>\n", opcode_set->opcodes[i].name);
    printf("<entry>%d</entry>\n", opcode_set->opcodes[i].dest_size[0]);
    printf("<entry>%d</entry>\n", opcode_set->opcodes[i].src_size[0]);
    if (opcode_set->opcodes[i].src_size[1]) {
      printf("<entry>%d%s</entry>\n", opcode_set->opcodes[i].src_size[1],
          (opcode_set->opcodes[i].flags & ORC_STATIC_OPCODE_SCALAR) ? "S" : "");
    } else {
      printf("<entry></entry>\n");
    }
    printf("<entry>%s</entry>\n", get_desc(&opcode_set->opcodes[i]));
    printf("<entry>%s</entry>\n", get_code(&opcode_set->opcodes[i]));
    printf("</row>\n");
  }
  printf(
"</tbody>\n"
"</tgroup>\n"
"</table>\n");

  return 0;
}
int createCon(struct node* arg_head) {
    struct node* loc_head = arg_head; // -0x18(rbp)
    struct node* n = loc_head; // -0x08(rbp)
    int i = 0; // -0x0c(rbp)
    while(node->in_use && i <= 9) {
        node += sizeof(struct node);
        i++;
    }
    puts("Contact info: ");
    get_name(node);
    get_phone(node);
    get_desc(node);
    node->in_use = 1;
    con_cnt++;
    return con_cnt;
}
Exemple #19
0
int blk_print_device_num(enum if_type if_type, int devnum)
{
	struct blk_driver *drv = blk_driver_lookup_type(if_type);
	struct blk_desc *desc;
	int ret;

	if (!drv)
		return -ENOSYS;
	ret = get_desc(drv, devnum, &desc);
	if (ret)
		return ret;
	printf("\n%s device %d: ", drv->if_typename, devnum);
	dev_print(desc);

	return 0;
}
Exemple #20
0
int blk_print_part_devnum(enum if_type if_type, int devnum)
{
	struct blk_driver *drv = blk_driver_lookup_type(if_type);
	struct blk_desc *desc;
	int ret;

	if (!drv)
		return -ENOSYS;
	ret = get_desc(drv, devnum, &desc);
	if (ret)
		return ret;
	if (desc->type == DEV_TYPE_UNKNOWN)
		return -ENOENT;
	part_print(desc);

	return 0;
}
Exemple #21
0
void blk_list_devices(enum if_type if_type)
{
	struct blk_driver *drv = blk_driver_lookup_type(if_type);
	struct blk_desc *desc;
	int i;

	if (!drv)
		return;
	for (i = 0; i < drv->max_devs; ++i) {
		if (get_desc(drv, i, &desc))
			continue;
		if (desc->type == DEV_TYPE_UNKNOWN)
			continue;  /* list only known devices */
		printf("Device %d: ", i);
		dev_print(desc);
	}
}
Exemple #22
0
/*
 *  Read USB Device Endpoint Data
 *    Parameters:      EPNum: Device Endpoint Number
 *                       EPNum.0..3: Address
 *                       EPNum.7:    Dir
 *                     pData: Pointer to Data Buffer
 *    Return Value:    Number of bytes read
 */
U32 USBD_ReadEP (U32 EPNum, U8 *pData, U32 size)
{
    U32 cnt;
    ep_buffer_t *desc = get_desc(EPNum);
    USB_SETUP_PACKET *sup;

    EPNum &= EPNUM_MASK;

    if ((EPNum == 0) && setup_waiting) {
        cnt = USBD_MAX_PACKET0;

        if (size < cnt) {
            cnt = size;
        }
        setup_waiting = 0;
        memcpy(pData, (void*)&MXC_USB->setup0, cnt);
        sup = (USB_SETUP_PACKET*)pData;

        if ( (sup->bmRequestType.Dir == REQUEST_HOST_TO_DEVICE) && (sup->wLength > 0) ) {
            // There is an OUT stage for this setup packet. Register a request.
            if (!(MXC_USB->out_owner & 1)) {
                desc = &ep_buffer_descriptor.ep0.out_buffer;
                desc->buf0_address = (uint32_t)ep_buffer[0];
                desc->buf0_desc = sup->wLength;
                MXC_USB->out_owner = 1;
            }
        }
    } else {
        cnt = desc->buf0_desc;

        if (size < cnt) {
            cnt = size;
        }
        memcpy(pData, ep_buffer[EPNum], cnt);

        // Register the next request.
        desc->buf0_address = (uint32_t)ep_buffer[EPNum];
        desc->buf0_desc = sizeof(ep_buffer[EPNum]);
        MXC_USB->out_owner = (1 << EPNum);
    }

    return cnt;
}
Exemple #23
0
D*
mad_desc_new(int nv, const ord_t var_ords[nv], const ord_t map_ords_[nv], str_t var_nam_[nv])
{
  ensure(var_ords);
  ord_t mo, map_ords[nv];  // to parse optional param

  if (map_ords_) {
    for (int i = 0; i < nv; ++i) ensure(var_ords[i] <= map_ords_[i]);
    mad_mono_copy(nv,map_ords_,map_ords);
    mo = mad_mono_max(nv,map_ords);
  }
  else {
    mo = mad_mono_max(nv,var_ords);
    mad_mono_fill(nv,map_ords,mo);
  }
  ensure(mo < desc_max_order);

  return get_desc(nv,map_ords,var_nam_, nv,var_ords, 0);
}
Exemple #24
0
ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
		      lbaint_t blkcnt, void *buffer)
{
	struct blk_driver *drv = blk_driver_lookup_type(if_type);
	struct blk_desc *desc;
	ulong n;
	int ret;

	if (!drv)
		return -ENOSYS;
	ret = get_desc(drv, devnum, &desc);
	if (ret)
		return ret;
	n = desc->block_read(desc, start, blkcnt, buffer);
	if (IS_ERR_VALUE(n))
		return n;

	return n;
}
Exemple #25
0
/*
 *  Write USB Device Endpoint Data
 *    Parameters:      EPNum: Endpoint Number
 *                       EPNum.0..3: Address
 *                       EPNum.7:    Dir
 *                     pData: Pointer to Data Buffer
 *                     cnt:   Number of bytes to write
 *    Return Value:    Number of bytes written
 */
U32 USBD_WriteEP (U32 EPNum, U8 *pData, U32 cnt)
{
    ep_buffer_t *desc = get_desc(EPNum);
    uint32_t mask;

    EPNum &= EPNUM_MASK;
    mask = (1 << EPNum);

    if (MXC_USB->in_owner & mask) {
        return 0;
    }

    if (EPNum == 0) {
        // Prepare to ACK the status stage.
        MXC_USB->ep[0] |= MXC_F_USB_EP_ST_ACK;

        if ((cnt == 0) && !ep0_expect_zlp) {
            // This is a status stage ACK. Handled in hardware.
            return 0;
        } else if (cnt == USBD_MAX_PACKET0) {
            ep0_expect_zlp = 1;
        } else {
            ep0_expect_zlp = 0;
        }
    }

    if (cnt > MXC_USB_MAX_PACKET) {
        cnt = MXC_USB_MAX_PACKET;
    }

    /* prepare data to be sent */
    memcpy(ep_buffer[EPNum], pData, cnt);
    desc->buf0_address = (uint32_t)ep_buffer[EPNum];
    desc->buf0_desc = cnt;

    /* start the transaction */
    MXC_USB->in_owner = mask;

    return cnt;
}
Exemple #26
0
int blk_show_device(enum if_type if_type, int devnum)
{
	struct blk_driver *drv = blk_driver_lookup_type(if_type);
	struct blk_desc *desc;
	int ret;

	if (!drv)
		return -ENOSYS;
	printf("\nDevice %d: ", devnum);
	if (devnum >= drv->max_devs) {
		puts("unknown device\n");
		return -ENODEV;
	}
	ret = get_desc(drv, devnum, &desc);
	if (ret)
		return ret;
	dev_print(desc);

	if (desc->type == DEV_TYPE_UNKNOWN)
		return -ENOENT;

	return 0;
}
unsigned long get_phys_addr(pid_t target, unsigned long virt_addr)
{
    FILE *pmap;
    size_t pagesize = getpagesize();
    unsigned long phys_page_num;
    unsigned long offset_in_page;
    uint64_t page_desc;


    pmap = open_pagemap(target);
    if (!pmap) {
        perror("fopen");
        return 0;
    }

    offset_in_page = virt_addr % pagesize;
    page_desc = get_desc(pmap, pagesize, virt_addr);
    phys_page_num = page_desc & PFN_MASK;

    fclose(pmap);

    return (phys_page_num * pagesize) + offset_in_page;
}
Exemple #28
0
struct drive_info *get_drive_list(void) {
	int total_devs, listed_devs;
	static struct usb_device **devs=NULL;
	int i;
	struct usb_device **dev;
	struct drive_info *drive;

	total_devs=fc5025_find(NULL,0);
	if(total_devs==0)
		return NULL;
	if(devs!=NULL)
		free(devs);
	devs=malloc(total_devs*sizeof(struct usb_device));
	if(!devs)
		return NULL;
	listed_devs=fc5025_find(devs,total_devs);
	if(listed_devs==0)
		return NULL;
	if(drives!=NULL)
		free(drives);
	drives=malloc((listed_devs+1)*sizeof(struct drive_info));
	if(!drives)
		return NULL;
	dev=devs; drive=drives;
	for(i=0;i<listed_devs;i++) {
		snprintf(drive->id,256,"%s/%s",(*dev)->bus->dirname,(*dev)->filename);
		drive->usbdev=*dev;
		if(get_desc(drive)==0) {
			dev++; drive++;
		}
	}
	drive->id[0]='\0'; drive->desc[0]='\0'; drive->usbdev=NULL;

	if(drive==drives)
		return NULL;
	return drives;
}
Exemple #29
0
void single_inv(short ichar)
{
	short ch;
	char desc[DCOLS];
	object *obj;

	ch = ichar ? ichar : pack_letter("Inventory what?", ALL_OBJECTS);

	if (ch == ROGUE_KEY_CANCEL)
	{
		return;
	}
	if (!(obj = get_letter_object(ch)))
	{
		message("No such item.", 0);
		return;
	}
	desc[0] = ch;
	desc[1] = ((obj->what_is & ARMOR) && obj->is_protected) ? '}' : ')';
	desc[2] = ' ';
	desc[3] = 0;
	get_desc( obj, desc+3, 1 );
	message(desc, 0);
}
Exemple #30
0
result_t*
new_result_t(drizzle_con_st *con, drizzle_result_st *result)
{
    result_t *r = NULL;
    PyObject *desc = NULL;

    r = PyMem_Malloc(sizeof(result_t));
    if (r == NULL) {
        return NULL;
    }
    
    memset(r, 0, sizeof(result_t));
    
    desc = get_desc(r, con, result);
    if (desc == NULL) {
        PyMem_Free(r);
        return NULL;
    }

    r->con = con;
    r->result = result;
    r->description = desc;
    return r;
}