int main(void) { time_t current; struct tm *timer; time(¤t); timer = localtime(¤t); printf("current time is"); put_date(timer); printf(" is it. \n"); return(0); }
static AVP_dword DATA_PARAM WritePropertyItem( Serialize* sz, AVP_byte type, void* val ) { AVP_dword size = 0; AVP_dword psize; AVP_word wsize; AVP_byte tmpbyte; switch( type ) { case avpt_nothing : return sizeof(AVP_Property); // Byte-sized types case avpt_char : case avpt_byte : case avpt_group : size = put_byte( sz, (AVP_byte*)val ); break; case avpt_bool : tmpbyte = *((AVP_bool*)val) ? 1 : 0; size = put_byte(sz, &tmpbyte); break; // Word-sized types case avpt_wchar : case avpt_short : case avpt_word : size = put_word( sz, (AVP_word *)val ); break; // Dword-sized types case avpt_long : case avpt_dword : case avpt_int : case avpt_uint : size = put_dword( sz, (AVP_dword *)val ); break; // QWord-sized types case avpt_qword : case avpt_longlong: size = put_qword( sz, (AVP_qword*)val ); break; // size_t-sized types case avpt_size_t : size = put_size_t( sz, (AVP_size_t*)val ); break; // Custom structures case avpt_date : size = put_date(sz, (AVP_date *)val); break; case avpt_time : size = put_time(sz, (AVP_time *)val); break; case avpt_datetime: size = put_datetime(sz, (AVP_datetime *)val); break; // String case avpt_str : if ( *((AVP_char**)val) ) { psize = (AVP_dword)strlen( *((AVP_char**)val) ); wsize = (AVP_word)psize; if ( psize >= USHRT_MAX ) { _RPT0( _CRT_ASSERT, "String is too long" ); return 0; } if ( sizeof(AVP_word) == put_word (sz, &wsize) && psize == put_bytes(sz,*((AVP_char**)val),psize) ) size += sizeof(AVP_word) + psize; else size = 0; } else { AVP_word dummy = USHRT_MAX; if ( sizeof(AVP_word) == put_word (sz, &dummy) ) size += sizeof(AVP_word); else size = 0; } break; // Windows unicode string case avpt_wstr : size = put_wchar_string(sz,*((wchar_t**) val)); break; case avpt_bin : if ( ((AVP_Bin_Item *)val)->size > USHRT_MAX ) { _RPT0( _CRT_ASSERT, "Binary property is too large" ); return 0; } wsize = (AVP_word)((AVP_Bin_Item *)val)->size; if ( sizeof(AVP_word) == put_word (sz, &wsize ) && ((AVP_Bin_Item *)val)->size == put_bytes( sz, ((AVP_Bin_Item *)val)->data, ((AVP_Bin_Item *)val)->size ) ) size = sizeof(AVP_word) + ((AVP_Bin_Item *)val)->size; else size = 0; break; default : _RPT0( _CRT_ASSERT, "Bad property type" ); return 0; } return size ? size + sizeof(AVP_Property) : 0; }