Пример #1
0
void
adx_server::report_outcome(auction_context *ctx)
{
  a_out_bidder bout;
  a_out_seller sout;

  bout.id = ctx->id;
  bout.price = ctx->outcome.second;

  sout.id = ctx->id;
  sout.price = ctx->outcome.second;
  sout.ad_tag = ctx->ad_tags.at(ctx->outcome.first);
  
  a_write(SELLER_IDX, A_OUT, sout);
  a_write(ctx->outcome.first, A_OUT, bout);
}
Пример #2
0
// Handle an auction request
void
adx_server::process_a_req(int conn_idx, const a_req &req)
{
  b_req breq;

  // Create an auction context
  auction_context ctx;
  ctx.id = req.id;
  auctions_ctx_.insert(std::pair<uint32_t, auction_context>(req.id, ctx));

  breq.id = req.id;
  breq.url = req.url;
  breq.width = req.width;
  breq.height = req.height;
  breq.reserve_price = req.reserve_price;
  breq.cookie_version = req.cookie_version;
  breq.cookie_age_seconds = req.cookie_age_seconds;
  breq.cookie_id = req.cookie_id;
  breq.user_agent = req.user_agent;
  breq.geo_criteria_id = req.geo_criteria_id;
  breq.postal_code = req.postal_code;
  breq.timezone_offset = req.timezone_offset;
  breq.timestamp = req.timestamp; 

  breq.ip = rand();
  breq.seller_network_id = rand();
  breq.detected_language = rand(); 

  a_write(ALL_BIDDERS, B_REQ, breq); 
}
Пример #3
0
void
vex_adx_server::process_va_req(int conn_idx, const va_req &req)
{
    c_req creq;

    // Create auction context
    auction_context ctx;
    ctx.id = req.id;
    ctx.sig_id = req.sig_id;
    auctions_ctx_.insert(std::pair<std::vector<uint8_t>, auction_context>(req.id, ctx));

    creq.id = req.id;
    creq.sig_id = req.sig_id;
    creq.url = req.url;
    creq.width = req.width;
    creq.height = req.height;
    creq.reserve_price = req.reserve_price;
    creq.cookie_version = req.cookie_version;
    creq.cookie_age_seconds = req.cookie_age_seconds;
    creq.cookie_id = req.cookie_id;
    creq.user_agent = req.user_agent;
    creq.geo_criteria_id = req.geo_criteria_id;
    creq.postal_code = req.postal_code;
    creq.timezone_offset = req.timezone_offset;
    creq.timestamp = req.timestamp;

    creq.ip = rand();
    creq.seller_network_id = rand();
    creq.detected_language = rand();

    a_write(ALL_BIDDERS, C_REQ, creq);
}
Пример #4
0
void
vex_adx_server::report_outcome(auction_context *ctx)
{
    va_out_bidder bout;
    va_out_seller sout;

// Send outcome
    bout.id = ctx->id;
    bout.sale_price = ctx->vds.at(ctx->outcome.second).bid;
    bout.valid = ctx->invalid.size() ? 1 : 0;

    sout.id = ctx->id;
    sout.sale_price = bout.sale_price;
    sout.winner_idx = ctx->outcome.first;
    sout.ad_tag = ctx->vds.at(ctx->outcome.first).ad_tag;
    sout.valid = bout.valid;

    a_write(SELLER_IDX, A_OUT, sout);
    a_write(ctx->outcome.first, A_OUT, bout);
}
Пример #5
0
void
vex_adx_server::process_sign_sub(int conn_idx, const sign_sub &req)
{
    //Update auction context
    auction_context *ctx = &(auctions_ctx_.at(req.id));
    assert(ctx);

    ctx->sig_vo = req.sig_vo;

    // Send D_REQ
    d_req dreq;
    dreq.id = ctx->id;
    dreq.sig_vo = ctx->sig_vo;
    map_to_vector(ctx->vos, dreq.bundle);
    a_write(ALL_BIDDERS, D_REQ, dreq);
}
Пример #6
0
void
vex_adx_server::process_c_sub(int conn_idx, const c_sub &req)
{
    //Update auction context
    auction_context *ctx = &(auctions_ctx_.at(req.id));
    assert(ctx);

    ctx->vos.insert(std::pair<int, vex_object>(conn_idx, req.vo));

    if (ctx->vos.size() == conn_.size() - 1) {
        //Send SIGN_REQ
        sign_req sreq;
        sreq.id = req.id;
        map_to_vector(ctx->vos, sreq.bundle);
        a_write(SELLER_IDX, SIGN_REQ, sreq);
    }
}
Пример #7
0
void write_groups(struct storage *store, const faction * f)
{
    group *g;
    for (g = f->groups; g; g = g->next) {
        ally *a;
        WRITE_INT(store, g->gid);
        WRITE_STR(store, g->name);
        for (a = g->allies; a; a = a->next) {
            if (a->faction) {
                write_faction_reference(a->faction, store);
                WRITE_INT(store, a->status);
            }
        }
        WRITE_INT(store, 0);
        a_write(store, g->attribs, g);
        WRITE_SECTION(store);
    }
    WRITE_INT(store, 0);
}
Пример #8
0
int cmain(void) {
/* test the a_create() and a_close() functions */
    int fd, i, j;
    char buffer[TESTDATA_SIZE];

    fd = a_create ("to-curie-test-data", 0660);
    if (fd < 0) return 1;

    i = a_close(fd);
    if (i < 0) return 2;

/* test the a_write() and a_open_write() functions */
    fd = a_open_write ("to-curie-test-data");
    if (fd < 0) return 3;

    i = a_write(fd, TESTDATA, (unsigned int)TESTDATA_SIZE);
    if (i < 0) return 4;
    if (i != TESTDATA_SIZE) return 5;

/* close file descriptor */
    i = a_close(fd);
    if (i < 0) return 6;

/* test the a_read() and a_open_read() functions */
    fd = a_open_read ("to-curie-test-data");
    if (fd < 0) return 7;

    i = a_read (fd, buffer, (unsigned int)TESTDATA_SIZE);
    if (i < 0) return 8;
    if (i != TESTDATA_SIZE) return 9;

    for (j = 0; j < i; j++) {
      if (buffer[j] != TESTDATA[j]) return 10;
    }

    return 0;
}
Пример #9
0
static void
write_permissions(const attrib * a, const void *owner, struct storage *store)
{
  a_write(store, (attrib *) a->data.v, owner);
}