_PUBLIC_ void mapidump_freebusy_event(struct Binary_r *bin, uint32_t month, uint32_t year, const char *sep) { uint16_t event_start; uint16_t event_end; uint32_t i; uint32_t hour; uint32_t hours; uint32_t day; const char *month_name; uint32_t last; uint32_t minutes = 0; if (!bin) return; /* bin.cb must be a multiple of 4 */ if (bin->cb % 4) return; year = mapidump_freebusy_year(month, year); month_name = mapidump_freebusy_month(month, year); if (!month_name) return; for (i = 0; i < bin->cb; i+= 4) { event_start = (bin->lpb[i + 1] << 8) | bin->lpb[i]; event_end = (bin->lpb[i + 3] << 8) | bin->lpb[i + 2]; for (hour = 0; hour < 24; hour++) { if (!(((event_start - (60 * hour)) % 1440) && (((event_start - (60 * hour)) % 1440) - 30))) { day = ((event_start - (60 * hour)) / 1440) + 1; minutes = (event_start - (60 * hour)) % 1440; last = event_end - event_start; #if defined (__FreeBSD__) OC_DEBUG(0, "%s %u %s %u at %.2u%.2u hrs and lasts ", sep ? sep : "", day, month_name, year, hour, minutes); #else OC_DEBUG(0, "%s %u %s %u at %.2u%.2u hrs and lasts ", sep ? sep : "", day, month_name, year, hour + daylight, minutes); #endif if (last < 60) { OC_DEBUG(0, "%u mins", last); } else { hours = last / 60; minutes = last - hours * 60; if (minutes > 0) { OC_DEBUG(0, "%u hrs %u mins", hours, minutes); } else { OC_DEBUG(0, "%u hrs", hours); } } } } } }
/** \details Test dump of a free/busy event This function: -# builds a freebusy binary event -# tests dumping it using mapidump_freebusy_event() -# modifies the event, and dumps it again -# modifies the event, and dumps it again -# tests dumping a date using mapidump_freebusy_date() -# tests each months for mapidump_freebusy_month() \param mt pointer to the top-level mapitest structure \return true on success, otherwise false \note This currently doesn't check the results are sane, so manual inspection is required */ _PUBLIC_ bool mapitest_mapidump_freebusy(struct mapitest *mt) { struct Binary_r bin; bin.cb = 4; bin.lpb = talloc_array(mt->mem_ctx, uint8_t, bin.cb); /* this example from MS-OXOPFFB Section 4.4.3 */ bin.lpb[0] = 0x50; bin.lpb[1] = 0x0A; bin.lpb[2] = 0xC8; bin.lpb[3] = 0x0A; mapidump_freebusy_event(&bin, 2009*16+11, 2008, "[sep]"); /* this example adapted from MS-OXOPFFB Section 4.4.3 */ bin.lpb[0] = 0x50; bin.lpb[1] = 0x0A; bin.lpb[2] = 0xCA; bin.lpb[3] = 0x0A; mapidump_freebusy_event(&bin, 2009*16+11, 2009, "[sep]"); /* this example adapted from MS-OXOPFFB Section 4.4.3 */ bin.lpb[0] = 0x50; bin.lpb[1] = 0x0A; bin.lpb[2] = 0x80; bin.lpb[3] = 0x0A; mapidump_freebusy_event(&bin, 2009*16+11, 2009, "[sep]"); mapidump_freebusy_date(0x0CD18345, "[sep]"); if (strcmp("January", mapidump_freebusy_month(2009*16+1, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result January\n", "mapidump_freebusy"); return false; } if (strcmp("February", mapidump_freebusy_month(2009*16+2, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result February\n", "mapidump_freebusy"); return false; } if (strcmp("March", mapidump_freebusy_month(2009*16+3, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result March\n", "mapidump_freebusy"); return false; } if (strcmp("April", mapidump_freebusy_month(2009*16+4, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result April\n", "mapidump_freebusy"); return false; } if (strcmp("May", mapidump_freebusy_month(2009*16+5, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result May\n", "mapidump_freebusy"); return false; } if (strcmp("June", mapidump_freebusy_month(2009*16+6, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result June\n", "mapidump_freebusy"); return false; } if (strcmp("July", mapidump_freebusy_month(2009*16+7, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result July\n", "mapidump_freebusy"); return false; } if (strcmp("August", mapidump_freebusy_month(2009*16+8, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result August\n", "mapidump_freebusy"); return false; } if (strcmp("September", mapidump_freebusy_month(2009*16+9, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result September\n", "mapidump_freebusy"); return false; } if (strcmp("October", mapidump_freebusy_month(2009*16+10, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result October\n", "mapidump_freebusy"); return false; } if (strcmp("November", mapidump_freebusy_month(2009*16+11, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result November\n", "mapidump_freebusy"); return false; } if (strcmp("December", mapidump_freebusy_month(2009*16+12, 2009)) != 0) { mapitest_print(mt, "* %-40s: bad result December\n", "mapidump_freebusy"); return false; } if (mapidump_freebusy_month(2009*16+0, 2009) != 0) { mapitest_print(mt, "* %-40s: bad result underrange\n", "mapidump_freebusy"); return false; } if (mapidump_freebusy_month(2009*16+13, 2009) != 0) { mapitest_print(mt, "* %-40s: bad result overrange\n", "mapidump_freebusy"); return false; } return true; }