Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
T
time-slime
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Michael Rouse
time-slime
Commits
2b5f4e04
Commit
2b5f4e04
authored
Aug 20, 2018
by
Michael Rouse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforcing initialization
parent
3fd1dfc6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
1 deletion
+26
-1
README.md
README.md
+2
-0
timeslime.c
timeslime.c
+22
-1
timeslime.h
timeslime.h
+2
-0
No files found.
README.md
View file @
2b5f4e04
...
...
@@ -73,6 +73,8 @@ char* TimeSlime_StatusCode(TIMESLIME_STATUS_t status);
|
`TIMESLIME_ALREADY_CLOCKED_IN`
|Unable to clock in since a clock out action has not been performed|
|
`TIMESLIME_NOT_CLOCKED_IN`
|Unable to clock out since a clock in action has not been performed|
|
`TIMESLIME_NO_ENTIRES`
|No time sheet entries were found for a given date range|
|
`TIMESLIME_NOT_INITIALIZED`
|
`TimeSlime_Initialize(char[])`
has not been called yet|
If you want to get a string key that represents a status code,
use the
`TimeSlime_StatusCode(TIMESLIME_STATUS_t)`
method, and pass in the status code. A string will be returned.
...
...
timeslime.c
View file @
2b5f4e04
...
...
@@ -25,6 +25,7 @@ static char *database_file_path;
static
TIMESLIME_INTERNAL_ROW_t
**
database_results
;
static
int
number_of_results
;
static
int
result_array_size
;
static
int
is_initialized
;
/* Functions */
static
TIMESLIME_STATUS_t
_TimeSlime_CreateTables
(
void
);
...
...
@@ -50,6 +51,8 @@ TIMESLIME_STATUS_t TimeSlime_Initialize(char directory_for_database[])
db
=
NULL
;
database_results
=
NULL
;
is_initialized
=
1
;
// Generate path for database file
database_file_path
=
malloc
((
strlen
(
directory_for_database
)
+
1
+
strlen
(
TIMESLIME_DATABASE_FILE_NAME
))
*
sizeof
(
char
));
/* + 1 for the slash */
if
(
database_file_path
==
NULL
)
...
...
@@ -83,6 +86,9 @@ TIMESLIME_STATUS_t TimeSlime_Initialize(char directory_for_database[])
*/
TIMESLIME_STATUS_t
TimeSlime_Close
(
void
)
{
if
(
!
is_initialized
)
return
TIMESLIME_NOT_INITIALIZED
;
int
rc
;
if
(
db
!=
NULL
)
{
...
...
@@ -120,6 +126,9 @@ TIMESLIME_STATUS_t TimeSlime_Close(void)
*/
TIMESLIME_STATUS_t
TimeSlime_AddHours
(
float
hours
,
TIMESLIME_DATE_t
date
)
{
if
(
!
is_initialized
)
return
TIMESLIME_NOT_INITIALIZED
;
// Verify parameters
TIMESLIME_STATUS_t
paramTest
=
_TimeSlime_VerifyDate
(
date
);
if
(
paramTest
!=
TIMESLIME_OK
)
...
...
@@ -152,6 +161,9 @@ TIMESLIME_STATUS_t TimeSlime_AddHours(float hours, TIMESLIME_DATE_t date)
*/
TIMESLIME_STATUS_t
TimeSlime_ClockIn
(
TIMESLIME_DATETIME_t
time
)
{
if
(
!
is_initialized
)
return
TIMESLIME_NOT_INITIALIZED
;
TIMESLIME_STATUS_t
status
;
// Verify parameters are valid
status
=
_TimeSlime_VerifyTimestamp
(
time
);
...
...
@@ -190,7 +202,10 @@ TIMESLIME_STATUS_t TimeSlime_ClockIn(TIMESLIME_DATETIME_t time)
*/
TIMESLIME_STATUS_t
TimeSlime_ClockOut
(
TIMESLIME_DATETIME_t
time
)
{
// Verify parameters are valid
if
(
!
is_initialized
)
return
TIMESLIME_NOT_INITIALIZED
;
// Verify parameters are valid
TIMESLIME_STATUS_t
paramTest
=
_TimeSlime_VerifyTimestamp
(
time
);
if
(
paramTest
!=
TIMESLIME_OK
)
return
paramTest
;
...
...
@@ -228,6 +243,9 @@ TIMESLIME_STATUS_t TimeSlime_ClockOut(TIMESLIME_DATETIME_t time)
*/
TIMESLIME_STATUS_t
TimeSlime_GetReport
(
TIMESLIME_DATE_t
start
,
TIMESLIME_DATE_t
end
,
TIMESLIME_REPORT_t
**
out
)
{
if
(
!
is_initialized
)
return
TIMESLIME_NOT_INITIALIZED
;
int
i
;
TIMESLIME_STATUS_t
paramTest
;
char
sql
[
1000
];
...
...
@@ -326,8 +344,11 @@ char* TimeSlime_StatusCode(TIMESLIME_STATUS_t status)
return
"NOT_CLOCKED_IN"
;
case
TIMESLIME_NO_ENTIRES
:
return
"NO_TIMESHEET_ENTRIES"
;
case
TIMESLIME_NOT_INITIALIZED
:
return
"NOT_INITIALIZED"
;
case
TIMESLIME_SQLITE_ERROR
:
return
db_error
;
default:
return
"?"
;
}
...
...
timeslime.h
View file @
2b5f4e04
...
...
@@ -39,6 +39,8 @@
#define TIMESLIME_INVALID_HOUR 13
#define TIMESLIME_INVALID_MINUTE 14
#define TIMESLIME_NOT_INITIALIZED 99
#define TIMESLIME_ALREADY_CLOCKED_IN 60
/* When you try to clock in without clocking out */
#define TIMESLIME_NOT_CLOCKED_IN 61
/* When you try to clock out without clocking in */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment