Subversion Repositories freemyipod

Rev

Rev 770 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 770 Rev 785
Line 55... Line 55...
55
    "Not implemented",        /* EMCORE_ERROR_NOT_IMPLEMENTED = 7 */
55
    "Not implemented",        /* EMCORE_ERROR_NOT_IMPLEMENTED = 7 */
56
    "No more entries in dir", /* EMCORE_ERROR_NO_MORE_ENTRIES = 8 */
56
    "No more entries in dir", /* EMCORE_ERROR_NO_MORE_ENTRIES = 8 */
57
    "I/O error",              /* EMCORE_ERROR_IO = 9              */
57
    "I/O error",              /* EMCORE_ERROR_IO = 9              */
58
};
58
};
59
 
59
 
60
void dump_packet(const void* data, const size_t length)
60
void dump_packet(const void* data, size_t length)
61
{
61
{
62
    static size_t i;
62
    static size_t i;
63
 
63
 
64
    for (i = 0; i < length; ++i)
64
    for (i = 0; i < length; ++i)
65
    {
65
    {
Line 77... Line 77...
77
    }
77
    }
78
 
78
 
79
    fprintf(stderr, "\n");
79
    fprintf(stderr, "\n");
80
}
80
}
81
 
81
 
82
void alignsplit(struct alignsizes* sizeptr, const uint32_t addr,
82
void alignsplit(struct alignsizes* sizeptr, uint32_t addr,
83
    const uint32_t size, const uint32_t blksize, const uint32_t align)
83
    uint32_t size, uint32_t blksize, uint32_t align)
84
{
84
{
85
    uint32_t end, bodyaddr, tailaddr;
85
    uint32_t end, bodyaddr, tailaddr;
86
 
86
 
87
    if (size <= blksize)
87
    if (size <= blksize)
88
    {
88
    {
Line 119... Line 119...
119
    sizeptr->body = tailaddr - bodyaddr;
119
    sizeptr->body = tailaddr - bodyaddr;
120
 
120
 
121
    return;
121
    return;
122
}
122
}
123
 
123
 
124
time_t fat_time_to_unix_ts(const short wrttime, const short wrtdate)
124
time_t fat_time_to_unix_ts(short wrttime, short wrtdate)
125
{
125
{
126
    struct tm result;
126
    struct tm result;
127
    /*
127
    /*
128
        Example time: 0x9365
128
        Example time: 0x9365
129
        in memory:
129
        in memory:
Line 146... Line 146...
146
    result.tm_year = ((wrtdate >> 9) & 0x7f) + 80;
146
    result.tm_year = ((wrtdate >> 9) & 0x7f) + 80;
147
 
147
 
148
    return mktime(&result);
148
    return mktime(&result);
149
}
149
}
150
 
150
 
151
int32_t unix_ts_to_fat_time(const time_t datetime)
151
int32_t unix_ts_to_fat_time(time_t datetime)
152
{
152
{
153
    struct tm* tm_ptr;
153
    struct tm* tm_ptr;
154
    
154
    
155
    tm_ptr = localtime(&datetime);
155
    tm_ptr = localtime(&datetime);
156
    
156
    
Line 160... Line 160...
160
           (tm_ptr->tm_mday << 0x10) |
160
           (tm_ptr->tm_mday << 0x10) |
161
           ((tm_ptr->tm_mon + 1) << 0x15) |
161
           ((tm_ptr->tm_mon + 1) << 0x15) |
162
           ((tm_ptr->tm_year - 80) << 0x19);
162
           ((tm_ptr->tm_year - 80) << 0x19);
163
}
163
}
164
 
164
 
165
void print_error(const int code)
165
void print_error(int code)
166
{
166
{
167
    if (code > 0)
167
    if (code > 0)
168
    {
168
    {
169
        fprintf(stderr, "emcore error: %s\n", emcore_error_messages[code]);
169
        fprintf(stderr, "emcore error: %s\n", emcore_error_messages[code]);
170
    }
170
    }