include/hiker/sal.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Copyright (c) 1999-2008 ACCESS CO., LTD. All rights reserved.
00004  * Copyright 2006, 2007, ACCESS Systems Americas, Inc. All rights reserved.
00005  *
00006  * Version: MPL 1.1/LGPL 2.1
00007  *
00008  * The contents of this file are subject to the Mozilla Public License Version
00009  * 1.1 (the "License"); you may not use this file except in compliance with
00010  * the License. You may obtain a copy of the License at
00011  * http://www.mozilla.org/MPL/
00012  *
00013  * Software distributed under the License is distributed on an "AS IS" basis,
00014  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00015  * for the specific language governing rights and limitations under the
00016  * License.
00017  *
00018  * The Original Code is hikerproject.org code.
00019  *
00020  * The Initial Developer of the Original Code is ACCESS Systems Americas, Inc.
00021  *               Portions created by the Initial Developer are
00022  *      Copyright 2006-2007 the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
00028  * case the provisions of the LGPL are applicable instead of those above.
00029  * If you wish to allow use of your version of this file only under the terms
00030  * of the LGPL, and not to allow others to use your version of this file under
00031  * the terms of the MPL, indicate your decision by deleting the provisions
00032  * above and replace them with the notice and other provisions required by
00033  * the LGPL. If you do not delete the provisions above, a recipient may use
00034  * your version of this file under the terms of either the MPL or the LGPL. 
00035  * You may obtain a copy of the LGPL at http://www.gnu.org/licenses/lgpl.txt.
00036  *
00037  *****************************************************************************/
00044 #ifndef HIKER_SAL_H_
00045 #define HIKER_SAL_H_       1
00046 
00047 #include <stdio.h>
00048 #include <string.h>
00049 #include <stdlib.h>
00050 #include <sqlite3.h>
00051 #include <hiker/types.h>
00052 #include <hiker/sysclass.h>
00053 
00064 #define ALP_STATUS_SAL_BUSY                     (ALP_CLASS_SAL | 0x00010000)
00065 #define ALP_STATUS_SAL_LOCKED           (ALP_CLASS_SAL | 0x00020000)
00066 #define ALP_STATUS_SAL_NOMEM            (ALP_CLASS_SAL | 0x00030000)
00067 #define ALP_STATUS_SAL_READONLY         (ALP_CLASS_SAL | 0x00040000)
00068 #define ALP_STATUS_SAL_INTERRUPT        (ALP_CLASS_SAL | 0x00050000)
00069 #define ALP_STATUS_SAL_IOERR            (ALP_CLASS_SAL | 0x00060000)
00070 #define ALP_STATUS_SAL_CORRUPT          (ALP_CLASS_SAL | 0x00070000)
00071 #define ALP_STATUS_SAL_FULL             (ALP_CLASS_SAL | 0x00080000)
00072 #define ALP_STATUS_SAL_CANTOPEN         (ALP_CLASS_SAL | 0x00090000)
00073 #define ALP_STATUS_SAL_TOOBIG           (ALP_CLASS_SAL | 0x000A0000)
00074 #define ALP_STATUS_SAL_CONSTRAINT       (ALP_CLASS_SAL | 0x000B0000)
00075 #define ALP_STATUS_SAL_MISMATCH         (ALP_CLASS_SAL | 0x000C0000)
00076 #define ALP_STATUS_SAL_AUTH             (ALP_CLASS_SAL | 0x000D0000)
00077 #define ALP_STATUS_SAL_ERROR            (ALP_CLASS_SAL | 0x000E0000)
00078 #define ALP_STATUS_SAL_MISUSE           (ALP_CLASS_SAL | 0x000F0000)
00079 #define ALP_STATUS_SAL_NOLFS            (ALP_CLASS_SAL | 0x00100000)
00080 #define ALP_STATUS_SAL_PROTOCOL         (ALP_CLASS_SAL | 0x00110000)
00081 #define ALP_STATUS_SAL_EMPTY            (ALP_CLASS_SAL | 0x00120000)
00082 #define ALP_STATUS_SAL_SCHEMA           (ALP_CLASS_SAL | 0x00130000)
00083 #define ALP_STATUS_SAL_NOTFOUND         (ALP_CLASS_SAL | 0x00140000)
00084 #define ALP_STATUS_SAL_INTERNAL         (ALP_CLASS_SAL | 0x00150000)
00085 #define ALP_STATUS_SAL_PERM             (ALP_CLASS_SAL | 0x00160000)
00086 #define ALP_STATUS_SAL_ABORT            (ALP_CLASS_SAL | 0x00170000)
00087 #define ALP_STATUS_SAL_UNKNOWN          (ALP_CLASS_SAL | 0x00180000)
00088 #define ALP_STATUS_SAL_BADPARAM         (ALP_CLASS_SAL | 0x00190000)
00089 #define ALP_STATUS_SAL_NORECORDS        (ALP_CLASS_SAL | 0x001A0000)
00090 #define ALP_STATUS_SAL_DMLEXISTS        (ALP_CLASS_SAL | 0x001B0000)
00091 #define ALP_STATUS_SAL_NO_VALUE         (ALP_CLASS_SAL | 0x001C0000)
00092 
00093 /* @} */ /* end of Error Codes */
00094 
00095 
00104 #define ALP_SAL_UTF8_COLLATOR "alp_sal_utf8_collator"
00105  /* Other constants */
00107 
00116 typedef void *AlpSALHandle;
00117 
00123 typedef void *AlpSALStatement;
00124 
00133 typedef int (*AlpSalCollator)(void* user_data, int length1, const void* string1, int length2, const void* string2);
00134          /* end of Typedefs */
00136 
00137 #ifdef __cplusplus
00138 extern "C" {
00139 #endif
00140 
00159 extern alp_status_t     alp_sal_database_open(AlpSALHandle *sal,
00160                                                   const char *dbName);
00161 
00171 extern alp_status_t     alp_sal_database_close(AlpSALHandle sal);
00172 
00182 extern alp_status_t     alp_sal_database_create(const char *dbFileName,
00183                                                  const char *schemaFileName);
00184 
00192 extern alp_status_t     alp_sal_set_timeout(AlpSALHandle sal, int ms);
00193 
00201 extern alp_status_t     alp_sal_transaction_commit(AlpSALHandle sal);
00202 
00212 extern alp_status_t     alp_sal_transaction_begin(AlpSALHandle sal,
00213                                                   char exclusive);
00214 
00222 extern alp_status_t             alp_sal_transaction_rollback(AlpSALHandle sal);
00223 
00242 extern alp_status_t     alp_sal_sql_execute(AlpSALHandle sal, const char *sql, ...);
00243 
00253 extern alp_status_t     alp_sal_last_insert_rowid(AlpSALHandle sal,
00254                                                   uint32_t *rowID);
00255 
00280 extern alp_status_t   alp_sal_changes(AlpSALHandle sal, uint32_t *nRows);
00281 
00294 extern alp_status_t     alp_sal_execute_sql_script(AlpSALHandle sal, FILE *fd);
00295 
00314 extern alp_status_t     alp_sal_sql_get_value(AlpSALHandle sal,
00315                                               int32_t *value,
00316                                               const char *sql, ...);
00317 
00326 extern const char       *alp_sal_get_error_message(AlpSALHandle sal);
00327 
00352 extern alp_status_t     alp_sal_string_build(char **combined,
00353                                                   const char *sql, ...);
00354 
00366 extern void             alp_sal_string_destroy(char *s);
00367 
00379 extern alp_status_t     alp_sal_install_collator(AlpSALHandle sal, const char* collate_name, AlpSalCollator collate_function, void* user_data);
00380 
00389 extern alp_status_t     alp_sal_install_utf8_collator(AlpSALHandle sal);
00390 
00391 
00392 /* @} */ /* end of Data Access Functions */
00393 
00421 extern alp_status_t     alp_sal_statement_initialize(AlpSALHandle sal,
00422                                                   AlpSALStatement **stmt, const char *sql);
00423 
00433 extern AlpSALHandle     alp_sal_statement_get_handle(AlpSALStatement *stmt);
00434 
00447 extern alp_status_t     alp_sal_statement_set_null(AlpSALStatement *stmt,
00448                                                    int16_t pos);
00449 
00465 extern alp_status_t     alp_sal_statement_set_text(AlpSALStatement *stmt, 
00466                                                   int16_t pos, const char *s, bool copy);
00467 
00481 extern alp_status_t     alp_sal_statement_set_int(AlpSALStatement *stmt, 
00482                                                   int16_t pos, int32_t n);
00483 
00498 extern alp_status_t     alp_sal_statement_set_int64(AlpSALStatement *stmt, 
00499                                                   int16_t pos, int64_t n);
00500 
00517 extern alp_status_t     alp_sal_statement_set_blob(AlpSALStatement *stmt, 
00518                                                   int16_t pos, void *blob, int32_t size, bool copy);
00519 
00535 extern alp_status_t     alp_sal_statement_set_float(AlpSALStatement *stmt, 
00536                                                   int16_t pos, float f);
00537 
00551 extern int32_t                  alp_sal_statement_get_int(AlpSALStatement *stmt, 
00552                                                   int pos);
00553 
00567 extern int64_t                  alp_sal_statement_get_int64(AlpSALStatement *stmt, 
00568                                                   int pos);
00569 
00583 extern float                    alp_sal_statement_get_float(AlpSALStatement *stmt, 
00584                                                   int pos);
00585 
00601 extern char                     *alp_sal_statement_get_text(AlpSALStatement *stmt, 
00602                                                   int pos, bool copy);
00603 
00621 extern void             *alp_sal_statement_get_blob(AlpSALStatement *stmt, 
00622                                                   int pos, int32_t *size, bool copy);
00623 
00636 extern bool                     alp_sal_statement_is_null(AlpSALStatement *stmt, 
00637                                                   int pos);
00638 
00648 extern alp_status_t     alp_sal_statement_execute(AlpSALStatement *stmt);
00649 
00659 extern alp_status_t     alp_sal_statement_destroy(AlpSALStatement *stmt);
00660 
00681 extern alp_status_t     alp_sal_statement_next_result(AlpSALStatement *stmt);
00682 
00695 extern alp_status_t     alp_sal_statement_reset(AlpSALStatement *stmt);
00696 
00697 /* @} */ /* end of Statement Functions */
00698 
00699 /* @} */ /* end of HIKER_SAL group */
00700 
00701 #ifdef __cplusplus
00702 }
00703 #endif
00704 
00705 #endif /* HIKER_SAL_H_ */

Generated on Wed Jul 30 07:06:39 2008 by Doxygen 1.4.6 for ALP SDK + Hiker Documentation

Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.