Example #1
0
static int
parser_settings_on_message_complete(http_parser* parser)
{
    mrb_http_parser_context *context = (mrb_http_parser_context*) parser->data;
    mrb_state* mrb = context->mrb;
    mrb_value c = context->instance;

    if (context->handle.field_set & (1<<UF_SCHEMA)) {
        OBJECT_SET(mrb, c, "schema", mrb_str_substr(mrb, OBJECT_GET(mrb, c, "buf"), context->handle.field_data[UF_SCHEMA].off, context->handle.field_data[UF_SCHEMA].len));
    }
    if (context->handle.field_set & (1<<UF_HOST)) {
        OBJECT_SET(mrb, c, "host", mrb_str_substr(mrb, OBJECT_GET(mrb, c, "buf"), context->handle.field_data[UF_HOST].off, context->handle.field_data[UF_HOST].len));
    }
    if (context->handle.field_set & (1<<UF_HOST)) {
        OBJECT_SET(mrb, c, "host", mrb_str_substr(mrb, OBJECT_GET(mrb, c, "buf"), context->handle.field_data[UF_HOST].off, context->handle.field_data[UF_HOST].len));
    }
    if (context->handle.field_set & (1<<UF_PORT)) {
        OBJECT_SET(mrb, c, "port", mrb_fixnum_value(context->handle.port));
    } else {
        if (context->handle.field_set & (1<<UF_SCHEMA)) {
            mrb_value schema = mrb_str_substr(mrb, OBJECT_GET(mrb, c, "buf"), context->handle.field_data[UF_SCHEMA].off, context->handle.field_data[UF_SCHEMA].len);
            if (!mrb_nil_p(schema) && !strcmp("https", (char*) RSTRING_PTR(schema))) {
                OBJECT_SET(mrb, c, "port", mrb_fixnum_value(443));
            }
        }
    }
    if (context->handle.field_set & (1<<UF_PATH)) {
        OBJECT_SET(mrb, c, "path", mrb_str_substr(mrb, OBJECT_GET(mrb, c, "buf"), context->handle.field_data[UF_PATH].off, context->handle.field_data[UF_PATH].len));
    }
    if (context->handle.field_set & (1<<UF_QUERY)) {
        OBJECT_SET(mrb, c, "query", mrb_str_substr(mrb, OBJECT_GET(mrb, c, "buf"), context->handle.field_data[UF_QUERY].off, context->handle.field_data[UF_QUERY].len));
    }
    if (context->parser.method)
        OBJECT_SET(mrb, c, "method", mrb_str_new_cstr(mrb, http_method_str(context->parser.method)));
    if (context->parser.status_code)
        OBJECT_SET(mrb, c, "status_code", mrb_fixnum_value(context->parser.status_code));
    if (context->parser.content_length)
        OBJECT_SET(mrb, c, "content_length", mrb_fixnum_value(context->parser.content_length));
    OBJECT_REMOVE(mrb, c, "last_header_field");
    OBJECT_REMOVE(mrb, c, "last_header_value");
    OBJECT_REMOVE(mrb, c, "buf");

    return 0;
}
Example #2
0
void rescuePerson(boat b) /*Resgata definitivamente a pessoa no navio*/
{
    listLink aux;
    OBJECT_REMOVE(b->extra->personList->person);
    aux = b->extra->personList;
    b->extra->personList = b->extra->personList->next;
    free(aux);
    b->extra->peopleHeld--;
    b->extra->points += 50;
    debugMsg("I IS IN RESCUEEEEEEEE");
}