MISR Toolkit  1.5.1
MtkMakeFilename.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkMakeFilename =
4 = =
5 =============================================================================
6 
7  Jet Propulsion Laboratory
8  MISR
9  MISR Toolkit
10 
11  Copyright 2005, California Institute of Technology.
12  ALL RIGHTS RESERVED.
13  U.S. Government Sponsorship acknowledged.
14 
15 ============================================================================*/
16 
17 #include "MisrFileQuery.h"
18 #include "MisrError.h"
19 #include <stdio.h>
20 #include <string.h>
21 #include <ctype.h>
22 
50  const char *basedir,
51  const char *product,
52  const char *camera,
53  int path,
54  int orbit,
55  const char *version,
56  char **filename )
57 {
58  int status_code;
59  int len;
60  char *temp;
61  int i;
62  char *slash = "/";
63 
64  if (basedir == NULL || product == NULL || version == NULL ||
65  filename == NULL)
67 
68  len = (int)strlen(basedir);
69 
70  if (len == 0 || strncmp(&(basedir[len-1]), slash, 1) == 0)
71  slash = "";
72 
73  temp = (char*)malloc((len + 256) * sizeof(char));
74  if (temp == NULL)
76 
77  if (camera == NULL || strlen(camera) == 0)
78  if (orbit > 0) {
79  sprintf(temp,"%s%sMISR_AM1_%s_P%03d_O%06d_%s.hdf",basedir,
80  slash,product,path,orbit,version);
81  } else {
82  sprintf(temp,"%s%sMISR_AM1_%s_P%03d_%s.hdf",basedir,
83  slash,product,path,version);
84  }
85  else
86  sprintf(temp,"%s%sMISR_AM1_%s_P%03d_O%06d_%s_%s.hdf",basedir,
87  slash,product,path,orbit,camera,version);
88 
89  for (i = (int)strlen(basedir); (unsigned)i < strlen(temp) - 4; ++i)
90  temp[i] = toupper(temp[i]);
91 
92  *filename = temp;
93 
94  return MTK_SUCCESS;
95 
96  ERROR_HANDLE:
97  return status_code;
98 }
int version
Definition: jpeglib.h:901
HDFFCLIBAPI intf * len
char * filename
Definition: cdjpeg.h:133
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
MTKt_status
Definition: MisrError.h:11
MTKt_status MtkMakeFilename(const char *basedir, const char *product, const char *camera, int path, int orbit, const char *version, char **filename)
Given a base directory, product, camera, path, orbit, version.

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51