Ejemplo n.º 1
0
TEST_F(ImapPlainTest, AddAccount)
{
// prevent the embedded beginedit/commitedit from doing anything
    qof_instance_increase_editlevel(QOF_INSTANCE(t_bank_account));
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));
    gnc_account_imap_add_account(t_imap, "foo", "bar", t_expense_account1);
    gnc_account_imap_add_account(t_imap, "baz", "waldo", t_expense_account2);
    gnc_account_imap_add_account(t_imap, NULL, "pepper", t_expense_account1);
    gnc_account_imap_add_account(t_imap, NULL, "salt", t_expense_account2);
    EXPECT_EQ(1, qof_instance_get_editlevel(QOF_INSTANCE(t_bank_account)));
    EXPECT_TRUE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));
    gnc_account_imap_add_account(t_imap, NULL, NULL, t_expense_account2);
    EXPECT_FALSE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
    gnc_account_imap_add_account(t_imap, "pork", "sausage", NULL);
    EXPECT_FALSE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
    qof_instance_reset_editlevel(QOF_INSTANCE(t_bank_account));

    auto root = qof_instance_get_slots(QOF_INSTANCE(t_bank_account));
    auto value = root->get_slot({IMAP_FRAME, "foo", "bar"});
    auto check_account = [this](KvpValue* v) {
        return xaccAccountLookup(v->get<GncGUID*>(), this->t_imap->book); };
    EXPECT_EQ(t_expense_account1, check_account(value));
    value = root->get_slot({IMAP_FRAME, "baz", "waldo"});
    EXPECT_EQ(t_expense_account2, check_account(value));
    value = root->get_slot({IMAP_FRAME, "pepper"});
    EXPECT_EQ(t_expense_account1, check_account(value));
    value = root->get_slot({IMAP_FRAME, "salt"});
    EXPECT_EQ(t_expense_account2, check_account(value));
    value = root->get_slot({IMAP_FRAME, "pork", "sausage"});
    EXPECT_EQ(nullptr, value);
}
Ejemplo n.º 2
0
KvpValueImpl *
KvpFrameImpl::get_slot(Path path) const noexcept
{
    auto last_key = path.back();
    path.pop_back();
    auto cur_frame = walk_path_or_nullptr(this, path);
    if (cur_frame == nullptr)
        return nullptr;
    if (last_key.find(delim) != std::string::npos)
        return get_slot(make_vector(last_key));
    return cur_frame->get_slot(last_key.c_str());

}
Ejemplo n.º 3
0
int get(hashmap_t* map, int key) {
  slot_t* slot = get_slot(map, key);
  if (slot->used == 0) {
    return 0;
  }
  return slot->value;
}
Ejemplo n.º 4
0
/*===========================================================================*
 *                    block_close                                            *
 *===========================================================================*/
static int
block_close(dev_t minor)
{
	struct sd_slot *slot;

	slot = get_slot(minor);
	if (!slot) {
		mmc_log_debug(&log,
		    "Not handling open on non existing slot\n");
		return EIO;
	}

	/* if we arrived here we expect a card to be present, we will need do
	 * deal with removal later */
	assert(slot->host != NULL);
	assert(slot->card.open_ct >= 1);

	/* If this is not the last open count simply decrease the counter and
	 * return */
	if (slot->card.open_ct > 1) {
		slot->card.open_ct--;
		mmc_log_trace(&log, "decreased open count to %d\n",
		    slot->card.open_ct);
		return OK;
	}

	assert(slot->card.open_ct == 1);
	mmc_log_debug(&log,
	    "freeing the block device as it is no longer used\n");

	/* release the card as check the open_ct should be 0 */
	slot->host->card_release(&slot->card);
	assert(slot->card.open_ct == 0);
	return OK;
}
Ejemplo n.º 5
0
int disk_client_poll(struct disk_client *c)
{
    struct disk_msg msg;
    struct disk_client_slot *slot;
    int slot_num;

    while (channel_can_recv(c->resp_chan)) {
	channel_recv(c->resp_chan, &msg);

	slot_num = msg.handle;
	slot = get_slot(c, slot_num);

	if (msg.status != 0) {
	    slot->err(&msg);
	} else {
	    if (msg.type == DISK_SIZE) {
		slot->cb.size(msg.device_size);
	    } else if (msg.type == DISK_READ) {
		slot->cb.read(msg.num_sectors, msg.start_sector, msg.payload);	    } else {
		slot->cb.write(msg.num_sectors, msg.start_sector);
	    }
	}

	free_slot(c, slot_num);
    }

    return 0;
}
Ejemplo n.º 6
0
/*===========================================================================*
 *				block_ioctl		                     *
 *===========================================================================*/
static int
block_ioctl(dev_t minor,
    unsigned int request, endpoint_t endpt, cp_grant_id_t grant)
{
	/* IOCTL handling */
	struct sd_slot *slot;
	mmc_log_trace(&log,
	    "enter (minor,request,endpoint,grant)=(%d,%lu,%d)\n", minor,
	    request, endpt, grant);

	slot = get_slot(minor);
	if (!slot) {
		mmc_log_warn(&log,
		    "Doing ioctl on non existing block device(%d)\n", minor);
		return EINVAL;
	}

	switch (request) {
	case DIOCOPENCT:
		// TODO: add a check for card validity */
		mmc_log_trace(&log, "returning open count %d\n",
		    slot->card.open_ct);
		/* return the current open count */
		return sys_safecopyto(endpt, grant, 0,
		    (vir_bytes) & slot->card.open_ct,
		    sizeof(slot->card.open_ct));
	case DIOCFLUSH:
		/* No need to flush but some devices like movinands require
		 * 500 ms inactivity */
		return OK;
	}

	return EINVAL;
}
Ejemplo n.º 7
0
void scm_cache::update(int t, bool b)
{
    int c;

    scm_task task;

    glBindTexture(GL_TEXTURE_2D, texture);

    for (c = 0; (b || c < loads_per_cycle) && loads.try_remove(task); ++c)
    {
        if (task.d)
        {
            scm_page page(task.f, task.i);

            waits.remove(page);

            if (int l = get_slot(t, page.i))
            {
                page.l = l;
                page.t = t;
                pages.insert(page, t);
                task.make_page((l % s) * (n + 2),
                               (l / s) * (n + 2));
            }
            else task.dump_page();
        }
        else task.dump_page();

        pbos.enq(task.u);
    }
}
Ejemplo n.º 8
0
int disk_client_get_size(struct disk_client *c, size_callback_t cb, error_callback_t err)
{
    int slot_num, status;
    struct disk_client_slot *slot;

    if (channel_can_send(c->req_chan) && next_free_slot(c) >= 0) {
	slot_num = alloc_slot(c);
	slot = get_slot(c, slot_num);

	slot->cb.size = cb;
	slot->err = err;
	slot->msg.type = DISK_SIZE;
	slot->msg.handle = slot_num;

	status = channel_send(c->req_chan, &(slot->msg));
	if (status == CHANNEL_OK) {
	    return DISK_OK;
	} else {
	    printf("Error in channel send (size): %d\n", status);
	    return DISK_ERROR;
	}
    }

    return DISK_BUSY;
}
Ejemplo n.º 9
0
int disk_client_read(struct disk_client *c, size_t num_sectors,
		     unsigned long start_sector,
		     read_callback_t cb, error_callback_t err)
{
    int slot_num, status;
    struct disk_client_slot *slot;

    if (channel_can_send(c->req_chan) && next_free_slot(c) >= 0) {
	slot_num = alloc_slot(c);
	slot = get_slot(c, slot_num);

	slot->cb.read = cb;
	slot->err = err;
	slot->msg.type = DISK_READ;
	slot->msg.start_sector = start_sector;
	slot->msg.num_sectors = num_sectors;
	slot->msg.handle = slot_num;

	status =channel_send(c->req_chan, &(slot->msg));
	if (status == CHANNEL_OK) {
	    return DISK_OK;
	} else {
	    printf("Error in channel send (read): %d\n", status);
	    return DISK_ERROR;
	}
    }

    return DISK_BUSY;
}
Ejemplo n.º 10
0
static
void router_receive(receiver_t* self,
		    bytecode_stream_t* message, context_t* context)
{
    router_t* router = (router_t*) self;
    bytecode_t* selector = message->pop(message);

    if(selector && selector->verb == route_atom) {
	bytecode_t* destination = message->pop(message);

	if(!destination) {
	    WARNING1("no destination provided.");
	    return;
	} else {
	    atom_t dest = destination->verb;
	    if(!router_route(get_slot(router, dest), message, context)) {
		WARNING2("route '%s' not defined.", 
			 atom_get_cstring_value(dest));
	    }
	}
    } else {
	message->push(message, selector);
	router->receive_backup(self, message, context);
    }
}
Ejemplo n.º 11
0
inline link_list *
get_link_list(hash_table *table, uint64_t key)
{
    uint32_t slot = get_slot(key, table->size);

    return table->lists[slot];
}
Ejemplo n.º 12
0
int disk_client_write(struct disk_client *c, size_t num_sectors,
		      unsigned long start_sector, unsigned char *buf,
		      write_callback_t cb, error_callback_t err)
{
    int slot_num, status;
    struct disk_client_slot *slot;

    if (channel_can_send(c->req_chan) && next_free_slot(c) >= 0) {
	slot_num = alloc_slot(c);
	slot = get_slot(c, slot_num);

	slot->cb.write = cb;
	slot->err = err;
	slot->msg.type = DISK_WRITE;
	slot->msg.start_sector = start_sector;
	slot->msg.num_sectors = num_sectors;
	slot->msg.handle = slot_num;

	memcpy(slot->msg.payload, buf, num_sectors * SECTOR_SIZE);

	status = channel_send(c->req_chan, &(slot->msg));
	if (status == CHANNEL_OK) {
	    return DISK_OK;
	} else {
	    printf("Error in channel send (write): %d\n", status);
	    return DISK_ERROR;
	}
    }

    return DISK_BUSY;
}
Ejemplo n.º 13
0
static Win* begin_animation(GtkWidget * win, GtkWidget * context)
{
	int slot, begin;
	Win *w;

	update_working_area();

	slot = get_slot(win);
	begin = working_area.y + height - slot * NHEIGHT;
	w = g_new0(Win, 1);

	w->win = win;
	w->context = context;
	w->slot = slot;
	w->size = 0;

	gtk_widget_realize(win);
	gtk_window_move(
		GTK_WINDOW(win), 
		working_area.x + width - win->allocation.width, begin);
	gtk_widget_show_all(win);

	w->ani_timer_id = gtk_timeout_add(SPEED, slow_show_win, w);
	w->timeout_id = 0;

	return w;
}
Ejemplo n.º 14
0
TSS_RESULT
TCSP_CMK_CreateKey_Internal(TCS_CONTEXT_HANDLE	hContext,		/* in */
			    TCS_KEY_HANDLE	hWrappingKey,		/* in */
			    TPM_ENCAUTH		KeyUsageAuth,		/* in */
			    TPM_HMAC		MigAuthApproval,	/* in */
			    TPM_DIGEST		MigAuthorityDigest,	/* in */
			    UINT32*		keyDataSize,		/* in, out */
			    BYTE**		prgbKeyData,		/* in, out */
			    TPM_AUTH*		pAuth)			/* in, out */
{
	TSS_RESULT result;
	UINT64 offset = 0;
	UINT32 paramSize;
	UINT32 parentSlot;
	BYTE txBlob[TSS_TPM_TXBLOB_SIZE];

	LogDebugFn("Enter");

	if ((result = ctx_verify_context(hContext))) {
		free(*prgbKeyData);
		return result;
	}

	if ((result = get_slot(hContext, hWrappingKey, &parentSlot))) {
		free(*prgbKeyData);
		return result;
	}

	if (pAuth) {
		if ((result = auth_mgr_check(hContext, &pAuth->AuthHandle))) {
			free(*prgbKeyData);
			return result;
		}
	}

	if ((result = tpm_rqu_build(TPM_ORD_CMK_CreateKey, &offset, txBlob,
				    parentSlot, &KeyUsageAuth, *keyDataSize, *prgbKeyData,
				    &MigAuthApproval, &MigAuthorityDigest, pAuth))) {
		free(*prgbKeyData);
		goto done;
	}
	free(*prgbKeyData);

	if ((result = req_mgr_submit_req(txBlob)))
		goto done;

	result = UnloadBlob_Header(txBlob, &paramSize);
	if (!result) {
		result = tpm_rsp_parse(TPM_ORD_CMK_CreateKey, txBlob, paramSize,
				       keyDataSize, prgbKeyData, pAuth);
	}

	LogResult("CMK_SetRestrictions", result);

done:
	auth_mgr_release_auth(pAuth, NULL, hContext);

	return result;
}
Ejemplo n.º 15
0
static long get_cde_slots(IFILE *file, Axq axq)				/*;get_cde_slots*/
{
	long	dpos;
	int		n_code, n_data, n_exception;


	dpos = file->fh_slots;
	/* position to start of slot info */
	ifseek(file, "get-cde-slots-start", dpos, 0);
	n_code = getnum(file, "n-code");
	n_data = getnum(file, "n-data");
	n_exception = getnum(file, "n-exception");
	get_slot(file, "code");
	get_slot(file, "data");
	get_slot(file, "exceptions");
	return dpos; /* return offset of start of slot info */
}
Ejemplo n.º 16
0
TSS_RESULT
TCSP_CMK_ConvertMigration_Internal(TCS_CONTEXT_HANDLE	hContext,	/* in */
				   TCS_KEY_HANDLE	parentHandle,	/* in */
				   TPM_CMK_AUTH		restrictTicket,	/* in */
				   TPM_HMAC		sigTicket,	/* in */
				   UINT32		keyDataSize,	/* in */
				   BYTE*		prgbKeyData,	/* in */
				   UINT32		msaListSize,	/* in */
				   BYTE*		msaList,	/* in */
				   UINT32		randomSize,	/* in */
				   BYTE*		random,		/* in */
				   TPM_AUTH*		parentAuth,	/* in, out */
				   UINT32*		outDataSize,	/* out */
				   BYTE**		outData)	/* out */
{
	TSS_RESULT result;
	UINT64 offset = 0;
	UINT32 paramSize;
	UINT32 parentSlot;
	BYTE txBlob[TSS_TPM_TXBLOB_SIZE];

	LogDebugFn("Enter");

	if ((result = ctx_verify_context(hContext)))
		return result;

	if ((result = get_slot(hContext, parentHandle, &parentSlot)))
		return result;

	if (parentAuth) {
		if ((result = auth_mgr_check(hContext, &parentAuth->AuthHandle)))
			return result;
	}

	if ((result = tpm_rqu_build(TPM_ORD_CMK_ConvertMigration, &offset, txBlob,
				    parentSlot, &restrictTicket, &sigTicket,
				    keyDataSize, prgbKeyData, msaListSize, msaList,
				    randomSize, random, parentAuth)))
		goto done;

	if ((result = req_mgr_submit_req(txBlob)))
		goto done;

	result = UnloadBlob_Header(txBlob, &paramSize);
	if (!result) {
		result = tpm_rsp_parse(TPM_ORD_CMK_ConvertMigration, txBlob, paramSize,
				       outDataSize, outData, parentAuth, NULL);
	}

	LogResult("CMK_SetRestrictions", result);

done:
	auth_mgr_release_auth(parentAuth, NULL, hContext);

	return result;
}
Ejemplo n.º 17
0
Archivo: tmpl.c Proyecto: zhouqt/kbs
/* copy template from current board to some board, append it at the end
 * @board - the destination board
 * @pptemp - template array of destination board
 * @temp_size - array size
 * @pos - which template to copy, conf->pos
 * @return - 0 on success, -1 otherwise
 *
 * Warning: caller should check permission before this call.
 **/
int tmpl_copy_to_board(const char *board, struct a_template **pptemp, int *temp_size, int pos)
{
    if (!board || !pptemp || !*pptemp
            || !temp_size || *temp_size < 0 || *temp_size >= MAX_TEMPLATE
            || pos < 1 || pos > template_num)
        return -1;

    struct a_template *f = get_slot(&ptemplate, pos);
    struct a_template *t = get_slot(pptemp, *temp_size + 1);

    if (!deepcopy(t, board, f, currboard->filename)) {
        if (!orig_tmpl_save(*pptemp, *temp_size + 1, (char*)board)) {
            (*temp_size)++;
            return 0;
        }

        deepfree(t, board);
    }
    return -1;
}
Ejemplo n.º 18
0
KvpValueImpl *
KvpFrameImpl::get_slot(const char * key) const noexcept
{
    if (!key) return nullptr;
    if (strchr(key, delim))
        return get_slot(make_vector(key));
    auto spot = m_valuemap.find(key);
    if (spot == m_valuemap.end())
        return nullptr;
    return spot->second;
}
Ejemplo n.º 19
0
void copy(hashmap_t* old_map, hashmap_t* new_map) {
  int n;
  for (n = 0; n < old_map->size; n++) {
    if (old_map->slots[n].used == 1) {
      slot_t* slot = get_slot(new_map, old_map->slots[n].key);
      slot->used = 1;
      slot->key = old_map->slots[n].key;
      slot->value = old_map->slots[n].value;
    }
  }
}
Ejemplo n.º 20
0
void set(hashmap_t* map, int key, int value) {
  slot_t* slot = get_slot(map, key);
  if (slot->used == 0) {
    slot->used = 1;
    num_entries++;
  }
  slot->key = key;
  slot->value = value;
  if (num_entries / (float)map->size > 0.7) {
    resize(map);
  }
}
Ejemplo n.º 21
0
static
void wildcard_router_receive(receiver_t* self,
			     bytecode_stream_t* message, context_t* context)
{
    router_t* router = (router_t*) self;
    bytecode_t* selector = message->pop(message);

    if(selector && selector->verb == route_atom) {
	bytecode_t* destination = message->pop(message);

	if(!destination) {
	    WARNING1("no destination provided.");
	    return;
	} else {
	    atom_t dest = destination->verb;

	    TRACE2("routing towards selector '%s' requested.", atom_get_cstring_value(dest));
	    if(dest == star_atom) {
		map_iterator_t i; 
		map_value_t pslot = NULL_MAP_VALUE;
		
		map_get_iterator(&router->children, &i);
		
		while (map_value_is_there (pslot = map_iterator_next(&i))) {
		    router_slot_t* slot = map_value_obtain (pslot);
		    // clone each message
		    bytecode_stream_t* message_copy = bytecode_stream_instantiate_toplevel(NULL);
		    message_copy->copy(message_copy, message);

		    TRACE2("sending event to slot: '%s'", 
			   atom_get_cstring_value(slot->name));
		    if(!router_route(slot, message_copy, context)) {
			WARNING2("route '%s' not defined.", 
				 atom_get_cstring_value(slot->name));
		    }
		}
		map_iterator_destroy (&i);
		map_iterator_retire (&i);

		bytecode_stream_retire (message);
	    } else {
		if(!router_route(get_slot(router, dest), message, context)) {
		    WARNING2("route '%s' not defined.", 
			     atom_get_cstring_value(dest));
		}
	    }
	}
    } else {
	message->push(message, selector);
	router->receive_backup(self, message, context);
    }
}
Ejemplo n.º 22
0
TEST_F(ImapBayesTest, AddAccountBayes)
{
    // prevent the embedded beginedit/commitedit from doing anything
    qof_instance_increase_editlevel(QOF_INSTANCE(t_bank_account));
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));
    gnc_account_imap_add_account_bayes(t_imap, t_list1, t_expense_account1);
    gnc_account_imap_add_account_bayes(t_imap, t_list2, t_expense_account2);
    gnc_account_imap_add_account_bayes(t_imap, t_list3, t_expense_account1);
    gnc_account_imap_add_account_bayes(t_imap, t_list4, t_expense_account2);
    EXPECT_EQ(1, qof_instance_get_editlevel(QOF_INSTANCE(t_bank_account)));
    EXPECT_TRUE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));
    gnc_account_imap_add_account_bayes(t_imap, t_list5, NULL);
    EXPECT_FALSE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
    qof_instance_reset_editlevel(QOF_INSTANCE(t_bank_account));

    auto root = qof_instance_get_slots(QOF_INSTANCE(t_bank_account));
    auto acct1_guid = guid_to_string (xaccAccountGetGUID(t_expense_account1));
    auto acct2_guid = guid_to_string (xaccAccountGetGUID(t_expense_account2));
    auto value = root->get_slot({IMAP_FRAME_BAYES, "foo", "bar"});
    auto check_account = [this](KvpValue* v) {
        return (v->get<const char*>(), this->t_imap->book); };
    value = root->get_slot({IMAP_FRAME_BAYES, foo, acct1_guid});
    EXPECT_EQ(1, value->get<int64_t>());
    value = root->get_slot({IMAP_FRAME_BAYES, bar, acct1_guid});
    EXPECT_EQ(1, value->get<int64_t>());
    value = root->get_slot({IMAP_FRAME_BAYES, baz, acct2_guid});
    EXPECT_EQ(1, value->get<int64_t>());
    value = root->get_slot({IMAP_FRAME_BAYES, waldo, acct2_guid});
    EXPECT_EQ(1, value->get<int64_t>());
    value = root->get_slot({IMAP_FRAME_BAYES, pepper, acct1_guid});
    EXPECT_EQ(1, value->get<int64_t>());
    value = root->get_slot({IMAP_FRAME_BAYES, salt, acct2_guid});
    EXPECT_EQ(1, value->get<int64_t>());
    value = root->get_slot({IMAP_FRAME_BAYES, baz, acct1_guid});
    EXPECT_EQ(nullptr, value);

    qof_instance_increase_editlevel(QOF_INSTANCE(t_bank_account));
    gnc_account_imap_add_account_bayes(t_imap, t_list2, t_expense_account2);
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));
    qof_instance_reset_editlevel(QOF_INSTANCE(t_bank_account));
    value = root->get_slot({IMAP_FRAME_BAYES, baz, acct2_guid});
    EXPECT_EQ(2, value->get<int64_t>());
}
Ejemplo n.º 23
0
tnf_datum_t
tnf_get_slot_indexed(tnf_datum_t datum, unsigned index)
{
	struct slotinfo	*slotinfo;
	struct slot	*slot;

	CHECK_SLOTS(datum);

	slotinfo 	= get_slotinfo(datum);
	slot		= get_slot_indexed(slotinfo, index);

	return (get_slot(datum, slot));
}
Ejemplo n.º 24
0
tnf_datum_t
tnf_get_slot_named(tnf_datum_t datum, char *name)
{
	struct slotinfo	*slotinfo;
	struct slot	*slot;

	CHECK_SLOTS(datum);

	slotinfo 	= get_slotinfo(datum);
	slot		= get_slot_named(slotinfo, name);

	return (get_slot(datum, slot));
}
Ejemplo n.º 25
0
inline static gboolean
kvp_match_guid (KvpValue *v, const char *key, const GncGUID *guid)
{
    if (v->get_type() != KvpValue::Type::FRAME)
        return FALSE;
    auto frame = v->get<KvpFrame*>();
    auto val = frame->get_slot(key);
    if (val == nullptr || val->get_type() != KvpValue::Type::GUID)
        return FALSE;
    auto this_guid = val->get<GncGUID*>();

    return guid_equal (this_guid, guid);
}
Ejemplo n.º 26
0
TEST_F(ImapPlainTest, DeleteAccount)
{
    Path path1 {IMAP_FRAME, "foo", "waldo"};
    Path path2 {IMAP_FRAME, "foo"};
    Path path3 {IMAP_FRAME};

// prevent the embedded beginedit/commitedit from doing anything
    qof_instance_increase_editlevel(QOF_INSTANCE(t_bank_account));
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));
    gnc_account_imap_add_account(t_imap, "foo", "bar", t_expense_account1);
    gnc_account_imap_add_account(t_imap, "foo", "waldo", t_expense_account2);
    gnc_account_imap_add_account(t_imap, NULL, "pepper", t_expense_account1);
    EXPECT_EQ(1, qof_instance_get_editlevel(QOF_INSTANCE(t_bank_account)));
    EXPECT_TRUE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));

    gnc_account_imap_delete_account(t_imap, NULL, NULL);
    EXPECT_FALSE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));

    gnc_account_imap_delete_account(t_imap, "foo", "waldo");
    EXPECT_TRUE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));
    EXPECT_EQ(t_expense_account1, gnc_account_imap_find_account(t_imap, "foo", "bar"));
    EXPECT_EQ(nullptr, gnc_account_imap_find_account(t_imap, "foo", "waldo"));
    auto root = qof_instance_get_slots(QOF_INSTANCE(t_bank_account));
    EXPECT_EQ(nullptr, root->get_slot(path1));

    gnc_account_imap_delete_account(t_imap, "foo", "bar");
    EXPECT_TRUE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));
    EXPECT_EQ(nullptr, root->get_slot(path2));

    gnc_account_imap_delete_account(t_imap, NULL, "pepper");
    EXPECT_TRUE(qof_instance_get_dirty_flag(QOF_INSTANCE(t_bank_account)));
    qof_instance_mark_clean(QOF_INSTANCE(t_bank_account));
    EXPECT_EQ(nullptr, root->get_slot(path3));
    qof_instance_reset_editlevel(QOF_INSTANCE(t_bank_account));
}
Ejemplo n.º 27
0
/*===========================================================================*
 *                    block_part                                             *
 *===========================================================================*/
static struct device *
block_part(dev_t minor)
{
	/* 
	 * Reuse the existing MINIX major/minor partitioning scheme.
	 * - 8 drives
	 * - 5 devices per drive allowing direct access to the disk and up to 4
	 *   partitions (IBM style partitioning without extended partitions)
	 * - 4 Minix style sub partitions per partitions
	 */
	struct device *dev;
	struct sd_slot *slot;

	dev = NULL;
	slot = get_slot(minor);
	if (!slot) {
		mmc_log_warn(&log,
		    "Device information requested for non existing partition "
		    "minor(%d)\n", minor);
		return NULL;
	}

	if (!slot->host->card_detect(slot)) {
		mmc_log_warn(&log,
		    "Device information requested from empty slot(%d)\n",
		    minor);
		return NULL;
	}

	if (minor < 5) {
		/* we are talking about the first disk */
		dev = &slot->card.part[minor];
		mmc_log_trace(&log,
		    "returning partition(%d) (base,size)=(0x%016llx,0x%016llx)\n",
		    minor, dev->dv_base, dev->dv_size);
	} else if (minor >= 128 && minor < 128 + 16) {
		/* sub partitions of the first disk we don't care about the
		 * rest */
		dev = &slot->card.subpart[minor - 128];
		mmc_log_trace(&log,
		    "returning sub partition(%d) (base,size)=(0x%016llx,0x%016llx)\n",
		    minor - 128, dev->dv_base, dev->dv_size);

	} else {
		mmc_log_warn(&log,
		    "Device information requested for non existing "
		    "partition minor(%d)\n", minor);
	}
	return dev;
}
Ejemplo n.º 28
0
void global_slots_data::process_all_pallete()
{
	R_ASSERT( header( ).version() != u32(-1) );
	R_ASSERT( header( ).x_size() != u32(-1) );
	R_ASSERT( header( ).z_size() != u32(-1) );
	for ( u32 i=0; i < header().slots_count(); ++i )
	{
		
		DetailSlot& DS = get_slot( i );
		process_pallete( DS );
		
		if( is_empty( DS ) )
			recalculation_data.set_slot_calculated( i );
	}
}
Ejemplo n.º 29
0
/*
** Return a vector of all potions
*/
static std::vector< t_artifact_type > get_potion_vector()
{
	std::vector< t_artifact_type > result;

	result.reserve(22); // Current count, won't break anything if it changes

	for ( t_artifact_type type = t_artifact_type(0); type < k_artifact_type_count; enum_incr( type ) ) 
	{
		if ( !is_cut( type ) && get_slot( type ) == k_artifact_slot_potion )
		{
			result.push_back( type );
		}
	}

	return result;
}
Ejemplo n.º 30
0
int single_chip(void){
    int slot, final_slot;
    float path[PEG_ROWS+1];
    printf("\n*** DROP SINGLE CHIP ***\n");
    if(get_slot(slot) == NO_ERR){
        final_slot = single_chip_path(slot, path); 
        printf("\n*** DROPPING CHIP INTO SLOT %i ***\n", slot);
        printf("PATH: [");
        for(int r=0;r<=PEG_ROWS;r++){
            printf("%3.1f%c", path[r], ((r<PEG_ROWS)? ' ':']')); 
        }
        printf("\nWINNINGS: $%.2f\n\n", (float)final_slot_vals[final_slot]); 
        return NO_ERR;
    }
    return ERRORED;
}