1 /* tailor.c -- target dependent functions
2 * Copyright (C) 1993 Carsten Steger (carsten.steger@informatik.tu-muenchen.de)
3 * This is free software; you can redistribute it and/or modify it under the
4 * terms of the GNU General Public License, see the file COPYING.
8 * This file contains Amiga specific functions for gzip.
17 #include <exec/types.h>
19 #include <dos/dosextens.h>
20 #include <dos/dosasl.h>
21 #include <proto/dos.h>
26 extern struct DosLibrary
*DOSBase
;
28 extern void *xmalloc(unsigned int size
);
30 static char *expand_next_file (char *pattern
);
31 static int in_prev_args (char *arg
, char **argv
, int argc
);
32 extern void _expand_args (int *oargc
, char ***oargv
);
35 static char *expand_next_file (pattern
)
40 static struct AnchorPath
*an
= NULL
;
50 an
= xmalloc (sizeof (struct AnchorPath
) + MAXPATH
);
51 memset (an
, 0, sizeof (struct AnchorPath
) + MAXPATH
);
52 an
->ap_BreakBits
= SIGBREAKF_CTRL_C
;
53 an
->ap_Strlen
= MAXPATH
;
54 an
->ap_Flags
= APF_DOWILD
;
55 err
= MatchFirst (pattern
, an
);
60 pathname
= an
->ap_Buf
;
61 } while (err
== 0 && pathname
== NULL
);
75 static int in_prev_args (arg
, argv
, argc
)
82 for (i
= 1; i
< argc
- 1; i
++)
83 if (stricmp (arg
, argv
[i
]) == 0)
89 void _expand_args (oargc
, oargv
)
95 static char buf
[MAXPATH
];
96 int argc
, no_match_at_all
, num_matches
, contains_wildcards
;
98 /* With Kickstart 1.3 wildcards can't be expanded. */
99 if (DOSBase
->dl_lib
.lib_Version
< 37) return;
102 contains_wildcards
= 0;
104 argv
= xmalloc (MAXARGS
* sizeof (char *));
106 argv
[argc
++] = (*oargv
)[0];
107 for (i
= 1; i
< *oargc
; i
++)
109 if (ParsePattern ((*oargv
)[i
], buf
, MAXPATH
))
111 contains_wildcards
= 1;
113 while (str
= expand_next_file ((*oargv
)[i
]))
116 expand_next_file (NULL
);
117 fprintf (stderr
,"Too many files.\n");
122 /* Avoid duplicate entries */
123 if (!in_prev_args (str
, argv
, argc
))
125 argv
[argc
++] = strdup (str
);
129 if (num_matches
!= 0)
135 fprintf (stderr
,"Too many files.\n");
140 if (!in_prev_args ((*oargv
)[i
], argv
, argc
))
141 argv
[argc
++] = (*oargv
)[i
];
146 if (no_match_at_all
&& contains_wildcards
) {
147 fprintf (stderr
,"No match.\n");
153 int utime (path
, times
)
155 struct utimbuf
*times
;
157 struct DateStamp date
;
161 /* With Kickstart 1.3 setting the filedate could be done, I guess.
162 * Maybe someone else will implement and test the code for this
163 * case (I don't have Kickstart 1.3). */
164 if (DOSBase
->dl_lib
.lib_Version
< 37) return 0;
166 /* Amiga dates are counted from 1. Jan 1978 as opposed to 1. Jan 1970
167 * on Unix. Therefore we have to subtract 2922 days (8*365+2). We also
168 * have to subtract the value of __timezone since SAS/C uses "CST+06"
169 * as the default value. */
170 modtime
= times
->modtime
- __timezone
;
171 date
.ds_Days
= (modtime
/ 86400) - 2922;
173 date
.ds_Minute
= modtime
/ 60;
175 date
.ds_Tick
= modtime
* TICKS_PER_SECOND
;
176 error
= SetFileDate (path
, &date
);
177 if (error
== DOSFALSE
)