Changeset 712caac for zephyr.c


Ignore:
Timestamp:
Aug 15, 2009, 7:08:17 PM (15 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.10, 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>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.