awips2/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/dgdriv_c/dbgetstinfo.c
Brad Gonzales 632020195a Issue #628 committing PGEN code received from Plummer on 4-19-2012.
Former-commit-id: fda897d2d0 [formerly 253e8bc948] [formerly fda897d2d0 [formerly 253e8bc948] [formerly 295cbf95e5 [formerly 0816cd253c86acc699cb90866131619c4679f631]]]
Former-commit-id: 295cbf95e5
Former-commit-id: 2a3bf4ec32 [formerly ae3d17c698]
Former-commit-id: a610dcde73
2012-05-10 16:50:45 -05:00

103 lines
2.6 KiB
C
Executable file

#include "geminc.h"
#include "gemprm.h"
#include "dbcmn.h"
void db_getstinfo ( char *queryType, char *gemArea,
char *stInfo, int *lStInfo, int *iret )
/************************************************************************
* *
* db_getstinfo *
* *
* m.gamazaychikov/SAIC 11/08 Created *
************************************************************************/
{
int bufferSize = 200000;
char xsltFile[LLSCRN] = "response.xlt";
char xsltDir[LLSCRN] = "$NAWIPS/gempak/tables/xslt";
int ier, nbytes, ier1;
long flen;
char queryText[320], queryResult[bufferSize+1], xsltfile[FILE_FULLSZ];
unsigned char* bigStr;
/*---------------------------------------------------------------------*/
/*
* Initialization
*/
*iret = 0;
stInfo[0] = '\0';
queryText[0] = '\0';
queryResult[0] = '\0';
*lStInfo = 0;
/*
* Populate the query strings
*/
if (strcmp ( queryType, "stidqry" ) == 0 ||
strcmp ( queryType, "stnmqry" ) == 0 ) {
sprintf (ePlugIn, "%s", "obs");
sprintf (eLibClass, "%s", "GempakAreaRequest");
strcpy (gArea, gemArea);
}
else {
ier = -8;
er_wmsg ( "DB", &ier, queryType, &ier1, 2, strlen(queryType) );
*iret = -1;
return;
}
/*
* Get the query text
*/
db_getQueryText ( queryType, queryText, &ier);
if ( ier !=0 ) {
ier = -3;
er_wmsg ( "DB", &ier, NULL, &ier1, 2, 0 );
*iret = -1;
return;
}
/*
* Connect to database and get the query result
*/
db_runQuery ( queryText, queryResult, &ier);
if ( ier !=0 ) {
ier = -4;
er_wmsg ( "DB", &ier, NULL, &ier1, 2, 0 );
*iret = -1;
return;
}
/*
* Transform XML string to a string containing list of header parameters
*/
cfl_inqr(xsltFile, xsltDir, &flen, xsltfile, &ier);
if ( ier !=0 ) {
/*
* XSLT file not found -> returning
*/
ier = -5;
er_wmsg ( "DB", &ier, xsltFile, &ier1, 2, strlen(xsltFile) );
*iret = -1;
return;
}
nbytes=xml_transform( queryResult, strlen(queryResult), xsltfile, &bigStr, &ier );
if ( ier !=0 || nbytes==0) {
/*
* XML Transform run unsuccessfully -> returning
*/
ier = -6;
er_wmsg ( "DB", &ier, NULL, &ier1, 2, 0 );
G_FREE( bigStr, unsigned char );
*iret = -1;
return;
}
sprintf (stInfo, "%s", bigStr);
*lStInfo = strlen(stInfo);
G_FREE( bigStr, unsigned char );
return;
}