Exemplo n.º 1
0
int list_files(exword_t *d)
{
	int rsp, i;
	directory_entry_t *entries;
	uint16_t len;
	rsp = exword_list(d, &entries, &len);
	if (rsp != 0x20)
		goto fail;
	for (i = 0; i < len; i++) {
		print_entry(entries + i);
	}
	exword_free_list(entries);
fail:
	return rsp;
}
Exemplo n.º 2
0
DirEnts Exword::List(wxString path, wxString pattern)
{
    exword_dirent_t *entries;
    uint16_t count;
    DirEnts list;
    wxString fullpath = GetStoragePath() + path;
    if (IsConnected()) {
        if (exword_setpath(m_device, (uint8_t*)fullpath.utf8_str().data(), 0) == EXWORD_SUCCESS) {
            if (exword_list(m_device, &entries, &count) == EXWORD_SUCCESS) {
                for (int i = 0; i < count; i++) {
                    DirEntry entry(&entries[i]);
                    if (wxMatchWild(pattern.Lower(), entry.GetFilename().Lower(), true))
                        list.Add(entry);
                }
                exword_free_list(entries);
            }
        }
    }
    return list;
}
Exemplo n.º 3
0
bool Exword::IsSdInserted()
{
    exword_dirent_t *entries;
    uint16_t count;
    bool found = false;

    if (!IsConnected())
         return found;

    if (exword_setpath(m_device, (uint8_t*)"", 0) == EXWORD_SUCCESS) {
        if (exword_list(m_device, &entries, &count) == EXWORD_SUCCESS) {
            for (int i = 0; i < count; i++) {
                if (strcmp((const char*)entries[i].name, "_SD_00") == 0)
                    found = true;
            }
            exword_free_list(entries);
        }
    }

    return found;
}
Exemplo n.º 4
0
bool Exword::Authenticate(wxString user, wxMemoryBuffer& key)
{
    bool success = false;
    int rsp;
    uint16_t count;
    exword_dirent_t *entries;
    exword_authchallenge_t c;
    exword_authinfo_t ai;
    exword_userid_t u;

    if (!IsConnected())
        return success;

    memcpy(c.challenge, key.GetData(), 20);
    memcpy(ai.blk1, "FFFFFFFFFFFFFFFF", 16);
    strncpy((char*)ai.blk2, user.utf8_str().data(), 24);
    strncpy(u.name, user.utf8_str().data(), 16);
    exword_setpath(m_device, (uint8_t*)"\\_INTERNAL_00", 0);
    rsp = exword_authchallenge(m_device, c);
    if (rsp == EXWORD_SUCCESS) {
        exword_setpath(m_device, (uint8_t*)"", 0);
        exword_list(m_device, &entries, &count);
        for (int i = 0; i < count; i++) {
            if (strcmp((const char*)entries[i].name, "_SD_00") == 0) {
                exword_setpath(m_device, (uint8_t*)"\\_SD_00", 0);
                rsp = exword_authchallenge(m_device, c);
                if (rsp != EXWORD_SUCCESS)
                    exword_authinfo(m_device, &ai);
             }
        }
        exword_free_list(entries);
        exword_userid(m_device, u);
        success = true;
    }
    return success;
}