/* ** File ** FeiMailReport.h ** Copyright 1997, The California Institute of Technology ** ** Creator ** J. Rector ** ** Created ** July, 1997 ** ** History ** */ #ifndef FEI_MAILREPORT_H #define FEI_MAILREPORT_H #include#include #include "FeiMsg.h" // Causes FeiGlobal.h to be included too. #include "FeiSpaceDateTime.h" #include "FeiMtList.h" class FeiMailReport { private: // Prevent copy-construction. FeiMailReport (const FeiMailReport&); void operator =(FeiMailReport&); // Structure used to times at which report are scheduled. struct ReportTimeNode { time_t rptTime; FeiMailReport::ReportTimeNode *next; }; int _status; char _msg[feiMsgLen]; char *_mailAddress; char *_mailSubject; FeiMailReport::ReportTimeNode *_reportTimes; time_t _today; int _listLimit; FeiMtList *_itemList; // Associated with mailSchedule thread pthread_t _threadId; pthread_mutex_t _rptTimeMutex; pthread_cond_t _rptReady; bool _lastReport; // Time parser; FeiSpaceDateTime *_dt; public: FeiMailReport (const char *mailAddress, const char *subject = (const char *)NULL, unsigned int listLimit = 132); ~FeiMailReport (void); int setReportTime (const char *listOfTimes); int addToReport (char *string); int mailReport (FeiMtList::Node *list); time_t timeOfNextReport (void); int getStatus (void); const char *getMsg (void); // These functions are part of the scheduler thread. friend void *scheduler (void *arg); }; /* ** Returns the current status of the object. Returns FEI_OK if reporting is ** possible. A value of FEI_ERROR means reporting was disabled because of an ** error. A value of FEI_FATAL means the object was not able to get a resource. ** Failure to allocate memory is the primary case when value is reported. ** See also `getMsg`. */ inline int FeiMailReport::getStatus (void) { return _status; } /* ** Returns the message associated with the last detected error. Use `getStatus` ** to test for error conditions. If no error has occured this buffer contain ** nothing but a 0 byte. */ inline const char *FeiMailReport::getMsg (void) { return (const char *)_msg; } #endif