1 #define __VERSION_C__
3 /*
4 * Versions
5 *
6 * Authors:
7 * MenTaLguY <mental@rydia.net>
8 *
9 * Copyright (C) 2003 MenTaLguY
10 *
11 * Released under GNU GPL, read the file 'COPYING' for more information
12 */
14 #include <stdio.h>
15 #include <glib/gstrfuncs.h>
16 #include "version.h"
18 gboolean sp_version_from_string(const gchar *string, Inkscape::Version *version)
19 {
20 if (!string) {
21 return FALSE;
22 }
24 version->major = 0;
25 version->minor = 0;
27 return sscanf((const char *)string, "%u.%u",
28 &version->major, &version->minor) ||
29 sscanf((const char *)string, "%u", &version->major);
30 }
32 gchar *sp_version_to_string(Inkscape::Version version)
33 {
34 return g_strdup_printf("%u.%u", version.major, version.minor);
35 }
37 gboolean sp_version_inside_range(Inkscape::Version version,
38 unsigned major_min, unsigned minor_min,
39 unsigned major_max, unsigned minor_max)
40 {
41 if ( version.major < major_min || version.major > major_max ) {
42 return FALSE;
43 } else if ( version.major == major_min &&
44 version.minor <= minor_min )
45 {
46 return FALSE;
47 } else if ( version.major == major_max &&
48 version.minor >= minor_max )
49 {
50 return FALSE;
51 } else {
52 return TRUE;
53 }
54 }
56 /*
57 Local Variables:
58 mode:c++
59 c-file-style:"stroustrup"
60 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
61 indent-tabs-mode:nil
62 fill-column:99
63 End:
64 */
65 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :