]>
Commit | Line | Data |
---|---|---|
dfb56d6b | 1 | /* $Header$ |
2 | * | |
2ce085d2 | 3 | * Utility routines used by the MOIRA extraction programs. |
0a5ff702 | 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>. | |
dfb56d6b | 8 | */ |
9 | ||
10 | ||
0a5ff702 | 11 | #include <mit-copyright.h> |
dfb56d6b | 12 | #include <stdio.h> |
13 | #include <sys/time.h> | |
2ce085d2 | 14 | #include <moira.h> |
15 | #include <moira_site.h> | |
dfb56d6b | 16 | |
17 | ||
70c18c18 | 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); | |
2ce085d2 | 30 | exit(MR_CCONFIG); |
70c18c18 | 31 | } |
32 | } else { | |
33 | if (rename(filename, targetfile) < 0) { | |
34 | perror("Unable to rename old file\n"); | |
35 | fprintf(stderr, "Filename = %s\n", targetfile); | |
2ce085d2 | 36 | exit(MR_CCONFIG); |
70c18c18 | 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 | } | |
1889bd72 | 55 | if (*last == ' ') |
56 | *last = '\0'; | |
57 | else | |
58 | *(++last) = '\0'; | |
4d6f76b9 | 59 | return(s); |
70c18c18 | 60 | } |