File: forsupf.c

package info (click to toggle)
libhdf4 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 29,892 kB
  • sloc: ansic: 128,688; sh: 14,969; fortran: 12,444; java: 5,864; xml: 1,305; makefile: 900; yacc: 678; pascal: 418; perl: 360; javascript: 203; lex: 163; csh: 41
file content (103 lines) | stat: -rw-r--r-- 3,689 bytes parent folder | download | duplicates (3)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF.  The full HDF copyright notice, including       *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <stdlib.h>
#include <string.h>

#include "hdf.h"
#include "fortest.h"

/*-----------------------------------------------------------------------------
 * Name:    getverb
 * Purpose: Get the verbosity from the "HDF_VERBOSITY" environment variable
 *          and return it to the FORTRAN calling routine.
 * Inputs:  NONE
 * Returns: verbosity level on success, FAIL on failure
 * Users:   HDF Fortran programmers
 *---------------------------------------------------------------------------*/

intf
ngetverb(void)
{
    char *verb_str;
    intn  verb_level = FAIL;
    verb_str         = getenv(FOR_VERB);

    if (verb_str != NULL)
        verb_level = (intn)strtol(verb_str, NULL, 0); /* convert whole string using base 10 */
    return (intf)verb_level;
} /* end getverb() */

/*-----------------------------------------------------------------------------
 * Name:    hisystem
 * Purpose: Invoke the system call to execute cmd
 * Inputs:  cmd -- the command to execute
 *          cmdlen -- command length
 * Returns: Code returned by the system call
 * Users:   HDF Fortran programmers
 * Invokes: system
 *---------------------------------------------------------------------------*/

intf
nhisystem(_fcd cmd, intf *cmdlen)
{
    char *fn;
    intf  ret;

    fn = HDf2cstring(cmd, (intn)*cmdlen);
    if (!fn)
        return FAIL;
    ret = (intf)system(fn);
    free(fn);
    return ret;
} /* end nhisystem() */

/*-----------------------------------------------------------------------------
 * Name:    fixname
 * Purpose: Fix name for srcdir build and test
 * Inputs:  IN: name - original namea
 *          IN: name_len - name length
 *          IN/OUT: name_out - buffer to hold modified name
 *          IN/OUT: name_out_len - length of the buffer, and length of modified
 *                  string.
 * Returns: 0 on success and -1 on failure
 * Users:   HDF Fortran programmers
 *---------------------------------------------------------------------------*/

intf
nfixnamec(_fcd name, intf *name_len, _fcd name_out, intf *name_len_out)
{
    char *c_name;
    intf  ret;

    char  testfile[1024] = "";
    char *srcdir         = getenv("srcdir");

    c_name = HDf2cstring(name, (intn)*name_len);
    if (!c_name)
        return FAIL;

    /* Here comes Bill's code */
    /* Generate the correct name for the test file, by prepending the source path */
    if (srcdir && ((strlen(srcdir) + strlen(c_name) + 1) < sizeof(testfile))) {
        strcpy(testfile, srcdir);
        strcat(testfile, "/");
    }
    strcat(testfile, c_name);
    *name_len_out = (intf)strlen(testfile);
    HDpackFstring(testfile, _fcdtocp(name_out), *name_len_out);

    ret = 0;
    free(c_name);
    return ret;
} /* end nfixname() */