- Timestamp:
- Dec 20, 2003, 1:35:36 PM (20 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:
- 72836b5
- Parents:
- c8735aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
message.c
r25dd31a r5a95b69 34 34 } 35 35 36 /* add the named attribute to the message. If an attribute with the 37 * name already exists, replace the old value with the new value 38 */ 36 39 void owl_message_set_attribute(owl_message *m, char *attrname, char *attrvalue) 37 40 { 38 /* add the named attribute to the message. If an attribute with the39 name already exists, replace the old value with the new value */40 41 41 int i, j; 42 42 owl_pair *p; … … 61 61 } 62 62 63 /* return the value associated with the named attribute, or NULL if 64 * the attribute does not exist 65 */ 63 66 char *owl_message_get_attribute_value(owl_message *m, char *attrname) 64 67 { 65 /* return the value associated with the named attribute, or NULL if66 the attribute does not exist */67 68 int i, j; 68 69 owl_pair *p; … … 362 363 { 363 364 if (m->type==OWL_MESSAGE_TYPE_AIM) return(1); 365 return(0); 366 } 367 368 int owl_message_is_pseudo(owl_message *m) 369 { 370 if (owl_message_get_attribute_value(m, "pseudo")) return(1); 364 371 return(0); 365 372 } … … 707 714 { 708 715 struct hostent *hent; 709 int k ;716 int k, len; 710 717 char *ptr, *tmp, *tmp2; 711 718 … … 721 728 owl_zephyr_hackaway_cr(&(m->notice)); 722 729 723 m->delete=0;724 725 730 /* save the time, we need to nuke the string saved by message_init */ 726 if (m->timestr) { 727 owl_free(m->timestr); 728 } 731 if (m->timestr) owl_free(m->timestr); 729 732 m->time=n->z_time.tv_sec; 730 733 m->timestr=owl_strdup(ctime(&(m->time))); … … 751 754 /* Set the "isloginout" attribute if it's a login message */ 752 755 if (!strcasecmp(n->z_class, "login") || !strcasecmp(n->z_class, OWL_WEBZEPHYR_CLASS)) { 756 if (!strcasecmp(n->z_opcode, "user_login") || !strcasecmp(n->z_opcode, "user_logout")) { 757 ptr=owl_zephyr_get_field(n, 1, &len); 758 tmp=owl_malloc(len+10); 759 strncpy(tmp, ptr, len); 760 tmp[len]='\0'; 761 owl_message_set_attribute(m, "loginhost", tmp); 762 owl_free(tmp); 763 764 ptr=owl_zephyr_get_field(n, 3, &len); 765 tmp=owl_malloc(len+10); 766 strncpy(tmp, ptr, len); 767 tmp[len]='\0'; 768 owl_message_set_attribute(m, "logintty", tmp); 769 owl_free(tmp); 770 } 771 753 772 if (!strcasecmp(n->z_opcode, "user_login")) { 754 773 owl_message_set_islogin(m); … … 758 777 } 759 778 779 760 780 /* is the "isprivate" attribute if it's a private zephyr */ 761 781 if (!strcasecmp(n->z_recipient, owl_zephyr_get_sender())) { … … 810 830 #endif 811 831 832 /* If 'direction' is '0' it is a login message, '1' is a logout message. */ 833 void owl_message_create_pseudo_zlogin(owl_message *m, int direction, char *user, char *host, char *time, char *tty) 834 { 835 char *longuser, *ptr; 836 837 memset(&(m->notice), 0, sizeof(ZNotice_t)); 838 839 longuser=long_zuser(user); 840 841 owl_message_init(m); 842 843 owl_message_set_type_zephyr(m); 844 owl_message_set_direction_in(m); 845 846 owl_message_set_attribute(m, "pseudo", ""); 847 owl_message_set_attribute(m, "loginhost", host ? host : ""); 848 owl_message_set_attribute(m, "logintty", tty ? tty : ""); 849 850 owl_message_set_sender(m, longuser); 851 owl_message_set_class(m, "LOGIN"); 852 owl_message_set_instance(m, longuser); 853 owl_message_set_recipient(m, ""); 854 if (direction==0) { 855 owl_message_set_opcode(m, "USER_LOGIN"); 856 owl_message_set_islogin(m); 857 } else if (direction==1) { 858 owl_message_set_opcode(m, "USER_LOGOUT"); 859 owl_message_set_islogout(m); 860 } 861 862 if ((ptr=strchr(longuser, '@'))!=NULL) { 863 owl_message_set_realm(m, ptr+1); 864 } else { 865 owl_message_set_realm(m, owl_zephyr_get_realm()); 866 } 867 868 m->zwriteline=strdup(""); 869 870 owl_message_set_body(m, "<uninitialized>"); 871 872 /* save the hostname */ 873 owl_function_debugmsg("create_pseudo_login: host is %s", host); 874 strcpy(m->hostname, host ? host : ""); 875 owl_free(longuser); 876 } 877 812 878 void owl_message_create_from_zwriteline(owl_message *m, char *line, char *body, char *zsig) 813 879 {
Note: See TracChangeset
for help on using the changeset viewer.