MODULE rebuild_time_slots_if_new_day (THREAD *thread) { SPEC *spec; /* Spec in list */ tcb = thread-> tcb; /* Point to thread's context */ if (tcb-> today != date_now ()) { tcb-> today = date_now (); day_range_empty (tcb-> range); /* All slots in day are cleared */ for (spec = tcb-> specs.next; spec != (SPEC *) &tcb-> specs; spec = spec-> next) parse_slot_specifier (thread, spec); } }
MODULE define_standard_values (void) { xml_put_attr (xml_switches, "date", conv_date_pict (date_now (), "yyyy/mm/dd")); xml_put_attr (xml_switches, "time", conv_time_pict (time_now (), "h:mm:ss")); xml_put_attr (xml_switches, "version", VERSION); xml_put_attr (xml_switches, "me", me); xml_put_attr (xml_switches, "shuffle", "1"); xml_put_attr (xml_switches, "ignorecase", "1"); }
MODULE write_body_header (THREAD *thread) { tcb = thread-> tcb; /* Point to thread's context */ smtp_msg = tcb-> message; /* only for readability */ *strout = '\0'; /* clears out buffer */ /* Set the date and time of the message. */ xstrcat ( strout, "Date: ", encode_mime_time (date_now (), time_now ()), " \r\n", NULL); replacechrswith (smtp_msg-> dest_uids, ";", ','); xstrcat (strout, "To: ", smtp_msg-> dest_uids, "\r\n", NULL); if ( strstr( smtp_msg-> sender_uid, "<" ) != NULL && strstr( smtp_msg-> sender_uid, ">" ) != NULL ) xstrcat (strout, "Reply-To:", smtp_msg-> sender_uid, "\r\n", NULL); else xstrcat (strout, "Reply-To:<", smtp_msg-> sender_uid, ">\r\n", NULL); xstrcat (strout, "Sender:", smtp_msg-> sender_uid, "\r\n", NULL); xstrcat (strout, "From:", smtp_msg-> sender_uid, "\r\n", NULL); xstrcat (strout, "X-Mailer: sflmail function\r\n", NULL); /* Set the mime version. */ xstrcat (strout, "MIME-Version: 1.0\r\n", "Content-Type: Multipart/Mixed; boundary=\"", tcb-> message_boundary, "\"\r\n", NULL); /* Send the subject and message body. */ ASSERT (smtp_msg-> subject != NULL); /* XXX I'm not too sure */ xstrcat (strout, "Subject:", smtp_msg-> subject, "\r\n\r\n", NULL); /* Send the plain text body header */ xstrcat (strout, tcb-> plain_text_body_header, NULL); send_smtsock_write( &sockq, 0, /* Timeout in seconds, zero = none */ tcb-> sock_handle, /* Socket to write to */ (word) strlen (strout), /* Amount of data to write */ strout, /* Block of data to write */ FALSE, /* Whether to always reply */ (void *) SOCK_TAG_WRITE); /* User-defined request tag */ TRACE_SMTP (strout); }
static char *generate_body (word length) { char *body = NULL; dword size, idx; static char now_str[BUF_SIZE]; static char date_str[BUF_SIZE]; int rc; randomize (); ASSERT (length > 100); /* precondition */ body = mem_alloc (length+1); rc = snprintf (now_str, BUF_SIZE, "%s", conv_time_pict (time_now(), "hh:mm")); ASSERT (rc > 0); rc = snprintf (date_str, BUF_SIZE, "%s", conv_date_pict (date_now(), "yymmdd")); ASSERT (rc > 0); rc = snprintf (body, length, "automatic body generated %s-%s\n",date_str, now_str); ASSERT (rc > 0); size = strlen (body); coprintf ("Size [%i] - Length [%i]", size, length); for (idx=size; idx<length; idx++) body[idx] = 'A' + random(26); coprintf ("idx : %i", idx); body[idx] = 0; return body; }
int main (int argc, char *argv []) { long date, time; date = date_now (); time = time_now (); printf ("Date=%ld time=%ld\n", date, time); date = days_to_date (date_to_days (date)); time = csecs_to_time (time_to_csecs (time)); printf ("Date=%ld time=%ld\n", date, time); date = date_now (); time = time_now (); date = days_to_date (date_to_days (date)); time = csecs_to_time (time_to_csecs (time)); future_date (&date, &time, 0, INTERVAL_HOUR); printf ("Date in one hour = %ld, %ld\n", date, time); date = date_now (); time = time_now (); future_date (&date, &time, 0, INTERVAL_DAY); printf ("Date in one day = %ld, %ld\n", date, time); date = date_now (); time = time_now (); future_date (&date, &time, 1, 0); printf ("Date in one day = %ld, %ld\n", date, time); date = date_now (); time = time_now (); future_date (&date, &time, 7, 0); printf ("Date in one week = %ld, %ld\n", date, time); date = date_now (); time = time_now (); future_date (&date, &time, 365, 0); printf ("Date in one year = %ld, %ld\n", date, time); return (EXIT_SUCCESS); }
static void parse_get_date(void) { uart_puts_P("+ "); date_print(date_now()); uart_puts(NEWLINE); }