1 /* -*- Mode: c; c-basic-offset: 2 -*-
2 *
3 * rasqal_engine.c - Rasqal query engine utility functions
4 *
5 * Copyright (C) 2011, David Beckett http://www.dajobe.org/
6 *
7 * This package is Free Software and part of Redland http://librdf.org/
8 *
9 * It is licensed under the following three licenses as alternatives:
10 * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
11 * 2. GNU General Public License (GPL) V2 or any newer version
12 * 3. Apache License, V2.0 or any newer version
13 *
14 * You may not use this file except in compliance with at least one of
15 * the above three licenses.
16 *
17 * See LICENSE.html or LICENSE.txt at the top of this package for the
18 * complete terms and further detail along with the license texts for
19 * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
20 *
21 */
22
23
24 #ifdef HAVE_CONFIG_H
25 #include <rasqal_config.h>
26 #endif
27
28 #ifdef WIN32
29 #include <win32_rasqal_config.h>
30 #endif
31
32 #include <stdio.h>
33 #include <string.h>
34
35 #include <raptor.h>
36
37 #include "rasqal.h"
38 #include "rasqal_internal.h"
39
40
41
42 #ifdef RASQAL_DEBUG
43 static const char rasqal_engine_parts_string[16][5] = {
44 /* 0 - 3 */ "----", "S---", "-P--", "SP--",
45 /* 4 - 7 */ "--O-", "S-O-", "-PO-", "SPO-",
46 /* 8 - 11 */ "---G", "S--G", "-P-G", "SP-G",
47 /* 12 - 15 */ "--OG", "S-OG", "-POG", "SPOG",
48 };
49
50
51 const char*
rasqal_engine_get_parts_string(rasqal_triple_parts parts)52 rasqal_engine_get_parts_string(rasqal_triple_parts parts)
53 {
54 return rasqal_engine_parts_string[RASQAL_GOOD_CAST(int, parts) & RASQAL_TRIPLE_SPOG];
55 }
56 #endif
57
58
59 #ifdef RASQAL_DEBUG
60 static const char* const rasqal_engine_error_labels[RASQAL_ENGINE_ERROR_LAST+2]=
61 {
62 "ok",
63 "FAILED",
64 "finished",
65 "unknown"
66 };
67
68 const char*
rasqal_engine_error_as_string(rasqal_engine_error error)69 rasqal_engine_error_as_string(rasqal_engine_error error)
70 {
71 if(error > RASQAL_ENGINE_ERROR_LAST)
72 error = (rasqal_engine_error)(RASQAL_ENGINE_ERROR_LAST+1);
73
74 return rasqal_engine_error_labels[RASQAL_GOOD_CAST(int, error)];
75 }
76 #endif
77