00001 /*************************************************************************** 00002 BSD License 00003 00004 Copyright (c) 2002, Intel Corporation 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without 00008 modification, are permitted provided that the following conditions are met: 00009 00010 a.. Redistributions of source code must retain the above copyright notice, 00011 this list of conditions and the following disclaimer. 00012 b.. Redistributions in binary form must reproduce the above copyright notice, 00013 this list of conditions and the following disclaimer in the documentation 00014 and/or other materials provided with the distribution. 00015 c.. Neither the name of Intel Corporation nor the names of its contributors 00016 may be used to endorse or promote products derived from this software 00017 without specific prior written permission. 00018 00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 00023 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00024 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00025 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00026 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 00030 ****************************************************************************/ 00031 00032 00033 #ifndef __UTILS_H__ 00034 #define __UTILS_H__ 00035 00036 #include "ahm.h" 00037 00038 /** Parses the command line options */ 00039 void get_command_line_options(int a_argc, char *a_argv[]); 00040 00041 /** Opens the fifo and stores the descriptor in the structure provided */ 00042 int open_fifo(registration_info **a_reginfo); 00043 00044 /** Determines if a file exists */ 00045 int file_exists(const char *a_fname); 00046 00047 /** Checks to ensure the mode of the file is as desired */ 00048 int check_file_mode(const char *a_fname); 00049 00050 /** Checks the owner and mode of a file */ 00051 int check_file_owner_mode(const char *a_fname, uid_t a_uid, gid_t a_gid); 00052 00053 /** Checks the owner of a the file speicifed */ 00054 int check_file_owner(const char *a_fname, uid_t a_uid, gid_t a_gid); 00055 00056 /** Frees memory associated with a key (i.e. registration key) */ 00057 void key_destroy_func(gpointer a_data); 00058 00059 /** Frees memory associated with a value (i.e. registration data) */ 00060 void value_destroy_func(gpointer a_data); 00061 00062 /** Scans the regsitration directory for new registration files */ 00063 int read_registration_file(const char * a_fname, registration_info **a_reginfo); 00064 00065 /** Logs a message using syslog or posix_log_printf if POSIX_EVENT_LOGGING is defined */ 00066 void log_message(int a_event, 00067 int a_severity, 00068 unsigned int a_flags, 00069 const char *a_format, ...); 00070 00071 /** This is a debugging function to display registration data */ 00072 void display_registration_info(const registration_info *a_reginfo); 00073 00074 #endif /* __UTILS_H__ */ 00075 00076