Changeset 30678ae for perlconfig.c
- Timestamp:
- Jan 29, 2007, 9:54:41 PM (18 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 29ebcea
- Parents:
- a8a3433
- git-author:
- Nelson Elhage <nelhage@mit.edu> (01/29/07 21:54:30)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (01/29/07 21:54:41)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perlconfig.c
r8203afd r30678ae 26 26 } 27 27 28 SV *owl_perlconfig_message2hashref(owl_message *m) /*noproto*/28 SV *owl_perlconfig_message2hashref(owl_message *m) 29 29 { 30 30 HV *h; 31 31 SV *hr; 32 char *ptr, *blessas ;32 char *ptr, *blessas, *type; 33 33 int i, j; 34 34 owl_pair *pair; … … 86 86 hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0); 87 87 88 if (owl_message_is_type_zephyr(m)) blessas = "BarnOwl::Message::Zephyr"; 89 else if (owl_message_is_type_aim(m)) blessas = "BarnOwl::Message::AIM"; 90 else if (owl_message_is_type_jabber(m)) blessas = "BarnOwl::Message::Jabber"; 91 else if (owl_message_is_type_admin(m)) blessas = "BarnOwl::Message::Admin"; 92 else if (owl_message_is_type_generic(m)) blessas = "BarnOwl::Message::Generic"; 93 else blessas = "BarnOwl::Message"; 88 type = owl_message_get_type(m); 89 if(!type) type = "generic"; 90 type = owl_strdup(type); 91 type[0] = toupper(type[0]); 92 blessas = owl_sprintf("BarnOwl::Message::%s", type); 94 93 95 94 hr = sv_2mortal(newRV_noinc((SV*)h)); 96 return sv_bless(hr, gv_stashpv(blessas,0)); 97 } 98 95 hr = sv_bless(hr, gv_stashpv(blessas,0)); 96 owl_free(type); 97 owl_free(blessas); 98 return hr; 99 } 99 100 100 101 SV *owl_perlconfig_curmessage2hashref(void) /*noproto*/ … … 110 111 } 111 112 113 /* XXX TODO: Messages should round-trip properly between 114 message2hashref and hashref2message. Currently we lose 115 zephyr-specific properties stored in the ZNotice_t 116 */ 117 owl_message * owl_perlconfig_hashref2message(SV *msg) 118 { 119 owl_message * m; 120 HE * ent; 121 I32 count, len; 122 char *key,*val; 123 HV * hash; 124 125 hash = (HV*)SvRV(msg); 126 127 m = owl_malloc(sizeof(owl_message)); 128 owl_message_init(m); 129 130 count = hv_iterinit(hash); 131 while((ent = hv_iternext(hash))) { 132 key = hv_iterkey(ent, &len); 133 val = SvPV_nolen(hv_iterval(hash, ent)); 134 if(!strcmp(key, "type")) { 135 owl_message_set_type(m, val); 136 } else if(!strcmp(key, "direction")) { 137 owl_message_set_direction(m, owl_message_parse_direction(val)); 138 } else if(!strcmp(key, "private")) { 139 SV * v = hv_iterval(hash, ent); 140 if(SvTRUE(v)) { 141 owl_message_set_isprivate(m); 142 } 143 } else if (!strcmp(key, "hostname")) { 144 owl_message_set_hostname(m, val); 145 } else if (!strcmp(key, "zwriteline")) { 146 owl_message_set_zwriteline(m, val); 147 } else if (!strcmp(key, "time")) { 148 m->timestr = owl_strdup(val); 149 struct tm tm; 150 strptime(val, "%a %b %d %T %Y", &tm); 151 m->time = mktime(&tm); 152 } else { 153 owl_message_set_attribute(m, key, val); 154 } 155 } 156 if(owl_message_is_type_admin(m)) { 157 if(!owl_message_get_attribute_value(m, "adminheader")) 158 owl_message_set_attribute(m, "adminheader", ""); 159 } 160 return m; 161 } 112 162 113 163 /* Calls in a scalar context, passing it a hash reference.
Note: See TracChangeset
for help on using the changeset viewer.