dav/finfo.c

changeset 519
ac5ac55b1b2e
parent 517
8531b63accae
child 520
da2b0cc44e4f
equal deleted inserted replaced
518:cca3e7aa30ed 519:ac5ac55b1b2e
73 return 1; 73 return 1;
74 } 74 }
75 return resource_set_finfo_s(&s, res, finfo); 75 return resource_set_finfo_s(&s, res, finfo);
76 } 76 }
77 77
78 static int buf_write_date(UcxBuffer *buf, time_t t) {
79 struct tm *date = gmtime(&t);
80 char str[32];
81 size_t len = strftime(str, 32, "%a, %d %b %Y %H:%M:%S GMT", date);
82 return ucx_buffer_write(str, 1, len, buf);
83 }
84
85 int resource_set_finfo_s(struct stat *s, DavResource *res, uint32_t finfo) { 78 int resource_set_finfo_s(struct stat *s, DavResource *res, uint32_t finfo) {
86 if(finfo == 0) { 79 if(finfo == 0) {
87 return 0; 80 return 0;
88 } 81 }
89 82
90 DavXmlNode *content = NULL; 83 DavXmlNode *content = NULL;
84 DavXmlNode *last = NULL;
91 85
92 if(finfo & FINFO_DATE == FINFO_DATE) { 86 if(finfo & FINFO_DATE == FINFO_DATE) {
93 char str[32]; 87 char str[32];
94 struct tm *date = gmtime(&s->st_mtime); 88 struct tm *date = gmtime(&s->st_mtime);
95 strftime(str, 32, "%a, %d %b %Y %H:%M:%S GMT", date); 89 strftime(str, 32, "%a, %d %b %Y %H:%M:%S GMT", date);
96 DavXmlNode *mtime = dav_xml_createnode_with_text(DAV_NS, "mtime", str); 90 DavXmlNode *mtime = dav_xml_createnode_with_text(DAV_NS, "mtime", str);
97 content = mtime; 91 content = mtime;
92 last = mtime;
98 } 93 }
99 #ifndef _WIN32 94 #ifndef _WIN32
100 if(finfo & FINFO_OWNER == FINFO_OWNER) { 95 if(finfo & FINFO_OWNER == FINFO_OWNER) {
101 // TODO 96 // TODO
102 } 97 }
103 if(finfo & FINFO_MODE == FINFO_MODE) { 98 if(finfo & FINFO_MODE == FINFO_MODE) {
104 // TODO 99 mode_t mode = s->st_mode & 07777;
100 char str[32];
101 snprintf(str, 32, "%o", (int)mode);
102 DavXmlNode *xmode = dav_xml_createnode_with_text(DAV_NS, "mode", str);
103 if(last) {
104 last->next = xmode;
105 } else {
106 content = xmode;
107 }
108 last = xmode;
105 } 109 }
106 #endif 110 #endif
107 111
108 112
109 dav_set_property(res, "idav:finfo", content);; 113 dav_set_property(res, "idav:finfo", content);;

mercurial