Remove CVS $Id$ keyword
[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 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
11 ;;;;
12 ;;;; CLSQL users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
14 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
15 ;;;; *************************************************************************
16
17 (in-package #:mysql)
18
19 (declaim (inline mysql-get-client-info))
20
21 (defvar *mysql-client-info* nil)
22
23 (eval-when (:compile-toplevel :load-toplevel :execute)
24   (uffi:def-function ("mysql_get_client_info" mysql-get-client-info)
25       ()
26     :module "mysql"
27     :returning :cstring)
28
29   (setf *mysql-client-info* (uffi:convert-from-cstring (mysql-get-client-info)))
30
31
32   (when (and (stringp *mysql-client-info*)
33              (plusp (length *mysql-client-info*)))
34     (cond
35       ((eql (schar *mysql-client-info* 0) #\3)
36        (pushnew :mysql-client-v3 cl:*features*))
37       ((eql (schar *mysql-client-info* 0) #\4)
38        (pushnew :mysql-client-v4 cl:*features*)
39        (when (and (>= (length *mysql-client-info*) 3)
40                   (string-equal "4.1" *mysql-client-info* :end2 3))
41          (pushnew :mysql-client-v4.1 cl:*features*)))
42       ((eql (schar *mysql-client-info* 0) #\5)
43        (pushnew :mysql-client-v5 cl:*features*)
44        (when (and (>= (length *mysql-client-info*) 3)
45                   (string-equal "5.1" *mysql-client-info* :end2 3))
46          (pushnew :mysql-client-v5.1 cl:*features*)))
47       (t
48        (error "Unknown mysql client version '~A'." *mysql-client-info*)))))
49