Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

filestathandler.h

Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2004 Russell Leighton
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 */
00018 
00019 
00020 
00021 
00022 #ifndef __AWHANDLER_FILESTAT__
00023 #define __AWHANDLER_FILESTAT__
00024 
00025 #include <regex.h>
00026 
00027 #include "monitor.h"
00028 #include "wire.h"
00029 
00031 /*\@{*/
00032 
00122 /*
00123 
00124 Changes:
00125 
00126 02/11/04 Russell Leighton
00127 Port to handler
00128 
00129 */
00130 
00134 typedef struct {
00135 
00136   aw_event_sig_t
00137     file_exists,
00138     file_notexists,
00139     file_created,
00140     file_deleted,
00141     file_size,
00142     file_size_change,
00143     file_size_nochange,
00144     file_mtime,
00145     file_mtime_change;
00146 
00147 } aw_filestathandler_events_t;
00148 
00149 
00153 typedef struct {
00154 
00155   int32_t
00156    fd;               /* open fd to text file */
00157 
00158   struct stat
00159    last_stat;
00160 
00161 } aw_filestathandler_state_t;
00162 
00163 
00167 typedef struct {
00168 
00169   aw_handler_t 
00170     handler_header;
00171 
00172   aw_filestathandler_events_t
00173    events;
00174 
00175   /* filename to watch */
00176   const byte_t
00177    *filename;
00178 
00179   /* non-zero if you DON'T want to log file not found errors */
00180   int32_t
00181    dont_log_file_not_found;
00182 
00183   /* non-zero on first handler() after start(), forces exits checks */
00184   int32_t
00185    firsthandler;
00186 
00187   aw_filestathandler_state_t
00188    state;
00189 
00190 } aw_filestathandler_t ;
00191 
00203 aw_filestathandler_t *aw_create_filestathandler(const aw_filestathandler_events_t *events,
00204                                                 const char *filename,
00205                                                 int32_t dont_log_file_not_found,
00206                                                 int32_t (*regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00207                                                 int32_t (*regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00208                                                 const aw_alarm_sched_t *sched,
00209                                                 aw_logger_t *logger
00210                                                 );
00211 
00216 void aw_free_filestathandler(aw_filestathandler_t *p);
00217 
00221 aw_handler_t *aw_wire_filestathandler(aw_wire_mkhandler_args_t *args);
00222 
00223 /*\@}*/
00224 
00225 #endif
Aware 0.11.1 Copyright (C) 1998-2005 Russell Leighton (russ@elegant-software.com)