~ubuntu-branches/ubuntu/intrepid/psicode/intrepid

« back to all changes in this revision

Viewing changes to src/lib/libchkpt/prefix.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2006-09-10 14:01:33 UTC
  • Revision ID: james.westby@ubuntu.com-20060910140133-ib2j86trekykfsfv
Tags: upstream-3.2.3
ImportĀ upstreamĀ versionĀ 3.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!
 
2
  \file prefix.c
 
3
  \ingroup (CHKPT)
 
4
*/
 
5
 
 
6
#include <stdlib.h>
 
7
#include <string.h>
 
8
#include "chkpt.h"
 
9
#include <psifiles.h>
 
10
#include <libpsio/psio.h>
 
11
 
 
12
/*!
 
13
**  char *chkpt_rd_prefix() 
 
14
**  Reads the global default chkpt prefix keyword stored in the CHKPT file.
 
15
**
 
16
**  returns: the prefix string
 
17
** \ingroup (CHKPT)
 
18
*/
 
19
 
 
20
char *chkpt_rd_prefix(void)
 
21
{  
 
22
  char *prefix;
 
23
 
 
24
  prefix = (char *) malloc(CHKPT_PREFIX_LEN*sizeof(char));
 
25
 
 
26
  psio_read_entry(PSIF_CHKPT, "Default prefix", prefix, CHKPT_PREFIX_LEN*sizeof(char));
 
27
 
 
28
  return prefix;
 
29
}
 
30
 
 
31
/*!
 
32
**  void chkpt_wt_prefix() 
 
33
**  Writes the global default chkpt prefix keyword.
 
34
**
 
35
**  \param prefix = the prefix string (must be CHKPT_PREFIX_LEN long)
 
36
**
 
37
**  returns: none
 
38
** \ingroup (CHKPT)
 
39
*/
 
40
void chkpt_wt_prefix(char *prefix)
 
41
{  
 
42
  psio_write_entry(PSIF_CHKPT, "Default prefix", prefix, CHKPT_PREFIX_LEN*sizeof(char));
 
43
}
 
44
 
 
45
 
 
46
/*!
 
47
**  void chkpt_set_prefix() 
 
48
**  Sets the default chkpt prefix in global memory.  After this is set,
 
49
**  it is intended that all chkpt_rd_() and chkpt_wt_() calls will use
 
50
**  this prefix for psio keyword strings.
 
51
**
 
52
**  \param prefix = the prefix string
 
53
**
 
54
**  returns: none
 
55
** \ingroup (CHKPT)
 
56
*/
 
57
void chkpt_set_prefix(char *prefix)
 
58
{
 
59
  strcpy(chkpt_prefix, prefix);
 
60
}
 
61
 
 
62
/*!
 
63
**  void chkpt_commit_prefix() 
 
64
**  Writes the default chkpt prefix from global memory into the chkpt file.
 
65
**
 
66
**  arguments: none
 
67
**
 
68
**  returns: none
 
69
** \ingroup (CHKPT)
 
70
*/
 
71
void chkpt_commit_prefix(void)
 
72
{
 
73
  chkpt_wt_prefix(chkpt_prefix);
 
74
}
 
75
 
 
76
/*!
 
77
**  void chkpt_reset_prefix() 
 
78
**  Sets the chkpt prefix in global memory back to its default.  At 
 
79
**  present this is a null string.
 
80
**
 
81
**  arguments: none
 
82
**
 
83
**  returns: none
 
84
** \ingroup (CHKPT)
 
85
*/
 
86
void chkpt_reset_prefix(void)
 
87
{
 
88
  chkpt_prefix[0] = '\0';
 
89
}
 
90
 
 
91
/*!
 
92
**  char * chkpt_get_prefix() 
 
93
**  Returns a copy of the current chkpt prefix default stored 
 
94
**  in global memory.
 
95
**
 
96
**  arguments: none
 
97
**
 
98
**  returns: prefix = the current global prefix
 
99
** \ingroup (CHKPT)
 
100
*/
 
101
char *chkpt_get_prefix(void)
 
102
{
 
103
  char *prefix;
 
104
 
 
105
  prefix = (char *) malloc(CHKPT_PREFIX_LEN*sizeof(char));
 
106
 
 
107
  strcpy(prefix,chkpt_prefix);
 
108
 
 
109
  return prefix;
 
110
}