3 * Utility routines used by the MOIRA extraction programs.
5 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
6 * For copying and distribution information, please see the file
11 #include <mit-copyright.h>
15 #include <moira_site.h>
17 extern void sqlglm(char buf[], int *, int *);
19 fix_file(char *targetfile)
21 char oldfile[64], filename[64];
23 sprintf(oldfile, "%s.old", targetfile);
24 sprintf(filename, "%s~", targetfile);
25 if (rename(targetfile, oldfile) == 0)
27 if (rename(filename, targetfile) < 0)
29 rename(oldfile, targetfile);
30 perror("Unable to install new file (rename failed)\n");
31 fprintf(stderr, "Filename = %s\n", targetfile);
37 if (rename(filename, targetfile) < 0)
39 perror("Unable to rename old file\n");
40 fprintf(stderr, "Filename = %s\n", targetfile);
48 char *dequote(char *s)
72 int bufsize = 256, len = 0;
76 com_err(whoami, 0, "build cancelled by user");
80 com_err(whoami, MR_DBMS_ERR, " code %d\n", code);
81 sqlglm(buf, &bufsize, &len);
83 com_err(whoami, 0, "SQL error text = %s", buf);
84 critical_alert("DCM", "%s build encountered DATABASE ERROR %d\n%s",