Changeset 712caac


Ignore:
Timestamp:
Aug 15, 2009, 7:08:17 PM (8 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
c529ac8
Parents:
defe4a3
git-author:
Anders Kaseorg <andersk@mit.edu> (08/04/09 02:00:22)
git-committer:
Anders Kaseorg <andersk@mit.edu> (08/15/09 19:08:17)
Message:
Cast away const on strings passed to libzephyr (with new function zstr).

libzephyr doesn’t use const anywhere, so we’re going to need to cast
const char * to char * all the time when passing strings to it.  We
wrap this cast in a new inline function for better type safety.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    rfea7992 r712caac  
    31263126        for (i=0; i<j; i++) {
    31273127          user=owl_list_get_element(&anyone, i);
    3128           ret=ZLocateUser(user, &numlocs, ZAUTH);
     3128          ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    31293129
    31303130          owl_function_mask_sigint(NULL);
     
    34803480  for (i=0; i<j; i++) {
    34813481    user=owl_list_get_element(&anyone, i);
    3482     ret=ZLocateUser(user, &numlocs, ZAUTH);
     3482    ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    34833483    if (ret!=ZERR_NONE) {
    34843484      owl_function_error("Error getting location for %s", user);
  • owl.h

    r41c9a96 r712caac  
    193193
    194194#define LINE 2048
     195
     196#ifdef HAVE_LIBZEPHYR
     197/* libzephyr doesn't use const, so we appease the type system with this cast. */
     198static inline char *zstr(const char *str)
     199{
     200  return (char *)str;
     201}
     202#endif
    195203
    196204typedef struct _owl_variable {
  • perlconfig.c

    rf12d199 r712caac  
    179179    n->z_auth = ZAUTH_NO;
    180180    n->z_checked_auth = 0;
    181     n->z_class = owl_message_get_class(m);
    182     n->z_class_inst = owl_message_get_instance(m);
    183     n->z_opcode = owl_message_get_opcode(m);
    184     n->z_sender = owl_message_get_sender(m);
    185     n->z_recipient = owl_message_get_recipient(m);
    186     n->z_default_format = "[zephyr created from perl]";
    187     n->z_multinotice = "[zephyr created from perl]";
     181    n->z_class = zstr(owl_message_get_class(m));
     182    n->z_class_inst = zstr(owl_message_get_instance(m));
     183    n->z_opcode = zstr(owl_message_get_opcode(m));
     184    n->z_sender = zstr(owl_message_get_sender(m));
     185    n->z_recipient = zstr(owl_message_get_recipient(m));
     186    n->z_default_format = zstr("[zephyr created from perl]");
     187    n->z_multinotice = zstr("[zephyr created from perl]");
    188188    n->z_num_other_fields = 0;
    189189    n->z_message = owl_sprintf("%s%c%s", owl_message_get_zsig(m), '\0', owl_message_get_body(m));
  • zephyr.c

    rfea7992 r712caac  
    5454  req.z_kind = STAT;
    5555  req.z_port = 0;
    56   req.z_class = HM_STAT_CLASS;
    57   req.z_class_inst = HM_STAT_CLIENT;
    58   req.z_opcode = HM_GIMMESTATS;
    59   req.z_sender = "";
    60   req.z_recipient = "";
    61   req.z_default_format = "";
     56  req.z_class = zstr(HM_STAT_CLASS);
     57  req.z_class_inst = zstr(HM_STAT_CLIENT);
     58  req.z_opcode = zstr(HM_GIMMESTATS);
     59  req.z_sender = zstr("");
     60  req.z_recipient = zstr("");
     61  req.z_default_format = zstr("");
    6262  req.z_message_len = 0;
    6363
     
    427427  ZSubscription_t subs[5];
    428428
    429   subs[0].zsub_class=class;
    430   subs[0].zsub_classinst=inst;
    431   subs[0].zsub_recipient=recip;
     429  subs[0].zsub_class=zstr(class);
     430  subs[0].zsub_classinst=zstr(inst);
     431  subs[0].zsub_recipient=zstr(recip);
    432432
    433433  ZResetAuthentication();
     
    448448  ZSubscription_t subs[5];
    449449
    450   subs[0].zsub_class=class;
    451   subs[0].zsub_classinst=inst;
    452   subs[0].zsub_recipient=recip;
     450  subs[0].zsub_class=zstr(class);
     451  subs[0].zsub_classinst=zstr(inst);
     452  subs[0].zsub_recipient=zstr(recip);
    453453
    454454  ZResetAuthentication();
     
    676676  notice.z_kind=ACKED;
    677677  notice.z_port=0;
    678   notice.z_class=class;
    679   notice.z_class_inst=instance;
     678  notice.z_class=zstr(class);
     679  notice.z_class_inst=zstr(instance);
    680680  notice.z_sender=NULL;
    681681  if (!strcmp(recipient, "*") || !strcmp(recipient, "@")) {
    682     notice.z_recipient="";
     682    notice.z_recipient=zstr("");
    683683    if (*owl_global_get_zsender(&g))
    684         notice.z_sender=owl_global_get_zsender(&g);
     684        notice.z_sender=zstr(owl_global_get_zsender(&g));
    685685  } else {
    686     notice.z_recipient=recipient;
    687   }
    688   notice.z_default_format="Class $class, Instance $instance:\nTo: @bold($recipient) at $time $date\nFrom: @bold{$1 <$sender>}\n\n$2";
    689   if (opcode) notice.z_opcode=opcode;
     686    notice.z_recipient=zstr(recipient);
     687  }
     688  notice.z_default_format=zstr("Class $class, Instance $instance:\nTo: @bold($recipient) at $time $date\nFrom: @bold{$1 <$sender>}\n\n$2");
     689  if (opcode) notice.z_opcode=zstr(opcode);
    690690
    691691  notice.z_message_len=strlen(zsig)+1+strlen(message);
     
    895895  strcpy(out, "");
    896896  ZResetAuthentication();
    897   ret=ZLocateUser(user,&numlocs,auth?ZAUTH:ZNOAUTH);
     897  ret=ZLocateUser(zstr(user),&numlocs,auth?ZAUTH:ZNOAUTH);
    898898  if (ret != ZERR_NONE) {
    899899    sprintf(out, "Error locating user %s\n", user);
     
    10041004   
    10051005  eset=EXPOSE_REALMVIS;
    1006   exposure=ZGetVariable("exposure");
     1006  exposure=ZGetVariable(zstr("exposure"));
    10071007  if (exposure==NULL) {
    10081008    eset=EXPOSE_REALMVIS;
     
    10211021  }
    10221022   
    1023   ret=ZSetLocation(eset);
     1023  ret=ZSetLocation(zstr(eset));
    10241024  if (ret != ZERR_NONE) {
    10251025    /*
     
    11591159{
    11601160#ifdef HAVE_LIBZEPHYR
    1161   return(ZGetVariable(var));
     1161  return(ZGetVariable(zstr(var)));
    11621162#else
    11631163  return("");
     
    11681168{
    11691169#ifdef HAVE_LIBZEPHYR
    1170   ZInitLocationInfo(host, val);
     1170  ZInitLocationInfo(zstr(host), zstr(val));
    11711171#endif
    11721172}
Note: See TracChangeset for help on using the changeset viewer.