Main Page | Modules | Data Structures | File List | Data Fields | Globals

core.c

Go to the documentation of this file.
00001 
00011 /* $Progeny: core.c 4060 2004-01-26 15:43:06Z branden $
00012  *
00013  * Copyright 2002 Progeny Linux Systems, Inc.
00014  * Copyright 2002 Hewlett-Packard Company
00015  *
00016  * Permission is hereby granted, free of charge, to any person obtaining a
00017  * copy of this software and associated documentation files (the "Software"),
00018  * to deal in the Software without restriction, including without limitation
00019  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00020  * and/or sell copies of the Software, and to permit persons to whom the
00021  * Software is furnished to do so, subject to the following conditions:
00022  *
00023  * The above copyright notice and this permission notice shall be included in
00024  * all copies or substantial portions of the Software.
00025  *
00026  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00027  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00028  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00029  * THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00030  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00031  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00032  * DEALINGS IN THE SOFTWARE.
00033  */
00034 
00035 #include <config.h>
00036 
00037 #include <assert.h>
00038 
00039 #include <discover.h>
00040 #include <discover-xml.h>
00041 
00042 #include "utils.h"
00043 
00044 static char *discover_errlist[] = {
00045     N_("Success."),
00046     N_("Input/output error."),
00047     N_("XML parsing error."),
00048     N_("System error."),
00049     N_("Disabled bus."),
00050     N_("Bus not found."),
00051     N_("Data source not found."),
00052     N_("Device not found."),
00053     N_("Invalid version range."),
00054     N_("Not implemented.")
00055 };
00056 static int
00057 discover_nerr = sizeof(discover_errlist) / sizeof(discover_errlist[0]);
00058 
00067 discover_error_t *
00068 discover_error_new(void)
00069 {
00070     discover_error_t *status = _discover_xmalloc(sizeof(discover_error_t));
00071     status->code = 0;
00072     status->message = NULL;
00073     status->create_message = _discover_create_message;
00074     return status;
00075 }
00076 
00081 void *
00082 _discover_create_message(discover_error_t **status, char *message)
00083 {
00084     if((*status)->message) {
00085         free((*status)->message);
00086     }
00087     (*status)->message = _discover_xmalloc(strlen(message) + 1);
00088     strcpy((*status)->message, message);
00089 }
00090 
00094 void
00095 discover_error_free(discover_error_t *status)
00096 {
00097     assert(status != NULL);
00098     if (status->message != NULL) {
00099         free(status->message);
00100     }
00101     free(status);
00102 }
00103 
00110 char *
00111 discover_strerror(discover_error_t *err)
00112 {
00113     assert(err != NULL);
00114     assert(err->code >= 0);
00115     assert(err->code < discover_nerr);
00116 
00117     return _(discover_errlist[err->code]);
00118 }
00119 
00123 int
00124 discover_major_version(void)
00125 {
00126     return PACKAGE_MAJOR;
00127 }
00128 
00132 int
00133 discover_minor_version(void)
00134 {
00135     return PACKAGE_MINOR;
00136 }
00137 
00141 int
00142 discover_micro_version(void)
00143 {
00144     return PACKAGE_MICRO;
00145 }
00146 

Generated on Sat Jan 31 14:39:17 2004 for discover by doxygen 1.3.4