OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [fs/] [isofs/] [util.c] - Diff between revs 1765 and 1782

Only display areas with differences | Details | Blame | View Log

Rev 1765 Rev 1782
/*
/*
 *  linux/fs/isofs/util.c
 *  linux/fs/isofs/util.c
 *
 *
 *  The special functions in the file are numbered according to the section
 *  The special functions in the file are numbered according to the section
 *  of the iso 9660 standard in which they are described.  isonum_733 will
 *  of the iso 9660 standard in which they are described.  isonum_733 will
 *  convert numbers according to section 7.3.3, etc.
 *  convert numbers according to section 7.3.3, etc.
 *
 *
 *  isofs special functions.  This file was lifted in its entirety from
 *  isofs special functions.  This file was lifted in its entirety from
 *  the 386bsd iso9660 filesystem, by Pace Willisson <pace@blitz.com>.
 *  the 386bsd iso9660 filesystem, by Pace Willisson <pace@blitz.com>.
 */
 */
 
 
#include <linux/time.h>
#include <linux/time.h>
 
 
int
int
isonum_711 (char * p)
isonum_711 (char * p)
{
{
        return (*p & 0xff);
        return (*p & 0xff);
}
}
 
 
int
int
isonum_712 (char * p)
isonum_712 (char * p)
{
{
        int val;
        int val;
 
 
        val = *p;
        val = *p;
        if (val & 0x80)
        if (val & 0x80)
                val |= 0xffffff00;
                val |= 0xffffff00;
        return (val);
        return (val);
}
}
 
 
int
int
isonum_721 (char * p)
isonum_721 (char * p)
{
{
        return ((p[0] & 0xff) | ((p[1] & 0xff) << 8));
        return ((p[0] & 0xff) | ((p[1] & 0xff) << 8));
}
}
 
 
int
int
isonum_722 (char * p)
isonum_722 (char * p)
{
{
        return (((p[0] & 0xff) << 8) | (p[1] & 0xff));
        return (((p[0] & 0xff) << 8) | (p[1] & 0xff));
}
}
 
 
int
int
isonum_723 (char * p)
isonum_723 (char * p)
{
{
#if 0
#if 0
        if (p[0] != p[3] || p[1] != p[2]) {
        if (p[0] != p[3] || p[1] != p[2]) {
                fprintf (stderr, "invalid format 7.2.3 number\n");
                fprintf (stderr, "invalid format 7.2.3 number\n");
                exit (1);
                exit (1);
        }
        }
#endif
#endif
        return (isonum_721 (p));
        return (isonum_721 (p));
}
}
 
 
int
int
isonum_731 (char * p)
isonum_731 (char * p)
{
{
        return ((p[0] & 0xff)
        return ((p[0] & 0xff)
                | ((p[1] & 0xff) << 8)
                | ((p[1] & 0xff) << 8)
                | ((p[2] & 0xff) << 16)
                | ((p[2] & 0xff) << 16)
                | ((p[3] & 0xff) << 24));
                | ((p[3] & 0xff) << 24));
}
}
 
 
int
int
isonum_732 (char * p)
isonum_732 (char * p)
{
{
        return (((p[0] & 0xff) << 24)
        return (((p[0] & 0xff) << 24)
                | ((p[1] & 0xff) << 16)
                | ((p[1] & 0xff) << 16)
                | ((p[2] & 0xff) << 8)
                | ((p[2] & 0xff) << 8)
                | (p[3] & 0xff));
                | (p[3] & 0xff));
}
}
 
 
int
int
isonum_733 (char * p)
isonum_733 (char * p)
{
{
#if 0
#if 0
        int i;
        int i;
 
 
        for (i = 0; i < 4; i++) {
        for (i = 0; i < 4; i++) {
                if (p[i] != p[7-i]) {
                if (p[i] != p[7-i]) {
                        fprintf (stderr, "bad format 7.3.3 number\n");
                        fprintf (stderr, "bad format 7.3.3 number\n");
                        exit (1);
                        exit (1);
                }
                }
        }
        }
#endif
#endif
        return (isonum_731 (p));
        return (isonum_731 (p));
}
}
 
 
/* We have to convert from a MM/DD/YY format to the unix ctime format.
/* We have to convert from a MM/DD/YY format to the unix ctime format.
 * We have to take into account leap years and all of that good stuff.
 * We have to take into account leap years and all of that good stuff.
 */
 */
int iso_date(char * p, int flag)
int iso_date(char * p, int flag)
{
{
        int year, month, day, hour ,minute, second, tz;
        int year, month, day, hour ,minute, second, tz;
        int crtime, days, i;
        int crtime, days, i;
 
 
        year = p[0] - 70;
        year = p[0] - 70;
        month = p[1];
        month = p[1];
        day = p[2];
        day = p[2];
        hour = p[3];
        hour = p[3];
        minute = p[4];
        minute = p[4];
        second = p[5];
        second = p[5];
        if (flag == 0) tz = p[6]; /* High sierra has no time zone */
        if (flag == 0) tz = p[6]; /* High sierra has no time zone */
        else tz = 0;
        else tz = 0;
 
 
        if (year < 0) {
        if (year < 0) {
                crtime = 0;
                crtime = 0;
        } else {
        } else {
                int monlen[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
                int monlen[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
                extern struct timezone sys_tz;
                extern struct timezone sys_tz;
 
 
                days = year * 365;
                days = year * 365;
                if (year > 2)
                if (year > 2)
                        days += (year+1) / 4;
                        days += (year+1) / 4;
                for (i = 1; i < month; i++)
                for (i = 1; i < month; i++)
                        days += monlen[i-1];
                        days += monlen[i-1];
                if (((year+2) % 4) == 0 && month > 2)
                if (((year+2) % 4) == 0 && month > 2)
                        days++;
                        days++;
                days += day - 1;
                days += day - 1;
                crtime = ((((days * 24) + hour) * 60 + minute) * 60)
                crtime = ((((days * 24) + hour) * 60 + minute) * 60)
                        + second;
                        + second;
                if (sys_tz.tz_dsttime)
                if (sys_tz.tz_dsttime)
                        crtime -= 3600;
                        crtime -= 3600;
 
 
                /* sign extend */
                /* sign extend */
                if (tz & 0x80)
                if (tz & 0x80)
                        tz |= (-1 << 8);
                        tz |= (-1 << 8);
 
 
                /* timezone offset is unreliable on some disks */
                /* timezone offset is unreliable on some disks */
                if (-48 <= tz && tz <= 52)
                if (-48 <= tz && tz <= 52)
                        crtime += tz * 15 * 60;
                        crtime += tz * 15 * 60;
        }
        }
        return crtime;
        return crtime;
}
}
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.