mail-notification

Fork of Jean-Yves Lefort's mail-notification, a tray icon to notify of new mail
git clone https://code.djc.id.au/git/mail-notification/

jbsrc/lib/src/extras/jb-sasl2.c (2374B) - raw

      1 /*
      2  * JB, the Jean-Yves Lefort's Build System
      3  * Copyright (C) 2008 Jean-Yves Lefort <jylefort@brutele.be>
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation; either version 3 of the License, or
      8  * (at your option) any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License along
     16  * with this program; if not, write to the Free Software Foundation, Inc.,
     17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     18  */
     19 
     20 #include <stdio.h>
     21 #include "jb-tests.h"
     22 #include "jb-variable.h"
     23 #include "jb-util.h"
     24 
     25 #define JB_SASL2_CFLAGS		NULL
     26 #define JB_SASL2_CPPFLAGS	NULL
     27 #define JB_SASL2_LDFLAGS	NULL
     28 #define JB_SASL2_LIBS		"-lsasl2"
     29 
     30 gboolean
     31 jb_sasl2_check (const char *minversion)
     32 {
     33   gboolean result;
     34   char *cppflags;
     35   int major;
     36   int minor;
     37   int step = 0;
     38   int patch = 0;
     39 
     40   if (! minversion)
     41     minversion = "2.0";
     42 
     43   jb_message_checking("for Cyrus SASL >= %s", minversion);
     44 
     45   if (sscanf(minversion, "%d.%d.%d.%d", &major, &minor, &step, &patch) < 2)
     46     g_error("invalid version string `%s'", minversion);
     47 
     48   cppflags = g_strdup_printf("-DJB_SASL2_MAJOR=%i -DJB_SASL2_MINOR=%i -DJB_SASL2_STEP=%i -DJB_SASL2_PATCH=%i",
     49 			     major, minor, step, patch);
     50 
     51   result = jb_test_run_string("#include <sasl/sasl.h>\n"
     52 			      "int main () {\n"
     53 			      "  int major, minor, step, patch;\n"
     54 			      "  sasl_version_info(0, 0, &major, &minor, &step, &patch);\n"
     55 			      "  if ((major << 24) + (minor << 16) + (step << 8) + patch\n"
     56 			      "      < (JB_SASL2_MAJOR << 24) + (JB_SASL2_MINOR << 16) + (JB_SASL2_STEP << 8) + JB_SASL2_PATCH)\n"
     57 			      "    exit(2); /* version too old */\n"
     58 			      "  exit(0);\n"
     59 			      "}\n",
     60 			      JB_SASL2_CFLAGS,
     61 			      cppflags,
     62 			      JB_SASL2_LDFLAGS,
     63 			      JB_SASL2_LIBS);
     64 
     65   g_free(cppflags);
     66 
     67   jb_message_result_bool(result);
     68 
     69   if (result)
     70     jb_variable_set_package_flags("sasl2",
     71 				  JB_SASL2_CFLAGS,
     72 				  JB_SASL2_CPPFLAGS,
     73 				  JB_SASL2_LDFLAGS,
     74 				  JB_SASL2_LIBS);
     75 
     76   return result;
     77 }