ocssw V2020
chk_str.c
Go to the documentation of this file.
1 #include "fmt_check.h"
2 extern int fmt_status; /* status of format check, see fmt_check */
3 
4 void chk_str(attr_str attr, char *str, int32 len)
5 /*******************************************************************
6 
7  chk_str
8 
9  purpose: make sure that a string read from a hdf dataset has
10  only one null at the end
11 
12  Returns type: none
13 
14  Parameters: (in calling order)
15  Type Name I/O Description
16  ---- ---- --- -----------
17  attr_str attr I attribute description
18  structure.
19  char * str I string to check
20  int32 len I length reported by HDF
21 
22  Modification history:
23  Programmer Date Description of change
24  ---------- ---- ---------------------
25  W. Robinson 20-Nov-1995 Original development
26  L. Kumar 19-Dec-1995 Modified an output (printf) stmt
27  W. Robinson 17-Sep-1996 Fix strings so they print if
28  null is imbedded somewhere (noted
29  here but done in attr_disp because
30  string can be used and should not
31  be altered)
32 
33  *******************************************************************/
34  {
35  int32 i;
36 
37  /*
38  * only do this if it is char string read in
39  */
40  if ((attr.type == DFNT_CHAR) && (attr.read != -1)) {
41  /*
42  * loop through the bytes and look for the null at the right place
43  */
44  for (i = 0; i < len; i++) {
45  if ((str[i] == 0) && (i != len - 1)) {
46  printf("**** object: '%s', attribute: '%s', String has \n",
47  attr.obj_nm, attr.access_nm);
48  printf(" a null at a location ( %d ) other than the end\n",
49  i);
50  printf(" For printing, replaced with '?'\n");
51  printf(" (NOTE, no error condition set currently\n");
52  /* WDR temporarily disable for processing
53  fmt_status = fmt_status | 2;
54  */
55  } else if ((str[i] != 0) && (i == len - 1)) {
56  printf("**** object: '%s', attribute: '%s', String lacks \n",
57  attr.obj_nm, attr.access_nm);
58  /*
59  printf( " a null at the end location ( %d )\n", i );
60  */
61  printf(" a null at the end location ( %d )\n", i + 1); /*LK*/
62  fmt_status = fmt_status | 2;
63  }
64  }
65  }
66 }
void chk_str(attr_str attr, char *str, int32 len)
Definition: chk_str.c:4
int fmt_status
Definition: fmt_check.c:7
const char * str
Definition: l1c_msi.cpp:37
int i
Definition: decode_rs.h:71