Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/amiga/filedate.c  view on Meta::CPAN

 * 23 Aug 00, Paul Kienitz, moved timezone code out from here into separate
 *            platform-independent module 'timezone.c'.
 * 31 Dec 00, Christian Spieler, moved system-specific timezone help funcions
 *            back in here, from 'timezone.c'.
 * 07 Jan 01, Paul Kienitz, Chr. Spieler, added missing #include "timezone.h"
 *            and "symbolic" preprocessor constants for time calculations.
 * 15 Jan 02, Paul Kienitz, excluded all time handling code from compilation
 *            for Zip utilities (when "defined(UTIL)")
 */

#ifndef __amiga_filedate_c
#define __amiga_filedate_c


#include "zip.h"
#include <ctype.h>
#include <errno.h>

#include <exec/types.h>
#include <exec/execbase.h>
#include <exec/memory.h>
#include <dos/dosextens.h>

#ifdef AZTEC_C
#  include <libraries/dos.h>
#  include <libraries/dosextens.h>
#  include <clib/exec_protos.h>
#  include <clib/dos_protos.h>
#  include <clib/locale_protos.h>
#  include <pragmas/exec_lib.h>
#  include <pragmas/dos_lib.h>
#  include <pragmas/locale_lib.h>
#  define ESRCH  ENOENT
#  define EOSERR EIO
#endif

#ifdef __SASC
#  include <stdlib.h>
#  if (defined(_M68020) && (!defined(__USE_SYSBASE)))
                            /* on 68020 or higher processors it is faster   */
#    define __USE_SYSBASE   /* to use the pragma libcall instead of syscall */
#  endif                    /* to access functions of the exec.library      */
#  include <proto/exec.h>   /* see SAS/C manual:part 2,chapter 2,pages 6-7  */
#  include <proto/dos.h>
#  include <proto/locale.h>
#  ifdef DEBUG
#     include <sprof.h>
#  endif
#  ifdef MWDEBUG
#    include <stdio.h>      /* include both before memwatch.h again just */
#    include <stdlib.h>     /* to be safe */
#    include "memwatch.h"
#  endif /* MWDEBUG */
#endif /* __SASC */

#include "crypt.h"            /* just so we can tell if CRYPT is supported */


#if (!defined(FUNZIP) && !defined(UTIL))

#include "timezone.h"         /* for AMIGA-specific timezone callbacks */

#ifndef SUCCESS
#  define SUCCESS (-1L)
#  define FAILURE 0L
#endif

#define ReqVers 36L        /* required library version for SetFileDate() */
#define ENVSIZE 100        /* max space allowed for an environment var   */

extern struct ExecBase *SysBase;

#ifndef min
#  define min(a, b)  ((a) < (b) ? (a) : (b))
#  define max(a, b)  ((a) < (b) ? (b) : (a))
#endif

#if defined(ZIP) || defined(HAVE_MKTIME)
static const unsigned short ydays[] =
    { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
#else
extern const unsigned short ydays[];  /* in unzip's fileio.c */
#endif

#define LEAP(y)     (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0)
#define YDAYS(m, y) (ydays[m] + (m > 1 && LEAP(y)))
/* Number of leap years from 1978 to `y' (not including `y' itself). */
#define ANLEAP(y)   (((y) - 1977) / 4 - ((y) - 1901) / 100 + ((y) - 1601) / 400)
#define SECSPERMIN  60
#define MINSPERHOUR 60
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
#define SECSPERDAY  86400L

/* prototypes */
char *getenv(const char *var);
#ifdef __SASC
/*  XXX !!  We have really got to find a way to operate without these. */
int setenv(const char *var, const char *value, int overwrite);
void set_TZ(long time_zone, int day_light);
#endif

LONG FileDate(char *filename, time_t u[]);
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
int Agetch(void);

/* =============================================================== */

/***********************/
/* Function filedate() */
/***********************/

/*  FileDate() (originally utime.c), by Paul Wells.  Modified by John Bush
 *  and others (see also sendpkt() comments, below); NewtWare SetFileDate()
 *  clone cheaply ripped off from utime().
 */

/* DESCRIPTION
 * This routine chooses between 2 methods to set the file date on AMIGA.
 * Since AmigaDOS 2.x came out, SetFileDate() was available in ROM (v.36
 * and higher).  Under AmigaDOS 1.3.x (less than v.36 ROM), SetFileDate()
 * must be accomplished by constructing a message packet and sending it



( run in 4.354 seconds using v1.01-cache-2.11-cpan-5735350b133 )