#include <stdio.h>#include <stdlib.h>#include "mysql.h"#include "config.h"Include dependency graph for ssl_test.c:

Go to the source code of this file.
Defines | |
| #define | SELECT_QUERY "select name from test where num = %d" |
Functions | |
| int | main (int argc, char **argv) |
Definition at line 25 of file ssl_test.c.
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 28 of file ssl_test.c.
References atoi(), count, exit, mysql, mysql_close(), mysql_error(), mysql_free_result(), mysql_init(), mysql_num_fields(), mysql_query(), mysql_real_connect(), mysql_ssl_set(), mysql_store_result(), NULL, perror(), st_mysql::reconnect, SELECT_QUERY, and sock.
00029 { 00030 #ifdef HAVE_OPENSSL 00031 int count, num; 00032 MYSQL mysql,*sock; 00033 MYSQL_RES *res; 00034 char qbuf[160]; 00035 00036 if (argc != 3) 00037 { 00038 fprintf(stderr,"usage : ssl_test <dbname> <num>\n\n"); 00039 exit(1); 00040 } 00041 00042 mysql_init(&mysql); 00043 #ifdef HAVE_OPENSSL 00044 mysql_ssl_set(&mysql,"../SSL/MySQL-client-key.pem", 00045 "../SSL/MySQL-client-cert.pem", 00046 "../SSL/MySQL-ca-cert.pem", 0, 0); 00047 #endif 00048 if (!(sock = mysql_real_connect(&mysql,"127.0.0.1",0,0,argv[1],3306,NULL,0))) 00049 { 00050 fprintf(stderr,"Couldn't connect to engine!\n%s\n\n",mysql_error(&mysql)); 00051 perror(""); 00052 exit(1); 00053 } 00054 mysql.reconnect= 1; 00055 count = 0; 00056 num = atoi(argv[2]); 00057 while (count < num) 00058 { 00059 sprintf(qbuf,SELECT_QUERY,count); 00060 if(mysql_query(sock,qbuf)) 00061 { 00062 fprintf(stderr,"Query failed (%s)\n",mysql_error(sock)); 00063 exit(1); 00064 } 00065 if (!(res=mysql_store_result(sock))) 00066 { 00067 fprintf(stderr,"Couldn't get result from query failed (%s)\n", 00068 mysql_error(sock)); 00069 exit(1); 00070 } 00071 #ifdef TEST 00072 printf("number of fields: %d\n",mysql_num_fields(res)); 00073 #endif 00074 mysql_free_result(res); 00075 count++; 00076 } 00077 mysql_close(sock); 00078 #else /* HAVE_OPENSSL */ 00079 printf("ssl_test: SSL not configured.\n"); 00080 #endif /* HAVE_OPENSSL */ 00081 exit(0); 00082 return 0; /* Keep some compilers happy */ 00083 }
Here is the call graph for this function:

1.4.7

