Changeset 7325 for TI12-security/trunk


Ignore:
Timestamp:
16/08/10 11:25:36 (9 years ago)
Author:
pjkersha
Message:

ESG Security extension to NetCDF nc_open:

  • modified ncopen.c test program to retrieve ncid and query vars - works for authenticated case but hangs when no credentials are set in the .dodsrc
Location:
TI12-security/trunk/NDGSecurity/C/openDapPatch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/NDGSecurity/C/openDapPatch

    • Property svn:ignore
      •  

        old new  
        44ca 
        55cookie.txt 
         6netcdf-4.1.2-beta1-snapshot2010081520 
         7*.pem 
         8netcdf-4-daily.tar.gz 
  • TI12-security/trunk/NDGSecurity/C/openDapPatch/Makefile

    r6876 r7325  
    11 
    2 NETCDF_LIB_PATH=-L../netcdf-4.1.1/libsrc/.libs/ 
    3 ncopen: 
    4         cc -g ncopen.c ${NETCDF_LIB_PATH} -lnetcdf -lcurl -o ncopen 
     2NETCDF_LIB=-lnetcdf 
     3NETCDF_LIB_PATH=-L./netcdf-4.1.2-beta1-snapshot2010081520/liblib/.libs/ 
     4NETCDF_INCLUDES=-I./netcdf-4.1.2-beta1-snapshot2010081520/include 
     5 
     6ncopen: ncopen.c 
     7        cc -Wall -g ${NETCDF_INCLUDES} ${NETCDF_LIB_PATH} ncopen.c ${NETCDF_LIB} -lcurl -o ncopen  
    58         
    69clean: 
  • TI12-security/trunk/NDGSecurity/C/openDapPatch/ncopen.c

    r6876 r7325  
     1/* 
     2 * Test Harness for ESG Security extensions to NetCDF OPeNDAP client 
     3 * 
     4 * Author: Steve Crothers 
     5 * 
     6 * Modified: Philip Kershaw 
     7 * 
     8 * Copyright: STFC Rutherford Appleton Laboratory 
     9 * 
     10 * $Id$ 
     11 */ 
    112#include <stdio.h> 
    2 #include <netcdf.h> 
    3   
    4 int main(int argc, char **argv) { 
    5     int ncidp, ans; 
     13#include <stdlib.h> 
     14#include <libgen.h> 
     15 
     16#include "netcdf.h" 
     17 
     18 
     19int main(int argc, char **argv)  
     20{ 
     21    int ncId, status; 
     22    int nDims, nVars, nGlobalAttrs, unlimitedDimId; 
     23     
     24    int i=0; 
     25    int j=0; 
     26    nc_type varType; 
     27    char varName[NC_MAX_NAME+1]; 
     28    int varNDims; 
     29    int varDimIds[NC_MAX_VAR_DIMS]; 
     30    int varNVarAttrs; 
     31     
    632    printf("%s\n",nc_inq_libvers()); 
    7     printf("Go %s\n",argv[1]); 
    8     ans=nc_open(argv[1],NC_NOWRITE,&ncidp); 
    9     printf("got %d %d\n",ans,ncidp); 
    10     if (ans != NC_NOERR) { 
    11         printf("%s\n", nc_strerror(ans)); 
     33     
     34    if (argc < 2) 
     35    { 
     36        fprintf(stderr, "Usage: %s <netcdf file>\n",  
     37                (const char *)basename(argv[0])); 
     38        exit(1); 
    1239    } 
     40    printf("Go %s\n", argv[1]); 
     41    status = nc_open(argv[1], NC_NOWRITE, &ncId); 
     42    printf("Got nc_open status=%d; id=%d\n", status, ncId); 
     43    if (status != NC_NOERR)  
     44    { 
     45        fprintf(stderr, "Opening URI: %s\n", nc_strerror(status)); 
     46        exit(1); 
     47    } 
     48 
     49    status = nc_inq(ncId, &nDims, &nVars, &nGlobalAttrs, &unlimitedDimId); 
     50    if (status != NC_NOERR)  
     51    { 
     52        printf("Getting information about dataset: %s\n", nc_strerror(status)); 
     53        exit(1); 
     54    } 
     55     
     56    printf("Number of dimensions: %d\n", nDims); 
     57    printf("Number of variables: %d\n", nVars); 
     58    printf("Number of global attributes: %d\n", nGlobalAttrs); 
     59    printf("Unlimited dimension ID: %d\n", unlimitedDimId); 
     60 
     61    for (i=0; i < nVars; i++) 
     62    { 
     63        status = nc_inq_var(ncId, i, &varName, &varType, 
     64                            &varNDims, varDimIds, &varNVarAttrs); 
     65        if (status != NC_NOERR) 
     66        { 
     67            printf("Getting information about variable %d: %s\n", i, 
     68                   nc_strerror(status)); 
     69            exit(1); 
     70        } 
     71        printf("Variable name: %s\n", varName); 
     72        printf("Variable type: %d\n", varType); 
     73        for (j=0; j < varNDims; j++) 
     74            printf("Variable dimension ID: %d\n", varDimIds[j]); 
     75             
     76        printf("Variable number of variable attributes: %d\n", varNVarAttrs); 
     77    } 
     78     
     79    nc_close(ncId); 
     80     
     81    exit(0); 
    1382} 
    1483 
Note: See TracChangeset for help on using the changeset viewer.