Skip to content

Commit

Permalink
Moved string and time constants to respective util files
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Engel <[email protected]>
  • Loading branch information
engelmi committed Oct 14, 2024
1 parent 8e7f9ec commit 4442741
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
10 changes: 1 addition & 9 deletions src/libbluechi/common/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

#include <errno.h>

/* Time constants */
#define USEC_PER_SEC 1000000
#define USEC_PER_MSEC 1000
#define NSEC_PER_USEC 1000
#include "time-util.h"

/* Configuration defaults */
#define BC_DEFAULT_PORT "842"
Expand Down Expand Up @@ -124,8 +121,3 @@ typedef enum UnitActiveState {

const char *active_state_to_string(UnitActiveState s);
UnitActiveState active_state_from_string(const char *s);

/* Constants */
#define SYMBOL_WILDCARD "*"
#define SYMBOL_GLOB_ALL '*'
#define SYMBOL_GLOB_ONE '?'
5 changes: 4 additions & 1 deletion src/libbluechi/common/string-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
#include <stdlib.h>
#include <string.h>

#include "protocol.h"
/* Constants */
#define SYMBOL_WILDCARD "*"
#define SYMBOL_GLOB_ALL '*'
#define SYMBOL_GLOB_ONE '?'

#define streq(a, b) (strcmp((a), (b)) == 0)
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
Expand Down
3 changes: 3 additions & 0 deletions src/libbluechi/common/time-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include <stdlib.h>

#define USEC_INFINITY UINT64_MAX
#define USEC_PER_SEC 1000000
#define USEC_PER_MSEC 1000
#define NSEC_PER_USEC 1000

static const uint64_t sec_to_microsec_multiplier = 1000000;
static const double microsec_to_millisec_multiplier = 1e-3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <limits.h>
#include <stdlib.h>

#include "libbluechi/common/protocol.h"
#include "libbluechi/common/time-util.h"

int main() {
Expand Down

0 comments on commit 4442741

Please sign in to comment.