First commit
This commit is contained in:
24
include/comment.h
Normal file
24
include/comment.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef COMMENT_H
|
||||
#define COMMENT_H
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
typedef struct {
|
||||
int reply_id; /* should be 0 if comment is top-level */
|
||||
time_t creation_time;
|
||||
size_t text_length;
|
||||
char *user_sid, *user_displayname;
|
||||
} CommentHeader;
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
CommentHeader *header;
|
||||
char *text;
|
||||
} Comment;
|
||||
|
||||
/* does not copy strings given by pointers */
|
||||
CommentHeader *
|
||||
mk_comment_header(int reply_id, time_t creation_time, size_t text_length, char *user_sid, char *user_displayname);
|
||||
|
||||
#endif /* COMMENT_H */
|
15
include/driver.h
Normal file
15
include/driver.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef DRIVER_H
|
||||
#define DRIVER_H
|
||||
|
||||
#include "comment.h"
|
||||
|
||||
typedef struct {
|
||||
/* should return (id > 0) on success, and negative number on error */
|
||||
int (*leave_comment)(void*, CommentHeader*, char*);
|
||||
/* retrieve header information by id */
|
||||
int (*get_header)(void*, CommentHeader*, int);
|
||||
/* retrieve text of comment by id */
|
||||
int (*get_text)(void*, char*, int);
|
||||
} Driver;
|
||||
|
||||
#endif /* DRIVER_H */
|
22
include/drivers/unix_fs/unix_fs_driver.h
Normal file
22
include/drivers/unix_fs/unix_fs_driver.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef UNIX_FS_DRIVER_H
|
||||
#define UNIX_FS_DRIVER_H
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
#define ID_CTRL_FILE "max_id"
|
||||
#define TEXT_FILE_FMT "%s/%d.txt"
|
||||
#define HEADER_FILE_FMT "%s/%d.header"
|
||||
|
||||
typedef struct {
|
||||
char *path;
|
||||
} UnixFsDriverData;
|
||||
|
||||
int unix_fs_driver_leave_comment(void *driver_data_ptr, CommentHeader *header, char *text);
|
||||
|
||||
int unix_fs_driver_get_header(void *driver_data_ptr, CommentHeader *header, int id);
|
||||
|
||||
int unix_fs_driver_get_text(void *driver_data_ptr, char *text, int id);
|
||||
|
||||
static const Driver unix_fs_driver = { unix_fs_driver_leave_comment, unix_fs_driver_get_header, unix_fs_driver_get_text };
|
||||
|
||||
#endif /* UNIX_FS_DRIVER_H */
|
Reference in New Issue
Block a user