/[PAMELA software]/calo/ground/COMMON/src/qumy.c
ViewVC logotype

Contents of /calo/ground/COMMON/src/qumy.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Dec 6 10:18:53 2005 UTC (19 years ago) by mocchiut
Branch: MAIN, COMMON
CVS Tags: start, v2r01, v2r00, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
Error occurred while calculating annotation data.
Imported sources

1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <mysql.h>
5
6 short int qumy(char *db, const char *myquery){
7 int debug = 0;
8 if ( debug ) printf("Connecting to database... \n");
9 MYSQL *pConnection;
10 MYSQL_RES *pResult;
11 MYSQL_ROW Row;
12 short int retval = 0;
13 int t;
14 int r;
15 pConnection = mysql_init(NULL);
16 if(!pConnection) return(1);
17 //
18 int connect = (int)mysql_real_connect(pConnection,"srv-g2-01.ts.infn.it","root","Calo0%Ts",db,0,NULL,0);
19 if( !connect ) return(2);
20 if ( debug ) printf("...connected! \n\n");
21 if ( debug ) printf("The query is:\n \"%s\" \n",myquery);
22 int errqu = mysql_query(pConnection,myquery);
23 if ( !errqu ) {
24 pResult = mysql_store_result(pConnection);
25 for( r=0; r < mysql_field_count(pConnection); r++){
26 Row = mysql_fetch_row(pResult);
27 if( Row == NULL ) break;
28 int section = 0;
29 int fromtime = 0;
30 int totime = 0;
31 int calibtime = 0;
32 int obtjump = 0;
33 char *file = 0;
34 for( t = 0; t < mysql_num_fields(pResult); t++){
35 if ( t == 1 ) section = atoi(Row[t]);
36 if ( t == 2 ) obtjump = atoi(Row[t]);
37 if ( t == 3 ) fromtime = atoi(Row[t]);
38 if ( t == 4 ) totime = atoi(Row[t]);
39 if ( t == 5 ) calibtime = atoi(Row[t]);
40 if ( t == 6 ) file = Row[t];
41 };
42 if ( debug ) printf(" section %i from time %i to time %i use calibration at time %i from file %s ",section,fromtime,totime,calibtime,file);
43 if ( debug ) printf("\n");
44 };
45 mysql_free_result(pResult);
46 retval = 0;
47 } else {
48 if ( debug ) printf(" errqu = %i \n",errqu);
49 retval = 3;
50 };
51 if ( debug ) printf("\nClose the connection... \n");
52 mysql_close(pConnection);
53 if ( debug ) printf("...connection terminated!\n");
54 return(retval);
55 }

  ViewVC Help
Powered by ViewVC 1.1.23