📄 collection.h
字号:
#ifndef __COLLECTION_H__#define __COLLECTION_H__#include <iostream>#include <utmpx.h>#include <unistd.h>#include <time.h>#include <errno.h>#include <map>#include <list>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netdb.h>#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <time.h>#include <fstream>///////////////////////////////////#include <sys/ipc.h>#include <sys/msg.h>//////////////////////////////////using std::string;using std::cout;using std::endl;using std::ifstream;using std::ofstream;using std::list;using std::multimap;using std::pair;#ifndef __DEBUG#define __DEBUG#endif#ifndef __TIMER#define __TIMER#endif#define BACKUP_TAG "BACKUP"#define POSITION_TAG "POSITION"#define SYSTEM_TAG "SYSTEM"#define COMMENT_TAG "#"#define DELIMITER_TAG "="#define BACKUP "utmpx.bakx"#define SYSTEM "/var/adm/wtmpx"#define POSITION "utmpx.posx"#define DEFAULT_CONF "../etc/config.ini"#define NOT_ASSIGNED "**NOT**"#define END 999#define MAX_BUF 255struct info{ char user_name[50]; time_t start_time; time_t duration; char IP[16]; info() { strcpy(IP,"127.0.0.1"); }};#ifdef __TIMERclass timer{ time_t _start; time_t _end; string pro_name; public: timer() {} void start(const string pro_name) { this->pro_name = pro_name; _start = time(0); } void end() { _end = time(0); } void show() const { cout << " Timer Calc: " << (_end - _start)/60; cout << " min " << (_end - _start)%60 << " sec [" << pro_name << " ]\n"; }};#endifclass collection{ /////////////////////////////////////////// key_t key; pid_t pid; int msgid; struct msg{ long mtype; char inf[sizeof(info)]; }; /////////////////////////////////////////// string backup_file; string position_file; string system_file; multimap<short, utmpx*> login,logoff; list<info*> data; struct utmpx last; #ifdef __TIMER timer _timer; #endif void show(struct utmpx*&); void store(const utmpx*, const time_t&); void dump_unfinished(); void dump_lastposition(); void receive(); void setdefault(); string localIP(); public: collection(); ~collection(); void retrieve(); int processing(); void start_cllection(); void loadconfiguration(const char* file = NULL); };#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -