size_t len;
gchar *buf;
-/* cm_return_val_if_fail(bufptr != NULL, -1); TODO */
+ cm_return_val_if_fail(bufptr != NULL, -1);
len = BUFFSIZE;
buf = g_malloc(len);
- if (buf == NULL) {
- debug_print("generic_get_one_field: primary allocation error\n");
- *bufptr = NULL;
- return -1;
- }
+
if (hentry != NULL) {
/* skip non-required headers */
/* and get hentry header line */
/* read next line */
tmpbuf = g_malloc(BUFFSIZE);
- if (tmpbuf == NULL) {
- debug_print("generic_get_one_field: secondary allocation error\n");
- g_free(buf);
- *bufptr = NULL;
- return -1;
- }
+
if (getline(tmpbuf, BUFFSIZE, data) == NULL) {
g_free(tmpbuf);
break;
headers = g_ptr_array_new();
- while (procheader_get_one_field_asis(&buf, fp) != -1 && buf != NULL) {
+ while (procheader_get_one_field_asis(&buf, fp) != -1) {
if ((header = procheader_parse_header(buf)) != NULL)
g_ptr_array_add(headers, header);
g_free(buf);
if (hentry == NULL) return;
- while ((hnum = procheader_get_one_field(&buf, fp, hentry)) != -1 && buf != NULL) {
+ while ((hnum = procheader_get_one_field(&buf, fp, hentry)) != -1) {
hp = hentry + hnum;
p = buf + strlen(hp->name);
hentry = procheader_get_headernames(full);
if (MSG_IS_QUEUED(flags) || MSG_IS_DRAFT(flags)) {
- while (get_one_field(&buf, data, NULL) != -1 && buf != NULL) {
+ while (get_one_field(&buf, data, NULL) != -1) {
if ((!strncmp(buf, "X-Claws-End-Special-Headers: 1",
strlen("X-Claws-End-Special-Headers:"))) ||
(!strncmp(buf, "X-Sylpheed-End-Special-Headers: 1",
avatar_hook_id = 0;
}
- while ((hnum = get_one_field(&buf, data, hentry)) != -1 && buf != NULL) {
+ while ((hnum = get_one_field(&buf, data, hentry)) != -1) {
hp = buf + strlen(hentry[hnum].name);
while (*hp == ' ' || *hp == '\t') hp++;
*zone = '\0';
- /* RFC3339 subset */
- /* This particular "subset" is invalid, RFC requires the time offset */
+ /* RFC3339 subset, no fraction of second, and no timezone offset */
+ /* This particular "subset" is invalid, RFC requires the offset */
result = sscanf(str, "%4d-%2d-%2d %2d:%2d:%2d",
year, &month_n, day, hh, mm, ss);
if (result == 6) {
}
}
+ /* ISO8601 format with just date (YYYY-MM-DD) */
+ result = sscanf(str, "%4d-%2d-%2d",
+ year, &month_n, day);
+ if (result == 3) {
+ *hh = *mm = *ss = 0;
+ if (1 <= month_n && month_n <= 12) {
+ strncpy2(month, monthstr+((month_n-1)*3), 4);
+ return 0;
+ }
+ }
+
return -1;
}
#ifdef G_OS_WIN32
GTimeZone *tz;
- GDateTime *dt;
-
- tz = g_time_zone_new(zone);
- dt = g_date_time_new(tz, year, dmonth, day, hh, mm, ss);
+ GDateTime *dt, *dt2;
- timer = g_date_time_to_unix(dt);
-
- g_date_time_unref(dt);
+ tz = g_time_zone_new(zone); // can't return NULL no need to check for it
+ dt = g_date_time_new(tz, 1, 1, 1, 0, 0, 0);
g_time_zone_unref(tz);
+ dt2 = g_date_time_add_full(dt, year-1, dmonth-1, day-1, hh, mm, ss);
+ g_date_time_unref(dt);
+
+ timer = g_date_time_to_unix(dt2);
+ g_date_time_unref(dt2);
#else
struct tm t;
return -1;
}
val = procheader_get_one_field(buf, fp, hentry);
- if (buf == NULL) {
- claws_unlink(file);
- g_free(file);
- g_free(*buf);
- *buf = NULL;
- return -1;
- }
+
if (fclose(fp) == EOF) {
FILE_OP_ERROR(file, "fclose");
claws_unlink(file);