gsasl-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS gsasl/lib/gl


From: gsasl-commit
Subject: CVS gsasl/lib/gl
Date: Sat, 25 Jun 2005 11:45:37 +0200

Update of /home/cvs/gsasl/lib/gl
In directory dopio:/tmp/cvs-serv13060/gl

Modified Files:
        Makefile.am 
Added Files:
        check_version.c check_version.h 
Log Message:
Use check_version gnulib module.

--- /home/cvs/gsasl/lib/gl/Makefile.am  2005/06/15 10:35:28     1.20
+++ /home/cvs/gsasl/lib/gl/Makefile.am  2005/06/25 09:45:37     1.21
@@ -9,7 +9,7 @@
 #
 # Generated by gnulib-tool.
 # Invoked as: gnulib-tool --import
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgl --source-base=gl 
--m4-base=gl/m4 --aux-dir=. --libtool --lgpl alloca-opt base64 gettext 
lgetdelim lgetline restrict size_max stdbool strdup vasnprintf vasprintf xsize
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgl --source-base=gl 
--m4-base=gl/m4 --aux-dir=. --libtool --lgpl alloca-opt base64 check_version 
gettext lgetdelim lgetline restrict size_max stdbool strdup vasnprintf 
vasprintf xsize
 
 AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
 
@@ -46,6 +46,12 @@
 
 ## end   gnulib module base64
 
+## begin gnulib module check_version
+
+libgl_la_SOURCES += check_version.h check_version.c
+
+## end   gnulib module check_version
+
 ## begin gnulib module gettext
 
 libgl_la_SOURCES += gettext.h

--- /home/cvs/gsasl/lib/gl/check_version.c      2005/06/25 09:45:37     NONE
+++ /home/cvs/gsasl/lib/gl/check_version.c      2005/06/25 09:45:37     1.1
/* check_version.h --- Check version string compatibility.
   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free
   Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation; either version 2.1, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

/* This file is based on src/global.c from Werner Koch's Libgcrypt.
   Modularized for gnulib by Simon Josefsson.  */

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <ctype.h>
#include <string.h>

static const char *
parse_version_number (const char *s, int *number)
{
  int val = 0;

  if (*s == '0' && isdigit (s[1]))
    return NULL;                /* leading zeros are not allowed */

  for (; isdigit (*s); s++)
    {
      val *= 10;
      val += *s - '0';
    }

  *number = val;

  return val < 0 ? NULL : s;
}


static const char *
parse_version_string (const char *s, int *major, int *minor, int *micro)
{
  s = parse_version_number (s, major);
  if (!s || *s != '.')
    return NULL;

  s++;

  s = parse_version_number (s, minor);
  if (!s || *s != '.')
    return NULL;

  s++;

  s = parse_version_number (s, micro);
  if (!s)
    return NULL;

  return s;                     /* patchlevel */
}

/* Check that the the version of the library (i.e., the CPP symbol
 * VERSION) is at minimum the requested one in REQ_VERSION (typically
 * found in a header file) and return the version string.  Return NULL
 * if the condition is not satisfied.  If a NULL is passed to this
 * function, no check is done, but the version string is simply
 * returned.
 */
extern const char *
check_version (const char *req_version)
{
  const char *ver = VERSION;
  int my_major, my_minor, my_micro;
  int rq_major, rq_minor, rq_micro;
  const char *my_plvl, *rq_plvl;

  if (!req_version)
    return ver;

  my_plvl = parse_version_string (ver, &my_major, &my_minor, &my_micro);
  if (!my_plvl)
    return NULL;                /* very strange our own version is bogus */

  rq_plvl = parse_version_string (req_version, &rq_major, &rq_minor,
                                  &rq_micro);
  if (!rq_plvl)
    return NULL;                /* req version string is invalid */

  if (my_major > rq_major
      || (my_major == rq_major && my_minor > rq_minor)
      || (my_major == rq_major && my_minor == rq_minor
          && my_micro > rq_micro)
      || (my_major == rq_major && my_minor == rq_minor
          && my_micro == rq_micro && strcmp (my_plvl, rq_plvl) >= 0))
    {
      return ver;
    }

  return NULL;
}
--- /home/cvs/gsasl/lib/gl/check_version.h      2005/06/25 09:45:37     NONE
+++ /home/cvs/gsasl/lib/gl/check_version.h      2005/06/25 09:45:37     1.1
/* check_version.h --- Check version string compatibility.
   Copyright (C) 2005 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation; either version 2.1, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

/* Written by Simon Josefsson. */

#ifndef CHECK_VERSION_H
# define CHECK_VERSION_H

extern const char *
check_version (const char *req_version);

#endif /* CHECK_VERSION_H */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]