50 lines
1.4 KiB
C
50 lines
1.4 KiB
C
#ifndef FIFO_H
|
|
#define FIFO_H
|
|
#include <stdio.h>
|
|
#define T_CHAR 0
|
|
#define T_INT 1
|
|
#define T_FLOAT 2
|
|
#define T_STRING 3
|
|
#define T_MAGIC 4
|
|
#define T_COUNT 5
|
|
extern char *type_name[];
|
|
int getType(const char *name);
|
|
char *getTypeName(int type);
|
|
void *readData(FILE *input, int type, void *storage);
|
|
int writeData(FILE *output, int type, void *data);
|
|
|
|
/*
|
|
struct Dir, struct DirEntry, openDir, readDir, and closeDir act as a cross-platform wrapper to ordered directory listing. Note that openDir() reads in ALL files and readDir() simply provides the next one in the DirEntry linked list. This is unlike opendir()/readdir(), which provides a live structure (or so I think).
|
|
*/
|
|
#define SORT_DESCEND 0
|
|
#define SORT_ASCEND 1
|
|
#define F_UKN 0
|
|
#define F_REG 1
|
|
#define F_DIR 2
|
|
#define F_LNK 3
|
|
struct Dir {
|
|
char *dirname;
|
|
int order;
|
|
struct DirEntry *start;
|
|
struct DirEntry *current;
|
|
};
|
|
struct Dir *openDir(const char *path, int order);
|
|
int closeDir(struct Dir *dir);
|
|
struct DirEntry {
|
|
char *d_name;
|
|
unsigned char d_type;
|
|
struct DirEntry *next; // lazy
|
|
};
|
|
struct DirEntry *readDir(struct Dir *dir);
|
|
|
|
int fileToBuffer(char **buffer, const char *filename);
|
|
int fileExists(const char *filename);
|
|
int deleteFile(const char *filename);
|
|
int hasExtension(const char *name, const char *extension);
|
|
char *remExtension(char *name, const char *extension);
|
|
|
|
float htonf(float fl);
|
|
float ntohf(float fl);
|
|
|
|
#endif
|