~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
17
#ifdef __WIN__
18
#include <windows.h>
19
#endif
20
#include <stdio.h>
21
#include <stdlib.h>
22
#include "mysql.h"
23
#include "config.h"
24
#define SELECT_QUERY "select name from test where num = %d"
25
26
27
int main(int argc, char **argv)
28
{
29
#ifdef HAVE_OPENSSL
30
  int	count, num;
31
  MYSQL mysql,*sock;
32
  MYSQL_RES *res;
33
  char	qbuf[160];
34
35
  if (argc != 3)
36
  {
37
    fprintf(stderr,"usage : ssl_test <dbname> <num>\n\n");
38
    exit(1);
39
  }
40
41
  mysql_init(&mysql);
42
#ifdef HAVE_OPENSSL
43
  mysql_ssl_set(&mysql,"../SSL/MySQL-client-key.pem",
44
    "../SSL/MySQL-client-cert.pem",
45
    "../SSL/MySQL-ca-cert.pem", 0, 0);
46
#endif
47
  if (!(sock = mysql_real_connect(&mysql,"127.0.0.1",0,0,argv[1],MYSQL_PORT,NULL,0)))
48
  {
49
    fprintf(stderr,"Couldn't connect to engine!\n%s\n\n",mysql_error(&mysql));
50
    perror("");
51
    exit(1);
52
  }
53
  mysql.reconnect= 1;
54
  count = 0;
55
  num = atoi(argv[2]);
56
  while (count < num)
57
  {
58
    sprintf(qbuf,SELECT_QUERY,count);
59
    if(mysql_query(sock,qbuf))
60
    {
61
      fprintf(stderr,"Query failed (%s)\n",mysql_error(sock));
62
      exit(1);
63
    }
64
    if (!(res=mysql_store_result(sock)))
65
    {
66
      fprintf(stderr,"Couldn't get result from query failed (%s)\n",
67
	      mysql_error(sock));
68
      exit(1);
69
    }
70
#ifdef TEST
71
    printf("number of fields: %d\n",mysql_num_fields(res));
72
#endif
73
    mysql_free_result(res);
74
    count++;
75
  }
76
  mysql_close(sock);
77
#else /* HAVE_OPENSSL */
78
  printf("ssl_test: SSL not configured.\n");
79
#endif /* HAVE_OPENSSL */
80
  exit(0);
81
  return 0;					/* Keep some compilers happy */
82
}