NCEPLIBS-g2c  1.8.0
g2c_index.c
Go to the documentation of this file.
1 
7 #include <ctype.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <grib2.h>
12 
25 int
26 main(int argc, char **argv)
27 {
28  char *path[2] = {NULL, NULL};
29  int verbose = 0;
30  int index;
31  int c;
32  int p = 0;
33  /* int g2cid; */
34  /* int ret; */
35 
36  opterr = 0;
37 
38  /* Parse command line arguments. */
39  while ((c = getopt(argc, argv, "v")) != -1)
40  {
41  switch (c)
42  {
43  case 'v':
44  verbose = 1;
45  break;
46  case '?':
47  if (isprint(optopt))
48  fprintf(stderr, "Unknown option `-%c'.\n", optopt);
49  else
50  fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
51  return 1;
52  default:
53  return G2C_ERROR;
54  }
55  }
56 
57  /* Get names of input and output files. */
58  for (index = optind; index < argc; index++)
59  {
60  if (!(path[p] = malloc(sizeof(char) * strlen(argv[index]) + 1)))
61  return G2C_ENOMEM;
62  strcpy(path[p], argv[index]);
63  if (++p == 2)
64  break;
65  }
66 
67  /* Yammer on and on. */
68  if (verbose)
69  printf("g2c_index %s reading index file %s summarizing into %s.\n", G2C_VERSION, path[0], path[1]);
70 
71  /* Open the GRIB2 file. */
72  /* if ((ret = g2c_open(path[0], G2C_NOWRITE, &g2cid))) */
73  /* return ret; */
74 
75  /* /\* Write the degrib2 summary. *\/ */
76  /* if ((ret = g2c_degrib2(g2cid, path[1]))) */
77  /* return ret; */
78 
79  /* /\* Close the file. *\/ */
80  /* if ((ret = g2c_close(g2cid))) */
81  /* return ret; */
82 
83  /* Free memory. */
84  if (path[0])
85  free(path[0]);
86  if (path[1])
87  free(path[1]);
88 
89  printf("returning 0\n");
90 
91  return 0;
92 }
int main(int argc, char **argv)
Print a summary of a GRIB1 or GRIB2 index file.
Definition: g2c_index.c:26
Header file for NCEPLIBS-g2c library.
#define G2C_ENOMEM
Out of memory.
Definition: grib2.h:500
#define G2C_ERROR
General error code, returned for some test errors.
Definition: grib2.h:492
#define G2C_VERSION
Current version of NCEPLIBS-g2c library.
Definition: grib2.h:26