2015-01-16 16:35:11 +00:00
|
|
|
/*
|
2015-12-31 12:44:51 +00:00
|
|
|
* Copyright 2005-2016 ECMWF.
|
2015-01-16 16:35:11 +00:00
|
|
|
*
|
|
|
|
* This software is licensed under the terms of the Apache Licence Version 2.0
|
|
|
|
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
*
|
|
|
|
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
|
|
|
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* C Implementation: codes_info
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "grib_tools.h"
|
|
|
|
|
|
|
|
void usage( char*);
|
|
|
|
|
2015-01-22 17:00:59 +00:00
|
|
|
#define INFO_PRINT_ALL 0
|
|
|
|
#define INFO_PRINT_VERSION (1<<0)
|
|
|
|
#define INFO_PRINT_DEFINITION_PATH (1<<1)
|
2015-01-16 16:35:11 +00:00
|
|
|
#define INFO_PRINT_SAMPLES_PATH (1<<2)
|
|
|
|
|
|
|
|
int main( int argc,char* argv[])
|
|
|
|
{
|
|
|
|
char* path=NULL;
|
|
|
|
int c=0;
|
|
|
|
int nfiles=0;
|
|
|
|
unsigned long print_flags=0;
|
2015-02-25 17:42:04 +00:00
|
|
|
int major=ECCODES_MAJOR_VERSION;
|
|
|
|
int minor=ECCODES_MINOR_VERSION;
|
|
|
|
int revision=ECCODES_REVISION_VERSION;
|
2015-01-16 16:35:11 +00:00
|
|
|
|
|
|
|
while (1) {
|
2015-01-22 17:00:59 +00:00
|
|
|
c = getopt (argc, argv, "vds");
|
2015-01-16 16:35:11 +00:00
|
|
|
|
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case 'v':
|
|
|
|
print_flags|=INFO_PRINT_VERSION;
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
print_flags|=INFO_PRINT_DEFINITION_PATH;
|
|
|
|
break;
|
2015-01-22 17:00:59 +00:00
|
|
|
case 's':
|
2015-01-16 16:35:11 +00:00
|
|
|
print_flags|=INFO_PRINT_SAMPLES_PATH;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage(argv[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nfiles=argc-optind;
|
|
|
|
if (nfiles != 0) usage(argv[0]);
|
|
|
|
|
|
|
|
if (print_flags == INFO_PRINT_ALL) {
|
|
|
|
printf("\n");
|
|
|
|
printf("eccodes Version %d.%d.%d",
|
|
|
|
major,minor,revision);
|
2015-03-10 18:20:46 +00:00
|
|
|
/* if (ECCODES_MAJOR_VERSION < 1) printf(" PRE-RELEASE"); */
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("\n");
|
|
|
|
printf("\n");
|
2015-01-29 15:49:23 +00:00
|
|
|
#if GRIB_PTHREADS
|
|
|
|
grib_context_log(grib_context_get_default(), GRIB_LOG_DEBUG, "PTHREADS enabled");
|
|
|
|
#endif
|
2016-01-11 16:36:46 +00:00
|
|
|
if ((path=codes_getenv("ECCODES_DEFINITION_PATH")) != NULL) {
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("Definition files path from environment variable");
|
2015-01-23 22:47:51 +00:00
|
|
|
printf(" ECCODES_DEFINITION_PATH=%s\n",path);
|
2015-01-16 16:35:11 +00:00
|
|
|
} else {
|
2015-01-24 22:19:32 +00:00
|
|
|
printf("Default definition files path is used: %s\n",ECCODES_DEFINITION_PATH);
|
2015-01-23 22:47:51 +00:00
|
|
|
printf("Definition files path can be changed setting ECCODES_DEFINITION_PATH environment variable\n");
|
2015-01-16 16:35:11 +00:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
2016-01-11 16:36:46 +00:00
|
|
|
if ((path=codes_getenv("ECCODES_SAMPLES_PATH")) != NULL) {
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("SAMPLES path from environment variable");
|
2015-01-23 22:47:51 +00:00
|
|
|
printf(" ECCODES_SAMPLES_PATH=%s\n",path);
|
2015-01-16 16:35:11 +00:00
|
|
|
} else {
|
2015-01-24 22:19:32 +00:00
|
|
|
printf("Default SAMPLES path is used: %s\n",ECCODES_SAMPLES_PATH);
|
2015-01-23 22:47:51 +00:00
|
|
|
printf("SAMPLES path can be changed setting ECCODES_SAMPLES_PATH environment variable\n");
|
2015-01-16 16:35:11 +00:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_flags & INFO_PRINT_VERSION)
|
|
|
|
printf("%d.%d.%d ",major,minor,revision);
|
|
|
|
|
|
|
|
if (print_flags & INFO_PRINT_DEFINITION_PATH) {
|
2016-01-11 16:36:46 +00:00
|
|
|
if ((path=codes_getenv("ECCODES_DEFINITION_PATH")) != NULL) {
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("%s",path);
|
|
|
|
} else {
|
2015-01-24 22:19:32 +00:00
|
|
|
printf("%s",ECCODES_DEFINITION_PATH);
|
2015-01-16 16:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_flags & INFO_PRINT_SAMPLES_PATH) {
|
2016-01-11 16:36:46 +00:00
|
|
|
if ((path=codes_getenv("ECCODES_SAMPLES_PATH")) != NULL) {
|
2015-01-16 16:35:11 +00:00
|
|
|
printf("%s",path);
|
|
|
|
} else {
|
2015-01-24 22:19:32 +00:00
|
|
|
printf("%s",ECCODES_SAMPLES_PATH);
|
2015-01-16 16:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void usage(char* progname) {
|
2015-01-22 17:00:59 +00:00
|
|
|
printf("\nUsage: %s [-v] [-d] [-s]\n",progname);
|
2015-01-16 16:35:11 +00:00
|
|
|
exit(1);
|
|
|
|
}
|