cList *statbuf_to_list(struct stat * sbuf) { cList *list; cData *d; char buf[LINE]; register Int x; list = list_new(5); d = list_empty_spaces(list, 5); for (x = 1; x < 5; x++) d[x].type = INTEGER; if (sizeof(sbuf->st_mode) == sizeof(long)) { sprintf(buf, "%lo", (long unsigned int) (sbuf->st_mode)); } else { sprintf(buf, "%o", sbuf->st_mode); } d[0].type = STRING; d[0].u.str = string_from_chars(buf, strlen(buf)); d[1].u.val = (Int) sbuf->st_size; d[2].u.val = (Int) sbuf->st_atime; d[3].u.val = (Int) sbuf->st_mtime; d[4].u.val = (Int) sbuf->st_ctime; return list; }
static cList *unpack_list(cBuf *buf, Long *buf_pos) { Int len, i; cList *list; cData *d; len = read_long(buf, buf_pos); if (len == -1) { list = NULL; } else { list = list_new(len); d = list_empty_spaces(list, len); for (i = 0; i < len; i++) unpack_data(buf, buf_pos, d++); } return list; }