OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
replace_ocroots.cpp
Go to the documentation of this file.
1 #include "genutils.h"
2 
3 #include <stdlib.h>
4 #include <string.h>
5 #include <string>
6 
13  constexpr size_t numSubstitutes = 3;
14  char *envSubstitutes[numSubstitutes][2] = {
15  {"$OCVARROOT", getenv("OCVARROOT")},
16  {"$OCDATAROOT", getenv("OCDATAROOT")},
17  {"$OCSSWROOT", getenv("OCSSWROOT")}
18  };
19 
20  for(size_t sub = 0; sub < numSubstitutes; sub++) {
21  if(envSubstitutes[sub][1] == NULL)
22  continue;
23  size_t pos;
24  while((pos = str.find(envSubstitutes[sub][1])) != std::string::npos) {
25  str.replace(pos, strlen(envSubstitutes[sub][1]), envSubstitutes[sub][0]);
26  }
27  }
28 }
29 
30 
37 extern "C" char* replace_ocroots(const char* inStr) {
38  std::string str = inStr;
40  return strdup(str.c_str());
41 }
42 
void replaceOCroots(std::string &str)
#define NULL
Definition: decode_rs.h:63
float32 * pos
Definition: l1_czcs_hdf.c:35
@ string
char * strdup(const char *)
char * replace_ocroots(const char *inStr)
const char * str
Definition: l1c_msi.cpp:35