]>
Commit | Line | Data |
---|---|---|
1 | /* $Header$ | |
2 | * | |
3 | * Utility routines used by the MOIRA extraction programs. | |
4 | * | |
5 | * (c) Copyright 1988 by the Massachusetts Institute of Technology. | |
6 | * For copying and distribution information, please see the file | |
7 | * <mit-copyright.h>. | |
8 | */ | |
9 | ||
10 | ||
11 | #include <mit-copyright.h> | |
12 | #include <stdio.h> | |
13 | #include <sys/time.h> | |
14 | #include <moira.h> | |
15 | #include <moira_site.h> | |
16 | ||
17 | ||
18 | fix_file(targetfile) | |
19 | char *targetfile; | |
20 | { | |
21 | char oldfile[64], filename[64]; | |
22 | ||
23 | sprintf(oldfile, "%s.old", targetfile); | |
24 | sprintf(filename, "%s~", targetfile); | |
25 | if (rename(targetfile, oldfile) == 0) { | |
26 | if (rename(filename, targetfile) < 0) { | |
27 | rename(oldfile, targetfile); | |
28 | perror("Unable to install new file (rename failed)\n"); | |
29 | fprintf(stderr, "Filename = %s\n", targetfile); | |
30 | exit(MR_CCONFIG); | |
31 | } | |
32 | } else { | |
33 | if (rename(filename, targetfile) < 0) { | |
34 | perror("Unable to rename old file\n"); | |
35 | fprintf(stderr, "Filename = %s\n", targetfile); | |
36 | exit(MR_CCONFIG); | |
37 | } | |
38 | } | |
39 | unlink(oldfile); | |
40 | } | |
41 | ||
42 | ||
43 | char *dequote(s) | |
44 | register char *s; | |
45 | { | |
46 | char *last = s; | |
47 | ||
48 | while (*s) { | |
49 | if (*s == '"') | |
50 | *s = '\''; | |
51 | else if (*s != ' ') | |
52 | last = s; | |
53 | s++; | |
54 | } | |
55 | if (*last == ' ') | |
56 | *last = '\0'; | |
57 | else | |
58 | *(++last) = '\0'; | |
59 | return(s); | |
60 | } |