1 /* 2 * Definition for a task 3 * 4 * Copyright: 5 * (C) 1999 Craig Knudsen, cknudsen@cknudsen.com 6 * See accompanying file "COPYING". 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the 20 * Free Software Foundation, Inc., 59 Temple Place, 21 * Suite 330, Boston, MA 02111-1307, USA 22 * 23 * 17-Apr-2005 Add support for subtracting a particular offset 24 * off of timers. (Russ Allbery) 25 */ 26 27 28 #ifndef _TASK_H 29 #define _TASK_H 30 31 #define TASK_DIRECTORY ".gtimer" /* from $HOME */ 32 33 /* Errors */ 34 #define TASK_ERROR_SYSTEM_ERROR 1 /* check errno value */ 35 #define TASK_ERROR_BAD_FILE 2 /* bad file format */ 36 37 typedef struct { 38 int seconds; /* time in seconds */ 39 int mon, mday, year; /* MM/DD/YYYY */ 40 int marked_seconds; /* time in seconds - used by taskMark() */ 41 } TaskTimeEntry; 42 43 typedef struct { 44 char *text; /* text of annotiation */ 45 time_t text_time; /* GMT of annotation */ 46 } TaskAnnotation; 47 48 typedef struct { 49 char *name; /* name of task */ 50 TaskTimeEntry **entries; /* entries */ 51 int num_entries; /* number entries (dates) */ 52 time_t created; /* time created */ 53 int number; /* unique task id number */ 54 int project_id; /* id of parent project (-1=no project) */ 55 unsigned int options; /* app-defined bit-or options */ 56 TaskAnnotation **annotations; /* annotations */ 57 int num_annotations; /* size of above array */ 58 } Task; 59 60 /* 61 * Functions 62 */ 63 64 65 void taskAdd ( Task *task ); 66 int taskSave ( Task *task, char *taskdir ); 67 int taskSaveAll ( char *taskdir ); 68 /* rra 2005-04-17 - add an offset to subtract from running times */ 69 void taskMark ( Task *task, int offset ); 70 void taskMarkAll ( int offset ); 71 void taskRestore ( Task *task ); 72 void taskRestoreAll (); 73 void taskClearAll (); 74 int taskLoad ( char *file, Task **task ); 75 int taskLoadAll ( char *taskdir ); 76 Task *taskCreate ( char *name ); 77 int taskDelete ( Task *task, char *taskdir ); 78 void taskFree (); 79 int taskCount (); 80 Task *taskGet ( int number ); 81 Task *taskGetFirst (); 82 Task *taskGetNext (); 83 TaskTimeEntry *taskGetTimeEntry ( Task *task, int year, int month, int day ); 84 TaskTimeEntry *taskNewTimeEntry ( Task *task, int year, int month, int day ); 85 unsigned int taskOptions ( Task *task ); 86 unsigned int taskOptionEnabled ( Task *task, unsigned int option ); 87 void taskSetOption ( Task *task, unsigned int option ); 88 void taskUnsetOption ( Task *task, unsigned int option ); 89 void taskAddAnnotation ( Task *task, char *taskdir, char *text ); 90 TaskAnnotation **TaskGetAnnotationEntries ( Task *task, int year, 91 int month, int day, int time_offset, int *num_ret ); 92 char *taskErrorString ( int task_error ); 93 94 #endif /* _TASK_H */ 95