Source refactoring; no functional changes.

This commit is contained in:
Felicity Tarnell 2014-03-07 17:43:41 +00:00
parent b174130c91
commit 332fdba0bd
20 changed files with 1806 additions and 1440 deletions

59
entry.h Normal file
View file

@ -0,0 +1,59 @@
/*
* TTS - track your time.
* Copyright (c) 2012-2014 Felicity Tarnell.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely. This software is provided 'as-is', without any express or implied
* warranty.
*/
#ifndef TTS_ENTRY_H
#define TTS_ENTRY_H
#include <time.h>
#include "queue.h"
#include "wide.h"
typedef struct entry {
WCHAR *en_desc;
int en_secs;
time_t en_started;
time_t en_created;
struct {
int efl_visible:1;
int efl_invoiced:1;
int efl_marked:1;
int efl_deleted:1;
int efl_nonbillable:1;
} en_flags;
TAILQ_ENTRY(entry) en_entries;
} entry_t;
typedef TAILQ_HEAD(entrylist, entry) entry_list;
extern entry_list entries;
extern entry_t *running;
entry_t *entry_new (const WCHAR *);
void entry_start (entry_t *);
void entry_stop (entry_t *);
void entry_free (entry_t *);
void entry_account (entry_t *);
time_t entry_time_for_day (time_t, int, int);
#define time_day(t) (((t) / (60 * 60 * 24)) * (60 * 60 * 24))
#define entry_day(e) (time_day((e)->en_created))
#define time_to_hms(t, h, m, s) do { \
time_t n = t; \
h = n / (60 * 60); \
n %= (60 * 60); \
m = n / 60; \
n %= 60; \
s = n; \
} while (0)
#endif /* !TTS_ENTRY_H */