Esempio n. 1
0
void update_limit_test(void)
{
#if UM_TEST & UM_TEST_JSON
    struct um_user user = {
        .ip = umd.intf[UM_INTF_TC].ip,
        .head = { 
            .tag = LIST_HEAD_INIT(user.head.tag),
        },
    };
    os_maccpy(user.mac, umd.intf[UM_INTF_TC].mac);
    
    jobj_t obj = jobj_file("./auth.json");
    if (NULL==obj) {
        os_println("read auth.json failed");

        exit(1);
    }
    
    update_limit(&user, obj);
    update_aging(&user, true);
    jobj_put(obj);

    obj = um_juser(&user);
    os_println("%s", jobj_string(obj));
    os_system("echo '%s' | jq .", jobj_string(obj));
    jobj_put(obj);
#endif
}
Esempio n. 2
0
static inline void
show_cursor(struct part_cursor *c, bool simple)
{
    if (simple) {
        os_println("%s", c->v.var);
    } else {
        os_println("%s=%s", c->k.var, c->v.var);
    }
}
Esempio n. 3
0
/* {"-part", "partname", "-crc"} */
static int
partool_crc(int argc, char *argv[])
{
    int err = 0;
    unsigned int crc_part = 0;
    unsigned int crc_calc = 0;
    
    err = partool_init(PART_MODE_CRC, argc, argv);
    if (err<0) {
        debug_error("partool init error(%d)", err);
        
        /* 
        * if block is good, NO return
        */
        if (false==part_block_is_good(blk)) {
            return err;
        }
    }

    part_block_crc_get(blk, &crc_part, &crc_calc);
    if (err<0) {
        return part_error(err, NULL);
    }

    os_println("0x%x 0x%x", crc_part, crc_calc);
    
    return 0;
}
Esempio n. 4
0
static int
__main(int argc, char *argv[])
{
    int type;

    if (argc<3) {
        return EFORMAT;
    }

    type = os_atoi(argv[1]);

    switch(type) {
        case AT_COOKIE_FILE: {
            int id = os_atoi(argv[2]);
            char *file = atcookie_file(id);
            if (NULL==file) {
                return ENOEXIST;
            }

            os_println("%s", file);
        }   break;
        case AT_COOKIE_DOMAIN: {
            char *domain = argv[2];
            
        }   break;
        default:
            return EFORMAT;
    }

    return 0;
}
Esempio n. 5
0
static int
part_error(int err, char *name)
{
    switch(err) {
        case -ENOEXIST:
            os_println("%s not exist", os_safestring(name));
            
            break;
        case -EEXIST:
            os_println("%s exist", os_safestring(name));
            
            break;
        default:
            os_println("error(%d)", err);
            
            break;
    }

    return err;
}
Esempio n. 6
0
static inline int
part_init(char *partition)
{
    if (ADDR_BAD==part_begin(partition)) {
        os_println(NAME_HELP);
        
        return -EFORMAT;
    } else {
        return mtd_2_tmp(partition);
    }
}
Esempio n. 7
0
static inline int
part_init(char *partition)
{
    if (ADDR_BAD==part_begin(partition)) {
        os_println(NAME_HELP);
        
        return -EINVAL9;
    } else {
        return 0;
    }
}