| 1 | /* $Id$ */ |
|---|
| 2 | /* |
|---|
| 3 | * FedStage DRMAA for PBS Pro |
|---|
| 4 | * Copyright (C) 2006-2009 FedStage Systems |
|---|
| 5 | * |
|---|
| 6 | * This program is free software: you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation, either version 3 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #ifndef __PBS_DRMAA__LOG_READER_H |
|---|
| 21 | #define __PBS_DRMAA__LOG_READER_H |
|---|
| 22 | |
|---|
| 23 | #ifdef HAVE_CONFIG_H |
|---|
| 24 | # include <config.h> |
|---|
| 25 | #endif |
|---|
| 26 | |
|---|
| 27 | #include <drmaa_utils/job.h> |
|---|
| 28 | #include <drmaa_utils/session.h> |
|---|
| 29 | |
|---|
| 30 | typedef struct pbsdrmaa_log_reader_s pbsdrmaa_log_reader_t; |
|---|
| 31 | |
|---|
| 32 | pbsdrmaa_log_reader_t * |
|---|
| 33 | pbsdrmaa_log_reader_new ( fsd_drmaa_session_t * session, fsd_job_t * job ); |
|---|
| 34 | |
|---|
| 35 | void |
|---|
| 36 | pbsdrmaa_log_reader_destroy ( pbsdrmaa_log_reader_t * self ); |
|---|
| 37 | |
|---|
| 38 | struct pbsdrmaa_log_reader_s { |
|---|
| 39 | fsd_drmaa_session_t *volatile session ; |
|---|
| 40 | fsd_job_t *volatile job; |
|---|
| 41 | |
|---|
| 42 | void (* |
|---|
| 43 | read_log) ( pbsdrmaa_log_reader_t * self ); |
|---|
| 44 | |
|---|
| 45 | void (* |
|---|
| 46 | select_file) ( pbsdrmaa_log_reader_t * self ); |
|---|
| 47 | |
|---|
| 48 | /* line - read line, buffer - keeps read but not returned lines, idx, end_idx and line_idx values needed to be kept outside the function */ |
|---|
| 49 | ssize_t (* |
|---|
| 50 | read_line) ( pbsdrmaa_log_reader_t * self, char * line, char * buffer, ssize_t size, int * idx, int * end_idx, int * line_idx ); |
|---|
| 51 | |
|---|
| 52 | /* specifies if function should run */ |
|---|
| 53 | bool run_flag; |
|---|
| 54 | |
|---|
| 55 | /* date of current file */ |
|---|
| 56 | time_t t; |
|---|
| 57 | |
|---|
| 58 | /* for job_on_missing - available log files */ |
|---|
| 59 | char ** log_files; |
|---|
| 60 | |
|---|
| 61 | /* for job_on_missing - number of log files */ |
|---|
| 62 | int log_files_number; |
|---|
| 63 | |
|---|
| 64 | /* log file descriptor */ |
|---|
| 65 | int volatile fd; |
|---|
| 66 | |
|---|
| 67 | /* for job_on_missing - log file size when function was ran */ |
|---|
| 68 | off_t log_file_initial_size; |
|---|
| 69 | |
|---|
| 70 | /* for job_on_missing - read lines size */ |
|---|
| 71 | off_t log_file_read_size; |
|---|
| 72 | |
|---|
| 73 | /* for wait_thread - day changed */ |
|---|
| 74 | bool volatile date_changed; |
|---|
| 75 | |
|---|
| 76 | /* for wait_thread - log file first open */ |
|---|
| 77 | bool volatile first_open; |
|---|
| 78 | |
|---|
| 79 | char * name; |
|---|
| 80 | }; |
|---|
| 81 | |
|---|
| 82 | #endif /* __PBS_DRMAA__LOG_READER_H */ |
|---|