Checkpointing, working on N-ary tree traversal code
Somewhat uncertain how I want to lay out the tree in main() Signed-off-by: R. Tyler Ballance <tyler@monkeypox.org>
This commit is contained in:
parent
31b2869db1
commit
cc1be35f7f
26
imuse.c
26
imuse.c
|
@ -16,31 +16,11 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "imapper.h"
|
||||
#include "muse_tree.h"
|
||||
|
||||
static GHashTable *__special_directories = NULL;
|
||||
static GHashTable *_accounts = NULL;
|
||||
|
||||
struct stat *default_stat_entry(struct stat *stat_defaults)
|
||||
{
|
||||
if (stat_defaults)
|
||||
memset(stat_defaults, 0, sizeof(struct stat));
|
||||
else
|
||||
stat_defaults = malloc(sizeof(struct stat));
|
||||
stat_defaults->st_mode = 0;
|
||||
stat_defaults->st_ino = 0;
|
||||
stat_defaults->st_dev = 0;
|
||||
stat_defaults->st_nlink = 0;
|
||||
stat_defaults->st_uid = getuid();
|
||||
stat_defaults->st_gid = getgid();
|
||||
stat_defaults->st_size = 0;
|
||||
stat_defaults->st_atime = time(NULL);
|
||||
stat_defaults->st_mtime = time(NULL);
|
||||
stat_defaults->st_ctime = time(NULL);
|
||||
|
||||
return stat_defaults;
|
||||
}
|
||||
|
||||
static int glist_data_compare(GList *a, GList *b)
|
||||
{
|
||||
if (a->data == b->data)
|
||||
|
@ -51,11 +31,11 @@ static int glist_data_compare(GList *a, GList *b)
|
|||
static int imuse_getattr(const char *path, struct stat *stbuf)
|
||||
{
|
||||
int res = 0;
|
||||
stbuf = default_stat_entry(stbuf);
|
||||
stbuf = default_stat(stbuf);
|
||||
|
||||
if (strcmp(path, "/") == 0) {
|
||||
stbuf->st_mode = S_IFDIR | 0755;
|
||||
stbuf->st_nlink = 2;
|
||||
stbuf->st_nlink = 1;
|
||||
} else {
|
||||
++path;
|
||||
GList *rc = g_list_find_custom(g_hash_table_get_keys(__special_directories), path, (GCompareFunc)(glist_data_compare));
|
||||
|
|
37
muse_tree.c
37
muse_tree.c
|
@ -28,7 +28,44 @@
|
|||
* and special_open())
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "muse_tree.h"
|
||||
|
||||
|
||||
int muse_tree_attrs_by_path(const char *path, struct stat *s) {
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
|
||||
struct stat *default_stat(struct stat *s) {
|
||||
if (s == NULL)
|
||||
s = (struct stat *)(malloc(sizeof(struct stat)));
|
||||
|
||||
memset(s, 0, sizeof(struct stat));
|
||||
|
||||
s->st_mode = 0;
|
||||
s->st_ino = 0;
|
||||
s->st_dev = 0;
|
||||
s->st_nlink = 0;
|
||||
s->st_uid = getuid();
|
||||
s->st_gid = getgid();
|
||||
s->st_size = 0;
|
||||
s->st_atime = time(NULL);
|
||||
s->st_mtime = time(NULL);
|
||||
s->st_ctime = time(NULL);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
|
25
muse_tree.h
25
muse_tree.h
|
@ -7,4 +7,29 @@
|
|||
#ifndef __MUSE_TREE_H
|
||||
#define __MUSE_TREE_H
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define NODE_TYPE_EMAIL 1334
|
||||
#define NODE_TYPE_DIR 1335
|
||||
#define NODE_TYPE_FILE 1336
|
||||
#define NODE_TYPE_SPECIAL 1337
|
||||
|
||||
struct muse_tree_node {
|
||||
unsigned int type;
|
||||
char *display_name;
|
||||
struct stat *st;
|
||||
void *node_data;
|
||||
};
|
||||
|
||||
struct muse_tree_email_node;
|
||||
struct muse_tree_dir_node;
|
||||
struct must_tree_file_node;
|
||||
struct muse_tree_special_node;
|
||||
|
||||
extern struct stat *default_stat(struct stat *);
|
||||
extern int muse_tree_attrs_by_path(const char *, struct stat *);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue