2022-05-16 23:48:32 +00:00
|
|
|
#ifndef LAIKA_CONTENT_H
|
|
|
|
#define LAIKA_CONTENT_H
|
|
|
|
|
2022-05-17 15:37:58 +00:00
|
|
|
#include "laika.h"
|
|
|
|
#include "lpacket.h"
|
2022-05-16 23:48:32 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CONTENT_FILE,
|
|
|
|
CONTENT_PAYLOAD
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CONTENT_ERR_ID_IN_USE,
|
|
|
|
CONTENT_ERR_INVALID_ID
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef uint8_t CONTENT_TYPE;
|
|
|
|
typedef uint8_t CONTENT_ERRCODE;
|
2022-05-17 15:37:58 +00:00
|
|
|
typedef uint16_t CONTENT_ID;
|
2022-05-16 23:48:32 +00:00
|
|
|
|
|
|
|
struct sLaika_content {
|
2022-05-17 15:37:58 +00:00
|
|
|
struct sLaika_content *next;
|
2022-05-16 23:48:32 +00:00
|
|
|
FILE *fd;
|
|
|
|
uint32_t sz; /* content size */
|
|
|
|
uint32_t processed;
|
2022-05-17 15:37:58 +00:00
|
|
|
CONTENT_ID id;
|
2022-05-16 23:48:32 +00:00
|
|
|
CONTENT_TYPE type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sLaika_contentContext {
|
|
|
|
struct sLaika_content *headIn; /* receiving from peer */
|
|
|
|
struct sLaika_content *headOut; /* sending to peer */
|
2022-05-17 15:37:58 +00:00
|
|
|
CONTENT_ID nextID;
|
2022-05-16 23:48:32 +00:00
|
|
|
};
|
|
|
|
|
2022-05-17 15:37:58 +00:00
|
|
|
void laikaF_initContext(struct sLaika_contentContext *context);
|
2022-05-16 23:48:32 +00:00
|
|
|
void laikaF_cleanContext(struct sLaika_contentContext *context);
|
|
|
|
|
2022-05-17 15:37:58 +00:00
|
|
|
int laikaF_newOutContent(struct sLaika_peer *peer, FILE *fd, CONTENT_TYPE type);
|
|
|
|
void laikaF_newInContent(struct sLaika_peer *peer, CONTENT_ID id, uint32_t sz, CONTENT_TYPE type);
|
|
|
|
|
|
|
|
void laikaF_pollContent(struct sLaika_peer *peer);
|
2022-05-16 23:48:32 +00:00
|
|
|
|
2022-05-17 15:37:58 +00:00
|
|
|
void laikaF_handleContentChunk(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uData);
|
2022-05-16 23:48:32 +00:00
|
|
|
|
|
|
|
#endif
|