File: ocdebug.c

package info (click to toggle)
netcdf 1:4.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 104,952 kB
  • sloc: ansic: 228,683; sh: 10,980; yacc: 2,561; makefile: 1,319; lex: 1,173; xml: 173; awk: 2
file content (82 lines) | stat: -rw-r--r-- 1,509 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Copyright 2018, UCAR/Unidata and OPeNDAP, Inc.
   See the COPYRIGHT file for more information. */

#include "config.h"
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
#include "ocinternal.h"
#include "ocdebug.h"

int ocdebug;

#ifdef OCCATCHERROR
/* Place breakpoint here to catch errors close to where they occur*/
OCerror
ocbreakpoint(OCerror err) {return err;}

OCerror
occatch(OCerror err)
{
    if(err == 0) return err;
    return ocbreakpoint(err);
}
#endif

int
xxdrerror(void)
{
    nclog(NCLOGERR,"xdr failure");
    return OCCATCH(OC_EDATADDS);
}


void*
occalloc(size_t size, size_t nelems)
{
    return ocmalloc(size*nelems);
}

void*
ocmalloc(size_t size)
{
    void* memory = calloc(size,1); /* use calloc to zero memory*/
    if(memory == NULL) nclog(NCLOGERR,"ocmalloc: out of memory");
    return memory;
}

void
ocfree(void* mem)
{
    if(mem != NULL) free(mem);
}

int
ocpanic(const char* fmt, ...)
{
    va_list args;
    if(fmt != NULL) {
      va_start(args, fmt);
      vfprintf(stderr, fmt, args);
      fprintf(stderr, "\n" );
      va_end( args );
    } else {
      fprintf(stderr, "panic" );
    }
    fprintf(stderr, "\n" );
    fflush(stderr);
    return 0;
}

CURLcode
ocreportcurlerror(OCstate* state, CURLcode cstat)
{
    if(cstat != CURLE_OK) {
        fprintf(stderr,"CURL Error: %s",curl_easy_strerror(cstat));
	if(state != NULL)
            fprintf(stderr," ; %s",state->error.curlerrorbuf);
        fprintf(stderr,"\n");
    }
    fflush(stderr);
    return cstat;
}