Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reformat using 3.3

  • Loading branch information...
commit 952b8c7a13a0637f9acbe362346978aa46729f80 1 parent 7f9dd7d
@scheibo authored
View
28 activity.c
@@ -4,31 +4,21 @@
#include "gpx.h"
#include "tcx.h"
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define DEFAULT_WRITE_FORMAT CSV
/* indexed by FileFormat */
-static ReadFn *readers[] = {
- csv_read,
- fit_read,
- gpx_read,
- tcx_read
-};
+static ReadFn *readers[] = { csv_read, fit_read, gpx_read, tcx_read };
/* indexed by FileFormat */
-static WriteFn *writers[] = {
- csv_write,
- fit_write,
- gpx_write,
- tcx_write
-};
+static WriteFn *writers[] = { csv_write, fit_write, gpx_write, tcx_write };
static FileFormat file_format_from_name(char *filename) {
char ext[4];
unsigned i;
size_t len = strlen(filename);
for (i = 2; i >= 0; i++) {
- ext[i] = tolower(*(filename+len-3+i));
+ ext[i] = tolower(*(filename + len - 3 + i));
}
ext[3] = '\0';
@@ -54,7 +44,7 @@ int activity_read(Activity *activity, char *filename) {
}
}
- return 1;
+ return 1;
}
int activity_write(Activity *activity, char *filename) {
FileFormat format = file_format_from_name(filename);
@@ -64,11 +54,13 @@ int activity_write(Activity *activity, char *filename) {
return activity_write_format(activity, filename, format);
}
-int activity_read_format(Activity *activity, char *filename, FileFormat format) {
+int activity_read_format(Activity *activity, char *filename,
+ FileFormat format) {
return readers[format](filename, activity);
}
-int activity_write_format(Activity *activity, char *filename, FileFormat format) {
+int activity_write_format(Activity *activity, char *filename,
+ FileFormat format) {
return writers[format](filename, activity);
}
@@ -131,7 +123,7 @@ int activity_add_point(Activity *a, uint32_t timestamp, double latitude,
// TODO
int activity_add_lap(uint32_t lap) {
if (activity->laps) {
- // see if theres enough space else realloc
+ // see if theres enough space else realloc
} else {
// alloc a certain amount of space
}
View
8 activity.h
@@ -118,7 +118,13 @@ typedef struct {
typedef int (*ReadFn)(char *, Activity *);
typedef int (*WriteFn)(char *, Activity *);
-typedef enum { CSV, GPX, TCX, FIT, UnknownFileFormat } FileFormat;
+typedef enum {
+ CSV,
+ GPX,
+ TCX,
+ FIT,
+ UnknownFileFormat
+} FileFormat;
#define activity_new() \
{ UnknownSport, NULL, NULL }
View
8 csv.c
@@ -1,9 +1,5 @@
#include "csv.h"
-int csv_read(char *filename, Activity *activity) {
- return 1;
-}
+int csv_read(char *filename, Activity *activity) { return 1; }
-int csv_write(char *filename, Activity *activity) {
- return 1;
-}
+int csv_write(char *filename, Activity *activity) { return 1; }
View
8 fit.c
@@ -1,9 +1,5 @@
#include "fit.h"
-int fit_read(char *filename, Activity *activity) {
- return 1;
-}
+int fit_read(char *filename, Activity *activity) { return 1; }
-int fit_write(char *filename, Activity *activity) {
- return 1;
-}
+int fit_write(char *filename, Activity *activity) { return 1; }
View
19 gpx.c
@@ -6,7 +6,10 @@
#include "mxml.h"
#include "util.h"
-typedef enum { false, true } bool;
+typedef enum {
+ false,
+ true
+} bool;
typedef struct {
bool metadata;
@@ -67,19 +70,19 @@ static int sax_cb(mxml_node_t *node, mxml_sax_event_t event, void *sax_data) {
state->data.altitude = (int32_t)(strtod(data, &end) * 1000);
if (*end) state->data.altitude = UNSET_ALTITUDE;
} else if (!strcmp(name, "gpxtpx:hr")) {
- state->data.heart_rate = (uint8_t)strtod(data, &end);
+ state->data.heart_rate = (uint8_t) strtod(data, &end);
if (*end) state->data.heart_rate = UNSET_HEART_RATE;
} else if (!strcmp(name, "gpxdata:hr")) {
- state->data.heart_rate = (uint8_t)strtod(data, &end);
+ state->data.heart_rate = (uint8_t) strtod(data, &end);
if (*end) state->data.heart_rate = UNSET_HEART_RATE;
} else if (!strcmp(name, "gpxdata:temp")) {
- state->data.temperature = (int8_t)strtod(data, &end);
+ state->data.temperature = (int8_t) strtod(data, &end);
if (*end) state->data.temperature = UNSET_TEMPERATURE;
} else if (!strcmp(name, "gpxdata:cadence")) {
- state->data.cadence = (uint8_t)strtod(data, &end);
+ state->data.cadence = (uint8_t) strtod(data, &end);
if (*end) state->data.cadence = UNSET_CADENCE;
} else if (!strcmp(name, "gpxdata:bikepower")) {
- state->data.power = (uint16_t)strtod(data, &end);
+ state->data.power = (uint16_t) strtod(data, &end);
if (*end) state->data.power = UNSET_POWER;
} else if (!strcmp(name, "trkpt")) {
/* TODO */
@@ -95,8 +98,8 @@ static int sax_cb(mxml_node_t *node, mxml_sax_event_t event, void *sax_data) {
int gpx_read(char *filename, Activity *activity) {
FILE *f = NULL;
- State state = {false /* metadata */, true /* first_element */,
- true /* first_time */, UNSET_DATA_POINT};
+ State state = { false /* metadata */, true /* first_element */,
+ true /* first_time */, UNSET_DATA_POINT };
if (!(f = fopen(filename, "r"))) {
return 1;
}
View
8 tcx.c
@@ -1,9 +1,5 @@
#include "tcx.h"
-int tcx_read(char *filename, Activity *activity) {
- return 1;
-}
+int tcx_read(char *filename, Activity *activity) { return 1; }
-int tcx_write(char *filename, Activity *activity) {
- return 1;
-}
+int tcx_write(char *filename, Activity *activity) { return 1; }
View
7 util.c
@@ -8,13 +8,12 @@
uint32_t parse_timestamp(const char *date) {
unsigned long timestamp;
int offset;
- return (parse_date_basic(date, &timestamp, &offset) < 0)
- ? 0
- : (uint32_t)timestamp;
+ return (parse_date_basic(date, &timestamp, &offset) < 0) ? 0 : (uint32_t)
+ timestamp;
}
int format_timestamp(char *buf, uint32_t timestamp) {
- time_t time = (time_t)timestamp;
+ time_t time = (time_t) timestamp;
struct tm *tm = gmtime(&time);
return !strftime(buf, 21, "%Y-%m-%dT%H:%M:%SZ", tm) ? -1 : 0;
}
Please sign in to comment.
Something went wrong with that request. Please try again.