#include "libhpcs.h"
#include "libhpcs_p.h"
-#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdlib.h>
#include <string.h>
enum HPCS_RetCode hpcs_read_file(const char* filename, struct HPCS_MeasuredData* mdata)
{
- FILE* datafile;
+ FILE* datafile;
enum HPCS_ParseCode pret;
enum HPCS_RetCode ret;
return PARSE_OK;
}
-static uint8_t month_to_number(const char* const month)
+static uint8_t month_to_number(const char* month)
{
if (strcmp(MON_JAN_STR, month) == 0)
return 1;
const HPCS_step step, const double sampling_rate)
{
const double time_step = 1 / (60 * sampling_rate);
- size_t alloc_size = 60 * sampling_rate;
+ size_t alloc_size = (size_t)((60 * sampling_rate) + 0.5);
bool read_file = true;
double value = 0;
double time = 0;
/* Expand storage if there is more data than we can store */
if (alloc_size == data_segments_read) {
struct HPCS_TVPair* nptr;
- alloc_size += 60 * sampling_rate;
+ alloc_size += (size_t)((60 * sampling_rate) + 0.5);
nptr = realloc(*pairs, sizeof(struct HPCS_TVPair) * alloc_size);
if (nptr == NULL) {
*result = string;
return PARSE_OK;
}
+
+#ifdef __cplusplus
+}
+#endif
LIBHPCS_API struct HPCS_MeasuredData* LIBHPCS_CC hpcs_alloc();
LIBHPCS_API void LIBHPCS_CC hpcs_free(struct HPCS_MeasuredData* const mdata);
LIBHPCS_API char* LIBHPCS_CC hpcs_error_to_string(const enum HPCS_RetCode);
-LIBHPCS_API enum HPCS_RetCode LIBHPCS_CC hpcs_read_file(const char* const filename, struct HPCS_MeasuredData* mdata);
+LIBHPCS_API enum HPCS_RetCode LIBHPCS_CC hpcs_read_file(const char* filename, struct HPCS_MeasuredData* mdata);
#ifdef __cplusplus
}
-#ifdef _MSC_VER
-typedef int uint8_t
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_MSC_VER)
+typedef int bool;
#define true 1
#define false 0
#else
#include <stdbool.h>
#endif
-
#include <stdio.h>
enum HPCS_DataCheckCode {
const char* HPCS_E__UNKNOWN_EC_STR = "Unknown error code.";
static enum HPCS_ParseCode autodetect_file_type(FILE* datafile, enum HPCS_FileType* file_type, const bool p_means_pressure);
-static enum HPCS_DataCheckCode check_for_marker(const char* const segment, size_t* const next_marker_idx);
+static enum HPCS_DataCheckCode check_for_marker(const char* segment, size_t* const next_marker_idx);
static HPCS_step guess_current_step(const struct HPCS_MeasuredData* mdata);
static HPCS_step guess_elec_sigstep(const struct HPCS_MeasuredData *mdata);
static bool guess_p_meaning(const struct HPCS_MeasuredData* mdata);
static void guess_sampling_rate(struct HPCS_MeasuredData* mdata);
static enum HPCS_ParseCode read_dad_wavelength(FILE* datafile, struct HPCS_Wavelength* const measured, struct HPCS_Wavelength* const reference);
-static uint8_t month_to_number(const char* const month);
-static enum HPCS_ParseCode read_date(FILE* datafile, struct HPCS_Date* const date);
+static uint8_t month_to_number(const char* month);
+static enum HPCS_ParseCode read_date(FILE* datafile, struct HPCS_Date* date);
static enum HPCS_ParseCode read_signal(FILE* datafile, struct HPCS_TVPair** pairs, size_t* pairs_count,
const HPCS_step step, const double sampling_rate);
static enum HPCS_ParseCode read_sampling_rate(FILE* datafile, double* sampling_rate);
#define PR_DEBUGF(fmt, msg) ((void)0)
#define PR_DEBUG(msg) ((void)0)
#endif
+
+#ifdef __cplusplus
+}
+#endif