Mercurial > pidgin.yaz
comparison src/util.c @ 592:7c75d69a1129
[gaim-migrate @ 602]
this really cool guy sent a patch to convert %n, %d and %t to things in
away messages. i just wish i could remember his name.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 03 Aug 2000 05:35:13 +0000 |
parents | 4bf9c74b9e4d |
children | 9b0717b4a490 |
comparison
equal
deleted
inserted
replaced
591:a26eb4c472d8 | 592:7c75d69a1129 |
---|---|
835 } | 835 } |
836 gtk_text_set_point(GTK_TEXT(text), point); | 836 gtk_text_set_point(GTK_TEXT(text), point); |
837 | 837 |
838 } | 838 } |
839 | 839 |
840 /* Look for %n, %d, or %t in msg, and replace with the sender's name, date, | |
841 or time */ | |
842 char *away_subs(char *msg, char *name) | |
843 { | |
844 char *c; | |
845 static char cpy[BUF_LONG]; | |
846 int cnt=0; | |
847 time_t t = time(0); | |
848 struct tm *tme = localtime(&t); | |
849 char tmp[20]; | |
850 | |
851 cpy[0] = '\0'; | |
852 c = msg; | |
853 while(*c) { | |
854 switch(*c) { | |
855 case '%': | |
856 if (*(c+1)) { | |
857 switch (*(c+1)) { | |
858 case 'n': | |
859 // append name | |
860 strcpy (cpy+cnt, name); | |
861 cnt += strlen(name); | |
862 c++; | |
863 break; | |
864 case 'd': | |
865 // append date | |
866 strftime (tmp, 20, "%D", tme); | |
867 strcpy (cpy+cnt, tmp); | |
868 cnt += strlen(tmp); | |
869 c++; | |
870 break; | |
871 case 't': | |
872 // append time | |
873 strftime (tmp, 20, "%r", tme); | |
874 strcpy (cpy+cnt, tmp); | |
875 cnt += strlen(tmp); | |
876 c++; | |
877 break; | |
878 default: | |
879 cpy[cnt++]=*c; | |
880 } | |
881 } | |
882 break; | |
883 default: | |
884 cpy[cnt++]=*c; | |
885 } | |
886 c++; | |
887 } | |
888 cpy[cnt]='\0'; | |
889 return(cpy); | |
890 } |