CS360 Midterm -- October 18, 1999. Cheat Sheet

Stat

Here are relevant fields for the stat struct:

struct stat {
  int    st_size;
  int    st_ino;
  int    st_mode;
  int    st_nlink;
  time_t st_atime;
  time_t st_mtime;
  ...
}

S_ISDIR(int) -- returns whether or not the given mode is a directory.

int stat(char *name, struct stat *buf);   /* Returns 0 if ok */

Opendir

Here are relevant fields for the dirent struct:

struct dirent {
  char   d_name[256];
...
}

DIR *opendir(char *name);          /* Returns NULL on an error */
int closedir(DIR *d);
struct dirent *readdir(DIR *d);    /* Returns NULL when there are no more
                                      directory listings */

Red-black Trees

typedef struct jrb_tree {
  struct jrb_tree *flink;
  struct jrb_tree *blink;
  Jval key;
  Jval val;
  ...
}

#define jrb_traverse(node, tree) \
    for (node = tree->flink; node != tree; node = node->flink)

Jvals

typedef union {
  int i;
  char *s;
  void *v;
  double d;
  ....
} Jval;