Changeset d0d65df for functions.c


Ignore:
Timestamp:
Feb 17, 2003, 3:47:41 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
985f85b
Parents:
a2641cd9
Message:
The message object now uses a list of attributes internally, in
  prep. for supporting new messaging protocols
owl_function_info now uses fmtext instead of one staticly sized
  buffer
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r8f44c6b rd0d65df  
    10881088void owl_function_info() {
    10891089  owl_message *m;
     1090  owl_fmtext fm;
    10901091  ZNotice_t *n;
    1091   char buff[5000], tmpbuff[1024];
     1092  char buff[10000], tmpbuff[1024];
    10921093  char *ptr;
    10931094  int i, j, fields, len;
    10941095  owl_view *v;
    10951096
     1097  owl_fmtext_init_null(&fm);
     1098 
    10961099  v=owl_global_get_current_view(&g);
    10971100  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
     
    11011104  }
    11021105
    1103   sprintf(buff,     "Msg Id    : %i\n", owl_message_get_id(m));
     1106  owl_fmtext_append_normal(&fm, "Msg Id    : ");
     1107  sprintf(buff, "%i", owl_message_get_id(m));
     1108  owl_fmtext_append_normal(&fm, buff);
     1109  owl_fmtext_append_normal(&fm, "\n");
    11041110  if (owl_message_is_type_zephyr(m)) {
    1105     sprintf(buff, "%sType      : zephyr\n", buff);
     1111    owl_fmtext_append_normal(&fm, "Type      : zephyr\n");
    11061112  } else if (owl_message_is_type_admin(m)) {
    1107     sprintf(buff, "%sType      : admin\n", buff);
     1113    owl_fmtext_append_normal(&fm, "Type      : admin\n");
    11081114  } else if (owl_message_is_type_generic(m)) {
    1109     sprintf(buff, "%sType      : generic\n", buff);
     1115    owl_fmtext_append_normal(&fm, "Type      : generic\n");
    11101116  } else {
    1111     sprintf(buff, "%sType      : unknown\n", buff);
     1117    owl_fmtext_append_normal(&fm, "Type      : unknown\n");
    11121118  }
    11131119  if (owl_message_is_direction_in(m)) {
    1114     sprintf(buff, "%sDirection : in\n", buff);
     1120    owl_fmtext_append_normal(&fm, "Direction : in\n");
    11151121  } else if (owl_message_is_direction_out(m)) {
    1116     sprintf(buff, "%sDirection : out\n", buff);
     1122    owl_fmtext_append_normal(&fm, "Direction : out\n");
    11171123  } else if (owl_message_is_direction_none(m)) {
    1118     sprintf(buff, "%sDirection : none\n", buff);
     1124    owl_fmtext_append_normal(&fm, "Direction : none\n");
    11191125  } else {
    1120     sprintf(buff, "%sDirection : unknown\n", buff);
    1121   }
    1122   sprintf(buff, "%sTime      : %s\n", buff, owl_message_get_timestr(m));
    1123 
    1124   if (!owl_message_is_type_zephyr(m)) {
    1125     owl_function_popless_text(buff);
    1126     return;
    1127   }
    1128 
    1129 
    1130   if (owl_message_is_direction_out(m)) {
    1131     sprintf(buff, "%sClass     : %s\n", buff, owl_message_get_class(m));
    1132     sprintf(buff, "%sInstance  : %s\n", buff, owl_message_get_instance(m));
    1133     sprintf(buff, "%sSender    : %s\n", buff, owl_message_get_sender(m));
    1134     sprintf(buff, "%sRecip     : %s\n", buff, owl_message_get_recipient(m));
    1135     sprintf(buff, "%sOpcode    : %s\n", buff, owl_message_get_opcode(m));
    1136    
    1137     owl_function_popless_text(buff);
    1138     return;
    1139   }
    1140 
    1141   n=owl_message_get_notice(m);
    1142 
    1143   sprintf(buff, "%sClass     : %s\n", buff, owl_message_get_class(m));
    1144   sprintf(buff, "%sInstance  : %s\n", buff, owl_message_get_instance(m));
    1145   sprintf(buff, "%sSender    : %s\n", buff, owl_message_get_sender(m));
    1146   sprintf(buff, "%sRecip     : %s\n", buff, owl_message_get_recipient(m));
    1147   sprintf(buff, "%sOpcode    : %s\n", buff, owl_message_get_opcode(m));
    1148   strcat(buff,    "Kind      : ");
    1149   if (n->z_kind==UNSAFE) {
    1150     strcat(buff, "UNSAFE\n");
    1151   } else if (n->z_kind==UNACKED) {
    1152     strcat(buff, "UNACKED\n");
    1153   } else if (n->z_kind==ACKED) {
    1154     strcat(buff, "ACKED\n");
    1155   } else if (n->z_kind==HMACK) {
    1156     strcat(buff, "HMACK\n");
    1157   } else if (n->z_kind==HMCTL) {
    1158     strcat(buff, "HMCTL\n");
    1159   } else if (n->z_kind==SERVACK) {
    1160     strcat(buff, "SERVACK\n");
    1161   } else if (n->z_kind==SERVNAK) {
    1162     strcat(buff, "SERVNAK\n");
    1163   } else if (n->z_kind==CLIENTACK) {
    1164     strcat(buff, "CLIENTACK\n");
    1165   } else if (n->z_kind==STAT) {
    1166     strcat(buff, "STAT\n");
    1167   } else {
    1168     strcat(buff, "ILLEGAL VALUE\n");
    1169   }
    1170   sprintf(buff, "%sTime      : %s\n", buff, owl_message_get_timestr(m));
    1171   sprintf(buff, "%sHost      : %s\n", buff, owl_message_get_hostname(m));
    1172   sprintf(buff, "%sPort      : %i\n", buff, n->z_port);
    1173   strcat(buff,    "Auth      : ");
    1174   if (n->z_auth == ZAUTH_FAILED) {
    1175     strcat(buff, "FAILED\n");
    1176   } else if (n->z_auth == ZAUTH_NO) {
    1177     strcat(buff, "NO\n");
    1178   } else if (n->z_auth == ZAUTH_YES) {
    1179     strcat(buff, "YES\n");
    1180   } else {
    1181     sprintf(buff, "%sUnknown State (%i)\n", buff, n->z_auth);
    1182   }
    1183   sprintf(buff, "%sCheckd Ath: %i\n", buff, n->z_checked_auth);
    1184   sprintf(buff, "%sMulti notc: %s\n", buff, n->z_multinotice);
    1185   sprintf(buff, "%sNum other : %i\n", buff, n->z_num_other_fields);
    1186   sprintf(buff, "%sMsg Len   : %i\n", buff, n->z_message_len);
    1187 
    1188   sprintf(buff, "%sFields    : %i\n", buff, owl_zephyr_get_num_fields(n));
    1189 
    1190   fields=owl_zephyr_get_num_fields(n);
    1191   for (i=0; i<fields; i++) {
    1192     sprintf(buff, "%sField %i   : ", buff, i+1);
    1193 
    1194     ptr=owl_zephyr_get_field(n, i+1, &len);
    1195     if (!ptr) break;
    1196     if (len<30) {
    1197       strncpy(tmpbuff, ptr, len);
    1198       tmpbuff[len]='\0';
    1199     } else {
    1200       strncpy(tmpbuff, ptr, 30);
    1201       tmpbuff[30]='\0';
    1202       strcat(tmpbuff, "...");
    1203     }
    1204 
    1205     /* just for testing for now */
    1206     for (j=0; j<strlen(tmpbuff); j++) {
    1207       if (tmpbuff[j]=='\n') tmpbuff[j]='~';
    1208       if (tmpbuff[j]=='\r') tmpbuff[j]='!';
    1209     }
    1210 
    1211     strcat(buff, tmpbuff);
    1212     strcat(buff, "\n");
    1213   }
    1214   sprintf(buff, "%sDefault Fm: %s\n", buff, n->z_default_format);
     1126    owl_fmtext_append_normal(&fm, "Direction : unknown\n");
     1127  }
     1128  owl_fmtext_append_normal(&fm, "Time      : ");
     1129  owl_fmtext_append_normal(&fm, owl_message_get_timestr(m));
     1130  owl_fmtext_append_normal(&fm, "\n");
     1131
     1132  if (owl_message_is_type_zephyr(m)) {
     1133
     1134    if (owl_message_is_direction_in(m)) {
     1135      n=owl_message_get_notice(m);
     1136      owl_fmtext_append_normal(&fm, "Class     : ");
     1137      owl_fmtext_append_normal(&fm, owl_message_get_class(m));
     1138      owl_fmtext_append_normal(&fm, "\n");
     1139      owl_fmtext_append_normal(&fm, "Instance  : ");
     1140      owl_fmtext_append_normal(&fm, owl_message_get_instance(m));
     1141      owl_fmtext_append_normal(&fm, "\n");
     1142      owl_fmtext_append_normal(&fm, "Sender    : ");
     1143      owl_fmtext_append_normal(&fm, owl_message_get_sender(m));
     1144      owl_fmtext_append_normal(&fm, "\n");
     1145      owl_fmtext_append_normal(&fm, "Recipient : ");
     1146      owl_fmtext_append_normal(&fm, owl_message_get_recipient(m));
     1147      owl_fmtext_append_normal(&fm, "\n");
     1148      owl_fmtext_append_normal(&fm, "Opcode    : ");
     1149      owl_fmtext_append_normal(&fm, owl_message_get_opcode(m));
     1150      owl_fmtext_append_normal(&fm, "\n");
     1151      owl_fmtext_append_normal(&fm, "Kind      : ");
     1152      if (n->z_kind==UNSAFE) {
     1153        owl_fmtext_append_normal(&fm, "UNSAFE\n");
     1154      } else if (n->z_kind==UNACKED) {
     1155        owl_fmtext_append_normal(&fm, "UNACKED\n");
     1156      } else if (n->z_kind==ACKED) {
     1157        owl_fmtext_append_normal(&fm, "ACKED\n");
     1158      } else if (n->z_kind==HMACK) {
     1159        owl_fmtext_append_normal(&fm, "HMACK\n");
     1160      } else if (n->z_kind==HMCTL) {
     1161        owl_fmtext_append_normal(&fm, "HMCTL\n");
     1162      } else if (n->z_kind==SERVACK) {
     1163        owl_fmtext_append_normal(&fm, "SERVACK\n");
     1164      } else if (n->z_kind==SERVNAK) {
     1165        owl_fmtext_append_normal(&fm, "SERVNACK\n");
     1166      } else if (n->z_kind==CLIENTACK) {
     1167        owl_fmtext_append_normal(&fm, "CLIENTACK\n");
     1168      } else if (n->z_kind==STAT) {
     1169        owl_fmtext_append_normal(&fm, "STAT\n");
     1170      } else {
     1171        owl_fmtext_append_normal(&fm, "ILLEGAL VALUE\n");
     1172      }
     1173
     1174      owl_fmtext_append_normal(&fm, "Time      : ");
     1175      owl_fmtext_append_normal(&fm, owl_message_get_timestr(m));
     1176      owl_fmtext_append_normal(&fm, "\n");
     1177      owl_fmtext_append_normal(&fm, "Host      : ");
     1178      owl_fmtext_append_normal(&fm, owl_message_get_hostname(m));
     1179      owl_fmtext_append_normal(&fm, "\n");
     1180      sprintf(buff, "Port      : %i\n", n->z_port);
     1181      owl_fmtext_append_normal(&fm, buff);
     1182
     1183      owl_fmtext_append_normal(&fm,    "Auth      : ");
     1184      if (n->z_auth == ZAUTH_FAILED) {
     1185        owl_fmtext_append_normal(&fm, "FAILED\n");
     1186      } else if (n->z_auth == ZAUTH_NO) {
     1187        owl_fmtext_append_normal(&fm, "NO\n");
     1188      } else if (n->z_auth == ZAUTH_YES) {
     1189        owl_fmtext_append_normal(&fm, "YES\n");
     1190      } else {
     1191        sprintf(buff, "Unknown State (%i)\n", n->z_auth);
     1192        owl_fmtext_append_normal(&fm, buff);
     1193      }
     1194
     1195      sprintf(buff, "Checkd Ath: %i\n", buff, n->z_checked_auth);
     1196      sprintf(buff, "%sMulti notc: %s\n", buff, n->z_multinotice);
     1197      sprintf(buff, "%sNum other : %i\n", buff, n->z_num_other_fields);
     1198      sprintf(buff, "%sMsg Len   : %i\n", buff, n->z_message_len);
     1199      owl_fmtext_append_normal(&fm, buff);
     1200     
     1201      sprintf(buff, "Fields    : %i\n", owl_zephyr_get_num_fields(n));
     1202      owl_fmtext_append_normal(&fm, buff);
     1203     
     1204      fields=owl_zephyr_get_num_fields(n);
     1205      for (i=0; i<fields; i++) {
     1206        sprintf(buff, "Field %i   : ", i+1);
    12151207       
    1216   owl_function_popless_text(buff);
     1208        ptr=owl_zephyr_get_field(n, i+1, &len);
     1209        if (!ptr) break;
     1210        if (len<30) {
     1211          strncpy(tmpbuff, ptr, len);
     1212          tmpbuff[len]='\0';
     1213        } else {
     1214          strncpy(tmpbuff, ptr, 30);
     1215          tmpbuff[30]='\0';
     1216          strcat(tmpbuff, "...");
     1217        }
     1218       
     1219        /* just for testing for now */
     1220        for (j=0; j<strlen(tmpbuff); j++) {
     1221          if (tmpbuff[j]=='\n') tmpbuff[j]='~';
     1222          if (tmpbuff[j]=='\r') tmpbuff[j]='!';
     1223        }
     1224       
     1225        strcat(buff, tmpbuff);
     1226        strcat(buff, "\n");
     1227        owl_fmtext_append_normal(&fm, buff);
     1228      }
     1229      owl_fmtext_append_normal(&fm, "Default Fm:");
     1230      owl_fmtext_append_normal(&fm, n->z_default_format);
     1231    }
     1232  }
     1233 
     1234  owl_function_popless_fmtext(&fm);
    12171235}
    12181236
Note: See TracChangeset for help on using the changeset viewer.