2
* $Id: arjdata.c,v 1.6 2004/04/17 11:44:46 andrew_belov Exp $
3
* ---------------------------------------------------------------------------
4
* User-modifyable resource information. It must be kept binding-independent.
15
#define TAG_SPECIAL_BEGIN '{'
16
#define TAG_SPECIAL_END '}'
22
#define ALIGN_CENTER 2
24
/* Resource list hash array. The syntax is: <tag> <substitution> */
26
static char *resources[][2]=
37
/* ARJ Software, Inc. counterparts (note: always 4 chars, spaces allowed!) */
39
"COUNTERPARTS", "2.7x" /* The docs mention DOS */
41
/* Short product description */
67
#elif defined(__FreeBSD__)
71
#elif defined(__QNXNTO__)
78
/* Platform -- legal filename format */
89
/* Platform specification for FILE_ID.DIZ (appended to description) */
94
#elif defined(__FreeBSD__)
98
#elif defined(__QNXNTO__)
106
/* Long product description */
111
"ARJ version @VERSION Open-Source"
112
#elif LOCALE==LANG_ru
113
"ARJ, ����� @VERSION"
117
"ARJ for @PLATFORM, version @VERSION"
118
#elif LOCALE==LANG_ru
119
"ARJ ��� @PLATFORM, ����� @VERSION"
123
/* Registration token */
132
/* Extension of executables (for resources) */
133
{"EXE_EXT", EXE_EXTENSION},
134
/* Archive extension */
137
".ARJ" /* ASR 27/10/2000 -- for packaging
147
/* Returns year (for Q&D copyright formatting) */
149
static int cur_year()
154
cur_unixtime=time(NULL);
155
stm=localtime(&cur_unixtime);
156
return(stm->tm_year+1900);
161
void date_fmt(char *dest)
164
static char *mon[]={"January", "February", "March", "April", "May", "June",
165
"July", "August", "September", "October", "November",
167
#elif LOCALE==LANG_fr
168
static char *mon[]={"janvier", "fevrier", "mars", "avril", "mai", "juin",
169
"juillet", "aout", "septembre", "octobre", "novembre",
171
#elif LOCALE==LANG_de
172
static char *mon[]={"Januar", "Februar", "Maerz", "April", "Mai", "Juni",
173
"Juli", "August", "September", "Oktober", "November",
175
#elif LOCALE==LANG_ru
176
static char *mon[]={"ﭢ���", "䥢ࠫ�", "����", "��५�", "���", "���",
177
"���", "������", "ᥭ����", "������", "�����",
183
char *enstr; /* -rd, -th, ... */
186
cur_unixtime=time(NULL);
187
stm=localtime(&cur_unixtime);
189
if(stm->tm_mday==1||stm->tm_mday==21||stm->tm_mday==31)
191
else if(stm->tm_mday==2||stm->tm_mday==22)
193
else if(stm->tm_mday==3||stm->tm_mday==23)
197
sprintf(dest, "%s %d%s, %d", mon[stm->tm_mon], stm->tm_mday, enstr, cur_year());
198
#elif LOCALE==LANG_fr
199
sprintf(dest, "%d %s %d", stm->tm_mday, mon[stm->tm_mon], cur_year());
200
#elif LOCALE==LANG_de
201
sprintf(dest, "%d %s %d", stm->tm_mday, mon[stm->tm_mon], cur_year());
202
#elif LOCALE==LANG_ru
203
sprintf(dest, "%d %s %d �.", stm->tm_mday, mon[stm->tm_mon], cur_year());
207
/* A safe strcpy() */
209
static void safe_strcpy(char *dest, char *src)
211
memmove(dest, src, strlen(src)+1);
214
/* Context substitution routine */
216
char *expand_tags(char *str, int limit)
219
int l, rl; /* Tag/substitution length */
220
int align_lmargin=0, align_rmargin=0;
221
int align_type=ALIGN_NONE;
225
int repl_len, repl_j;
238
else if(*(p+1)==TAG_SPECIAL_BEGIN&&(et=strchr(p+3, TAG_SPECIAL_END))!=NULL)
245
sprintf(date_stg, "%u", cur_year());
251
safe_strcpy(p+rl, p);
252
memcpy(p, date_stg, rl);
259
align_type=ALIGN_RIGHT;
261
align_rmargin=atoi(p+3);
264
align_type=ALIGN_CENTER;
266
align_rmargin=atoi(p+3);
270
if(align_type==ALIGN_RIGHT)
271
shift=align_rmargin-i; /* The margin is 1-relative! */
272
else if(align_type==ALIGN_CENTER)
273
shift=align_rmargin-(i+align_lmargin)/2-1;
274
if(align_type!=ALIGN_NONE&&shift>0&&sl+shift<limit)
277
safe_strcpy(str+align_lmargin+shift, str+align_lmargin);
278
memset(str+align_lmargin, 32, shift);
282
align_type=ALIGN_NONE;
287
safe_strcpy(p, et+1);
292
for(j=0; resources[j][0]!=NULL; j++)
294
l=strlen(resources[j][0]);
295
if(!memcmp(p+1, resources[j][0], l))
297
/* Try to find the longest possible match */
307
printf("ARJDATA: unknown tag <%s>\n", p);
312
rl=strlen(resources[repl_j][1]);
313
/* Is it OK to stick the substitution in? */
316
safe_strcpy(p+rl, p+repl_len+1);
317
memcpy(p, resources[repl_j][1], rl);