#ifndef _WEBSEARCHFS_H
#define _WEBSEARCHFS_H
#ifdef __HAIKU__
#include <fs_interface.h>
#include <fs_info.h>
#include <private/shared/locks.h>
#include <NodeMonitor.h>
#define lock mutex
#define new_lock mutex_init
#define free_lock mutex_destroy
#define LOCK mutex_lock
#define UNLOCK mutex_unlock
typedef dev_t nspace_id;
#endif
#include "lists2.h"
#include <Errors.h>
#include <sys/stat.h>
#include <SupportDefs.h>
#define WEBSEARCHFS_NAME_LEN 70
#define WEBSEARCHFS_NAME "websearchfs"
#define WEBSEARCHFS_PRETTY_NAME "Web Search Bookmark File System"
#define MAX_VNIDS 5000
#ifdef __cplusplus
extern "C" {
#endif
struct attr_entry {
const char *name;
uint32 type;
size_t size;
void *value;
};
#undef ASSERT
#define ASSERT(op) if (!(op)) panic("ASSERT: %s in %s:%s", #op, __FILE__, __FUNCTION__)
struct mount_fs_params
{
};
struct fs_file_cookie;
struct fs_node
{
struct fs_node *nlnext;
struct fs_node *qnext;
struct fs_node *next;
struct fs_node *parent, *children;
struct fs_file_cookie *opened;
char name[WEBSEARCHFS_NAME_LEN];
ino_t vnid;
lock l;
int is_perm:1;
int deleted:1;
int qcompleted:1;
int hidden:1;
struct stat st;
struct duckduckgo_request *request;
struct duckduckgo_result *result;
struct attr_entry *attrs_indirect;
struct attr_entry attrs[10];
void *data;
size_t data_size;
};
struct vnidpool;
struct fs_nspace
{
nspace_id nsid;
ino_t rootid;
struct vnidpool *vnids;
struct fs_node *root;
struct fs_node *nodes;
struct fs_node *queries;
int32 nodecount;
lock l;
};
struct fs_file_cookie
{
struct fs_file_cookie *next;
struct fs_node *node;
int dir_current;
int omode;
int type;
struct attr_entry *attr;
};
#define S_IFQUERY 00000070000
typedef struct attr_entry attr_entry;
typedef struct fs_nspace fs_nspace;
typedef struct fs_node fs_node;
typedef struct fs_file_cookie fs_file_cookie;
#define fs_dir_cookie fs_file_cookie
#define fs_attr_dir_cookie fs_file_cookie
#define fs_query_cookie fs_file_cookie
ino_t new_vnid(fs_nspace *ns);
int websearchfs_event(fs_nspace *ns, fs_node *node, int flags);
extern int websearchfs_push_result_to_query(struct duckduckgo_request *request,
struct duckduckgo_result *result);
#ifdef __cplusplus
}
#endif
#endif