Changeset e1c4636
- Timestamp:
- Jul 9, 2002, 12:04:35 AM (22 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:
- 2c8a07c
- Parents:
- 10b866d
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r10b866d re1c4636 34 34 of a zephyr being composed: C-c it and restart it 35 35 and then M-p to get the aborted composition back. 36 Added owl::send_zwrite(command, message) to the perl glue 37 to allow for the direct sending of multi-line messages. 38 For example: owl::send_zwrite("-c foo -i bar", "hello"); 39 Reverted attempted fix for the pagedown problem 40 which just made things worse. 41 Changed owl_fmtext_print_plain to return an alloc'd string to 42 avoid buffer overrun risks. 43 Added owl::ztext_stylestrip("...") function to perlglue 44 which returns the ztext with formatting stripped out. 45 Added colorztext variable which can be used to disable @color() 46 strings arriving in messages after it is set. 47 (Currently, changing its value won't reformat messages). 48 Outgoing zephyr logging now obeys the logpath variable. 49 The '~' character in logpath and classlogpath now gets 50 replaced with the user's home directory. 36 51 37 52 1.2.1-pre-1 … … 84 99 color messages matching the current one green. 85 100 86 1.2.0-pre- erikdevel-17101 1.2.0-pre-1 87 102 Integrated change to fix problem with popup blinking on new zephyrs. 88 103 C-l and resizes will now refresh an open viewwin (eg, help). … … 94 109 and to not mess up spaces. exec also returns a string 95 110 of the output now. 96 97 1.2.0-pre-erikdevel-1698 111 Integrated changes from 1.1.3, and added docs for "zlocate -d" 99 112 and new show commands. … … 101 114 Fix a bug in readconfig caught by efence (where we'd try to read before 102 115 the beginning of a string if it was empty). 103 104 1.1.2-erikdevel-15105 116 The perl command doesn't do makemsg directly, but instead 106 117 returns the string and it will get printed if it 107 118 was run interactively. 108 109 1.1.2-erikdevel-14110 *** NOTE: I probably missed some things here...111 119 New framework for command handling. 112 120 New framework for keymap handling. -
fmtext.c
r1aee7d9 re1c4636 180 180 /* if it's a color read the color, set the current color and 181 181 continue */ 182 } else if (!strcasecmp(buff, "@color") && owl_global_get_hascolors(&g)) { 182 } else if (!strcasecmp(buff, "@color") 183 && owl_global_get_hascolors(&g) 184 && owl_global_is_colorztext(&g)) { 183 185 owl_free(buff); 184 186 txtptr+=7; … … 325 327 326 328 327 void owl_fmtext_print_plain(owl_fmtext *f, char *buff) { 328 strcpy(buff, f->textbuff); 329 /* caller is responsible for freeing */ 330 char *owl_fmtext_print_plain(owl_fmtext *f) { 331 return owl_strdup(f->textbuff); 332 } 333 334 /* strips formatting from ztext and returns the unformatted text. 335 * caller is responsible for freeing. */ 336 char *owl_fmtext_ztext_stylestrip(char *zt) { 337 owl_fmtext fm; 338 char *plaintext; 339 340 owl_fmtext_init_null(&fm); 341 owl_fmtext_append_ztext(&fm, zt); 342 plaintext = owl_fmtext_print_plain(&fm); 343 owl_fmtext_free(&fm); 344 return(plaintext); 329 345 } 330 346 -
global.c
r10b866d re1c4636 18 18 struct hostent *hent; 19 19 char hostname[MAXHOSTNAMELEN]; 20 char buff[MAXPATHLEN];21 20 22 21 gethostname(hostname, MAXHOSTNAMELEN); … … 78 77 /* TODO: come back later and check passwd file first */ 79 78 strcpy(g->homedir, getenv("HOME")); 80 sprintf(buff, "%s/zlog/people/", owl_global_get_homedir(g));81 owl_global_set_logpath(g, buff);82 sprintf(buff, "%s/zlog/class/", owl_global_get_homedir(g));83 owl_global_set_classlogpath(g, buff);84 85 79 86 80 owl_messagelist_create(&(g->msglist)); -
logging.c
r1aee7d9 re1c4636 9 9 void owl_log_outgoing(char *to, char *text) { 10 10 FILE *file; 11 char filename[MAXPATHLEN] ;11 char filename[MAXPATHLEN], *logpath; 12 12 char *tobuff, *ptr; 13 13 … … 21 21 } 22 22 23 sprintf(filename, "%s/zlog/people/%s", owl_global_get_homedir(&g), tobuff); 23 /* expand ~ in path names */ 24 logpath = owl_util_substitute(owl_global_get_logpath(&g), "~", 25 owl_global_get_homedir(&g)); 26 27 snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff); 24 28 file=fopen(filename, "a"); 25 29 if (!file) { 26 30 owl_function_makemsg("Unable to open file for outgoing logging"); 31 owl_free(logpath); 27 32 return; 28 33 } … … 33 38 fclose(file); 34 39 35 sprintf(filename, "%s/zlog/people/all", owl_global_get_homedir(&g)); 40 snprintf(filename, MAXPATHLEN, "%s/all", logpath); 41 owl_free(logpath); 36 42 file=fopen(filename, "a"); 37 43 if (!file) { … … 50 56 void owl_log_incoming(owl_message *m) { 51 57 FILE *file, *allfile; 52 char filename[MAXPATHLEN], allfilename[MAXPATHLEN] ;58 char filename[MAXPATHLEN], allfilename[MAXPATHLEN], *logpath; 53 59 char *frombuff, *ptr, *from, *buff, *tmp; 54 60 int len, ch, i, personal; … … 86 92 87 93 for (i=0; i<len; i++) { 88 if (frombuff[i]<'!' || frombuff[i]> '~') from="weird";94 if (frombuff[i]<'!' || frombuff[i]>='~') from="weird"; 89 95 } 90 96 … … 95 101 } 96 102 97 /* create the filename */103 /* create the filename (expanding ~ in path names) */ 98 104 if (personal) { 99 sprintf(filename, "%s/%s", owl_global_get_logpath(&g), from); 100 sprintf(allfilename, "%s/all", owl_global_get_logpath(&g)); 105 logpath = owl_util_substitute(owl_global_get_logpath(&g), "~", 106 owl_global_get_homedir(&g)); 107 snprintf(filename, MAXPATHLEN, "%s/%s", logpath, from); 108 snprintf(allfilename, MAXPATHLEN, "%s/all", logpath); 109 101 110 } else { 102 sprintf(filename, "%s/%s", owl_global_get_classlogpath(&g), from); 111 logpath = owl_util_substitute(owl_global_get_classlogpath(&g), "~", 112 owl_global_get_homedir(&g)); 113 114 snprintf(filename, MAXPATHLEN, "%s/%s", logpath, from); 103 115 } 116 owl_free(logpath); 104 117 105 118 file=fopen(filename, "a"); -
perlglue.xs
r83a9b63 re1c4636 6 6 7 7 /* Yeah, we should just include owl.h, but curses and perl don't play nice. */ 8 extern char *owl_function_command(char *cmd); 9 extern void owl_free(void *x); 8 extern char *owl_function_command(char *); 9 extern void owl_free(void *); 10 extern int owl_zwrite_create_and_send_from_line(char *, char *); 11 extern char *owl_fmtext_ztext_stylestrip(char *); 10 12 11 13 MODULE = owl PACKAGE = owl … … 24 26 if (rv) owl_free(rv); 25 27 28 void 29 send_zwrite(cmd,msg) 30 char *cmd 31 char *msg 32 PREINIT: 33 int i; 34 CODE: 35 i = owl_zwrite_create_and_send_from_line(cmd, msg); 36 37 char * 38 ztext_stylestrip(ztext) 39 char *ztext 40 PREINIT: 41 char *rv = NULL; 42 CODE: 43 rv = owl_fmtext_ztext_stylestrip(ztext); 44 RETVAL = rv; 45 OUTPUT: 46 RETVAL 47 CLEANUP: 48 if (rv) owl_free(rv); 49 -
tester.c
r1aee7d9 re1c4636 30 30 screeninit(); 31 31 32 owl_editwin_init(&e, stdscr, LINES, COLS, OWL_EDITWIN_STYLE_MULTILINE );32 owl_editwin_init(&e, stdscr, LINES, COLS, OWL_EDITWIN_STYLE_MULTILINE, NULL); 33 33 /* owl_editwin_set_locktext(&e, "Here is some locktext:\n");*/ 34 34 doupdate(); … … 137 137 int numfailures=0; 138 138 if (argc==2 && 0==strcmp(argv[1],"reg")) { 139 numfailures += owl_util_regtest(); 139 140 numfailures += owl_dict_regtest(); 140 141 numfailures += owl_variable_regtest(); -
util.c
r10b866d re1c4636 148 148 149 149 /* skips n tokens and returns where that would be. 150 * TODO: handle quotes . */150 * TODO: handle quotes more sanely. */ 151 151 char *skiptokens(char *buff, int n) { 152 152 int inquotes=0; … … 154 154 while (*buff == ' ') buff++; 155 155 while (*buff && (inquotes || *buff != ' ')) { 156 if (*buff == '"' ) inquotes=!inquotes;156 if (*buff == '"' || *buff == '\'') inquotes=!inquotes; 157 157 buff++; 158 158 } … … 386 386 } 387 387 388 /* Caller must free returned string. 389 * Returns a string with any occurances of 'from' replaced with 'to'. 390 * Does not currently handle backslash quoting, but may in the future. 391 */ 392 char *owl_util_substitute(char *in, char *from, char *to) { 393 char *out; 394 int outlen, tolen, fromlen, inpos=0, outpos=0; 395 396 if (!*from) return owl_strdup(in); 397 398 outlen = strlen(in)+1; 399 tolen = strlen(to); 400 fromlen = strlen(from); 401 out = malloc(outlen); 402 403 while (in[inpos]) { 404 if (!strncmp(in+inpos, from, fromlen)) { 405 outlen += tolen; 406 out = owl_realloc(out, outlen); 407 strcpy(out+outpos, to); 408 inpos += fromlen; 409 outpos += tolen; 410 } else { 411 out[outpos] = in[inpos]; 412 inpos++; outpos++; 413 } 414 } 415 out[outpos] = '\0'; 416 return(out); 417 } 418 388 419 389 420 int owl_util_string_to_color(char *color) { … … 422 453 return("Unknown color"); 423 454 } 455 456 457 /**************************************************************************/ 458 /************************* REGRESSION TESTS *******************************/ 459 /**************************************************************************/ 460 461 #ifdef OWL_INCLUDE_REG_TESTS 462 463 #define FAIL_UNLESS(desc,pred) printf("\t%-4s: %s\n", (pred)?"ok":(numfailed++,"FAIL"), desc) 464 465 int owl_util_regtest(void) { 466 int numfailed=0; 467 468 printf("BEGIN testing owl_util\n"); 469 470 FAIL_UNLESS("owl_util_substitute 1", 471 !strcmp("foo", owl_util_substitute("foo", "", "Y"))); 472 FAIL_UNLESS("owl_util_substitute 2", 473 !strcmp("fYZYZ", owl_util_substitute("foo", "o", "YZ"))); 474 FAIL_UNLESS("owl_util_substitute 3", 475 !strcmp("foo", owl_util_substitute("fYZYZ", "YZ", "o"))); 476 FAIL_UNLESS("owl_util_substitute 4", 477 !strcmp("/u/foo/meep", owl_util_substitute("~/meep", "~", "/u/foo"))); 478 479 FAIL_UNLESS("skiptokens 1", 480 !strcmp("bar quux", skiptokens("foo bar quux", 1))); 481 FAIL_UNLESS("skiptokens 2", 482 !strcmp("meep", skiptokens("foo 'bar quux' meep", 2))); 483 484 if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); 485 printf("END testing owl_util (%d failures)\n", numfailed); 486 return(numfailed); 487 } 488 489 #endif /* OWL_INCLUDE_REG_TESTS */ -
variable.c
r217a43e re1c4636 7 7 8 8 static const char fileIdent[] = "$Id$"; 9 10 static int in_regtest = 0; 9 11 10 12 #define OWLVAR_BOOL(name,default,docstring) \ … … 85 87 "turn class logging on or off" ), 86 88 89 OWLVAR_BOOL( "colorztext" /* %OwlVarStub */, 1, 90 "allow @color() in zephyrs to change color" ), 91 87 92 OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1, 88 93 "don't send zephyrs on C-d (or disable if in the middle of the message if set to 'middle')", "off,middle,on", … … 193 198 * any user setting of this */ 194 199 int owl_variable_disable_ctrl_d_set(owl_variable *v, void *newval) { 200 201 if (in_regtest) return owl_variable_int_set_default(v, newval); 202 195 203 if (newval && !owl_context_is_startup(owl_global_get_context(&g))) { 196 204 if (*(int*)newval == 2) { … … 675 683 char buf[1024]; 676 684 685 in_regtest = 1; 686 677 687 printf("BEGIN testing owl_variable\n"); 678 688 FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd)); -
zwrite.c
r1c6c4d3 re1c4636 36 36 } 37 37 myargc=argc; 38 myargc--; 39 myargv++; 38 if (myargc && *(myargv[0])!='-') { 39 myargc--; 40 myargv++; 41 } 40 42 while (myargc) { 41 43 if (!strcmp(myargv[0], "-c")) {
Note: See TracChangeset
for help on using the changeset viewer.