Changeset e19eb97 for message.c


Ignore:
Timestamp:
Aug 15, 2009, 7:08:18 PM (12 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:
1077891a
Parents:
fa4562c
git-author:
Anders Kaseorg <andersk@mit.edu> (08/04/09 02:37:51)
git-committer:
Anders Kaseorg <andersk@mit.edu> (08/15/09 19:08:18)
Message:
Add const qualifiers for char * and void *.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • message.c

    r65b2173 re19eb97  
    5555 * name already exists, replace the old value with the new value
    5656 */
    57 void owl_message_set_attribute(owl_message *m, char *attrname, const char *attrvalue)
     57void owl_message_set_attribute(owl_message *m, const char *attrname, const char *attrvalue)
    5858{
    5959  int i, j;
     
    8282 * the attribute does not exist
    8383 */
    84 char *owl_message_get_attribute_value(owl_message *m, char *attrname)
     84const char *owl_message_get_attribute_value(owl_message *m, const char *attrname)
    8585{
    8686  int i, j;
     
    159159}
    160160
    161 void owl_message_set_class(owl_message *m, char *class)
     161void owl_message_set_class(owl_message *m, const char *class)
    162162{
    163163  owl_message_set_attribute(m, "class", class);
    164164}
    165165
    166 char *owl_message_get_class(owl_message *m)
    167 {
    168   char *class;
     166const char *owl_message_get_class(owl_message *m)
     167{
     168  const char *class;
    169169
    170170  class=owl_message_get_attribute_value(m, "class");
     
    173173}
    174174
    175 void owl_message_set_instance(owl_message *m, char *inst)
     175void owl_message_set_instance(owl_message *m, const char *inst)
    176176{
    177177  owl_message_set_attribute(m, "instance", inst);
    178178}
    179179
    180 char *owl_message_get_instance(owl_message *m)
    181 {
    182   char *instance;
     180const char *owl_message_get_instance(owl_message *m)
     181{
     182  const char *instance;
    183183
    184184  instance=owl_message_get_attribute_value(m, "instance");
     
    187187}
    188188
    189 void owl_message_set_sender(owl_message *m, char *sender)
     189void owl_message_set_sender(owl_message *m, const char *sender)
    190190{
    191191  owl_message_set_attribute(m, "sender", sender);
    192192}
    193193
    194 char *owl_message_get_sender(owl_message *m)
    195 {
    196   char *sender;
     194const char *owl_message_get_sender(owl_message *m)
     195{
     196  const char *sender;
    197197
    198198  sender=owl_message_get_attribute_value(m, "sender");
     
    201201}
    202202
    203 void owl_message_set_zsig(owl_message *m, char *zsig)
     203void owl_message_set_zsig(owl_message *m, const char *zsig)
    204204{
    205205  owl_message_set_attribute(m, "zsig", zsig);
    206206}
    207207
    208 char *owl_message_get_zsig(owl_message *m)
    209 {
    210   char *zsig;
     208const char *owl_message_get_zsig(owl_message *m)
     209{
     210  const char *zsig;
    211211
    212212  zsig=owl_message_get_attribute_value(m, "zsig");
     
    215215}
    216216
    217 void owl_message_set_recipient(owl_message *m, char *recip)
     217void owl_message_set_recipient(owl_message *m, const char *recip)
    218218{
    219219  owl_message_set_attribute(m, "recipient", recip);
    220220}
    221221
    222 char *owl_message_get_recipient(owl_message *m)
     222const char *owl_message_get_recipient(owl_message *m)
    223223{
    224224  /* this is stupid for outgoing messages, we need to fix it. */
    225225
    226   char *recip;
     226  const char *recip;
    227227
    228228  recip=owl_message_get_attribute_value(m, "recipient");
     
    236236}
    237237
    238 char *owl_message_get_realm(owl_message *m)
    239 {
    240   char *realm;
     238const char *owl_message_get_realm(owl_message *m)
     239{
     240  const char *realm;
    241241 
    242242  realm=owl_message_get_attribute_value(m, "realm");
     
    245245}
    246246
    247 void owl_message_set_body(owl_message *m, char *body)
     247void owl_message_set_body(owl_message *m, const char *body)
    248248{
    249249  owl_message_set_attribute(m, "body", body);
    250250}
    251251
    252 char *owl_message_get_body(owl_message *m)
    253 {
    254   char *body;
     252const char *owl_message_get_body(owl_message *m)
     253{
     254  const char *body;
    255255
    256256  body=owl_message_get_attribute_value(m, "body");
     
    260260
    261261
    262 void owl_message_set_opcode(owl_message *m, char *opcode)
     262void owl_message_set_opcode(owl_message *m, const char *opcode)
    263263{
    264264  owl_message_set_attribute(m, "opcode", opcode);
    265265}
    266266
    267 char *owl_message_get_opcode(owl_message *m)
    268 {
    269   char *opcode;
     267const char *owl_message_get_opcode(owl_message *m)
     268{
     269  const char *opcode;
    270270
    271271  opcode=owl_message_get_attribute_value(m, "opcode");
     
    288288int owl_message_is_loginout(owl_message *m)
    289289{
    290   char *res;
     290  const char *res;
    291291
    292292  res=owl_message_get_attribute_value(m, "loginout");
     
    297297int owl_message_is_login(owl_message *m)
    298298{
    299   char *res;
     299  const char *res;
    300300
    301301  res=owl_message_get_attribute_value(m, "loginout");
     
    308308int owl_message_is_logout(owl_message *m)
    309309{
    310   char *res;
     310  const char *res;
    311311
    312312  res=owl_message_get_attribute_value(m, "loginout");
     
    323323int owl_message_is_private(owl_message *m)
    324324{
    325   char *res;
     325  const char *res;
    326326
    327327  res=owl_message_get_attribute_value(m, "isprivate");
     
    330330}
    331331
    332 char *owl_message_get_timestr(owl_message *m)
     332const char *owl_message_get_timestr(owl_message *m)
    333333{
    334334  if (m->timestr) return(m->timestr);
     
    356356}
    357357
    358 void owl_message_set_type(owl_message *m, char* type)
     358void owl_message_set_type(owl_message *m, const char* type)
    359359{
    360360  owl_message_set_attribute(m, "type", type);
    361361}
    362362
    363 int owl_message_is_type(owl_message *m, char *type) {
    364   char * t = owl_message_get_attribute_value(m, "type");
     363int owl_message_is_type(owl_message *m, const char *type) {
     364  const char * t = owl_message_get_attribute_value(m, "type");
    365365  if(!t) return 0;
    366366  return !strcasecmp(t, type);
     
    399399}
    400400
    401 char *owl_message_get_text(owl_message *m)
     401const char *owl_message_get_text(owl_message *m)
    402402{
    403403  owl_message_format(m);
     
    462462}
    463463
    464 char *owl_message_get_zwriteline(owl_message *m)
    465 {
    466   char *z = owl_message_get_attribute_value(m, "zwriteline");
     464const char *owl_message_get_zwriteline(owl_message *m)
     465{
     466  const char *z = owl_message_get_attribute_value(m, "zwriteline");
    467467  if (!z) return "";
    468468  return z;
    469469}
    470470
    471 void owl_message_set_zwriteline(owl_message *m, char *line)
     471void owl_message_set_zwriteline(owl_message *m, const char *line)
    472472{
    473473  owl_message_set_attribute(m, "zwriteline", line);
     
    493493#endif
    494494
    495 void owl_message_set_hostname(owl_message *m, char *hostname)
     495void owl_message_set_hostname(owl_message *m, const char *hostname)
    496496{
    497497  m->hostname=owl_global_intern(&g, hostname);
    498498}
    499499
    500 char *owl_message_get_hostname(owl_message *m)
     500const char *owl_message_get_hostname(owl_message *m)
    501501{
    502502  return(m->hostname);
     
    542542
    543543int owl_message_is_answered(owl_message *m) {
    544   char *q;
     544  const char *q;
    545545  if(!owl_message_is_question(m)) return 0;
    546546  q = owl_message_get_attribute_value(m, "question");
     
    568568char *owl_message_get_cc(owl_message *m)
    569569{
    570   char *cur;
     570  const char *cur;
    571571  char *out, *end;
    572572
     
    586586{
    587587  char *cc, *out, *end, *shortuser, *recip;
    588   char *user;
     588  const char *user;
    589589
    590590  cc = owl_message_get_cc(m);
     
    625625}
    626626
    627 char *owl_message_get_type(owl_message *m) {
    628   char * type = owl_message_get_attribute_value(m, "type");
     627const char *owl_message_get_type(owl_message *m) {
     628  const char * type = owl_message_get_attribute_value(m, "type");
    629629  if(!type) {
    630630    return "generic";
     
    633633}
    634634
    635 char *owl_message_get_direction(owl_message *m) {
     635const char *owl_message_get_direction(owl_message *m) {
    636636  switch (m->direction) {
    637637  case OWL_MESSAGE_DIRECTION_IN:
     
    646646}
    647647
    648 int owl_message_parse_direction(char *d) {
     648int owl_message_parse_direction(const char *d) {
    649649  if(!strcmp(d, "in")) {
    650650    return OWL_MESSAGE_DIRECTION_IN;
     
    657657
    658658
    659 char *owl_message_get_login(owl_message *m) {
     659const char *owl_message_get_login(owl_message *m) {
    660660  if (owl_message_is_login(m)) {
    661661    return "login";
     
    668668
    669669
    670 char *owl_message_get_header(owl_message *m) {
     670const char *owl_message_get_header(owl_message *m) {
    671671  return owl_message_get_attribute_value(m, "adminheader");
    672672}
     
    688688 *                 1 it's a login message
    689689 */
    690 void owl_message_create_aim(owl_message *m, char *sender, char *recipient, char *text, int direction, int loginout)
     690void owl_message_create_aim(owl_message *m, const char *sender, const char *recipient, const char *text, int direction, int loginout)
    691691{
    692692  owl_message_init(m);
     
    714714}
    715715
    716 void owl_message_create_admin(owl_message *m, char *header, char *text)
     716void owl_message_create_admin(owl_message *m, const char *header, const char *text)
    717717{
    718718  owl_message_init(m);
     
    723723
    724724/* caller should set the direction */
    725 void owl_message_create_loopback(owl_message *m, char *text)
     725void owl_message_create_loopback(owl_message *m, const char *text)
    726726{
    727727  owl_message_init(m);
     
    737737{
    738738  struct hostent *hent;
    739   char *ptr;
     739  const char *ptr;
    740740  char *tmp, *tmp2;
    741741  int len;
     
    852852
    853853/* If 'direction' is '0' it is a login message, '1' is a logout message. */
    854 void owl_message_create_pseudo_zlogin(owl_message *m, int direction, char *user, char *host, char *time, char *tty)
     854void owl_message_create_pseudo_zlogin(owl_message *m, int direction, const char *user, const char *host, const char *time, const char *tty)
    855855{
    856856  char *longuser;
    857   char *ptr;
     857  const char *ptr;
    858858
    859859#ifdef HAVE_LIBZEPHYR
     
    898898}
    899899
    900 void owl_message_create_from_zwriteline(owl_message *m, char *line, char *body, char *zsig)
     900void owl_message_create_from_zwriteline(owl_message *m, const char *line, const char *body, const char *zsig)
    901901{
    902902  owl_zwrite z;
Note: See TracChangeset for help on using the changeset viewer.