示例#1
0
文件: protocol.c 项目: jezze/fudge
static unsigned int protocol_child(struct service_backend *backend, struct service_state *state, unsigned int id, char *path, unsigned int length)
{

    struct system_node *node = (struct system_node *)backend->map(state, id, sizeof (struct system_node));
    struct list_item *current;
    struct system_node *n = node;

    spinlock_acquire(&node->children.spinlock);

    for (current = node->children.head; current; current = current->next)
    {

        struct system_node *n2 = current->data;
        unsigned int length0 = ascii_length(n2->name);

        if (n2->type == SYSTEM_NODETYPE_MULTIGROUP)
        {

            unsigned int colon = memory_findbyte(path, length, ':');
            unsigned int val;

            if (length0 != colon)
                continue;

            if (!memory_match(n2->name, path, colon))
                continue;

            val = ascii_rvalue(path + colon + 1, length - colon - 1, 10);

            if (val != n2->index)
                continue;

        }

        else
        {

            if (length0 != length)
                continue;

            if (!memory_match(n2->name, path, length))
                continue;

        }

        n = n2;

        break;

    }

    spinlock_release(&node->children.spinlock);

    return (unsigned int)n;

}
示例#2
0
文件: main.c 项目: jezze/fudge
static void write(struct list *states, unsigned int level, char *string, char *file, unsigned int line)
{

    union event_message message;
    char num[FUDGE_NSIZE];

    event_create(&message, EVENT_DATA);

    switch (level)
    {

    case DEBUG_CRITICAL:
        event_append(&message, 7, "[CRIT] ");

        break;

    case DEBUG_ERROR:
        event_append(&message, 7, "[ERRO] ");

        break;

    case DEBUG_WARNING:
        event_append(&message, 7, "[WARN] ");

        break;

    case DEBUG_INFO:
        event_append(&message, 7, "[INFO] ");

        break;

    }

    event_append(&message, ascii_length(string), string);
    event_append(&message, 2, " (");
    event_append(&message, ascii_length(file), file);
    event_append(&message, 1, ":");
    event_append(&message, ascii_wvalue(num, FUDGE_NSIZE, line, 10), num);
    event_append(&message, 2, ")\n");
    kernel_multicast(EVENT_BROADCAST, states, &message);

}
示例#3
0
static unsigned int resolvesymbols(unsigned int id, struct elf_sectionheader *relocationheader, struct elf_sectionheader *symbolheader, char *strings, unsigned int offset)
{

    unsigned int i;

    for (i = 0; i < relocationheader->size / relocationheader->esize; i++)
    {

        unsigned char index;
        unsigned int address;
        unsigned int value;
        char *symbolname;
        unsigned int count;
        struct elf_relocation relocation;
        struct elf_symbol symbol;

        if (!file_seekreadall(id, &relocation, relocationheader->esize, relocationheader->offset + i * relocationheader->esize))
            return 0;

        index = relocation.info >> 8;

        if (!file_seekreadall(id, &symbol, symbolheader->esize, symbolheader->offset + index * symbolheader->esize))
            return 0;

        if (symbol.shindex)
            continue;

        symbolname = strings + symbol.name;
        count = ascii_length(symbolname);
        address = findmodulesymbol(count, symbolname);

        if (!address)
            address = findsymbol(CALL_L0, count, symbolname);

        if (!address)
            return 0;

        if (!file_seekreadall(id, &value, 4, offset + relocation.offset))
            return 0;

        value += address;

        if (!file_seekwriteall(id, &value, 4, offset + relocation.offset))
            return 0;

    }

    return 1;

}
示例#4
0
unsigned int tar_readvalue(char *attribute)
{

    return ascii_rvalue(attribute, ascii_length(attribute), 8);

}