Coverage Report

Created: 2025-10-28 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/netcdf-c/libsrc4/nc4dispatch.c
Line
Count
Source
1
/* Copyright 2005-2018 University Corporation for Atmospheric
2
   Research/Unidata. */
3
/**
4
 * @file
5
 * @internal This header file contains libsrc4 dispatch
6
 * initialization, user-defined format, and logging prototypes and
7
 * macros.
8
 *
9
 * @author Dennis Heimbigner, Ed Hartnett
10
 */
11
12
#include "config.h"
13
#include <stdlib.h>
14
#include "netcdf.h"
15
#include "nc4internal.h"
16
#include "nc4dispatch.h"
17
#include "nc.h"
18
19
/* If user-defined formats are in use, we need to declare their
20
 * dispatch tables. */
21
#ifdef USE_UDF0
22
extern NC_Dispatch UDF0_DISPATCH;
23
#endif /* USE_UDF0 */
24
#ifdef USE_UDF1
25
extern NC_Dispatch UDF1_DISPATCH;
26
#endif /* USE_UDF1 */
27
28
extern int nc_plugin_path_initialize(void);
29
extern int nc_plugin_path_finalize(void);
30
    
31
/**
32
 * @internal Initialize netCDF-4. If user-defined format(s) have been
33
 * specified in configure, load their dispatch table(s).
34
 *
35
 * @return ::NC_NOERR No error.
36
 * @author Dennis Heimbigner
37
 */
38
int
39
NC4_initialize(void)
40
1
{
41
1
    int ret = NC_NOERR;
42
43
#ifdef USE_UDF0
44
    /* If user-defined format 0 was specified during configure, set up
45
     * it's dispatch table. */
46
    if ((ret = nc_def_user_format(NC_UDF0, UDF0_DISPATCH_FUNC, NULL)))
47
        return ret;
48
#endif /* USE_UDF0 */
49
50
#ifdef USE_UDF1
51
    /* If user-defined format 0 was specified during configure, set up
52
     * it's dispatch table. */
53
    if ((ret = nc_def_user_format(NC_UDF1F, &UDF1_DISPATCH_FUNC, NULL)))
54
        return ret;
55
#endif /* USE_UDF0 */
56
57
#ifdef LOGGING
58
    if(getenv(NCLOGLEVELENV) != NULL) {
59
        char* slevel = getenv(NCLOGLEVELENV);
60
        long level = atol(slevel);
61
#ifdef USE_NETCDF4
62
        if(level >= 0) {
63
            nc_set_log_level((int)level);
64
        }
65
    }
66
#endif
67
#endif
68
69
1
#if defined(USE_HDF5) || defined(NETCDF_ENABLE_NCZARR)
70
1
    nc_plugin_path_initialize();
71
1
#endif
72
73
1
    NC_initialize_reserved();
74
1
    return ret;
75
1
}
76
77
/**
78
 * @internal Finalize netCDF-4.
79
 *
80
 * @return ::NC_NOERR No error.
81
 * @author Dennis Heimbigner
82
 */
83
int
84
NC4_finalize(void)
85
1
{
86
1
#if defined(USE_HDF5) || defined(NETCDF_ENABLE_NCZARR)
87
1
    nc_plugin_path_finalize();
88
1
#endif
89
1
    return NC_NOERR;
90
1
}