Changeset 56330ff for zwrite.c


Ignore:
Timestamp:
Aug 25, 2002, 3:02:14 PM (19 years ago)
Author:
James M. Kretchmar <kretch@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:
c01e477
Parents:
4b464a4
Message:
Moved zsig generation to the zwrite object
Print the zsig used for outgoing messages
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zwrite.c

    r4b464a4 r56330ff  
    11#include <string.h>
     2#include <pwd.h>
     3#include <sys/types.h>
     4#include <unistd.h>
    25#include "owl.h"
    36
     
    1720  int argc, badargs, myargc;
    1821  char **argv, **myargv;
     22  char *zsigexec, *zsigowlvar, *zsigzvar, *ptr;
     23  struct passwd *pw;
    1924
    2025  badargs=0;
     
    2530  strcpy(z->inst, "personal");
    2631  strcpy(z->opcode, "");
     32  z->zsig=owl_strdup("");
    2733  z->cc=0;
    2834  z->noping=0;
     
    103109  }
    104110
     111  /* set a zsig */
     112  zsigexec = owl_global_get_zsig_exec(&g);
     113  zsigowlvar = owl_global_get_zsig(&g);
     114  zsigzvar = ZGetVariable("zwrite-signature");
     115
     116  if (zsigowlvar && *zsigowlvar) {
     117    owl_free(z->zsig);
     118    z->zsig=strdup(zsigowlvar);
     119  } else if (zsigexec && *zsigexec) {
     120    FILE *file;
     121    char buff[LINE];
     122
     123    file=popen(zsigexec, "r");
     124    if (!file) {
     125      if (zsigzvar && *zsigzvar) {
     126        owl_free(z->zsig);
     127        z->zsig=owl_strdup(zsigzvar);
     128      }
     129    } else {
     130      owl_free(z->zsig);
     131      z->zsig=owl_malloc(LINE);
     132      strcpy(z->zsig, "");
     133      while (fgets(buff, LINE, file)) { /* wrong sizing */
     134        strcat(z->zsig, buff);
     135      }
     136      pclose(file);
     137      if (z->zsig[strlen(z->zsig)-1]=='\n') {
     138        z->zsig[strlen(z->zsig)-1]='\0';
     139      }
     140    }
     141  } else if (zsigzvar) {
     142    owl_free(z->zsig);
     143    z->zsig=owl_strdup(zsigzvar);
     144  } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
     145    owl_free(z->zsig);
     146    z->zsig=strdup(pw->pw_gecos);
     147    ptr=strchr(z->zsig, ',');
     148    if (ptr) {
     149      ptr[0]='\0';
     150    }
     151  }
     152
    105153  return(0);
    106154}
     
    160208      }
    161209      if (z->cc) {
    162         send_zephyr(z->opcode, NULL, z->class, z->inst, to, tmpmsg);
     210        send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, tmpmsg);
    163211      } else {
    164         send_zephyr(z->opcode, NULL, z->class, z->inst, to, msg);
     212        send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, msg);
    165213      }
    166214    }
     
    190238}
    191239
     240char *owl_zwrite_get_zsig(owl_zwrite *z) {
     241  return(z->zsig);
     242}
     243
    192244void owl_zwrite_get_recipstr(owl_zwrite *z, char *buff) {
    193245  int i, j;
     
    225277void owl_zwrite_free(owl_zwrite *z) {
    226278  owl_list_free_all(&(z->recips), &owl_free);
    227 }
     279  owl_free(z->zsig);
     280}
Note: See TracChangeset for help on using the changeset viewer.