- Timestamp:
- Oct 26, 2003, 2:43:40 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 70b53ec
- Parents:
- eec69e1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
message.c
reec69e1 r25dd31a 15 15 void owl_message_init(owl_message *m) 16 16 { 17 time_t t;18 19 17 m->id=owl_global_get_nextmsgid(&g); 20 18 m->type=OWL_MESSAGE_TYPE_GENERIC; … … 28 26 29 27 /* save the time */ 30 t=time(NULL); 31 m->time=owl_strdup(ctime(&t)); 32 m->time[strlen(m->time)-1]='\0'; 28 m->time=time(NULL); 29 m->timestr=owl_strdup(ctime(&(m->time))); 30 m->timestr[strlen(m->timestr)-1]='\0'; 31 32 /* initialize the fmtext */ 33 33 owl_fmtext_init_null(&(m->fmtext)); 34 34 } … … 305 305 char *owl_message_get_timestr(owl_message *m) 306 306 { 307 return(m->time); 307 if (m->timestr) return(m->timestr); 308 return(""); 309 } 310 311 /* caller must free the return */ 312 char *owl_message_get_shorttimestr(owl_message *m) 313 { 314 struct tm *tmstruct; 315 char *out; 316 317 tmstruct=localtime(&(m->time)); 318 out=owl_sprintf("%2.2i:%2.2i", tmstruct->tm_hour, tmstruct->tm_min); 319 if (out) return(out); 320 return("??:??"); 308 321 } 309 322 … … 705 718 memcpy(&(m->notice), n, sizeof(ZNotice_t)); 706 719 707 /* a little gross, we'll re aplace \r's with ' ' for now */720 /* a little gross, we'll replace \r's with ' ' for now */ 708 721 owl_zephyr_hackaway_cr(&(m->notice)); 709 722 710 723 m->delete=0; 724 725 /* save the time, we need to nuke the string saved by message_init */ 726 if (m->timestr) { 727 owl_free(m->timestr); 728 } 729 m->time=n->z_time.tv_sec; 730 m->timestr=owl_strdup(ctime(&(m->time))); 731 m->timestr[strlen(m->timestr)-1]='\0'; 711 732 712 733 /* set other info */ … … 782 803 strcpy(m->hostname, inet_ntoa(n->z_sender_addr)); 783 804 } 784 785 /* save the time */786 m->time=owl_strdup(ctime((time_t *) &n->z_time.tv_sec));787 m->time[strlen(m->time)-1]='\0';788 805 } 789 806 #else … … 847 864 } 848 865 #endif 849 if (m->time ) owl_free(m->time);866 if (m->timestr) owl_free(m->timestr); 850 867 if (m->zwriteline) owl_free(m->zwriteline); 851 868
Note: See TracChangeset
for help on using the changeset viewer.