79 lines
1.5 KiB
C
79 lines
1.5 KiB
C
/**
|
|
* @file tftp.h
|
|
* @brief tftp server
|
|
* @author Sander S.
|
|
*/
|
|
|
|
#ifndef PROJECT_TFTP_H
|
|
#define PROJECT_TFTP_H
|
|
#include <tftp_server.h>
|
|
#ifndef TESTING
|
|
#include "lcd_api.h"
|
|
#endif
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "llfs.h"
|
|
#include "log.h"
|
|
|
|
#define TFTP_READ 0
|
|
|
|
#ifndef UNUSED
|
|
#define UNUSED(x) (void)(x)
|
|
#endif
|
|
|
|
typedef struct tftp_custom_file_s {
|
|
char* data;
|
|
size_t len;
|
|
char* name;
|
|
size_t offset;
|
|
} tftp_custom_file_t;
|
|
|
|
/**
|
|
* @brief Initialize the TFTP server
|
|
*/
|
|
void tftp_server_init(void);
|
|
|
|
/**
|
|
* @brief Uninitialize the TFTP server
|
|
*/
|
|
void tftp_server_deinit(void);
|
|
|
|
/**
|
|
* @brief Custom fseek function
|
|
*
|
|
* @param handle The custom file handle
|
|
* @param offset The offset
|
|
* @param whence The whence
|
|
*/
|
|
void tftp_custom_fseek(tftp_custom_file_t* handle, size_t offset, int whence);
|
|
|
|
/**
|
|
* @brief Custom fread function
|
|
*
|
|
* @param buf The buffer to read from
|
|
* @param bytes The amount of bytes to read
|
|
* @param handle The custom file handle
|
|
* @return The amount of bytes read
|
|
*/
|
|
size_t tftp_custom_fread(void* buf, size_t bytes, tftp_custom_file_t* handle);
|
|
|
|
/**
|
|
* @brief Custom fwrite function
|
|
*
|
|
* @param buf The buffer to write to
|
|
* @param bytes The amount of bytes to write
|
|
* @param handle The custom file handle
|
|
* @return The amount of bytes written
|
|
*/
|
|
size_t tftp_custom_fwrite(const void* buf, size_t bytes, tftp_custom_file_t* handle);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // PROJECT_TFTP_H
|