Skip to content

Commit

Permalink
Merge pull request #453 from grumvalski/cnxcc_include
Browse files Browse the repository at this point in the history
cnxcc: define inline functions in cnxcc.h
  • Loading branch information
grumvalski committed Dec 22, 2015
2 parents fed70c4 + a9ec529 commit fd8f7dd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
24 changes: 0 additions & 24 deletions modules/cnxcc/cnxcc.c
Expand Up @@ -28,30 +28,6 @@

#include "cnxcc.h"

inline void get_datetime(str *dest)
{
timestamp2isodt(dest, get_current_timestamp());
}

inline unsigned int get_current_timestamp()
{
return time(NULL);
}

inline int timestamp2isodt(str *dest, unsigned int timestamp)
{
time_t tim;
struct tm *tmPtr;

tim = timestamp;
tmPtr = localtime(&tim);

strftime( dest->s, DATETIME_SIZE, "%Y-%m-%d %H:%M:%S", tmPtr);
dest->len = DATETIME_LENGTH;

return 0;
}

double str2double(str *string)
{
char buffer[string->len + 1];
Expand Down
27 changes: 24 additions & 3 deletions modules/cnxcc/cnxcc.h
Expand Up @@ -31,9 +31,30 @@
#define DATETIME_LENGTH DATETIME_SIZE - 1


inline void get_datetime(str *dest);
inline unsigned int get_current_timestamp();
inline int timestamp2isodt(str *dest, unsigned int timestamp);
static inline unsigned int get_current_timestamp()
{
return time(NULL);
}

static inline int timestamp2isodt(str *dest, unsigned int timestamp)
{
time_t tim;
struct tm *tmPtr;

tim = timestamp;
tmPtr = localtime(&tim);

strftime( dest->s, DATETIME_SIZE, "%Y-%m-%d %H:%M:%S", tmPtr);
dest->len = DATETIME_LENGTH;

return 0;
}

static inline void get_datetime(str *dest)
{
timestamp2isodt(dest, get_current_timestamp());
}

double str2double(str *string);

#endif /* _CNXCC_H */

0 comments on commit fd8f7dd

Please sign in to comment.