2 * Copyright (C) 2002 Manish Singh
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <sys/types.h>
29 compare (const char *f1
,
36 if (stat (f2
, &b2
) || stat (f1
, &b1
))
39 if (b1
.st_size
!= b2
.st_size
)
45 execlp ("cmp", "cmp", "-s", f1
, f2
, NULL
);
50 rpid
= waitpid (pid
, &status
, 0);
51 while (rpid
== -1 && errno
== EINTR
);
56 if (status
!= -1 && WIFEXITED (status
) && WEXITSTATUS (status
) == 0)
67 char *dot
, *lastarg
, *start
;
69 lastarg
= argv
[argc
- 1];
71 dot
= strrchr (lastarg
, '.');
74 len
= strlen (lastarg
);
75 if (len
< strlen ("orbit-idl-2"))
78 start
= lastarg
+ len
- strlen ("orbit-idl-2");
79 if (strcmp (start
, "orbit-idl-2") != 0)
82 else if (dot
[1] != 'h' && dot
[1] != 'c' && strcmp (dot
+ 1, "idl") != 0)
86 (strcmp (argv
[1], "-c") == 0) &&
87 (strcmp (argv
[2], "-d") != 0) &&
88 !stat (argv
[3], &buf
) &&
89 !S_ISDIR (buf
.st_mode
))
90 compare (argv
[2], argv
[3]);
91 else if ((argc
== 3) &&
92 (strcmp (argv
[1], "-d") != 0) &&
93 !stat (argv
[2], &buf
) &&
94 !S_ISDIR (buf
.st_mode
))
95 compare (argv
[1], argv
[2]);
96 else if ((argc
== 6) &&
97 (strcmp (argv
[1], "-c") == 0) &&
98 (strcmp (argv
[2], "-m") == 0) &&
99 !stat (argv
[5], &buf
) &&
100 !S_ISDIR (buf
.st_mode
))
101 compare (argv
[4], argv
[5]);
102 else if ((argc
== 5) &&
103 (strcmp (argv
[1], "-m") == 0) &&
104 !stat (argv
[4], &buf
) &&
105 !S_ISDIR (buf
.st_mode
))
106 compare (argv
[3], argv
[4]);
109 args
= malloc (sizeof (char *) * (argc
+ 1));
114 args
[0] = WITH_INSTALL
;
117 for (i
= 1; i
< argc
; i
++)
122 execvp (args
[0], args
);
123 perror("executing 'install' failed");