r9574: Remove loading of unnecessary zlib library
[clsql.git] / db-mysql / mysql-client-info.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          mysql-client-info.lisp
6 ;;;; Purpose:       Check mysql client version
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  April 2004
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
13 ;;;;
14 ;;;; CLSQL users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
18
19 (in-package #:mysql)
20
21 (declaim (inline mysql-get-client-info))
22
23 (defvar *mysql-client-info* nil)
24
25 (eval-when (:compile-toplevel :load-toplevel :execute)
26   (uffi:def-function ("mysql_get_client_info" mysql-get-client-info)
27       ()
28     :module "mysql"
29     :returning :cstring)
30
31   (setf *mysql-client-info* (uffi:convert-from-cstring (mysql-get-client-info)))
32
33   (when (and (stringp *mysql-client-info*)
34              (plusp (length *mysql-client-info*)))
35     (cond
36       ((eql (schar *mysql-client-info* 0) #\3)
37        (pushnew :mysql-client-v3 cl:*features*))
38       ((eql (schar *mysql-client-info* 0) #\4)
39        (pushnew :mysql-client-v4 cl:*features*)
40        (when (and (>= (length *mysql-client-info*) 3)
41                   (string-equal "4.1" *mysql-client-info* :end2 3))
42          (pushnew :mysql-client-v4.1 cl:*features*)))
43       (t
44        (error "Unknown mysql client version '~A'." *mysql-client-info*)))))
45