Changes in perlconfig.c [5b37c063:3ea31b6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perlconfig.c
r5b37c063 r3ea31b6 44 44 h = newHV(); 45 45 46 #define MSG2H(h,field) hv_store(h, #field, strlen(#field),\47 46 #define MSG2H(h,field) (void)hv_store(h, #field, strlen(#field), \ 47 newSVpv(owl_message_get_##field(m),0), 0) 48 48 49 49 if (owl_message_is_type_zephyr(m) … … 59 59 owl_free(ptr); 60 60 } 61 hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);62 63 hv_store(h, "auth", strlen("auth"),64 61 (void)hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0); 62 63 (void)hv_store(h, "auth", strlen("auth"), 64 newSVpv(owl_zephyr_get_authstr(owl_message_get_notice(m)),0),0); 65 65 } 66 66 … … 68 68 for(i=0; i<j; i++) { 69 69 pair=owl_list_get_element(&(m->attributes), i); 70 hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),71 70 (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)), 71 newSVpv(owl_pair_get_value(pair),0),0); 72 72 } 73 73 … … 88 88 MSG2H(h, header); 89 89 } 90 hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0);91 hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0);92 hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0);93 hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0);94 hv_store(h, "should_wordwrap",95 96 90 (void)hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0); 91 (void)hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0); 92 (void)hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0); 93 (void)hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0); 94 (void)hv_store(h, "should_wordwrap", 95 strlen("should_wordwrap"), newSViv( 96 owl_filter_message_match(wrap, m)),0); 97 97 98 98 type = owl_message_get_type(m); … … 102 102 blessas = owl_sprintf("BarnOwl::Message::%s", type); 103 103 104 hr = sv_2mortal(newRV_noinc((SV*)h));104 hr = newRV_noinc((SV*)h); 105 105 stash = gv_stashpv(blessas,0); 106 106 if(!stash) { … … 182 182 dSP ; 183 183 int count; 184 unsigned int len;185 184 SV *msgref, *srv; 186 char *out , *preout;185 char *out; 187 186 188 187 ENTER ; … … 191 190 PUSHMARK(SP) ; 192 191 msgref = owl_perlconfig_message2hashref(m); 193 XPUSHs( msgref);192 XPUSHs(sv_2mortal(msgref)); 194 193 PUTBACK ; 195 194 … … 199 198 200 199 if (SvTRUE(ERRSV)) { 201 STRLEN n_a; 202 owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a)); 200 owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV)); 203 201 /* and clear the error */ 204 202 sv_setsv (ERRSV, &PL_sv_undef); … … 213 211 214 212 if (srv) { 215 preout=SvPV(srv, len); 216 out = owl_malloc(strlen(preout)+1); 217 strncpy(out, preout, len); 218 out[len] = '\0'; 213 out = owl_strdup(SvPV_nolen(srv)); 219 214 } else { 220 215 out = NULL; … … 235 230 { 236 231 dSP; 237 unsigned int count, len,i;232 unsigned int count, i; 238 233 SV *msgref, *srv; 239 char *out , *preout;234 char *out; 240 235 241 236 msgref = owl_perlconfig_message2hashref(m); … … 245 240 246 241 PUSHMARK(SP); 247 XPUSHs( msgref);242 XPUSHs(sv_2mortal(msgref)); 248 243 for(i=0;i<argc;i++) { 249 244 XPUSHs(sv_2mortal(newSVpv(argv[i], 0))); … … 261 256 262 257 if (SvTRUE(ERRSV)) { 263 STRLEN n_a; 264 owl_function_error("Error: '%s'", SvPV(ERRSV, n_a)); 258 owl_function_error("Error: '%s'", SvPV_nolen(ERRSV)); 265 259 /* and clear the error */ 266 260 sv_setsv (ERRSV, &PL_sv_undef); … … 270 264 271 265 if (srv) { 272 preout=SvPV(srv, len); 273 out = owl_malloc(strlen(preout)+1); 274 strncpy(out, preout, len); 275 out[len] = '\0'; 266 out = owl_strdup(SvPV_nolen(srv)); 276 267 } else { 277 268 out = NULL; … … 286 277 287 278 288 char *owl_perlconfig_initperl(char * file , int *Pargc, char ***Pargv, char *** Penv)279 char *owl_perlconfig_initperl(char * file) 289 280 { 290 281 int ret; … … 294 285 295 286 /* create and initialize interpreter */ 296 PERL_SYS_INIT3(Pargc, Pargv, Penv);297 287 p=perl_alloc(); 298 288 owl_global_set_perlinterp(&g, (void*)p); … … 304 294 ret=perl_parse(p, owl_perl_xs_init, 2, args, NULL); 305 295 if (ret || SvTRUE(ERRSV)) { 306 STRLEN n_a; 307 err=owl_strdup(SvPV(ERRSV, n_a)); 296 err=owl_strdup(SvPV_nolen(ERRSV)); 308 297 sv_setsv(ERRSV, &PL_sv_undef); /* and clear the error */ 309 298 return(err); … … 312 301 ret=perl_run(p); 313 302 if (ret || SvTRUE(ERRSV)) { 314 STRLEN n_a; 315 err=owl_strdup(SvPV(ERRSV, n_a)); 303 err=owl_strdup(SvPV_nolen(ERRSV)); 316 304 sv_setsv(ERRSV, &PL_sv_undef); /* and clear the error */ 317 305 return(err); … … 342 330 343 331 if (SvTRUE(ERRSV)) { 344 STRLEN n_a; 345 err=owl_strdup(SvPV(ERRSV, n_a)); 332 err=owl_strdup(SvPV_nolen(ERRSV)); 346 333 sv_setsv (ERRSV, &PL_sv_undef); /* and clear the error */ 347 334 return(err); … … 396 383 397 384 if (SvTRUE(ERRSV)) { 398 STRLEN n_a; 399 owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a)); 385 owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV)); 400 386 sv_setsv (ERRSV, &PL_sv_undef); /* and clear the error */ 401 387 } 402 388 403 389 preout=SvPV(response, len); 404 /* leave enough space in case we have to add a newline */ 405 out = owl_malloc(strlen(preout)+2); 406 strncpy(out, preout, len); 407 out[len] = '\0'; 408 if (!strlen(out) || out[strlen(out)-1]!='\n') { 409 strcat(out, "\n"); 410 } 390 if (len == 0 || preout[len - 1] != '\n') 391 out = owl_sprintf("%s\n", preout); 392 else 393 out = owl_strdup(preout); 411 394 412 395 return(out); … … 439 422 char * ret = NULL; 440 423 SV *rv; 441 STRLEN n_a;442 424 dSP; 443 425 … … 458 440 459 441 if(SvTRUE(ERRSV)) { 460 owl_function_error("%s", SvPV (ERRSV, n_a));442 owl_function_error("%s", SvPV_nolen(ERRSV)); 461 443 (void)POPs; 462 444 } else { … … 465 447 rv = POPs; 466 448 if(SvTRUE(rv)) { 467 ret = owl_strdup(SvPV (rv, n_a));449 ret = owl_strdup(SvPV_nolen(rv)); 468 450 } 469 451 } … … 489 471 SV *cb = (SV*)(e->cbdata); 490 472 SV *text; 491 unsigned int n_a;492 473 dSP; 493 474 … … 508 489 509 490 if(SvTRUE(ERRSV)) { 510 owl_function_error("%s", SvPV (ERRSV, n_a));491 owl_function_error("%s", SvPV_nolen(ERRSV)); 511 492 } 512 493 … … 526 507 call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL); 527 508 if(SvTRUE(ERRSV)) { 528 STRLEN n_a; 529 owl_function_error("%s", SvPV(ERRSV, n_a)); 509 owl_function_error("%s", SvPV_nolen(ERRSV)); 530 510 } 531 511 return; … … 535 515 { 536 516 SV *cb = d->pfunc; 537 unsigned int n_a;538 517 dSP; 539 518 if(cb == NULL) { … … 550 529 551 530 if(SvTRUE(ERRSV)) { 552 owl_function_error("%s", SvPV (ERRSV, n_a));531 owl_function_error("%s", SvPV_nolen(ERRSV)); 553 532 } 554 533
Note: See TracChangeset
for help on using the changeset viewer.