Commit 6248160e by Eric Coissac

C Syntax error patches

parent 30ddb32d
......@@ -51,7 +51,6 @@ static char *build_directory_name(const char *name) {
}
OBIDMS_p obi_create_dms(const char *name) {
OBIDMS_p dms=NULL;
char *dirdbname;
// Build and check the directory name
......@@ -61,7 +60,7 @@ OBIDMS_p obi_create_dms(const char *name) {
// Try to create the directory
if (mkdir(dirdbname,) < 0)
if (mkdir(dirdbname,0x777) < 0)
{
if (errno==EEXIST)
obi_set_errno(OBIDMS_EXIST_ERROR);
......@@ -111,7 +110,7 @@ OBIDMS_p obi_open_dms(const char *name) {
}
// Allocate the data structure
dms = <OBIDMS_p> malloc(sizeof(OBIDMS_t));
dms = (OBIDMS_p) malloc(sizeof(OBIDMS_t));
if (dms==NULL)
{
......
......@@ -12,6 +12,8 @@
#include <sys/stat.h>
#include <errno.h>
#include <dirent.h>
#include <string.h>
#include <stdio.h>
#include <obierrno.h>
......@@ -28,7 +30,7 @@ typedef struct OBIDMS {
char dirname[OBIDMS_MAX_NAME+1]; /**< The name of the directory
* containing the DMS
*/
DIR *directory /**< A directory entry usable to
DIR *directory; /**< A directory entry usable to
* refer and scan the database directory
*/
} OBIDMS_t, *OBIDMS_p;
......@@ -54,6 +56,9 @@ typedef struct OBIDMS {
*/
#define OBIDMS_ACCESS_ERROR (6) /**< Permission error for accessing to the database
*/
#define OBIDMS_BAD_ENDIAN_ERROR (7) /**< The opened data structure does not corresponds
* to the endianess of the platform.
*/
/**@}*/
......
......@@ -16,8 +16,12 @@
#include <sys/types.h>
#include <unistd.h>
#include <stdbool.h>
#include <time.h>
#include "obitypes.h"
#include <obidms.h>
#include <obitypes.h>
#include <obierrno.h>
#include <obilittlebigman.h>
/**
* @brief Value separator in OBIDMSColumn files.
......@@ -36,24 +40,110 @@ static const int HEADER_SIZE = 4096;
*/
static const int BUFFER_SIZE = 4;
#define OBIDMS_MAX_COLNAME (128) /**< The maximum length of an OBIDMS column name
*/
typedef int32_t obiversion_t; /**< Used to store the column version number
*/
/**
* @brief OBIColumnHeader structure.
*/
typedef struct OBIDMSColumnHeader {
bool endyan_byte_order; /**< endyan byte order */
int header_size_value; /**< size of the header: a multiple of PAGESIZE */
bool file_status; /**< file status : 0 is Open and 1 is Closed */
pid_t PID; /**< PID of the process that created the file and is
the only one allowed to modify it if it is open */
int line_count; /**< number of lines of data */
bool little_endian; /**< endianess of the column:
- `true` on little endian platform
- `false` on big endian platform
@see obi_is_little_end()
*/
int header_size; /**< size of the header in bytes */
size_t line_count; /**< number of lines of data */
size_t line_used; /**< number of lines of data used*/
OBIType_t data_type; /**< type of the data */
char* creation_date; /**< date of creation of the file */
int version; /**< version of the OBIColumn */
char* comments; /**< comments */
time_t creation_date; /**< date of creation of the file */
obiversion_t version; /**< version of the OBIColumn */
char name[OBIDMS_MAX_COLNAME]; /**< The column name as a NULL
* terminated string.
*/
char comments[1]; /**< comments stored as a classical
zero end C string. T
The size of the comment is just limited
by the header size
*/
} OBIDMSColumnHeader_t, *OBIDMSColumnHeader_p;
/**
* @brief Structure describing a Column of the OBITools DMS
*
* A data structure of this type is returned by the functions
* creating, opening or cloning an OBIDMSColumn.
*/
typedef struct OBIDMSColumn {
OBIDMS_p dms ; /**< A pointer to a DMS instance
*/
OBIDMSColumnHeader_p header; /**< A pointer to the header of the column
*/
void* data; /**< A `void` pointer to the beginning of the
* data.
*
* @attention never use this member directly
* outside of the code of the
* low level functions
* of the OBITools DMS
*/
bool writable;/**< Indicates if the column is writable or not.
* - `true` the column is writable
* - `false` the column is read-only
*
* A column is writable only by its creator
* until he closes it.
*/
} OBIDMSColumn_t, *OBIDMSColumn_p;
/**
* @brief Return the header size in bytes of a column on this platform.
*
* Header size is defined as a multiple of the memory page size.
* Up to now the header size is defined as one time the page size
*
* @return a `size_t` value corresponding to the header size in bytes
*
* @since May 2015
* @author Eric Coissac (eric.coissac@metabarcoding.org)
*/
size_t obi_get_platform_header_size();
/**
* @brief Create a column.
*
* @param dms a pointer as returned by obi_create_dms() or obi_open_dms()
* @param name the name of the new column
* @param type the OBIType code used to create the column
* @param nbelement the number of element to be stored
*
* @since May 2015
* @author Eric Coissac (eric.coissac@metabarcoding.org)
*/
OBIDMSColumn_p obi_create_column(OBIDMS_p dms,
char* name,
OBIType_t type,
size_t nbelement);
/**
* @brief Return the latest column version in the `dms` database
*
* @param dms a pointer as returned by obi_create_dms() or obi_open_dms()
* @param name the name of the column
*
* @return the bigger version number used for this column
* @return -1 if the column does not exist
*/
obiversion_t obi_latest_version(OBIDMS_p dms,char *name);
char* obi_map_read_only(int file, int start, int size);
......
......@@ -8,7 +8,7 @@
#include <obitypes.h>
size_t obi_sizeof(OBIType_t type) {
size_t size=0
size_t size=0;
switch (type) {
case OBI_VOID: size = 1;
......
......@@ -10,6 +10,7 @@
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#define OBIInt_NA (INT32_MIN)
#define OBIFloat_NA (NAN)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment