MISR Toolkit
1.5.1
odl
comments.c
Go to the documentation of this file.
1
/*****************************************************************************
2
3
Description: Routines for attaching comments to aggregate and parameter
4
nodes on an ODL tree and for removing such comments.
5
6
Author: Randy Davis, University of Colorado LASP
7
8
Creation Date: 25 August 1990
9
Last Modified: 18 May 1991
10
11
History:
12
13
Creation - This set of routines was introduced in Version 2.1 of the
14
ODLC library.
15
16
Version 2.2 - 18 May 1991 - M. DeMore, Jet Propulsion Laboratory
17
Removed include statements that were Unix specific and placed them
18
in odldef.h.
19
20
*****************************************************************************/
21
22
#include "
odldef.h
"
23
#include "
odlinter.h
"
24
#include <stdlib.h>
25
26
27
28
29
/*****************************************************************************
30
31
Routine: CommentAggregate
32
33
Description: Attach a comment to or detach one from an aggregate node.
34
The previous comment, if any, is discarded.
35
36
Input:
37
aggregate - Pointer to the aggregate node.
38
comment - Character string with comment to be attached. If
39
this argument is NULL, then the aggregate node
40
will have no comment.
41
42
Output: A value of 1 is returned as the function value if processing
43
is successful. If the operation fails, typically due to a
44
lack of memory in which to store the comment, a value of 0
45
is returned. A value of 0 will also be returned if the
46
input base node argument is NULL.
47
48
*****************************************************************************/
49
50
51
int
CommentAggregate
(
AGGREGATE
aggregate,
char
*comment)
52
{
53
char
*
string
;
/* Pointer to storage space for comment */
54
55
56
if
(aggregate == NULL)
57
{
58
return
(0);
59
}
60
61
/* Detach the current comment, if any, from this aggregate */
62
63
if
(aggregate->
comment
!= NULL)
64
{
65
free (aggregate->
comment
);
66
aggregate->
comment
= NULL;
67
}
68
69
/* If a comment was supplied, copy it and attach it to the node */
70
71
if
(comment == NULL)
72
{
73
aggregate->
comment
= NULL;
74
}
75
else
76
{
77
string
= (
char
*) malloc (strlen (comment)+1);
78
if
(
string
== NULL)
79
{
80
/* Error: couldn't get memory for the copy of the string */
81
82
return
(0);
83
}
84
85
aggregate->
comment
= strcpy (
string
, comment);
86
}
87
88
return
(1);
89
}
90
91
92
/*****************************************************************************
93
94
Routine: CommentParameter
95
96
Description: Attach a comment to or detach one from a parameter node.
97
The previous comment, if any, is discarded.
98
99
Input:
100
parameter - Pointer to the parameter node.
101
comment - Character string with comment to be attached. If
102
this argument is NULL, then the parameter node
103
will have no comment.
104
105
Output: A value of 1 is returned as the function value if processing
106
is successful. If the operation fails, typically due to a
107
lack of memory in which to store the comment, a value of 0
108
is returned. A value of 0 will also be returned if the
109
input parameter argument is NULL.
110
111
*****************************************************************************/
112
113
114
int
CommentParameter
(
PARAMETER
parameter,
char
*comment)
115
{
116
char
*
string
;
/* Pointer to storage space for comment */
117
118
119
if
(parameter == NULL)
120
{
121
return
(0);
122
}
123
124
/* Detach the current comment, if any, from this parameter */
125
126
if
(parameter->
comment
!= NULL)
127
{
128
free (parameter->
comment
);
129
parameter->
comment
= NULL;
130
}
131
132
/* If a comment was supplied, copy it and attach it to the node */
133
134
if
(comment == NULL)
135
{
136
parameter->
comment
= NULL;
137
}
138
else
139
{
140
string
= (
char
*) malloc (strlen (comment)+1);
141
if
(
string
== NULL)
142
{
143
/* Error: couldn't get memory for the copy of the string */
144
145
return
(0);
146
}
147
148
parameter->
comment
= strcpy (
string
, comment);
149
}
150
151
return
(1);
152
}
CommentParameter
int CommentParameter(PARAMETER parameter, char *comment)
Definition:
comments.c:114
Parameter_Node::comment
char * comment
Definition:
odldef.h:139
Aggregate_Node::comment
char * comment
Definition:
odldef.h:114
string
HDFFCLIBAPI intf intf _fcd string
Definition:
hproto_fortran.h:720
odldef.h
Parameter_Node
Definition:
odldef.h:136
CommentAggregate
int CommentAggregate(AGGREGATE aggregate, char *comment)
Definition:
comments.c:51
odlinter.h
Aggregate_Node
Definition:
odldef.h:110
MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51