1 /* 2 * Copyright (c) 2014 Jerry Lundström <lundstrom.jerry@gmail.com> 3 * Copyright (c) 2014 .SE (The Internet Infrastructure Foundation). 4 * Copyright (c) 2014 OpenDNSSEC AB (svb) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 24 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef __db_join_h 31 #define __db_join_h 32 33 struct db_join; 34 struct db_join_list; 35 typedef struct db_join db_join_t; 36 typedef struct db_join_list db_join_list_t; 37 38 #include "db_type.h" 39 40 /** 41 * A database join description. 42 */ 43 struct db_join { 44 db_join_t* next; 45 char* from_table; 46 char* from_field; 47 char* to_table; 48 char* to_field; 49 }; 50 51 /** 52 * Get the from table name of a database join. 53 * \param[in] join a db_join_t pointer. 54 * \return a character pointer or NULL on error or if no from table name has 55 * been set. 56 */ 57 extern const char* db_join_from_table(const db_join_t* join); 58 59 /** 60 * Get the from field name of a database join. 61 * \param[in] join a db_join_t pointer. 62 * \return a character pointer or NULL on error or if no from field name has 63 * been set. 64 */ 65 extern const char* db_join_from_field(const db_join_t* join); 66 67 /** 68 * Get the to table name of a database join. 69 * \param[in] join a db_join_t pointer. 70 * \return a character pointer or NULL on error or if no to table name has been 71 * set. 72 */ 73 extern const char* db_join_to_table(const db_join_t* join); 74 75 /** 76 * Get the to field name of a database join. 77 * \param[in] join a db_join_t pointer. 78 * \return a character pointer or NULL on error or if no to field name has been 79 * set. 80 */ 81 extern const char* db_join_to_field(const db_join_t* join); 82 83 /** 84 * Get the next database join connected in a database join list. 85 * \param[in] join a db_join_t pointer. 86 * \return a db_join_t pointer or NULL on error or if there are no more database 87 * joins in the list. 88 */ 89 extern const db_join_t* db_join_next(const db_join_t* join); 90 91 /** 92 * A list of database joins. 93 */ 94 struct db_join_list { 95 db_join_t* begin; 96 db_join_t* end; 97 }; 98 99 /** 100 * Return the first database join in a database join list. 101 * \param[in] join_list a db_join_list_t pointer. 102 * \return a db_join_t pointer or NULL on error or if the list is empty. 103 */ 104 extern const db_join_t* db_join_list_begin(const db_join_list_t* join_list); 105 106 #endif 107