Changeset e1c4636


Ignore:
Timestamp:
Jul 9, 2002, 12:04:35 AM (19 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
2c8a07c
Parents:
10b866d
Message:
* Added owl::send_zwrite(command, message) to the perl glue
         to allow for the direct sending of multi-line messages.
         For example:  owl::send_zwrite("-c foo -i bar", "hello");
* Reverted attempted fix for the pagedown problem
         which just made things worse.
* Changed owl_fmtext_print_plain to return an alloc'd string to
         avoid buffer overrun risks.
* Added owl::ztext_stylestrip("...") function to perlglue
          which returns the ztext with formatting stripped out.
* Added colorztext variable which can be used to disable @color()
          strings arriving in messages after it is set.
          (Currently, changing its value won't reformat messages).
* Outgoing zephyr logging now obeys the logpath variable.
* The '~' character in logpath and classlogpath now gets
          replaced with the user's home directory.
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r10b866d re1c4636  
    3434                of a zephyr being composed:  C-c it and restart it
    3535                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.
    3651       
    37521.2.1-pre-1
     
    8499                color messages matching the current one green.
    85100       
    86 1.2.0-pre-erikdevel-17
     1011.2.0-pre-1
    87102        Integrated change to fix problem with popup blinking on new zephyrs.
    88103        C-l and resizes will now refresh an open viewwin (eg, help).
     
    94109                and to not mess up spaces.  exec also returns a string
    95110                of the output now.
    96        
    97 1.2.0-pre-erikdevel-16
    98111        Integrated changes from 1.1.3, and added docs for "zlocate -d"
    99112                and new show commands.
     
    101114        Fix a bug in readconfig caught by efence (where we'd try to read before
    102115                the beginning of a string if it was empty).
    103        
    104 1.1.2-erikdevel-15
    105116        The perl command doesn't do makemsg directly, but instead
    106117             returns the string and it will get printed if it
    107118             was run interactively.
    108 
    109 1.1.2-erikdevel-14
    110         *** NOTE: I probably missed some things here...
    111119        New framework for command handling.
    112120        New framework for keymap handling.
  • fmtext.c

    r1aee7d9 re1c4636  
    180180        /* if it's a color read the color, set the current color and
    181181           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)) {
    183185        owl_free(buff);
    184186        txtptr+=7;
     
    325327
    326328
    327 void owl_fmtext_print_plain(owl_fmtext *f, char *buff) {
    328   strcpy(buff, f->textbuff);
     329/* caller is responsible for freeing */
     330char *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. */
     336char *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);
    329345}
    330346
  • global.c

    r10b866d re1c4636  
    1818  struct hostent *hent;
    1919  char hostname[MAXHOSTNAMELEN];
    20   char buff[MAXPATHLEN];
    2120
    2221  gethostname(hostname, MAXHOSTNAMELEN);
     
    7877  /* TODO: come back later and check passwd file first */
    7978  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  
    8579
    8680  owl_messagelist_create(&(g->msglist));
  • logging.c

    r1aee7d9 re1c4636  
    99void owl_log_outgoing(char *to, char *text) {
    1010  FILE *file;
    11   char filename[MAXPATHLEN];
     11  char filename[MAXPATHLEN], *logpath;
    1212  char *tobuff, *ptr;
    1313
     
    2121  }
    2222
    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);
    2428  file=fopen(filename, "a");
    2529  if (!file) {
    2630    owl_function_makemsg("Unable to open file for outgoing logging");
     31    owl_free(logpath);
    2732    return;
    2833  }
     
    3338  fclose(file);
    3439
    35   sprintf(filename, "%s/zlog/people/all", owl_global_get_homedir(&g));
     40  snprintf(filename, MAXPATHLEN, "%s/all", logpath);
     41  owl_free(logpath);
    3642  file=fopen(filename, "a");
    3743  if (!file) {
     
    5056void owl_log_incoming(owl_message *m) {
    5157  FILE *file, *allfile;
    52   char filename[MAXPATHLEN], allfilename[MAXPATHLEN];
     58  char filename[MAXPATHLEN], allfilename[MAXPATHLEN], *logpath;
    5359  char *frombuff, *ptr, *from, *buff, *tmp;
    5460  int len, ch, i, personal;
     
    8692
    8793  for (i=0; i<len; i++) {
    88     if (frombuff[i]<'!' || frombuff[i]>'~') from="weird";
     94    if (frombuff[i]<'!' || frombuff[i]>='~') from="weird";
    8995  }
    9096
     
    95101  }
    96102
    97   /* create the filename */
     103  /* create the filename (expanding ~ in path names) */
    98104  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
    101110  } 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);
    103115  }
     116  owl_free(logpath);
    104117 
    105118  file=fopen(filename, "a");
  • perlglue.xs

    r83a9b63 re1c4636  
    66
    77/* 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);
     8extern char *owl_function_command(char *);
     9extern void owl_free(void *);
     10extern int owl_zwrite_create_and_send_from_line(char *, char *);
     11extern char *owl_fmtext_ztext_stylestrip(char *);
    1012
    1113MODULE = owl            PACKAGE = owl           
     
    2426                if (rv) owl_free(rv);
    2527
     28void
     29send_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
     37char *
     38ztext_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  
    3030  screeninit();
    3131
    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);
    3333  /* owl_editwin_set_locktext(&e, "Here is some locktext:\n");*/
    3434  doupdate();
     
    137137  int numfailures=0;
    138138  if (argc==2 && 0==strcmp(argv[1],"reg")) {
     139    numfailures += owl_util_regtest();
    139140    numfailures += owl_dict_regtest();
    140141    numfailures += owl_variable_regtest();
  • util.c

    r10b866d re1c4636  
    148148
    149149/* skips n tokens and returns where that would be.
    150  * TODO: handle quotes. */
     150 * TODO: handle quotes more sanely. */
    151151char *skiptokens(char *buff, int n) {
    152152  int inquotes=0;
     
    154154      while (*buff == ' ') buff++;
    155155      while (*buff && (inquotes || *buff != ' ')) {
    156         if (*buff == '"') inquotes=!inquotes;
     156        if (*buff == '"' || *buff == '\'') inquotes=!inquotes;
    157157        buff++;
    158158      }
     
    386386}
    387387
     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 */
     392char *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
    388419
    389420int owl_util_string_to_color(char *color) {
     
    422453  return("Unknown color");
    423454}
     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
     465int 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  
    77
    88static const char fileIdent[] = "$Id$";
     9
     10static int in_regtest = 0;
    911
    1012#define OWLVAR_BOOL(name,default,docstring) \
     
    8587               "turn class logging on or off" ),
    8688
     89  OWLVAR_BOOL( "colorztext" /* %OwlVarStub */, 1,
     90               "allow @color() in zephyrs to change color" ),
     91
    8792  OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1,
    8893                    "don't send zephyrs on C-d (or disable if in the middle of the message if set to 'middle')", "off,middle,on",
     
    193198 * any user setting of this */
    194199int 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
    195203  if (newval && !owl_context_is_startup(owl_global_get_context(&g))) {
    196204    if (*(int*)newval == 2) {
     
    675683  char buf[1024];
    676684
     685  in_regtest = 1;
     686
    677687  printf("BEGIN testing owl_variable\n");
    678688  FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd));
  • zwrite.c

    r1c6c4d3 re1c4636  
    3636  }
    3737  myargc=argc;
    38   myargc--;
    39   myargv++;
     38  if (myargc && *(myargv[0])!='-') {
     39    myargc--;
     40    myargv++;
     41  }
    4042  while (myargc) {
    4143    if (!strcmp(myargv[0], "-c")) {
Note: See TracChangeset for help on using the changeset viewer.