Debian Codegraph @

w4/aceutils.c

raw
1 /* File: aceutils.c
2 * Author: Fred Wobus ([email protected])
3 * Copyright (c) J Thierry-Mieg and R Durbin, 1999
4 *-------------------------------------------------------------------
5 * Acedb is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
19 * -------------------------------------------------------------------
20 * This file is part of the ACEDB genome database package, written by
21 * Richard Durbin (Sanger Centre, UK) [email protected], and
22 * Jean Thierry-Mieg (CRBM du CNRS, France) [email protected]
23 *
24 * Description: various highlevel utility functions for an acedb process
25 * Exported functions: See acedb.h
26 * HISTORY:
27 * Last edited: Jul 6 10:58 2000 (edgrif)
28 * Created: Wed Nov 3 15:09:10 1999 (fw)
29 * CVS info: $Id$
30 *-------------------------------------------------------------------
31 */
32
33 #include "acedb.h"
34 #include "aceio.h"
35
36 /******************************************************************/
37
38
39 /* used as user_func in context for messOutRegister,
40 * when the message is to be written to ACEOUT in acedb-style */
41 void acedbPrintMessage (char *message, void *user_pointer)
42 {
43 ACEOUT fo = (ACEOUT)user_pointer;
44 char *string;
45 char *start;
46 char *cp;
47 struct messContextStruct oldContext;
48 struct messContextStruct nullContext = { NULL, NULL };
49
50 /* It is possible that code called in this function
51 * may call messout etc.
52 * We need to make sure that we don't get back to this
53 * function to handle the output of messout, so
54 * we de-register this function as the messout-handler
55 * for the duration of this function.
56 */
57 oldContext = messOutRegister (nullContext);
58
59 string = strnew (message, 0);
60 start = string;
61 cp = string;
62
63 while (*cp)
64 {
65 if (*cp == '\n')
66 {
67 *cp = '\0';
68 aceOutPrint (fo, "// %s\n", start);
69 start = cp+1;
70 }
71 ++cp;
72 }
73
74 /* I'm not even sure if this is necessary, the above code looks like it */
75 /* will stop when the last line is printed anyway... */
76 if (*start)
77 aceOutPrint (fo, "// %s\n", start); /* print last line */
78
79 messfree (string);
80
81 messOutRegister (oldContext);
82
83 return;
84 } /* acedbPrintMessage */
85
86 /******************************************************************/
87
88 void simpleCrashRoutine (void)
89 /* The least amount of cleanup work we need to do,
90 this function is the default for the messcrashroutine,
91 more elaborate functions will typically save the current
92 session or close windows etc. */
93 {
94 sessionReleaseWriteAccess() ; /* must remove lock file */
95 readlockDeleteFile (); /* release readlock */
96
97 filtmpcleanup () ; /* deletes any temporary files made */
98
99 messout ("NB: changes made since the last explicit save "
100 "have NOT been saved\n") ;
101 return;
102 } /* simpleCrashRoutine */
103
104 /************************* eof ************************************/
105