You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.1 KiB

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