Skip to content

Latest commit

 

History

History
675 lines (549 loc) · 17 KB

platform_unix.c

File metadata and controls

675 lines (549 loc) · 17 KB
 
Mar 28, 2008
Mar 28, 2008
1
2
3
4
5
6
7
/**
* MojoPatch; a tool for updating data in the field.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
Jan 5, 2004
Jan 5, 2004
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/param.h>
#include <errno.h>
#include <assert.h>
Jul 14, 2004
Jul 14, 2004
20
#include <sys/wait.h>
Jul 14, 2004
Jul 14, 2004
21
22
#if USE_PTHREAD
Jan 5, 2004
Jan 5, 2004
23
#include <pthread.h>
Jul 14, 2004
Jul 14, 2004
24
#endif
Jan 5, 2004
Jan 5, 2004
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "platform.h"
#include "ui.h"
int file_exists(const char *fname)
{
struct stat statbuf;
return(stat(fname, &statbuf) == 0);
} /* file_exists */
int file_is_directory(const char *fname)
{
struct stat statbuf;
int retval = 0;
if (stat(fname, &statbuf) == 0)
{
if (S_ISDIR(statbuf.st_mode))
retval = 1;
} /* if */
return(retval);
} /* file_is_directory */
int file_is_symlink(const char *fname)
{
struct stat statbuf;
int retval = 0;
if (lstat(fname, &statbuf) == 0)
{
if (S_ISLNK(statbuf.st_mode))
retval = 1;
} /* if */
return(retval);
} /* file_is_symlink */
/* enumerate contents of (base) directory. */
file_list *make_filelist(const char *base)
{
file_list *retval = NULL;
file_list *l = NULL;
file_list *prev = NULL;
DIR *dir;
struct dirent *ent;
errno = 0;
dir = opendir(base);
if (dir == NULL)
{
_fatal("Error: could not read dir %s: %s.", base, strerror(errno));
return(NULL);
} /* if */
while (1)
{
ent = readdir(dir);
if (ent == NULL) /* we're done. */
break;
if (strcmp(ent->d_name, ".") == 0)
continue;
if (strcmp(ent->d_name, "..") == 0)
continue;
/*
* !!! FIXME: This is a workaround until symlinks are really
* !!! FIXME: supported...just pretend they don't exist for now. :(
*/
{
char buf[MAXPATHLEN];
snprintf(buf, sizeof (buf), "%s/%s", base, ent->d_name);
if (file_is_symlink(buf))
continue;
}
l = (file_list *) malloc(sizeof (file_list));
if (l == NULL)
{
_fatal("Error: out of memory.");
break;
} /* if */
l->fname = (char *) malloc(strlen(ent->d_name) + 1);
if (l->fname == NULL)
{
free(l);
_fatal("Error: out of memory.");
break;
} /* if */
strcpy(l->fname, ent->d_name);
if (retval == NULL)
retval = l;
else
prev->next = l;
prev = l;
l->next = NULL;
} /* while */
closedir(dir);
return(retval);
} /* make_filelist */
Jan 27, 2006
Jan 27, 2006
136
int get_file_size(const char *fname, unsigned int *fsize)
Jan 5, 2004
Jan 5, 2004
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
struct stat statbuf;
assert(fsize != NULL);
if (stat(fname, &statbuf) == -1)
{
_fatal("Error: failed to get filesize of [%s]: %s.",
fname, strerror(errno));
return(0);
} /* if */
*fsize = statbuf.st_size;
return(1);
} /* get_file_size */
char *get_realpath(const char *path)
{
char resolved_path[MAXPATHLEN];
char *retval = NULL;
errno = 0;
if (!realpath(path, resolved_path))
{
_fatal("Can't determine full path of [%s]: %s.",
path, strerror(errno));
return(NULL);
} /* if */
retval = malloc(strlen(resolved_path) + 1);
if (retval == NULL)
{
_fatal("Error: out of memory.");
return(NULL);
} /* if */
strcpy(retval, resolved_path);
return(retval);
} /* get_realpath */
Apr 22, 2005
Apr 22, 2005
179
#if PLATFORM_MACOSX
Jan 5, 2004
Jan 5, 2004
180
181
182
183
184
185
186
#include <ApplicationServices/ApplicationServices.h>
static char *parse_xml(char *ptr, char **tag, char **val)
{
char *ptr2;
while ( (ptr = strchr(ptr, '<')) != NULL )
{
May 28, 2004
May 28, 2004
187
188
189
190
ptr++; /* skip past '<' to start of tag.*/
if (*ptr == '/') continue; /* prior endtag? */
if (*ptr == '!') continue; /* initial crap? */
if (*ptr == '?') continue; /* initial crap? */
Jan 5, 2004
Jan 5, 2004
191
192
*tag = ptr;
May 28, 2004
May 28, 2004
193
194
*(ptr-1) = '/'; /* prepend a '/' so we can search for the endtag. */
ptr2 = strchr(ptr, ' '); /* look for a space (tag attributes?) */
Jan 5, 2004
Jan 5, 2004
195
if ( (ptr = strchr(ptr, '>')) == NULL ) return(NULL);
May 28, 2004
May 28, 2004
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
if ((ptr2) && (ptr2 < ptr)) *ptr2 = '\0'; /* chop out attributes. */
*ptr = '\0'; /* chop off '<' at end of tag. */
*val = ptr + 1; /* (*val) == start of children of this tag. */
/* Catch <tagname/> tags... */
ptr2 = ptr - 1;
while ( (ptr2 != *tag) && (isspace(*ptr2)) )
ptr2--;
if ((ptr2 != *tag) && (*ptr2 == '/')) /* it's a <tag/> ... skip it. */
{
ptr = *val;
continue;
} /* if */
/* look for endtag... */
ptr++;
Jan 5, 2004
Jan 5, 2004
213
214
while ( (ptr = strstr(ptr, (*tag)-1)) != NULL )
{
May 28, 2004
May 28, 2004
215
216
if (*(ptr-1) != '<') { ptr++; continue; } /* false positive */
*(ptr-1) = '\0'; /* null-terminate tag's children. */
Jan 5, 2004
Jan 5, 2004
217
218
219
break;
} /* while */
May 28, 2004
May 28, 2004
220
/* return everything after this tag's children. */
Jan 5, 2004
Jan 5, 2004
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
return((ptr == NULL) ? NULL : ptr + 1);
} /* while */
return(NULL);
} /* parse_xml */
static char *find_info_plist_version(char *ptr)
{
int have_key = 0;
char *tag;
char *val;
while ( (ptr = parse_xml(ptr, &tag, &val)) != NULL )
{
if (have_key)
{
have_key = 0;
if (strcasecmp(tag, "string") == 0)
return(val);
} /* if */
if ((strcasecmp(tag, "plist") == 0) || (strcasecmp(tag, "dict") == 0))
{
ptr = val;
continue;
} /* if */
May 25, 2004
May 25, 2004
249
250
251
252
253
254
255
256
257
258
259
/* You should only use CFBundleShortVersionString, for various
* reasons not worth explaining here. CFBundleVersion is here
* for older products that need to update to the other tag.
*/
if (strcasecmp(tag,"key") == 0)
{
if (strcasecmp(val,"CFBundleVersion") == 0)
have_key = 1;
if (strcasecmp(val,"CFBundleShortVersionString") == 0)
have_key = 1;
} /* if */
Jan 5, 2004
Jan 5, 2004
260
261
262
263
264
265
} /* while */
return(NULL);
} /* find_info_plist_version */
May 25, 2004
May 25, 2004
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/* !!! FIXME: Code duplication */
static char *find_info_plist_bundle_id(char *ptr)
{
int have_key = 0;
char *tag;
char *val;
while ( (ptr = parse_xml(ptr, &tag, &val)) != NULL )
{
if (have_key)
{
have_key = 0;
if (strcasecmp(tag, "string") == 0)
return(val);
} /* if */
if ((strcasecmp(tag, "plist") == 0) || (strcasecmp(tag, "dict") == 0))
{
ptr = val;
continue;
} /* if */
if (strcasecmp(tag,"key") == 0)
{
if (strcasecmp(val,"CFBundleIdentifier") == 0)
have_key = 1;
} /* if */
} /* while */
return(NULL);
} /* find_info_plist_version */
Apr 22, 2005
Apr 22, 2005
297
#endif /* PLATFORM_MACOSX */
May 25, 2004
May 25, 2004
298
299
May 18, 2005
May 18, 2005
300
301
/* you are already chdir()'d when this is called. */
int get_product_version(const char *ident, char *buf, size_t bufsize)
Jan 5, 2004
Jan 5, 2004
302
{
Apr 22, 2005
Apr 22, 2005
303
#if PLATFORM_MACOSX
May 30, 2004
May 30, 2004
304
const char *fname = "Contents/Info.plist"; /* already chdir'd for this. */
Jan 5, 2004
Jan 5, 2004
305
306
char *mem = NULL;
char *ptr;
Jan 27, 2006
Jan 27, 2006
307
unsigned int fsize;
Jan 5, 2004
Jan 5, 2004
308
309
310
311
312
313
314
315
316
317
318
int retval = 0;
FILE *io = NULL;
if ( !get_file_size(fname, &fsize) ) goto parse_info_plist_bailed;
if ( (mem = malloc(fsize + 1)) == NULL ) goto parse_info_plist_bailed;
if ( (io = fopen(fname, "r")) == NULL ) goto parse_info_plist_bailed;
if ( (fread(mem, fsize, 1, io)) != 1 ) goto parse_info_plist_bailed;
fclose(io);
io = NULL;
mem[fsize] = '\0';
Apr 22, 2005
Apr 22, 2005
319
if (ident != NULL)
May 25, 2004
May 25, 2004
320
{
Apr 22, 2005
Apr 22, 2005
321
322
ptr = find_info_plist_bundle_id(mem);
if ((ptr == NULL) || (strcasecmp(ptr, ident) != 0))
May 25, 2004
May 25, 2004
323
{
Apr 22, 2005
Apr 22, 2005
324
325
326
327
328
329
330
331
332
int yes = ui_prompt_ny("We don't think we're looking at the right directory!"
" Are you SURE this is the right place?"
" If you aren't sure, clicking 'Yes' can destroy unrelated files!");
if (!yes)
{
_fatal("Stopping at user's request.");
free(mem);
return(0);
} /* if */
May 25, 2004
May 25, 2004
333
334
335
} /* if */
} /* if */
Apr 22, 2005
Apr 22, 2005
336
/* !!! FIXME: this is kinda a lame hack. */
May 25, 2004
May 25, 2004
337
338
339
340
if ( (io = fopen(fname, "r")) == NULL ) goto parse_info_plist_bailed;
if ( (fread(mem, fsize, 1, io)) != 1 ) goto parse_info_plist_bailed;
fclose(io);
Jan 5, 2004
Jan 5, 2004
341
ptr = find_info_plist_version(mem);
May 18, 2005
May 18, 2005
342
343
344
345
346
347
if (ptr == NULL)
return(0);
strncpy(buf, ptr, bufsize);
buf[bufsize-1] = '\0';
retval = 1;
Jan 5, 2004
Jan 5, 2004
348
349
350
351
352
353
354
parse_info_plist_bailed:
free(mem);
if (io != NULL)
fclose(io);
return(retval);
Apr 22, 2005
Apr 22, 2005
355
356
#else
_fatal("Not implemented!"); /* !!! FIXME */
May 18, 2005
May 18, 2005
357
*buf = '\0';
Apr 22, 2005
Apr 22, 2005
358
359
return(0);
#endif
May 18, 2005
May 18, 2005
360
} /* check_product_version */
Jan 5, 2004
Jan 5, 2004
361
362
Apr 22, 2005
Apr 22, 2005
363
364
365
366
367
368
int locate_product_by_identifier(const char *str, char *buf, size_t bufsize)
{
#if PLATFORM_MACOSX
/* Ask LaunchServices to find product by identifier... */
OSStatus rc;
CFURLRef url = NULL;
Jan 27, 2006
Jan 27, 2006
369
370
371
CFStringRef id = CFStringCreateWithBytes(NULL,
(const unsigned char *) str,
strlen(str),
Apr 22, 2005
Apr 22, 2005
372
373
374
375
376
377
kCFStringEncodingISOLatin1, 0);
rc = LSFindApplicationForInfo(kLSUnknownCreator, id, NULL, NULL, &url);
CFRelease(id);
if (rc == noErr)
{
Jan 27, 2006
Jan 27, 2006
378
379
380
int b = (int) CFURLGetFileSystemRepresentation(url, TRUE,
(unsigned char *) buf,
bufsize);
May 18, 2005
May 18, 2005
381
if (b) b = 1;
Apr 22, 2005
Apr 22, 2005
382
CFRelease(url);
May 18, 2005
May 18, 2005
383
if ((b) && (strstr(buf, "/.Trash/")))
May 18, 2005
May 18, 2005
384
385
386
387
388
{
_fatal("It looks like your installation is in the Trash can."
" Please take it out of the trash first."
" If this is an old installation, please empty your"
" trash so we find the right one.");
May 18, 2005
May 18, 2005
389
b = -1;
May 18, 2005
May 18, 2005
390
391
} /* if */
May 18, 2005
May 18, 2005
392
return(b);
Apr 22, 2005
Apr 22, 2005
393
394
395
396
397
398
399
400
401
402
} /* if */
return(0);
#else
_fatal("Not implemented!"); /* !!! FIXME */
return(0);
#endif
} /* locate_product_by_identifier */
Jan 5, 2004
Jan 5, 2004
403
404
int update_version(const char *ver)
{
Apr 22, 2005
Apr 22, 2005
405
#if PLATFORM_MACOSX
May 30, 2004
May 30, 2004
406
const char *fname = "Contents/Info.plist"; /* already chdir'd for this. */
Jan 5, 2004
Jan 5, 2004
407
408
char *mem = NULL;
char *ptr;
Jan 27, 2006
Jan 27, 2006
409
unsigned int fsize;
Jan 5, 2004
Jan 5, 2004
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
int retval = 0;
long writestart;
long writeend;
FILE *io = NULL;
if ( !get_file_size(fname, &fsize) ) goto update_version_bailed;
if ( (mem = malloc(fsize + 1)) == NULL ) goto update_version_bailed;
if ( (io = fopen(fname, "r+")) == NULL ) goto update_version_bailed;
if ( (fread(mem, fsize, 1, io)) != 1 ) goto update_version_bailed;
mem[fsize] = '\0';
ptr = find_info_plist_version(mem);
if (ptr == NULL) goto update_version_bailed;
writestart = (long) (ptr - mem);
writeend = writestart + strlen(ptr);
ptr = mem + writeend;
if ( (fseek(io, 0, SEEK_SET) == -1) ) goto update_version_bailed;
if ( (fread(mem, fsize, 1, io)) != 1 ) goto update_version_bailed;
if ( (fseek(io, writestart, SEEK_SET) == -1) ) goto update_version_bailed;
if ( (fwrite(ver, strlen(ver), 1, io)) != 1 ) goto update_version_bailed;
if ( (fwrite(ptr, strlen(ptr), 1, io)) != 1 ) goto update_version_bailed;
for (fsize = (writeend - writestart); fsize > 0; fsize--)
if (fwrite(" ", 1, 1, io) != 1) goto update_version_bailed;
retval = 1;
update_version_bailed:
free(mem);
if (io != NULL)
fclose(io);
if (!retval) _fatal("Can't update product's installed version.");
return(retval);
Jul 14, 2004
Jul 14, 2004
443
444
445
446
447
448
449
450
451
452
#else /* Regular old POSIX-compliant Unix... */
/*
* !!! FIXME: need some way to flag this install as updated...
* !!! FIXME: maybe just leave unimplemented?
*/
_fatal("Not implemented!");
return(0);
Jan 5, 2004
Jan 5, 2004
453
#endif
Apr 22, 2005
Apr 22, 2005
454
} /* update_version */
Jan 5, 2004
Jan 5, 2004
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
int calc_tmp_filenames(char **tmp1, char **tmp2)
{
static char _tmp1[MAXPATHLEN];
static char _tmp2[MAXPATHLEN];
pid_t pid = getpid();
snprintf(_tmp1, sizeof (_tmp1), "/tmp/mojopatch.tmp1.%d", (int) pid);
snprintf(_tmp2, sizeof (_tmp2), "/tmp/mojopatch.tmp2.%d", (int) pid);
*tmp1 = _tmp1;
*tmp2 = _tmp2;
return(1);
} /* calc_tmp_filenames */
static char *basedir = NULL;
static volatile int thread_alive = 0;
static void *spawn_thread(void *arg)
{
static int rc;
rc = system((char *) arg);
thread_alive = 0;
return(&rc);
} /* spawn_thread */
May 18, 2005
May 18, 2005
482
static SpawnResult spawn_binary(const char *cmd)
Jan 5, 2004
Jan 5, 2004
483
{
May 18, 2005
May 18, 2005
484
485
int *ptr = NULL;
int rc = 127;
Jul 14, 2004
Jul 14, 2004
486
487
488
489
490
491
492
#if !USE_PTHREAD
pid_t pid = fork();
if (pid == -1)
{
int e = errno;
_fatal("fork() failed: %d (%s)", e, strerror(e));
May 18, 2005
May 18, 2005
493
return(SPAWN_FAILED);
Jul 14, 2004
Jul 14, 2004
494
495
} /* if */
Apr 22, 2005
Apr 22, 2005
496
else if (pid == 0) /* child process. */
Jul 14, 2004
Jul 14, 2004
497
{
May 18, 2005
May 18, 2005
498
499
500
ptr = (int *) spawn_thread((void *) cmd);
if (ptr) rc = *ptr;
exit(rc != 0);
Jul 14, 2004
Jul 14, 2004
501
502
503
504
505
506
507
508
509
} /* else if */
else
{
while (waitpid(pid, &rc, WNOHANG) == 0)
{
ui_pump();
usleep(10000);
} /* while */
May 18, 2005
May 18, 2005
510
return((rc == 0) ? SPAWN_RETURNGOOD : SPAWN_RETURNBAD);
Jul 14, 2004
Jul 14, 2004
511
512
513
514
} /* else */
#else
pthread_t thr;
Jan 5, 2004
Jan 5, 2004
515
thread_alive = 1;
Jul 14, 2004
Jul 14, 2004
516
Jan 5, 2004
Jan 5, 2004
517
if (pthread_create(&thr, NULL, spawn_thread, cmd) != 0)
May 18, 2005
May 18, 2005
518
return(SPAWN_FAILED);
Jan 5, 2004
Jan 5, 2004
519
520
521
522
523
524
525
while (thread_alive)
{
ui_pump();
usleep(10000);
} /* while */
May 18, 2005
May 18, 2005
526
527
528
pthread_join(thr, (void **) &ptr);
if (ptr) rc = *ptr;
return((rc == 0) ? SPAWN_RETURNGOOD : SPAWN_RETURNBAD);
Jul 14, 2004
Jul 14, 2004
529
#endif
May 18, 2005
May 18, 2005
530
531
532
533
534
} /* spawn_binary */
SpawnResult spawn_xdelta(const char *cmdline)
{
May 18, 2005
May 18, 2005
535
SpawnResult retval;
May 18, 2005
May 18, 2005
536
537
538
539
540
541
const char *binname = "xdelta";
char *cmd = alloca(strlen(cmdline) + strlen(basedir) + strlen(binname) + 5);
if (!cmd)
return(SPAWN_FAILED);
sprintf(cmd, "\"%s/%s\" %s", basedir, binname, cmdline);
May 18, 2005
May 18, 2005
542
543
544
545
546
547
548
retval = spawn_binary(cmd);
/* !!! FIXME: xdelta returns an unexpected value when making a delta. */
/* !!! FIXME: (we check the md5sums from all output anyhow. */
if (retval == SPAWN_RETURNBAD) retval = SPAWN_RETURNGOOD;
return(retval);
Jan 5, 2004
Jan 5, 2004
549
550
551
} /* spawn_xdelta */
May 18, 2005
May 18, 2005
552
553
554
555
556
557
558
559
560
561
562
563
564
/* you are chdir()'d to the directory with the patchfile here. */
SpawnResult spawn_script(const char *scriptname, const char *dstdir)
{
char *cmd = alloca(strlen(scriptname) + strlen(dstdir) + 32);
if (!file_exists(scriptname))
return(SPAWN_FILENOTFOUND);
sprintf(cmd, "./%s '%s'", scriptname, dstdir);
return(spawn_binary(cmd));
} /* spawn_script */
May 18, 2005
May 18, 2005
565
566
char *get_current_dir(char *buf, size_t bufsize)
{
May 18, 2005
May 18, 2005
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
size_t buflen = 0;
if (getcwd(buf, bufsize) == NULL)
return(NULL);
buflen = strlen(buf) + 1;
if (buflen <= bufsize)
{
*buf = '\0';
return(NULL);
} /* if */
if (buf[buflen - 2] != '/')
strcat(buf, "/");
return(buf);
May 18, 2005
May 18, 2005
582
583
584
} /* get_current_dir */
Jan 5, 2004
Jan 5, 2004
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
static void find_basedir(int *argc, char **argv)
{
const char *argv0 = argv[0];
char buf[MAXPATHLEN];
char realbuf[MAXPATHLEN];
if ((argv0 != NULL) && (strchr(argv0, '/') != NULL)) /* path specifed? */
strncpy(buf, argv0, sizeof (buf));
else
{
char *ptr;
char *envr = getenv("PATH");
if (!envr)
return;
while (*envr)
{
ptr = strchr(envr, ':');
if (!ptr)
strcpy(buf, envr);
else
{
memcpy(buf, envr, (size_t) (ptr - envr));
buf[(size_t) (ptr - envr)] = '\0';
} /* else */
envr = ptr + 1;
if (*buf == '\0')
continue;
strcat(buf, "/");
strcat(buf, argv0);
if (access(buf, X_OK) == 0)
break;
if (!ptr)
{
strcpy(buf, "."); /* oh well. */
break;
} /* if */
} /* while */
} /* else */
buf[sizeof (buf) - 1] = '\0'; /* null terminate, just in case. */
if (realpath(buf, realbuf) == NULL)
return;
char *ptr = strrchr(realbuf, '/'); /* chop off binary name. */
if (ptr != NULL)
*ptr = '\0';
if (realbuf[strlen(realbuf)-1] != '/')
strcat(realbuf, "/");
Jun 17, 2005
Jun 17, 2005
641
basedir = malloc(strlen(realbuf) + 1);
Jan 5, 2004
Jan 5, 2004
642
643
644
645
646
647
648
649
650
651
strcpy(basedir, realbuf);
#if PLATFORM_MACOSX
/* Chop off process serial number arg that the Finder adds... */
if ( (*argc >= 2) && (strncmp(argv[1], "-psn_", 5) == 0) )
{
*argc = *argc - 1;
argv[1] = NULL;
/* Now that we know where xdelta will be, chdir out of AppBundle... */
Mar 23, 2005
Mar 23, 2005
652
653
/* !!! FIXME: Fails if there are more than one of these in the string... */
ptr = strstr(realbuf, "/Contents/MacOS/");
Jan 5, 2004
Jan 5, 2004
654
655
if (ptr != NULL)
{
Mar 23, 2005
Mar 23, 2005
656
ptr++; /* keep a '/' at the end of the string... */
Jan 5, 2004
Jan 5, 2004
657
658
659
660
661
662
663
664
665
666
667
668
669
670
*ptr = '\0';
chdir(realbuf);
} /* if */
} /* if */
#endif
} /* find_basedir */
int main(int argc, char **argv)
{
int retval;
find_basedir(&argc, argv);
retval = mojopatch_main(argc, argv);
free(basedir);
May 28, 2004
May 28, 2004
671
return((retval == PATCHSUCCESS) ? 0 : 1);
Jan 5, 2004
Jan 5, 2004
672
673
674
} /* unixmain */
/* end of platform_unix.c ... */