diff options
70 files changed, 964 insertions, 822 deletions
diff --git a/alpine/adrbkcmd.c b/alpine/adrbkcmd.c index 3e89a3f5..592b16b8 100644 --- a/alpine/adrbkcmd.c +++ b/alpine/adrbkcmd.c @@ -626,7 +626,7 @@ expand_addrs_for_pico(struct headerentry *headents, char ***s) SIZEOF_20KBUF)); } - abe.addr.list[cnt] = '\0'; + abe.addr.list[cnt] = NULL; } else{ abe.tag = Single; @@ -3307,7 +3307,7 @@ ab_del_abook(long int cur_line, int command_line, char **err) * Init_abook(pab, TotallyClosed) via rd_close_remdata is * going to pine_mail_close it. */ - if(pab->type && REMOTE_VIA_IMAP + if(pab->type & REMOTE_VIA_IMAP && pab->address_book && pab->address_book->type == Imap && pab->address_book->rd @@ -4885,7 +4885,7 @@ prepare_abe_for_vcard(struct pine *ps, AdrBk_Entry *abe, int expand_nicks) fs_give((void **)&bufp); } - vinfo->email[cnt] = '\0'; + vinfo->email[cnt] = NULL; } else{ /* don't expand or qualify */ if(abe->tag == Single){ @@ -4893,7 +4893,7 @@ prepare_abe_for_vcard(struct pine *ps, AdrBk_Entry *abe, int expand_nicks) (abe->addr.addr && abe->addr.addr[0]) ? abe->addr.addr : ""; vinfo->email = (char **)fs_get((1+1) * sizeof(char *)); vinfo->email[0] = cpystr(astring); - vinfo->email[1] = '\0'; + vinfo->email[1] = NULL; } else{ char **ll; @@ -4905,7 +4905,7 @@ prepare_abe_for_vcard(struct pine *ps, AdrBk_Entry *abe, int expand_nicks) for(cnt = 0, ll = abe->addr.list; ll && *ll; ll++) vinfo->email[cnt++] = cpystr(*ll); - vinfo->email[cnt] = '\0'; + vinfo->email[cnt] = NULL; } } @@ -6971,12 +6971,12 @@ view_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *winning_e) void compose_to_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int allow_role) { - char **elecmail = NULL, + struct berval **elecmail = NULL, **mail = NULL, **cn = NULL, **sn = NULL, - **givenname = NULL, - **ll; + **givenname = NULL; + int num; size_t len = 0; dprint((9, "- compose_to_ldap_entry -\n")); @@ -6991,23 +6991,23 @@ compose_to_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int allow_role) if(strcmp(a, e->info_used->mailattr) == 0){ if(!mail) - mail = ldap_get_values(e->ld, e->selected_entry, a); + mail = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, "electronicmail") == 0){ if(!elecmail) - elecmail = ldap_get_values(e->ld, e->selected_entry, a); + elecmail = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, e->info_used->cnattr) == 0){ if(!cn) - cn = ldap_get_values(e->ld, e->selected_entry, a); + cn = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, e->info_used->gnattr) == 0){ if(!givenname) - givenname = ldap_get_values(e->ld, e->selected_entry, a); + givenname = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, e->info_used->snattr) == 0){ if(!sn) - sn = ldap_get_values(e->ld, e->selected_entry, a); + sn = ldap_get_values_len(e->ld, e->selected_entry, a); } our_ldap_memfree(a); @@ -7015,16 +7015,16 @@ compose_to_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int allow_role) } if(elecmail){ - if(elecmail[0] && elecmail[0][0] && !mail) + if(ALPINE_LDAP_can_use(elecmail) && !mail) mail = elecmail; else - ldap_value_free(elecmail); + ldap_value_free_len(elecmail); elecmail = NULL; } - for(ll = mail; ll && *ll; ll++) - len += strlen(*ll) + 1; + for(num = 0; ALPINE_LDAP_usable(mail, num); num++) + len += strlen(mail[num]->bv_val) + 1; if(len){ char *p, *address, *fn = NULL; @@ -7033,11 +7033,11 @@ compose_to_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int allow_role) address = (char *)fs_get(len * sizeof(char)); p = address; - ll = mail; - while(*ll){ - sstrncpy(&p, *ll, len-(p-address)); - ll++; - if(*ll) + num = 0; + while(ALPINE_LDAP_usable(mail, num)){ + sstrncpy(&p, mail[num]->bv_val, len-(p-address)); + num++; + if(mail[num]) sstrncpy(&p, ",", len-(p-address)); } @@ -7047,21 +7047,20 @@ compose_to_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int allow_role) * If we have a fullname and there is only a single address and * the address doesn't seem to have a fullname with it, add it. */ - if(mail && mail[0] && mail[0][0] && !mail[1]){ - if(cn && cn[0] && cn[0][0]) - fn = cpystr(cn[0]); - else if(sn && sn[0] && sn[0][0] && - givenname && givenname[0] && givenname[0][0]){ + if(ALPINE_LDAP_can_use(mail) && !mail[1]){ + if(ALPINE_LDAP_can_use(cn)) + fn = cpystr(cn[0]->bv_val); + else if(ALPINE_LDAP_can_use(sn) && ALPINE_LDAP_can_use(givenname)){ size_t l; - l = strlen(givenname[0]) + strlen(sn[0]) + 1; + l = strlen(givenname[0]->bv_val) + strlen(sn[0]->bv_val) + 1; fn = (char *) fs_get((l+1) * sizeof(char)); - snprintf(fn, l+1, "%s %s", givenname[0], sn[0]); + snprintf(fn, l+1, "%s %s", givenname[0]->bv_val, sn[0]->bv_val); fn[l] = '\0'; } } - if(mail && mail[0] && mail[0][0] && !mail[1] && fn){ + if(ALPINE_LDAP_can_use(mail) && !mail[1] && fn){ ADDRESS *adrlist = NULL; char *tmp_a_string; @@ -7117,13 +7116,13 @@ compose_to_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int allow_role) q_status_message(SM_ORDER, 0, 4, _("No address to compose to")); if(mail) - ldap_value_free(mail); + ldap_value_free_len(mail); if(cn) - ldap_value_free(cn); + ldap_value_free_len(cn); if(sn) - ldap_value_free(sn); + ldap_value_free_len(sn); if(givenname) - ldap_value_free(givenname); + ldap_value_free_len(givenname); } @@ -7163,7 +7162,7 @@ prep_ldap_for_viewing(struct pine *ps, LDAP_CHOOSE_S *winning_e, SourceType srct #define INDENTHERE (22) char obuf[W+10]; char hdr[6*INDENTHERE+1], hdr2[6*INDENTHERE+1]; - char **cn = NULL; + struct berval **cn = NULL; int indent = INDENTHERE; if(!(store = so_get(srctype, NULL, EDIT_ACCESS))) @@ -7202,14 +7201,14 @@ prep_ldap_for_viewing(struct pine *ps, LDAP_CHOOSE_S *winning_e, SourceType srct a = ldap_next_attribute(winning_e->ld, winning_e->selected_entry, ber)){ if(a && *a){ - char **vals; + struct berval **vals; char *fn = NULL; - vals = ldap_get_values(winning_e->ld, winning_e->selected_entry, a); + vals = ldap_get_values_len(winning_e->ld, winning_e->selected_entry, a); /* save this for mailto */ if(handlesp && !cn && !strcmp(a, winning_e->info_used->cnattr)) - cn = ldap_get_values(winning_e->ld, winning_e->selected_entry, a); + cn = ldap_get_values_len(winning_e->ld, winning_e->selected_entry, a); if(vals){ int do_mailto; @@ -7220,7 +7219,7 @@ prep_ldap_for_viewing(struct pine *ps, LDAP_CHOOSE_S *winning_e, SourceType srct utf8_snprintf(hdr, sizeof(hdr), "%-*.*w: ", indent-2,indent-2, ldap_translate(a, winning_e->info_used)); hdr[sizeof(hdr)-1] = '\0'; - for(i = 0; vals[i] != NULL; i++){ + for(i = 0; ALPINE_LDAP_usable(vals, i); i++){ if(do_mailto){ ADDRESS *ad = NULL; HANDLE_S *h; @@ -7229,9 +7228,9 @@ prep_ldap_for_viewing(struct pine *ps, LDAP_CHOOSE_S *winning_e, SourceType srct char *addr, *new_addr, *enc_addr; char *path = NULL; - addr = cpystr(vals[i]); - if(cn && cn[0] && cn[0][0]) - fn = cpystr(cn[0]); + addr = cpystr(vals[i]->bv_val); + if(ALPINE_LDAP_can_use(cn)) + fn = cpystr(cn[0]->bv_val); if(fn){ tmp_a_string = cpystr(addr); @@ -7327,7 +7326,7 @@ prep_ldap_for_viewing(struct pine *ps, LDAP_CHOOSE_S *winning_e, SourceType srct } } - ldap_value_free(vals); + ldap_value_free_len(vals); } else{ utf8_snprintf(obuf, sizeof(obuf), "%-*.*w\n", indent-1,indent-1, @@ -7341,7 +7340,7 @@ prep_ldap_for_viewing(struct pine *ps, LDAP_CHOOSE_S *winning_e, SourceType srct } if(cn) - ldap_value_free(cn); + ldap_value_free_len(cn); return(store); } diff --git a/alpine/arg.c b/alpine/arg.c index 1e33d9d9..bb949f3b 100644 --- a/alpine/arg.c +++ b/alpine/arg.c @@ -55,6 +55,10 @@ static char args_err_missing_pinerc[] = N_("missing argument for option \"-piner #if defined(DOS) || defined(OS2) static char args_err_missing_aux[] = N_("missing argument for option \"-aux\""); #endif +#ifdef SMIME +static char args_err_missing_smimedir[] = N_("missing argument for option \"-smimedir\""); +static char args_err_non_abs_smimedir[] = N_("argument to \"-smimedir\" should be fully-qualified"); +#endif /* SMIME */ #ifdef PASSFILE static char args_err_missing_passfile[] = N_("missing argument for option \"-passfile\""); static char args_err_non_abs_passfile[] = N_("argument to \"-passfile\" should be fully-qualified"); @@ -131,6 +135,10 @@ N_(" -nosplash \tDisable the PC-Alpine splash screen"), N_(" -erase_stored_passwords\tEliminate any stored passwords"), #endif +#ifdef SMIME +N_(" -smimedir <fully_qualified_path>\tdirectory where smime personal certificates are saved"), +#endif /* SMIME */ + #ifdef PASSFILE N_(" -passfile <fully_qualified_filename>\tSet the password file to something other"), N_("\t\tthan the default"), @@ -274,6 +282,31 @@ Loop: while(--ac > 0) } #endif /* defined(APPLEKEYCHAIN) || (WINCRED > 0) */ +#ifdef SMIME + else if(strcmp(*av, "smimedir") == 0){ + if(--ac){ + if((str = *++av) != NULL){ + if(!is_absolute_path(str)){ + display_args_err(_(args_err_non_abs_smimedir), + NULL, 1); + ++usage; + } + else{ + if(pine_state->smimedir) + fs_give((void **)&pine_state->pwdcertdir); + + pine_state->smimedir = cpystr(str); + } + } + } + else{ + display_args_err(_(args_err_missing_smimedir), NULL, 1); + ++usage; + } + + goto Loop; + } +#endif /* SMIME */ #ifdef PASSFILE else if(strcmp(*av, "passfile") == 0){ if(--ac){ diff --git a/alpine/imap.c b/alpine/imap.c index 3c33d1b3..4b6f0ee6 100644 --- a/alpine/imap.c +++ b/alpine/imap.c @@ -2782,10 +2782,11 @@ preserve_prompt(void) } return(0); #else /* PASSFILE */ -if(F_OFF(F_DISABLE_PASSWORD_FILE_SAVING,ps_global)) - return(want_to(_("Preserve password on DISK for next login"), + if(F_OFF(F_DISABLE_PASSWORD_FILE_SAVING,ps_global)) + return(want_to(_("Preserve password on DISK for next login"), 'y', 'x', NO_HELP, WT_NORM) == 'y'); + return(0); #endif /* PASSFILE */ } diff --git a/alpine/ldapconf.c b/alpine/ldapconf.c index 66cc3f02..e710f0e8 100644 --- a/alpine/ldapconf.c +++ b/alpine/ldapconf.c @@ -130,7 +130,7 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, e != NULL; e = ldap_next_entry(res_list->ld, e)){ char *dn, *a; - char **cn, **org, **unit, **title, **mail, **sn; + struct berval **cn, **org, **unit, **title, **mail, **sn; BerElement *ber; int indent, have_mail; @@ -143,28 +143,28 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, dprint((9, " %s", a ? a : "?")); if(strcmp(a, res_list->info_used->cnattr) == 0){ if(!cn) - cn = ldap_get_values(res_list->ld, e, a); + cn = ldap_get_values_len(res_list->ld, e, a); - if(cn && !(cn[0] && cn[0][0])){ - ldap_value_free(cn); + if(cn && !ALPINE_LDAP_can_use(cn)){ + ldap_value_free_len(cn); cn = NULL; } } else if(strcmp(a, res_list->info_used->mailattr) == 0){ if(!mail) - mail = ldap_get_values(res_list->ld, e, a); + mail = ldap_get_values_len(res_list->ld, e, a); } else if(strcmp(a, "o") == 0){ if(!org) - org = ldap_get_values(res_list->ld, e, a); + org = ldap_get_values_len(res_list->ld, e, a); } else if(strcmp(a, "ou") == 0){ if(!unit) - unit = ldap_get_values(res_list->ld, e, a); + unit = ldap_get_values_len(res_list->ld, e, a); } else if(strcmp(a, "title") == 0){ if(!title) - title = ldap_get_values(res_list->ld, e, a); + title = ldap_get_values_len(res_list->ld, e, a); } our_ldap_memfree(a); @@ -179,10 +179,10 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, if(strcmp(a, res_list->info_used->snattr) == 0){ if(!sn) - sn = ldap_get_values(res_list->ld, e, a); + sn = ldap_get_values_len(res_list->ld, e, a); - if(sn && !(sn[0] && sn[0][0])){ - ldap_value_free(sn); + if(sn && !ALPINE_LDAP_can_use(sn)){ + ldap_value_free_len(sn); sn = NULL; } } @@ -191,7 +191,7 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, } } - if(mail && mail[0] && mail[0][0]) + if(ALPINE_LDAP_can_use(mail)) have_mail = 1; else have_mail = 0; @@ -212,8 +212,8 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, if(need_mail && !have_mail) ctmpa->flags |= CF_PRIVATE; - ctmpa->value = cpystr(cn[0]); - ldap_value_free(cn); + ctmpa->value = cpystr(cn[0]->bv_val); + ldap_value_free_len(cn); ctmpa->valoffset = indent; ctmpa->keymenu = km; ctmpa->help = help; @@ -238,8 +238,8 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, if(need_mail && !have_mail) ctmpa->flags |= CF_PRIVATE; - ctmpa->value = cpystr(sn[0]); - ldap_value_free(sn); + ctmpa->value = cpystr(sn[0]->bv_val); + ldap_value_free_len(sn); ctmpa->valoffset = indent; ctmpa->keymenu = km; ctmpa->help = help; @@ -289,11 +289,11 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, } if(title){ - for(i = 0; title[i] && title[i][0]; i++){ + for(i = 0; ALPINE_LDAP_usable(title, i); i++){ new_confline(&ctmpa); ctmpa->flags |= CF_NOSELECT; ctmpa->valoffset = indent + 2; - ctmpa->value = cpystr(title[i]); + ctmpa->value = cpystr(title[i]->bv_val); ctmpa->keymenu = km; ctmpa->help = help; ctmpa->help_title = _(srch_res_help_title); @@ -305,15 +305,15 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, ctmpa->d.a.ac = ac; } - ldap_value_free(title); + ldap_value_free_len(title); } if(unit){ - for(i = 0; unit[i] && unit[i][0]; i++){ + for(i = 0; ALPINE_LDAP_usable(unit, i); i++){ new_confline(&ctmpa); ctmpa->flags |= CF_NOSELECT; ctmpa->valoffset = indent + 2; - ctmpa->value = cpystr(unit[i]); + ctmpa->value = cpystr(unit[i]->bv_val); ctmpa->keymenu = km; ctmpa->help = help; ctmpa->help_title = _(srch_res_help_title); @@ -325,15 +325,15 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, ctmpa->d.a.ac = ac; } - ldap_value_free(unit); + ldap_value_free_len(unit); } if(org){ - for(i = 0; org[i] && org[i][0]; i++){ + for(i = 0; ALPINE_LDAP_usable(org, i); i++){ new_confline(&ctmpa); ctmpa->flags |= CF_NOSELECT; ctmpa->valoffset = indent + 2; - ctmpa->value = cpystr(org[i]); + ctmpa->value = cpystr(org[i]->bv_val); ctmpa->keymenu = km; ctmpa->help = help; ctmpa->help_title = _(srch_res_help_title); @@ -345,20 +345,20 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, ctmpa->d.a.ac = ac; } - ldap_value_free(org); + ldap_value_free_len(org); } if(have_mail){ /* Don't show long list of email addresses. */ - if(!(mail[0] && mail[0][0]) || - !(mail[1] && mail[1][0]) || - !(mail[2] && mail[2][0]) || - !(mail[3] && mail[3][0])){ - for(i = 0; mail[i] && mail[i][0]; i++){ + if(!ALPINE_LDAP_can_use_num(mail, 0) || + !ALPINE_LDAP_can_use_num(mail, 1) || + !ALPINE_LDAP_can_use_num(mail, 2) || + !ALPINE_LDAP_can_use_num(mail, 3)){ + for(i = 0; ALPINE_LDAP_usable(mail, i); i++){ new_confline(&ctmpa); ctmpa->flags |= CF_NOSELECT; ctmpa->valoffset = indent + 2; - ctmpa->value = cpystr(mail[i]); + ctmpa->value = cpystr(mail[i]->bv_val); ctmpa->keymenu = km; ctmpa->help = help; ctmpa->help_title = _(srch_res_help_title); @@ -373,7 +373,7 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, else{ char tmp[200]; - for(i = 4; mail[i] && mail[i][0]; i++) + for(i = 4; ALPINE_LDAP_usable(mail, i); i++) ; new_confline(&ctmpa); @@ -410,7 +410,7 @@ ldap_addr_select(struct pine *ps, ADDR_CHOOSE_S *ac, LDAP_CHOOSE_S **result, } if(mail) - ldap_value_free(mail); + ldap_value_free_len(mail); new_confline(&ctmpa); /* blank line */ ctmpa->keymenu = km; diff --git a/alpine/takeaddr.c b/alpine/takeaddr.c index 5c13d8a9..e51bcb71 100644 --- a/alpine/takeaddr.c +++ b/alpine/takeaddr.c @@ -2980,16 +2980,15 @@ save_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int save) *first = NULL, *last = NULL, *comment = NULL; - char **cn = NULL, + struct berval **cn = NULL, **mail = NULL, **sn = NULL, **givenname = NULL, **title = NULL, **telephone = NULL, **elecmail = NULL, - **note = NULL, - **ll; - int j, + **note = NULL; + int j, num, export = 0; @@ -3006,35 +3005,35 @@ save_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int save) dprint((9, " %s", a ? a : "?")); if(strcmp(a, e->info_used->cnattr) == 0){ if(!cn) - cn = ldap_get_values(e->ld, e->selected_entry, a); + cn = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, e->info_used->mailattr) == 0){ if(!mail) - mail = ldap_get_values(e->ld, e->selected_entry, a); + mail = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, "electronicmail") == 0){ if(!elecmail) - elecmail = ldap_get_values(e->ld, e->selected_entry, a); + elecmail = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, "comment") == 0){ if(!note) - note = ldap_get_values(e->ld, e->selected_entry, a); + note = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, e->info_used->snattr) == 0){ if(!sn) - sn = ldap_get_values(e->ld, e->selected_entry, a); + sn = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, e->info_used->gnattr) == 0){ if(!givenname) - givenname = ldap_get_values(e->ld, e->selected_entry, a); + givenname = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, "telephonenumber") == 0){ if(!telephone) - telephone = ldap_get_values(e->ld, e->selected_entry, a); + telephone = ldap_get_values_len(e->ld, e->selected_entry, a); } else if(strcmp(a, "title") == 0){ if(!title) - title = ldap_get_values(e->ld, e->selected_entry, a); + title = ldap_get_values_len(e->ld, e->selected_entry, a); } } @@ -3065,10 +3064,10 @@ save_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int save) } if(elecmail){ - if(elecmail[0] && elecmail[0][0] && !mail) + if(ALPINE_LDAP_can_use(elecmail) && !mail) mail = elecmail; else - ldap_value_free(elecmail); + ldap_value_free_len(elecmail); elecmail = NULL; } @@ -3078,51 +3077,51 @@ save_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int save) char *d, *fakedomain = "@"; size_t len; - char **cm; + struct berval **cm; int how_many_selected = 0; - if(cn && cn[0] && cn[0][0]) - fullname = cpystr(cn[0]); - if(sn && sn[0] && sn[0][0]) - last = cpystr(sn[0]); - if(givenname && givenname[0] && givenname[0][0]) - first = cpystr(givenname[0]); - - if(note && note[0] && note[0][0]) + if(ALPINE_LDAP_can_use(cn)) + fullname = cpystr(cn[0]->bv_val); + if(ALPINE_LDAP_can_use(sn)) + last = cpystr(sn[0]->bv_val); + if(ALPINE_LDAP_can_use(givenname)) + first = cpystr(givenname[0]->bv_val); + + if(ALPINE_LDAP_can_use(note)) cm = note; else cm = title; - for(ll = cm, len = 0; ll && *ll; ll++) - len += strlen(*ll) + 2; + for(len = 0, num = 0; ALPINE_LDAP_usable(cm, num); num++) + len += strlen(cm[num]->bv_val) + 2; if(len){ comment = (char *)fs_get(len * sizeof(char)); d = comment; - ll = cm; - while(*ll){ - sstrncpy(&d, *ll, len-(d-comment)); - ll++; - if(*ll) + num = 0; + while(ALPINE_LDAP_usable(cm, num)){ + sstrncpy(&d, cm[num]->bv_val, len-(d-comment)); + num++; + if(ALPINE_LDAP_usable(cm, num)) sstrncpy(&d, "; ", len-(d-comment)); } comment[len-1] = '\0'; } - for(ll = mail, len = 0; ll && *ll; ll++) - len += strlen(*ll) + 1; + for(len = 0, num = 0; ALPINE_LDAP_usable(mail, num); num++) + len += strlen(mail[num]->bv_val) + 2; /* paste the email addresses together */ if(len){ address = (char *)fs_get(len * sizeof(char)); d = address; - ll = mail; - while(*ll){ - sstrncpy(&d, *ll, len-(d-address)); - ll++; - if(*ll) + num = 0; + while(ALPINE_LDAP_usable(mail, num)){ + sstrncpy(&d, mail[num]->bv_val, len-(d-address)); + num++; + if(ALPINE_LDAP_usable(mail, num)) sstrncpy(&d, ", ", len-(d-address)); } @@ -3295,14 +3294,14 @@ save_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int save) break; case 'a': - if(mail && mail[0] && mail[0][0]){ + if(ALPINE_LDAP_can_use(mail)){ srctype = CharStar; if(!(srcstore = so_get(srctype, NULL, EDIT_ACCESS))) q_status_message(SM_ORDER,0,2, _("Error allocating space")); else{ - for(ll = mail; ll && *ll; ll++){ - so_puts(srcstore, *ll); + for(num = 0; ALPINE_LDAP_usable(mail, num); num++){ + so_puts(srcstore, mail[num]->bv_val); so_puts(srcstore, "\n"); } @@ -3325,26 +3324,26 @@ save_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int save) vinfo = (VCARD_INFO_S *)fs_get(sizeof(VCARD_INFO_S)); memset((void *)vinfo, 0, sizeof(VCARD_INFO_S)); - if(cn && cn[0] && cn[0][0]) - vinfo->fullname = copy_list_array(cn); + if(ALPINE_LDAP_can_use(cn)) + vinfo->fullname = berval_to_array(cn); - if(note && note[0] && note[0][0]) - vinfo->note = copy_list_array(note); + if(ALPINE_LDAP_can_use(note)) + vinfo->note = berval_to_array(note); - if(title && title[0] && title[0][0]) - vinfo->title = copy_list_array(title); + if(ALPINE_LDAP_can_use(title)) + vinfo->title = berval_to_array(title); - if(telephone && telephone[0] && telephone[0][0]) - vinfo->tel = copy_list_array(telephone); + if(ALPINE_LDAP_can_use(telephone)) + vinfo->tel = berval_to_array(telephone); - if(mail && mail[0] && mail[0][0]) - vinfo->email = copy_list_array(mail); + if(ALPINE_LDAP_can_use(mail)) + vinfo->email = berval_to_array(mail); - if(sn && sn[0] && sn[0][0]) - vinfo->last = cpystr(sn[0]); + if(ALPINE_LDAP_can_use(sn)) + vinfo->last = cpystr(sn[0]->bv_val); - if(givenname && givenname[0] && givenname[0][0]) - vinfo->first = cpystr(givenname[0]); + if(ALPINE_LDAP_can_use(givenname)) + vinfo->first = cpystr(givenname[0]->bv_val); gf_set_so_writec(&pc, srcstore); @@ -3366,21 +3365,21 @@ save_ldap_entry(struct pine *ps, LDAP_CHOOSE_S *e, int save) } if(cn) - ldap_value_free(cn); + ldap_value_free_len(cn); if(mail) - ldap_value_free(mail); + ldap_value_free_len(mail); if(elecmail) - ldap_value_free(elecmail); + ldap_value_free_len(elecmail); if(note) - ldap_value_free(note); + ldap_value_free_len(note); if(sn) - ldap_value_free(sn); + ldap_value_free_len(sn); if(givenname) - ldap_value_free(givenname); + ldap_value_free_len(givenname); if(telephone) - ldap_value_free(telephone); + ldap_value_free_len(telephone); if(title) - ldap_value_free(title); + ldap_value_free_len(title); if(fullname) fs_give((void **)&fullname); if(address) @@ -18045,56 +18045,8 @@ $as_echo "$as_me: * * * Including LDAP Support" >&6;} $as_echo "#define ENABLE_LDAP /**/" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should define LDAP_DEPRECATED" >&5 -$as_echo_n "checking if we should define LDAP_DEPRECATED... " >&6; } - if test "$cross_compiling" = yes; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cross compiling: not checking" >&5 -$as_echo "$as_me: WARNING: cross compiling: not checking" >&2;} - - -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include <stdio.h> -#include <stdlib.h> -#include <ldap.h> -int main(void) { - - if (LDAP_VENDOR_VERSION >= 20300) - exit(0); - - exit(2); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -$as_echo "#define LDAP_DEPRECATED 1" >>confdefs.h - - - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: Cannot find LDAP functions! Excluding LDAP support." >&5 -$as_echo "$as_me: Cannot find LDAP functions! Excluding LDAP support." >&6;} fi -fi + fi if test "x$alpine_PAM" != "xnone" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pam_start" >&5 diff --git a/configure.ac b/configure.ac index 272144e7..f4cf950a 100644 --- a/configure.ac +++ b/configure.ac @@ -1426,40 +1426,40 @@ if test "$alpine_with_ldap" = "yes" ; then if test "$alpine_has_ldap" = "yes" ; then AC_MSG_NOTICE([* * * Including LDAP Support]) AC_DEFINE([ENABLE_LDAP], [], [Enable LDAP query support]) - + fi dnl we use deprecated functions (ldap_get_values) dnl OpenLDAP 2.3.x doesn't define LDAP_DEPRECATED by default like 2.2.x - AC_MSG_CHECKING([if we should define LDAP_DEPRECATED]) - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include <stdio.h> -#include <stdlib.h> -#include <ldap.h> -int main(void) { - - if (LDAP_VENDOR_VERSION >= 20300) - exit(0); - - exit(2); -} - ]])], - [ - AC_MSG_RESULT(yes) - AC_DEFINE(LDAP_DEPRECATED, 1, - [Define if you use OpenLDAP 2.3.x deprecated functions]) - - ], - [ - AC_MSG_RESULT(no) - ], - [ - AC_MSG_WARN([cross compiling: not checking]) - ] - ) - - else - AC_MSG_NOTICE([Cannot find LDAP functions! Excluding LDAP support.]) - fi +dnl AC_MSG_CHECKING([if we should define LDAP_DEPRECATED]) +dnl AC_RUN_IFELSE( +dnl [AC_LANG_SOURCE([[ +dnl #include <stdio.h> +dnl #include <stdlib.h> +dnl #include <ldap.h> +dnl int main(void) { +dnl +dnl if (LDAP_VENDOR_VERSION >= 20300) +dnl exit(0); +dnl +dnl exit(2); +dnl } +dnl ]])], +dnl [ +dnl AC_MSG_RESULT(yes) +dnl AC_DEFINE(LDAP_DEPRECATED, 1, +dnl [Define if you use OpenLDAP 2.3.x deprecated functions]) +dnl +dnl ], +dnl [ +dnl AC_MSG_RESULT(no) +dnl ], +dnl [ +dnl AC_MSG_WARN([cross compiling: not checking]) +dnl ] +dnl ) +dnl +dnl else +dnl AC_MSG_NOTICE([Cannot find LDAP functions! Excluding LDAP support.]) +dnl fi fi dnl PAM support is needed to build c-client in some linux, and hence Alpine. diff --git a/doc/alpine.1 b/doc/alpine.1 index 5d236774..312cb776 100644 --- a/doc/alpine.1 +++ b/doc/alpine.1 @@ -164,6 +164,9 @@ Use function keys for commands. This is the same as running the command .IP \fB-n\ \fInumber\fR 20 Start up with current message-number set to .I number. +.IP \fB-nowrite_password_cache\fR 20 +Read from a password cache if there is one, but +never offer to write a password to the cache .IP \fB-o\fR 20 Open first folder read-only. .IP \fB-p\ \fIconfig-file\fR 20 @@ -177,11 +180,24 @@ Use as the configuration file instead of default system-wide configuration file .IR pine.conf . +.IP \fB-passfile\ \fI<fully-qualified-path>\fR 20 +When password file support is compiled in, use the file specified in +.I <fully-qualified-path> +instead of the default. .IP \fB-pinerc\ \fIfile\fR 20 Output fresh pinerc configuration to .I file, preserving the settings of variables that the user has made. Use \fIfile\fR set to ``-'' to make output go to standard out. -<IP> \fB-registry\ \fIcmd\fR 20 +.IP \fB-pwdcertdir\ \fI<fully-qualified-path>\fR 20 +When SMIME and password file support are compiled in, this variable sets +the directory to store your personal key and certificate to encrypt and +decrypt your password file. +.IP \fB-r\fR 20 +Use restricted/demo mode. +.I Alpine +will only send mail to itself +and functions like save and export are restricted. +.IP \fB-registry\ \fIcmd\fR 20 For PC-Alpine only, this option affects the values of Alpine's registry entries. Possible values for \fIcmd\fR are set, clear, and dump. @@ -193,11 +209,11 @@ entries according to its current settings. Note that the dump command is currently disabled. Without the -registry option, PC-Alpine will write values into the registry only if there currently aren't any values set. -.IP \fB-r\fR 20 -Use restricted/demo mode. -.I Alpine -will only send mail to itself -and functions like save and export are restricted. +.IP \fB-smimedir\ \fI<fully-qualified-path>\fR +If SMIME is compiled in, this argument sets the directory where the +public, private, and certificate authorities certificates and keys +are stored. If not set by the command line the default is +~/.alpine-smime .IP \fB-sort\ \fIorder\fR Sort the FOLDER INDEX display in one of the following orders: .I arrival, date, subject, orderedsubj, thread, from, size, score, to, cc, diff --git a/imap/src/c-client/auth_ext.c b/imap/src/c-client/auth_ext.c index 61dfc1b8..c8c5f4ac 100644 --- a/imap/src/c-client/auth_ext.c +++ b/imap/src/c-client/auth_ext.c @@ -59,11 +59,11 @@ long auth_external_client (authchallenge_t challenger,authrespond_t responder, unsigned long clen; long ret = NIL; *trial = 65535; /* never retry */ - if (challenge = (*challenger) (stream,&clen)) { + if ((challenge = (*challenger) (stream,&clen)) != NULL) { fs_give ((void **) &challenge); /* send authorization id (empty string OK) */ if ((*responder) (stream,strcpy (user,mb->user),strlen (mb->user))) { - if (challenge = (*challenger) (stream,&clen)) + if ((challenge = (*challenger) (stream,&clen)) != NULL) fs_give ((void **) &challenge); else ret = LONGT; /* check the authentication */ } diff --git a/imap/src/c-client/auth_gss.c b/imap/src/c-client/auth_gss.c index 26bf9e50..66be8cce 100644 --- a/imap/src/c-client/auth_gss.c +++ b/imap/src/c-client/auth_gss.c @@ -97,7 +97,7 @@ long auth_gssapi_client (authchallenge_t challenger,authrespond_t responder, long ret = NIL; *trial = 65535; /* never retry */ /* get initial (empty) challenge */ - if (chal.value = (*challenger) (stream,(unsigned long *) &chal.length)) { + if ((chal.value = (*challenger) (stream,(unsigned long *) &chal.length)) != NULL) { if (chal.length) { /* abort if challenge non-empty */ mm_log ("Server bug: non-empty initial GSSAPI challenge",WARN); (*responder) (stream,NIL,0); @@ -336,7 +336,7 @@ char *auth_gssapi_server (authresponse_t responder,int argc,char *argv[]) GSS_S_COMPLETE) { if ((smj = gss_acquire_cred (&smn,crname,0,NIL,GSS_C_ACCEPT,&crd,NIL,NIL)) == GSS_S_COMPLETE) { - if (resp.value = (*responder) ("",0,(unsigned long *) &resp.length)) { + if ((resp.value = (*responder) ("",0,(unsigned long *) &resp.length)) != NULL) { do { /* negotiate authentication */ smj = gss_accept_sec_context (&smn,&ctx,crd,&resp, GSS_C_NO_CHANNEL_BINDINGS,&name,&mech, diff --git a/imap/src/c-client/auth_log.c b/imap/src/c-client/auth_log.c index 1e1b1b5c..6615744f 100644 --- a/imap/src/c-client/auth_log.c +++ b/imap/src/c-client/auth_log.c @@ -63,7 +63,7 @@ long auth_login_client (authchallenge_t challenger,authrespond_t responder, unsigned long clen; long ret = NIL; /* get user name prompt */ - if (challenge = (*challenger) (stream,&clen)) { + if ((challenge = (*challenger) (stream,&clen)) != NULL) { fs_give ((void **) &challenge); pwd[0] = NIL; /* prompt user */ mm_login (mb,user,pwd,*trial); @@ -78,7 +78,7 @@ long auth_login_client (authchallenge_t challenger,authrespond_t responder, fs_give ((void **) &challenge); /* send password */ if ((*responder) (stream,pwd,strlen (pwd))) { - if (challenge = (*challenger) (stream,&clen)) + if ((challenge = (*challenger) (stream,&clen)) != NULL) fs_give ((void **) &challenge); else { ++*trial; /* can try again if necessary */ @@ -104,10 +104,10 @@ char *auth_login_server (authresponse_t responder,int argc,char *argv[]) { char *ret = NIL; char *user,*pass,*authuser; - if (user = (*responder) (PWD_USER,sizeof (PWD_USER),NIL)) { - if (pass = (*responder) (PWD_PWD,sizeof (PWD_PWD),NIL)) { + if ((user = (*responder) (PWD_USER,sizeof (PWD_USER),NIL)) != NULL) { + if ((pass = (*responder) (PWD_PWD,sizeof (PWD_PWD),NIL)) != NULL) { /* delimit user from possible admin */ - if (authuser = strchr (user,'*')) *authuser++ = '\0'; + if ((authuser = strchr (user,'*')) != NULL) *authuser++ = '\0'; if (server_login (user,pass,authuser,argc,argv)) ret = myusername (); fs_give ((void **) &pass); } diff --git a/imap/src/c-client/auth_md5.c b/imap/src/c-client/auth_md5.c index f32ebc88..9c81d308 100644 --- a/imap/src/c-client/auth_md5.c +++ b/imap/src/c-client/auth_md5.c @@ -100,7 +100,7 @@ long auth_md5_client (authchallenge_t challenger,authrespond_t responder, unsigned long clen; long ret = NIL; /* get challenge */ - if (challenge = (*challenger) (stream,&clen)) { + if ((challenge = (*challenger) (stream,&clen)) != NULL) { pwd[0] = NIL; /* prompt user */ mm_login (mb,user,pwd,*trial); if (!pwd[0]) { /* user requested abort */ @@ -115,7 +115,7 @@ long auth_md5_client (authchallenge_t challenger,authrespond_t responder, fs_give ((void **) &challenge); /* send credentials, allow retry if OK */ if ((*responder) (stream,pwd,strlen (pwd))) { - if (challenge = (*challenger) (stream,&clen)) + if ((challenge = (*challenger) (stream,&clen)) != NULL) fs_give ((void **) &challenge); else { ++*trial; /* can try again if necessary */ @@ -150,14 +150,14 @@ char *auth_md5_server (authresponse_t responder,int argc,char *argv[]) sprintf (chal,"<%lu.%lu@%s>",(unsigned long) getpid (), (unsigned long) time (0),mylocalhost ()); /* send challenge, get user and hash */ - if (user = (*responder) (chal,cl = strlen (chal),NIL)) { + if ((user = (*responder) (chal,cl = strlen (chal),NIL)) != NULL) { /* got user, locate hash */ - if (hash = strrchr (user,' ')) { + if ((hash = strrchr (user,' ')) != NULL) { *hash++ = '\0'; /* tie off user */ /* see if authentication user */ - if (authuser = strchr (user,'*')) *authuser++ = '\0'; + if ((authuser = strchr (user,'*')) != NULL) *authuser++ = '\0'; /* get password */ - if (p = auth_md5_pwd ((authuser && *authuser) ? authuser : user)) { + if ((p = auth_md5_pwd ((authuser && *authuser) ? authuser : user)) != NULL) { pl = strlen (p); u = (md5try && !strcmp (hash,hmac_md5 (hshbuf,chal,cl,p,pl))) ? user : NIL; @@ -234,9 +234,9 @@ char *apop_login (char *chal,char *user,char *md5,int argc,char *argv[]) MD5CONTEXT ctx; char *hex = "0123456789abcdef"; /* see if authentication user */ - if (authuser = strchr (user,'*')) *authuser++ = '\0'; + if ((authuser = strchr (user,'*')) != NULL) *authuser++ = '\0'; /* get password */ - if (s = auth_md5_pwd ((authuser && *authuser) ? authuser : user)) { + if ((s = auth_md5_pwd ((authuser && *authuser) ? authuser : user)) != NULL) { md5_init (&ctx); /* initialize MD5 context */ /* build string to get MD5 digest */ sprintf (tmp,"%.128s%.128s",chal,s); diff --git a/imap/src/c-client/auth_pla.c b/imap/src/c-client/auth_pla.c index 73ca2259..ef991f1d 100644 --- a/imap/src/c-client/auth_pla.c +++ b/imap/src/c-client/auth_pla.c @@ -63,7 +63,7 @@ long auth_plain_client (authchallenge_t challenger,authrespond_t responder, if (!mb->sslflag && !mb->tlsflag) mm_log ("SECURITY PROBLEM: insecure server advertised AUTH=PLAIN",WARN); /* get initial (empty) challenge */ - if (challenge = (*challenger) (stream,&clen)) { + if ((challenge = (*challenger) (stream,&clen)) != NULL) { fs_give ((void **) &challenge); if (clen) { /* abort if challenge non-empty */ mm_log ("Server bug: non-empty initial PLAIN challenge",WARN); @@ -91,7 +91,7 @@ long auth_plain_client (authchallenge_t challenger,authrespond_t responder, for (u = pwd; *u; *t++ = *u++); /* send credentials */ if ((*responder) (stream,response,rlen)) { - if (challenge = (*challenger) (stream,&clen)) + if ((challenge = (*challenger) (stream,&clen)) != NULL) fs_give ((void **) &challenge); else { ++*trial; /* can try again if necessary */ @@ -120,7 +120,7 @@ char *auth_plain_server (authresponse_t responder,int argc,char *argv[]) char *user,*aid,*pass; unsigned long len; /* get user name */ - if (aid = (*responder) ("",0,&len)) { + if ((aid = (*responder) ("",0,&len)) != NULL) { /* note: responders null-terminate */ if ((((unsigned long) ((user = aid + strlen (aid) + 1) - aid)) < len) && (((unsigned long) ((pass = user + strlen (user) + 1) - aid)) < len) && diff --git a/imap/src/c-client/imap4r1.c b/imap/src/c-client/imap4r1.c index f35b14b4..dbd945ec 100644 --- a/imap/src/c-client/imap4r1.c +++ b/imap/src/c-client/imap4r1.c @@ -504,10 +504,10 @@ void imap_lsub (MAILSTREAM *stream,char *ref,char *pat) if (ref && *ref) sprintf (mbx,"%s%s",ref,pat); else strcpy (mbx,pat); - if (s = sm_read (tmp,&sdb)) do if (imap_valid (s) && pmatch (s,mbx)) + if ((s = sm_read (tmp,&sdb)) != NULL) do if (imap_valid (s) && pmatch (s,mbx)) mm_lsub (stream,NIL,s,NIL); /* until no more subscriptions */ - while (s = sm_read (tmp,&sdb)); + while ((s = sm_read (tmp,&sdb)) != NULL); } /* IMAP find list of mailboxes @@ -849,7 +849,7 @@ MAILSTREAM *imap_open (MAILSTREAM *stream) * order, attempt to open via simap, tryssl, rimap, and finally TCP. */ /* try simap */ - else if (reply = imap_rimap (stream,"*imap",&mb,usr,tmp)); + else if ((reply = imap_rimap (stream,"*imap",&mb,usr,tmp)) != NULL); else if (ssld && /* try tryssl if enabled */ (stream->tryssl || mail_parameters (NIL,GET_TRYSSLFIRST,NIL)) && (LOCAL->netstream = @@ -1325,7 +1325,7 @@ void imap_close (MAILSTREAM *stream,long options) } if (LOCAL->threaddata) mail_free_threadnode (&LOCAL->threaddata); /* flush threaders */ - if (thr = LOCAL->cap.threader) while (t = thr) { + if ((thr = LOCAL->cap.threader) != NULL) while ((t = thr) != NULL) { fs_give ((void **) &t->name); thr = t->next; fs_give ((void **) &t); @@ -1507,8 +1507,8 @@ ENVELOPE *imap_structure (MAILSTREAM *stream,unsigned long msgno,BODY **body, set = set->next) { i = (set->first == 0xffffffff) ? stream->nmsgs : min (set->first,stream->nmsgs); - if (j = (set->last == 0xffffffff) ? stream->nmsgs : - min (set->last,stream->nmsgs)) { + if ((j = (set->last == 0xffffffff) ? stream->nmsgs : + min (set->last,stream->nmsgs)) != 0L) { if (i > j) { /* swap the range if backwards */ x = i; i = j; j = x; } @@ -1530,7 +1530,7 @@ ENVELOPE *imap_structure (MAILSTREAM *stream,unsigned long msgno,BODY **body, sprintf (s += strlen (s),",%lu:%lu",i,x); i = 1 + x - i; /* number of messages in this range */ /* still can look ahead some more? */ - if (k = (k > i) ? k - i : 0) + if ((k = (k > i) ? k - i : 0) != 0) /* yes, scan further in this range */ for (i = x + 2; (i <= j) && ((i == msgno) || @@ -1708,7 +1708,7 @@ long imap_msgdata (MAILSTREAM *stream,unsigned long msgno,char *section, else if (!section[0]) /* BODY[] becomes RFC822 */ aatt.text = (void *) ((flags & FT_PEEK) ? "RFC822.PEEK" : "RFC822"); /* nested header */ - else if (t = strstr (section,".HEADER")) { + else if ((t = strstr (section,".HEADER")) != NULL) { aatt.type = (flags & FT_PEEK) ? BODYPEEK : BODYTEXT; args[2] = &acls; /* will need to close section */ aatt.text = (void *) tmp; /* convert .HEADER to .0 */ @@ -1892,7 +1892,7 @@ unsigned long imap_uid (MAILSTREAM *stream,unsigned long msgno) aatt.type = ATOM; aatt.text = (void *) "UID"; args[0] = &aseq; args[1] = &aatt; args[2] = NIL; sprintf (seq,"%lu",msgno); - if (k = imap_uidlookahead) {/* build UID list */ + if ((k = imap_uidlookahead) != 0L) {/* build UID list */ for (i = msgno + 1, s = seq; k && (i <= stream->nmsgs); i++) if (!mail_elt (stream,i)->private.uid) { s += strlen (s); /* find string end, see if nearing end */ @@ -2056,7 +2056,7 @@ long imap_search (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,long flags) LOCAL->filter = T; /* retry, filtering SEARCH results */ for (i = 1; i <= stream->nmsgs; i++) mail_elt (stream,i)->private.filter = NIL; - for (set = ss; set; set = set->next) if (i = set->first) { + for (set = ss; set; set = set->next) if ((i = set->first) != 0L) { /* single message becomes one-message range */ if (!(j = set->last)) j = i; else if (j < i) { /* swap reversed range */ @@ -2658,7 +2658,7 @@ void imap_gc (MAILSTREAM *stream,long gcflags) (*mc) (stream,stream->nmsgs,CH_SIZE); if (gcflags & GC_TEXTS) { /* garbage collect texts? */ if (!stream->scache) for (i = 1; i <= stream->nmsgs; ++i) - if (elt = (MESSAGECACHE *) (*mc) (stream,i,CH_ELT)) + if ((elt = (MESSAGECACHE *) (*mc) (stream,i,CH_ELT)) != NULL) imap_gc_body (elt->private.msg.body); imap_gc_body (stream->body); } @@ -2713,7 +2713,7 @@ void imap_capability (MAILSTREAM *stream) imap_send (stream,"CAPABILITY",NIL); if (!LOCAL->gotcapability) { /* did server get any? */ /* no, flush threaders just in case */ - if (thr = LOCAL->cap.threader) while (t = thr) { + if ((thr = LOCAL->cap.threader) != NULL) while ((t = thr) != NULL) { fs_give ((void **) &t->name); thr = t->next; fs_give ((void **) &t); @@ -2935,7 +2935,7 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) if (LOCAL->referral) fs_give ((void **) &LOCAL->referral); sprintf (CMDBASE,"%s %s",tag,cmd); s = CMDBASE + strlen (CMDBASE); - if (arglst = args) while (arg = *arglst++) { + if ((arglst = args) != NULL) while ((arg = *arglst++) != NULL) { *s++ = ' '; /* delimit argument with space */ switch (arg->type) { case ATOM: /* atom */ @@ -2955,11 +2955,11 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) break; case ASTRING: /* atom or string, must be literal? */ st.size = strlen ((char *) (st.data = (unsigned char *) arg->text)); - if (reply = imap_send_astring (stream,tag,&s,&st,NIL,CMDBASE+MAXCOMMAND)) + if ((reply = imap_send_astring (stream,tag,&s,&st,NIL,CMDBASE+MAXCOMMAND)) != NULL) return reply; break; case LITERAL: /* literal, as a stringstruct */ - if (reply = imap_send_literal (stream,tag,&s,arg->text)) return reply; + if ((reply = imap_send_literal (stream,tag,&s,arg->text)) != NULL) return reply; break; case LIST: /* list of strings */ @@ -2967,16 +2967,16 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) c = '('; /* open paren */ do { /* for each list item */ *s++ = c; /* write prefix character */ - if (reply = imap_send_astring (stream,tag,&s,&list->text,NIL, - CMDBASE+MAXCOMMAND)) return reply; + if ((reply = imap_send_astring (stream,tag,&s,&list->text,NIL, + CMDBASE+MAXCOMMAND)) != NULL) return reply; c = ' '; /* prefix character for subsequent strings */ } - while (list = list->next); + while ((list = list->next) != NULL); *s++ = ')'; /* close list */ break; case SEARCHPROGRAM: /* search program */ - if (reply = imap_send_spgm (stream,tag,CMDBASE,&s,arg->text, - CMDBASE+MAXCOMMAND)) + if ((reply = imap_send_spgm (stream,tag,CMDBASE,&s,arg->text, + CMDBASE+MAXCOMMAND)) != NULL) return reply; break; case SORTPROGRAM: /* search program */ @@ -3061,7 +3061,7 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) break; case LISTMAILBOX: /* astring with wildcards */ st.size = strlen ((char *) (st.data = (unsigned char *) arg->text)); - if (reply = imap_send_astring (stream,tag,&s,&st,T,CMDBASE+MAXCOMMAND)) + if ((reply = imap_send_astring (stream,tag,&s,&st,T,CMDBASE+MAXCOMMAND)) != NULL) return reply; break; @@ -3083,7 +3083,7 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) MESSAGECACHE elt; STRING es; if (!map->date || mail_parse_date (&elt,map->date)) { - if (t = map->flags) { /* flags given? */ + if ((t = map->flags) != NULL) { /* flags given? */ if (*t != '(') { *s++ = '('; /* wrap parens around string */ while (*t) *s++ = *t++; @@ -3095,11 +3095,11 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) if (map->date) { /* date given? */ st.size = strlen ((char *) (st.data = (unsigned char *) mail_date (datetmp,&elt))); - if (reply = imap_send_astring (stream,tag,&s,&st,NIL, - CMDBASE+MAXCOMMAND)) return reply; + if ((reply = imap_send_astring (stream,tag,&s,&st,NIL, + CMDBASE+MAXCOMMAND)) != NULL) return reply; *s++ = ' '; /* delimit with space */ } - if (reply = imap_send_literal (stream,tag,&s,map->message)) + if ((reply = imap_send_literal (stream,tag,&s,map->message)) != NULL) return reply; /* get next message */ if ((*map->af) (stream,map->data,&map->flags,&map->date, @@ -3129,7 +3129,7 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) c = ' '; /* prefix character for subsequent strings */ } } - while (list = list->next); + while ((list = list->next) != NULL); *s++ = ')'; /* close list */ break; default: @@ -3363,26 +3363,26 @@ IMAPPARSEDREPLY *imap_send_spgm (MAILSTREAM *stream,char *tag,char *base, pgm->references,limit)))) return reply; /* all other headers */ - if (hdr = pgm->header) do { + if ((hdr = pgm->header) != NULL) do { *s = imap_send_spgm_trim (base,*s," HEADER "); - if (reply = imap_send_astring (stream,tag,s,&hdr->line,NIL,limit)) + if ((reply = imap_send_astring (stream,tag,s,&hdr->line,NIL,limit)) != NULL) return reply; *(*s)++ = ' '; - if (reply = imap_send_astring (stream,tag,s,&hdr->text,NIL,limit)) + if ((reply = imap_send_astring (stream,tag,s,&hdr->text,NIL,limit)) != NULL) return reply; - } while (hdr = hdr->next); + } while ((hdr = hdr->next) != NULL); for (pgo = pgm->or; pgo; pgo = pgo->next) { *s = imap_send_spgm_trim (base,*s," OR ("); - if (reply = imap_send_spgm (stream,tag,base,s,pgo->first,limit)) + if ((reply = imap_send_spgm (stream,tag,base,s,pgo->first,limit)) != NULL) return reply; for (t = ") ("; *t; *(*s)++ = *t++); - if (reply = imap_send_spgm (stream,tag,base,s,pgo->second,limit)) + if ((reply = imap_send_spgm (stream,tag,base,s,pgo->second,limit)) != NULL) return reply; *(*s)++ = ')'; } for (pgl = pgm->not; pgl; pgl = pgl->next) { *s = imap_send_spgm_trim (base,*s," NOT ("); - if (reply = imap_send_spgm (stream,tag,base,s,pgl->pgm,limit)) + if ((reply = imap_send_spgm (stream,tag,base,s,pgl->pgm,limit)) != NULL) return reply; *(*s)++ = ')'; } @@ -3460,9 +3460,9 @@ IMAPPARSEDREPLY *imap_send_sset (MAILSTREAM *stream,char *tag,char *base, for (t =" ((OR BCC FOO NOT BCC "; *t; *(*s)++ = *t++); /* but broken by a literal */ INIT (&st,mail_string,(void *) "FOO",3); - if (reply = imap_send_literal (stream,tag,s,&st)) return reply; + if ((reply = imap_send_literal (stream,tag,s,&st)) != NULL) return reply; *(*s)++ = ')'; /* close glue */ - if (reply = imap_send_sset (stream,tag,NIL,s,set,prefix,limit)) + if ((reply = imap_send_sset (stream,tag,NIL,s,set,prefix,limit)) != NULL) return reply; *(*s)++ = ')'; /* close second OR argument */ } @@ -3563,7 +3563,7 @@ IMAPPARSEDREPLY *imap_reply (MAILSTREAM *stream,char *tag) { IMAPPARSEDREPLY *reply; while (LOCAL->netstream) { /* parse reply from server */ - if (reply = imap_parse_reply (stream,net_getline (LOCAL->netstream))) { + if ((reply = imap_parse_reply (stream,net_getline (LOCAL->netstream))) != NULL) { /* continuation ready? */ if (!strcmp (reply->tag,"+")) return reply; /* untagged data? */ @@ -3814,7 +3814,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) sprintf (LOCAL->tmp,"Unterminated header section: %.80s", (char *) t); /* point after the text */ - else if (t = strchr (s = t,' ')) *t++ = '\0'; + else if ((t = strchr (s = t,' ')) != NULL) *t++ = '\0'; } if (s && !LOCAL->tmp[0]) { *s++ = '\0'; /* tie off section specifier */ @@ -3918,11 +3918,11 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) } else if (!stream->user_flags[i]) stream->user_flags[i++] = cpystr (s); } - while (s = strtok_r (NIL," )",&r)); + while ((s = strtok_r (NIL," )",&r)) != NULL); else if (!strcmp (reply->key,"SEARCH")) { /* only do something if have text */ if (reply->text && (t = strtok_r (reply->text," ",&r))) do - if (i = strtoul (t,NIL,10)) { + if ((i = strtoul (t,NIL,10)) != 0L) { /* UIDs always passed to main program */ if (LOCAL->uidsearch) mm_searched (stream,i); /* should be a msgno then */ @@ -3931,7 +3931,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) mail_elt (stream,i)->searched = T; if (!stream->silent) mm_searched (stream,i); } - } while (t = strtok_r (NIL," ",&r)); + } while ((t = strtok_r (NIL," ",&r)) != NULL); } else if (!strcmp (reply->key,"SORT")) { sortresults_t sr = (sortresults_t) @@ -3955,7 +3955,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) threadresults_t tr = (threadresults_t) mail_parameters (NIL,GET_THREADRESULTS,NIL); if (LOCAL->threaddata) mail_free_threadnode (&LOCAL->threaddata); - if (s = reply->text) { + if ((s = reply->text) != NULL) { LOCAL->threaddata = imap_parse_thread (stream,&s); if (tr) (*tr) (stream,LOCAL->threaddata); if (s && *s) { @@ -4019,7 +4019,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) char delimiter = '\0'; *s++ = '\0'; /* tie off attribute list */ /* parse attribute list */ - if (t = strtok_r (reply->text+1," ",&r)) do { + if ((t = strtok_r (reply->text+1," ",&r)) != NULL) do { if (!compare_cstring (t,"\\NoInferiors")) i |= LATT_NOINFERIORS; else if (!compare_cstring (t,"\\NoSelect")) i |= LATT_NOSELECT; else if (!compare_cstring (t,"\\Marked")) i |= LATT_MARKED; @@ -4028,7 +4028,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) else if (!compare_cstring (t,"\\HasNoChildren")) i |= LATT_HASNOCHILDREN; /* ignore extension flags */ } - while (t = strtok_r (NIL," ",&r)); + while ((t = strtok_r (NIL," ",&r)) != NULL); switch (*++s) { /* process delimiter */ case 'N': /* NIL */ case 'n': @@ -4039,7 +4039,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) s += 3; /* skip over <delimiter><quote><space> */ } /* parse the mailbox name */ - if (t = imap_parse_astring (stream,&s,reply,&j)) { + if ((t = imap_parse_astring (stream,&s,reply,&j)) != NULL) { /* prepend prefix if requested */ if (LOCAL->prefix && ((strlen (LOCAL->prefix) + j) < IMAPTMPLEN)) sprintf (s = LOCAL->tmp,"%s%s",LOCAL->prefix,(char *) t); @@ -4057,7 +4057,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) mail_free_namespace (&LOCAL->namespace[2]); } else LOCAL->namespace = (NAMESPACE **) fs_get (3 * sizeof (NAMESPACE *)); - if (s = reply->text) { /* parse namespace results */ + if ((s = reply->text) != NULL) { /* parse namespace results */ LOCAL->namespace[0] = imap_parse_namespace (stream,&s,reply); LOCAL->namespace[1] = imap_parse_namespace (stream,&s,reply); LOCAL->namespace[2] = imap_parse_namespace (stream,&s,reply); @@ -4177,10 +4177,10 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) if ((qc->name = imap_parse_astring (stream,&s,reply,NIL)) && s && (*s++ == ' ') && (isdigit (*s) || (LOCAL->loser && (*s == '-')))) { if (isdigit (*s)) qc->usage = strtoul (s,(char **) &s,10); - else if (t = strchr (s,' ')) t = s; + else if ((t = strchr (s,' ')) != NULL) t = s; if ((*s++ == ' ') && (isdigit (*s) || (LOCAL->loser &&(*s == '-')))){ if (isdigit (*s)) qc->limit = strtoul (s,(char **) &s,10); - else if (t = strpbrk (s," )")) t = s; + else if ((t = strpbrk (s," )")) != NULL) t = s; /* another resource follows? */ if (*s == ' ') continue; /* end of resource list? */ @@ -4277,7 +4277,7 @@ void imap_parse_response (MAILSTREAM *stream,char *text,long errflg,long ntfy) if (text && (*text == '[') && (t = strchr (s = text + 1,']')) && ((i = t - s) < IMAPTMPLEN)) { LOCAL->tmp[i] = '\0'; /* make mungable copy of text code */ - if (s = strchr (strncpy (t = LOCAL->tmp,s,i),' ')) *s++ = '\0'; + if ((s = strchr (strncpy (t = LOCAL->tmp,s,i),' ')) != NULL) *s++ = '\0'; if (s) { /* have argument? */ ntfy = NIL; /* suppress mm_notify if normal SELECT data */ if (!compare_cstring (t,"CAPABILITY")) imap_parse_capabilities(stream,s); @@ -4287,7 +4287,7 @@ void imap_parse_response (MAILSTREAM *stream,char *text,long errflg,long ntfy) stream->perm_seen = stream->perm_deleted = stream->perm_answered = stream->perm_draft = stream->kwd_create = NIL; stream->perm_user_flags = NIL; - if (s = strtok_r (s+1," ",&r)) do { + if ((s = strtok_r (s+1," ",&r)) != NULL) do { if (*s == '\\') { /* system flags */ if (!compare_cstring (s,"\\Seen")) stream->perm_seen = T; else if (!compare_cstring (s,"\\Deleted")) @@ -4301,7 +4301,7 @@ void imap_parse_response (MAILSTREAM *stream,char *text,long errflg,long ntfy) } else stream->perm_user_flags |= imap_parse_user_flag (stream,s); } - while (s = strtok_r (NIL," ",&r)); + while ((s = strtok_r (NIL," ",&r)) != NULL); } else if (!compare_cstring (t,"UIDVALIDITY") && (j = strtoul (s,NIL,10))){ @@ -4311,7 +4311,7 @@ void imap_parse_response (MAILSTREAM *stream,char *text,long errflg,long ntfy) stream->uid_validity = j; /* purge any UIDs in cache */ for (j = 1; j <= stream->nmsgs; j++) - if (elt = (MESSAGECACHE *) (*mc) (stream,j,CH_ELT)) + if ((elt = (MESSAGECACHE *) (*mc) (stream,j,CH_ELT)) != NULL) elt->private.uid = 0; } } @@ -4864,7 +4864,7 @@ unsigned char *imap_parse_astring (MAILSTREAM *stream,unsigned char **txtptr, c && (c > ' ') && (c != '(') && (c != ')') && (c != '{') && (c != '%') && (c != '*') && (c != '"') && (c != '\\') && (c < 0x80); c = *++*txtptr); - if (i = *txtptr - s) { /* atom ends at atom_special */ + if ((i = *txtptr - s) != 0L) { /* atom ends at atom_special */ if (len) *len = i; /* return length of atom */ ret = strncpy ((char *) fs_get (i + 1),s,i); ret[i] = '\0'; /* tie off string */ @@ -4984,7 +4984,7 @@ unsigned char *imap_parse_string (MAILSTREAM *stream,unsigned char **txtptr, string = (char *) fs_get ((size_t) i + 1); *string = '\0'; /* init in case getbuffer fails */ /* get the literal */ - if (rp) for (k = 0; j = min ((long) MAILTMPLEN,(long) i); i -= j) { + if (rp) for (k = 0; (j = min ((long) MAILTMPLEN,(long) i)) != 0L; i -= j) { net_getbuffer (LOCAL->netstream,j,string + k); (*rp) (md,k += j); } @@ -4992,7 +4992,7 @@ unsigned char *imap_parse_string (MAILSTREAM *stream,unsigned char **txtptr, } fs_give ((void **) &reply->line); if (flags && string) /* need to filter newlines? */ - for (st = string; st = strpbrk (st,"\015\012\011"); *st++ = ' '); + for (st = string; (st = strpbrk (st,"\015\012\011")) != NULL; *st++ = ' '); /* get new reply text line */ if (!(reply->line = net_getline (LOCAL->netstream))) reply->line = cpystr (""); @@ -5142,7 +5142,7 @@ void imap_parse_body_structure (MAILSTREAM *stream,BODY *body, /* parse it */ imap_parse_body_structure (stream,&part->body,txtptr,reply); } while (**txtptr == '(');/* for each body part */ - if (body->subtype = imap_parse_string(stream,txtptr,reply,NIL,NIL,LONGT)) + if ((body->subtype = imap_parse_string(stream,txtptr,reply,NIL,NIL,LONGT)) != NULL) ucase (body->subtype); else { mm_notify (stream,"Missing multipart subtype",WARN); @@ -5182,7 +5182,7 @@ void imap_parse_body_structure (MAILSTREAM *stream,BODY *body, body->type = TYPEOTHER; /* assume unknown type */ body->encoding = ENCOTHER;/* and unknown encoding */ /* parse type */ - if (s = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT)) { + if ((s = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT)) != NULL) { ucase (s); /* application always gets uppercase form */ for (i = 0; /* look in existing table */ (i <= TYPEMAX) && body_types[i] && strcmp (s,body_types[i]); i++); @@ -5195,7 +5195,7 @@ void imap_parse_body_structure (MAILSTREAM *stream,BODY *body, } if (s) fs_give ((void **) &s); } - if (body->subtype = imap_parse_string(stream,txtptr,reply,NIL,NIL,LONGT)) + if ((body->subtype = imap_parse_string(stream,txtptr,reply,NIL,NIL,LONGT)) != NULL) ucase (body->subtype); /* parse subtype */ else { mm_notify (stream,"Missing body subtype",WARN); @@ -5206,7 +5206,7 @@ void imap_parse_body_structure (MAILSTREAM *stream,BODY *body, body->id = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT); body->description = imap_parse_string (stream,txtptr,reply,NIL,NIL, LONGT); - if (s = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT)) { + if ((s = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT)) != NULL) { ucase (s); /* application always gets uppercase form */ for (i = 0; /* search for body encoding */ (i <= ENCMAX) && body_encodings[i] && strcmp(s,body_encodings[i]); @@ -5410,7 +5410,7 @@ STRINGLIST *imap_parse_language (MAILSTREAM *stream,unsigned char **txtptr, STRINGLIST *ret = NIL; /* language is a list */ if (*++*txtptr == '(') ret = imap_parse_stringlist (stream,txtptr,reply); - else if (s = imap_parse_string (stream,txtptr,reply,NIL,&i,LONGT)) { + else if ((s = imap_parse_string (stream,txtptr,reply,NIL,&i,LONGT)) != NULL) { (ret = mail_newstringlist ())->text.data = (unsigned char *) s; ret->text.size = i; } @@ -5479,7 +5479,7 @@ void imap_parse_extension (MAILSTREAM *stream,unsigned char **txtptr, break; case '{': /* get size of literal */ ++*txtptr; /* bump past open squiggle */ - if (i = strtoul (*txtptr,(char **) txtptr,10)) do + if ((i = strtoul (*txtptr,(char **) txtptr,10)) != 0L) do net_getbuffer (LOCAL->netstream,j = min (i,(long) IMAPTMPLEN - 1), LOCAL->tmp); while (i -= j); @@ -5515,7 +5515,7 @@ void imap_parse_capabilities (MAILSTREAM *stream,char *t) THREADER *thr,*th; if (!LOCAL->gotcapability) { /* need to save previous capabilities? */ /* no, flush threaders */ - if (thr = LOCAL->cap.threader) while (th = thr) { + if ((thr = LOCAL->cap.threader) != NULL) while ((th = thr) != NULL) { fs_give ((void **) &th->name); thr = th->next; fs_give ((void **) &th); @@ -5558,7 +5558,7 @@ void imap_parse_capabilities (MAILSTREAM *stream,char *t) ((t[2] == 'R') || (t[2] == 'r')) && ((t[3] == 'T') || (t[3] == 't'))) LOCAL->cap.sort = T; /* capability with value? */ - else if (s = strchr (t,'=')) { + else if ((s = strchr (t,'=')) != NULL) { *s++ = '\0'; /* separate token from value */ if (!compare_cstring (t,"THREAD") && !LOCAL->loser) { THREADER *thread = (THREADER *) fs_get (sizeof (THREADER)); @@ -5647,7 +5647,7 @@ char *imap_reform_sequence (MAILSTREAM *stream,char *sequence,long flags) /* flush old reformed sequence */ if (LOCAL->reform) fs_give ((void **) &LOCAL->reform); rs = LOCAL->reform = (char *) fs_get (1+ strlen (sequence)); - for (s = sequence; t = strpbrk (s,",:"); ) switch (*t++) { + for (s = sequence; (t = strpbrk (s,",:")) != NULL; ) switch (*t++) { case ',': /* single message */ strncpy (rs,s,i = t - s); /* copy string up to that point */ rs += i; /* advance destination pointer */ diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c index da703a0d..1b6f93c3 100644 --- a/imap/src/c-client/mail.c +++ b/imap/src/c-client/mail.c @@ -210,7 +210,7 @@ void *mm_cache (MAILSTREAM *stream,unsigned long msgno,long op) break; case CH_EXPUNGE: /* expunge cache slot */ for (i = msgno - 1; msgno < stream->nmsgs; i++,msgno++) { - if (stream->cache[i] = stream->cache[msgno]) + if ((stream->cache[i] = stream->cache[msgno]) != NULL) stream->cache[i]->msgno = msgno; stream->sc[i] = stream->sc[msgno]; } @@ -388,32 +388,32 @@ void *mail_parameters (MAILSTREAM *stream,long function,void *value) case ENABLE_DRIVER: for (d = maildrivers; d && compare_cstring (d->name,(char *) value); d = d->next); - if (ret = (void *) d) d->flags &= ~DR_DISABLE; + if ((ret = (void *) d) != NULL) d->flags &= ~DR_DISABLE; break; case DISABLE_DRIVER: for (d = maildrivers; d && compare_cstring (d->name,(char *) value); d = d->next); - if (ret = (void *) d) d->flags |= DR_DISABLE; + if ((ret = (void *) d) != NULL) d->flags |= DR_DISABLE; break; case ENABLE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); - if (ret = (void *) a) a->flags &= ~AU_DISABLE; + if ((ret = (void *) a) != NULL) a->flags &= ~AU_DISABLE; break; case DISABLE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); - if (ret = (void *) a) a->flags |= AU_DISABLE; + if ((ret = (void *) a) != NULL) a->flags |= AU_DISABLE; break; case UNHIDE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); - if (ret = (void *) a) a->flags &= ~AU_HIDE; + if ((ret = (void *) a) != NULL) a->flags &= ~AU_HIDE; break; case HIDE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); - if (ret = (void *) a) a->flags |= AU_HIDE; + if ((ret = (void *) a) != NULL) a->flags |= AU_HIDE; break; case SET_EXTERNALAUTHID: if (value) { /* setting external authentication ID */ @@ -647,16 +647,16 @@ void *mail_parameters (MAILSTREAM *stream,long function,void *value) if (stream) ret = (void *) stream->snarf.name; break; default: - if (r = smtp_parameters (function,value)) ret = r; - if (r = env_parameters (function,value)) ret = r; - if (r = tcp_parameters (function,value)) ret = r; - if (r = utf8_parameters (function,value)) ret = r; + if ((r = smtp_parameters (function,value)) != NULL) ret = r; + if ((r = env_parameters (function,value)) != NULL) ret = r; + if ((r = tcp_parameters (function,value)) != NULL) ret = r; + if ((r = utf8_parameters (function,value)) != NULL) ret = r; if (stream && stream->dtb) {/* if have stream, do for its driver only */ - if (r = (*stream->dtb->parameters) (function,value)) ret = r; + if ((r = (*stream->dtb->parameters) (function,value)) != NULL) ret = r; } /* else do all drivers */ else for (d = maildrivers; d; d = d->next) - if (r = (d->parameters) (function,value)) ret = r; + if ((r = (d->parameters) (function,value)) != NULL) ret = r; break; } return ret; @@ -770,7 +770,7 @@ long mail_valid_net_parse_work (char *name,NETMBX *mb,char *service) break; case '/': /* switch */ /* find delimiter */ - if (t = strpbrk (s = t,"/:=")) { + if ((t = strpbrk (s = t,"/:=")) != NULL) { c = *t; /* remember delimiter for later */ *t++ = '\0'; /* tie off switch name */ } @@ -788,7 +788,7 @@ long mail_valid_net_parse_work (char *name,NETMBX *mb,char *service) arg[i] = '\0'; /* tie off argument */ } else { /* non-quoted argument */ - if (t = strpbrk (v = t,"/:")) { + if ((t = strpbrk (v = t,"/:")) != NULL) { c = *t; /* remember delimiter for later */ *t++ = '\0'; /* tie off switch name */ } @@ -937,7 +937,7 @@ void mail_list (MAILSTREAM *stream,char *ref,char *pat) else do if (!((d->flags & DR_DISABLE) || ((d->flags & DR_LOCAL) && remote))) (d->list) (NIL,ref,pat); - while (d = d->next); /* until at the end */ + while ((d = d->next) != NULL); /* until at the end */ } /* Mail list subscribed mailboxes @@ -970,7 +970,7 @@ void mail_lsub (MAILSTREAM *stream,char *ref,char *pat) else do if (!((d->flags & DR_DISABLE) || ((d->flags & DR_LOCAL) && remote))) (d->lsub) (NIL,ref,pat); - while (d = d->next); /* until at the end */ + while ((d = d->next) != NULL); /* until at the end */ } /* Mail subscribe to mailbox @@ -1014,7 +1014,7 @@ long mail_create (MAILSTREAM *stream,char *mailbox) size_t i; DRIVER *d; /* never allow names with newlines */ - if (s = strpbrk (mailbox,"\015\012")) { + if ((s = strpbrk (mailbox,"\015\012")) != NULL) { MM_LOG ("Can't create mailbox with such a name",ERROR); return NIL; } @@ -1030,7 +1030,7 @@ long mail_create (MAILSTREAM *stream,char *mailbox) return NIL; } /* validate name */ - if (s = mail_utf7_valid (mailbox)) { + if ((s = mail_utf7_valid (mailbox)) != NULL) { sprintf (tmp,"Can't create %s: %.80s",s,mailbox); MM_LOG (tmp,ERROR); return NIL; @@ -1110,7 +1110,7 @@ long mail_rename (MAILSTREAM *stream,char *old,char *newname) DRIVER *dtb = mail_valid (stream,old,"rename mailbox"); if (!dtb) return NIL; /* validate name */ - if (s = mail_utf7_valid (newname)) { + if ((s = mail_utf7_valid (newname)) != NULL) { sprintf (tmp,"Can't rename to %s: %.80s",s,newname); MM_LOG (tmp,ERROR); return NIL; @@ -1217,7 +1217,7 @@ MAILSTREAM *mail_open (MAILSTREAM *stream,char *name,long options) ((name[3] == 'V') || (name[3] == 'v')) && ((name[4] == 'E') || (name[4] == 'e')) && (c = name[5]) && (s = strchr (name+6,c)) && (i = s - (name + 6)) && (i < MAILTMPLEN)) { - if (stream = mail_open (stream,s+1,options)) { + if ((stream = mail_open (stream,s+1,options)) != NULL) { strncpy (tmp,name+6,i); /* copy snarf mailbox name */ tmp[i] = '\0'; /* tie off name */ mail_parameters (stream,SET_SNARFMAILBOXNAME,(void *) tmp); @@ -1234,7 +1234,7 @@ MAILSTREAM *mail_open (MAILSTREAM *stream,char *name,long options) ((name[3] == 'P') || (name[3] == 'p')) && mail_valid_net_parse_work (name+4,&mb,"pop3") && !strcmp (mb.service,"pop3") && !mb.anoflag && !mb.readonlyflag) { - if (stream = mail_open (stream,mb.mailbox,options)) { + if ((stream = mail_open (stream,mb.mailbox,options)) != NULL) { sprintf (tmp,"{%.255s",mb.host); if (mb.port) sprintf (tmp + strlen (tmp),":%lu",mb.port); if (mb.user[0]) sprintf (tmp + strlen (tmp),"/user=%.64s",mb.user); @@ -1265,7 +1265,7 @@ MAILSTREAM *mail_open (MAILSTREAM *stream,char *name,long options) ((name[6] == 'R') || (name[6] == 'r')) && (name[7] == '.')) { sprintf (tmp,"%.80s",name+8); /* tie off name at likely delimiter */ - if (s = strpbrk (tmp,"/\\:")) *s++ = '\0'; + if ((s = strpbrk (tmp,"/\\:")) != NULL) *s++ = '\0'; else { sprintf (tmp,"Can't resolve mailbox %.80s: bad driver syntax",name); MM_LOG (tmp,ERROR); @@ -1565,7 +1565,7 @@ ENVELOPE *mail_fetch_structure (MAILSTREAM *stream,unsigned long msgno, if (stream->dtb && stream->dtb->structure) return (*stream->dtb->structure) (stream,msgno,body,flags); if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return NIL; /* must get UID/msgno map first */ } elt = mail_elt (stream,msgno);/* get elt for real message number */ @@ -1747,7 +1747,7 @@ char *mail_fetch_header (MAILSTREAM *stream,unsigned long msgno,char *section, if (len) *len = 0; /* default return size */ if (section && (strlen (section) > (MAILTMPLEN - 20))) return ""; if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return ""; /* must get UID/msgno map first */ } elt = mail_elt (stream,msgno);/* get cache data */ @@ -1800,8 +1800,8 @@ char *mail_fetch_header (MAILSTREAM *stream,unsigned long msgno,char *section, else { /* top-level header fetch */ /* mark message seen */ markseen (stream,elt,flags); - if (rt.data = (unsigned char *) - (*stream->dtb->header) (stream,msgno,&rt.size,flags)) { + if ((rt.data = (unsigned char *) + (*stream->dtb->header) (stream,msgno,&rt.size,flags)) != NULL) { /* make a safe copy if need to filter */ if (lines) textcpy (t = &stream->text,&rt); else t = &rt; /* top level header */ @@ -1838,7 +1838,7 @@ char *mail_fetch_text (MAILSTREAM *stream,unsigned long msgno,char *section, memset (&stream->private.string,NIL,sizeof (STRING)); if (section && (strlen (section) > (MAILTMPLEN - 20))) return ""; if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return ""; /* must get UID/msgno map first */ } elt = mail_elt (stream,msgno);/* get cache data */ @@ -1893,7 +1893,7 @@ char *mail_fetch_mime (MAILSTREAM *stream,unsigned long msgno,char *section, if (len) *len = 0; /* default return size */ if (section && (strlen (section) > (MAILTMPLEN - 20))) return ""; if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return ""; /* must get UID/msgno map first */ } flags &= ~FT_INTERNAL; /* can't win with this set */ @@ -1976,7 +1976,7 @@ char *mail_fetch_body (MAILSTREAM *stream,unsigned long msgno,char *section, } if (len) *len = 0; /* default return size */ if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return ""; /* must get UID/msgno map first */ } /* must have body */ @@ -2034,7 +2034,7 @@ long mail_partial_text (MAILSTREAM *stream,unsigned long msgno,char *section, if (!mailgets) fatal ("mail_partial_text() called without a mailgets!"); if (section && (strlen (section) > (MAILTMPLEN - 20))) return NIL; if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return NIL; /* must get UID/msgno map first */ } elt = mail_elt (stream,msgno);/* get cache data */ @@ -2104,7 +2104,7 @@ long mail_partial_body (MAILSTREAM *stream,unsigned long msgno,char *section, return mail_partial_text (stream,msgno,NIL,first,last,flags); if (!mailgets) fatal ("mail_partial_body() called without a mailgets!"); if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return NIL; /* must get UID/msgno map first */ } /* must have body */ @@ -2254,7 +2254,7 @@ unsigned long mail_msgno (MAILSTREAM *stream,unsigned long uid) if (uid == firstuid) return first; if (uid == lastuid) return last; /* have anything between endpoints? */ - if (delta = ((last - first) / 2)) { + if ((delta = ((last - first) / 2)) != 0L){ if ((miduid = mail_elt (stream,middle = first + delta)->private.uid) == uid) return middle; /* found match in middle */ @@ -2408,7 +2408,7 @@ long mail_search_default (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm, unsigned long i; char *msg; /* make sure that charset is good */ - if (msg = utf8_badcharset (charset)) { + if ((msg = utf8_badcharset (charset)) != NULL) { MM_LOG (msg,ERROR); /* output error */ fs_give ((void **) &msg); return NIL; @@ -2634,7 +2634,7 @@ long mail_append_multiple (MAILSTREAM *stream,char *mailbox,append_t af, } else ret = SAFE_APPEND (d,stream,mailbox + (s - tmp),af,data); } - else if (d = mail_valid (stream,mailbox,NIL)) + else if ((d = mail_valid (stream,mailbox,NIL)) != NULL) ret = SAFE_APPEND (d,stream,mailbox,af,data); /* No driver, try for TRYCREATE if no stream. Note that we use the * createProto here, not the appendProto, since the dummy driver already @@ -2672,7 +2672,7 @@ void mail_gc (MAILSTREAM *stream,long gcflags) } /* garbage collect per-message stuff */ for (i = 1; i <= stream->nmsgs; i++) - if (elt = (MESSAGECACHE *) (*mailcache) (stream,i,CH_ELT)) + if ((elt = (MESSAGECACHE *) (*mailcache) (stream,i,CH_ELT)) != NULL) mail_gc_msg (&elt->private.msg,gcflags); } @@ -2744,7 +2744,7 @@ BODY *mail_body_section (BODY *b, unsigned char *section) /* multipart content? */ if (b->type == TYPEMULTIPART) { /* yes, find desired part */ - if (pt = b->nested.part) while (--i && (pt = pt->next)); + if ((pt = b->nested.part) != NULL) while (--i && (pt = pt->next)); if (!pt) return NIL; /* bad specifier */ b = &pt->body; /* note new body */ } @@ -3122,7 +3122,7 @@ long mail_parse_date (MESSAGECACHE *elt,unsigned char *s) t = localtime (&tn); /* get local minutes since midnight */ mi = t->tm_hour * 60 + t->tm_min; ms = t->tm_yday; /* note Julian day */ - if (t = gmtime (&tn)) { /* minus UTC minutes since midnight */ + if ((t = gmtime (&tn)) != NULL) { /* minus UTC minutes since midnight */ mi -= t->tm_hour * 60 + t->tm_min; /* ms can be one of: * 36x local time is December 31, UTC is January 1, offset -24 hours @@ -3343,7 +3343,7 @@ long mail_uid_sequence (MAILSTREAM *stream,unsigned char *sequence) case ',': /* single message */ ++sequence; /* skip the delimiter, fall into end case */ case '\0': /* end of sequence, mark this message */ - if (x = mail_msgno (stream,i)) mail_elt (stream,x)->sequence = T; + if ((x = mail_msgno (stream,i)) != 0L) mail_elt (stream,x)->sequence = T; break; default: /* anything else is a syntax error! */ MM_LOG ("UID sequence syntax error",ERROR); @@ -3376,7 +3376,7 @@ long mail_match_lines (STRINGLIST *lines,STRINGLIST *msglines,long flags) } if (!m) return NIL; /* didn't find in the list */ } - while (lines = lines->next); + while ((lines = lines->next) != NULL); return T; /* all lines found */ } @@ -3408,7 +3408,7 @@ unsigned long mail_filter (char *text,unsigned long len,STRINGLIST *lines, *t++ = *s++); *t = '\0'; /* tie off */ notfound = T; /* not found yet */ - if (i = t - tmp) /* see if found in header */ + if ((i = t - tmp) != 0L) /* see if found in header */ for (hdrs = lines; hdrs && notfound; hdrs = hdrs->next) if ((hdrs->text.size == i) && !compare_csizedtext (tmp,&hdrs->text)) notfound = NIL; @@ -3660,7 +3660,7 @@ long mail_search_header_text (char *s,STRINGLIST *st) { SIZEDTEXT h; /* have any text? */ - if (h.data = (unsigned char *) s) { + if ((h.data = (unsigned char *) s) != NULL) { h.size = strlen (s); /* yes, get its size */ return mail_search_header (&h,st); } @@ -3711,7 +3711,7 @@ long mail_search_text (MAILSTREAM *stream,unsigned long msgno,char *section, for (stream->private.search.string = s; st;) { s->text.data = st->text.data; s->text.size = st->text.size; - if (st = st->next) s = s->next = mail_newstringlist (); + if ((st = st->next) != NULL) s = s->next = mail_newstringlist (); } stream->private.search.text = NIL; if (flags) { /* want header? */ @@ -3793,7 +3793,7 @@ long mail_search_body (MAILSTREAM *stream,unsigned long msgno,BODY *body, if (h.data != st.data) fs_give ((void **) &h.data); } } - if (body = body->nested.msg->body) + if ((body = body->nested.msg->body) != NULL) ret = (body->type == TYPEMULTIPART) ? mail_search_body (stream,msgno,body,(prefix ? prefix : ""), section - 1,flags) : @@ -3810,14 +3810,14 @@ long mail_search_body (MAILSTREAM *stream,unsigned long msgno,BODY *body, if (!strcmp (param->attribute,"CHARSET")) t = param->value; switch (body->encoding) { /* what encoding? */ case ENCBASE64: - if (st.data = (unsigned char *) - rfc822_base64 ((unsigned char *) s,i,&st.size)) { + if ((st.data = (unsigned char *) + rfc822_base64 ((unsigned char *) s,i,&st.size)) != NULL) { ret = mail_search_string (&st,t,&stream->private.search.string); fs_give ((void **) &st.data); } break; case ENCQUOTEDPRINTABLE: - if (st.data = rfc822_qprint ((unsigned char *) s,i,&st.size)) { + if ((st.data = rfc822_qprint ((unsigned char *) s,i,&st.size)) != NULL) { ret = mail_search_string (&st,t,&stream->private.search.string); fs_give ((void **) &st.data); } @@ -3898,7 +3898,7 @@ long mail_search_keyword (MAILSTREAM *stream,MESSAGECACHE *elt,STRINGLIST *st, break; } if (flag && !j) return NIL; - } while (st = st->next); + } while ((st = st->next) != NULL); tf = elt->user_flags & f; /* get set flags which match */ return flag ? (f == tf) : !tf; } @@ -3927,9 +3927,9 @@ long mail_search_addr (ADDRESS *adr,STRINGLIST *st) /* write address list */ for (txt.size = 0,a = adr; a; a = a->next) { k = (tadr.mailbox = a->mailbox) ? 4 + 2*strlen (a->mailbox) : 3; - if (tadr.personal = a->personal) k += 3 + 2*strlen (a->personal); - if (tadr.adl = a->adl) k += 3 + 2*strlen (a->adl); - if (tadr.host = a->host) k += 3 + 2*strlen (a->host); + if ((tadr.personal = a->personal) != NULL) k += 3 + 2*strlen (a->personal); + if ((tadr.adl = a->adl) != NULL) k += 3 + 2*strlen (a->adl); + if ((tadr.host = a->host) != NULL) k += 3 + 2*strlen (a->host); if (tadr.personal || tadr.adl) k += 2; if (k < (SENDBUFLEN-10)) {/* ignore ridiculous addresses */ tmp[0] = '\0'; @@ -4164,7 +4164,7 @@ int mail_criteria_string (STRINGLIST **s,char **r) if (strchr (c+1,'"')) end = "\""; else return NIL; /* falls through */ default: /* atomic string */ - if (d = strtok_r (c,end,r)) n = strlen (d); + if ((d = strtok_r (c,end,r)) != NULL) n = strlen (d); else return NIL; break; } @@ -4375,7 +4375,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&maildateline,NIL, FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4411,7 +4411,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&mailfromline,NIL, FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) { - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4419,7 +4419,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) break; case 'f': /* continuation but with extra "From:" */ case 'F': - if (v = strchr (v,':')) { + if ((v = strchr (v,':')) != NULL) { memmove (x,v+1,strlen (v+1)); break; } @@ -4445,7 +4445,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&mailtonline,NIL, FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) { - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4453,7 +4453,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) break; case 't': /* continuation but with extra "To:" */ case 'T': - if (v = strchr (v,':')) { + if ((v = strchr (v,':')) != NULL) { memmove (x,v+1,strlen (v+1)); break; } @@ -4479,7 +4479,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&mailccline,NIL, FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) { - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4487,7 +4487,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) break; case 'c': /* continuation but with extra "cc:" */ case 'C': - if (v = strchr (v,':')) { + if ((v = strchr (v,':')) != NULL) { memmove (x,v+1,strlen (v+1)); break; } @@ -4514,7 +4514,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&mailsubline, NIL,FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4548,7 +4548,7 @@ unsigned int mail_strip_subject (char *t,char **ret) unsigned long i,slen; char c,*s,*x; unsigned int refwd = NIL; - if (src.size = strlen (t)) { /* have non-empty subject? */ + if ((src.size = strlen (t)) != 0) { /* have non-empty subject? */ src.data = (unsigned char *) t; /* Step 1 */ /* make copy, convert MIME2 if needed */ @@ -4704,7 +4704,7 @@ int mail_sort_compare (const void *a1,const void *a2) } if (pgm->reverse) i = -i; /* flip results if necessary */ } - while (pgm = i ? NIL : pgm->next); + while ((pgm = i ? NIL : pgm->next) != NULL); /* return result, avoid 0 if at all possible */ return i ? i : compare_ulong (s1->num,s2->num); } @@ -4831,7 +4831,7 @@ THREADNODE *mail_thread_orderedsubject (MAILSTREAM *stream,char *charset, pgm.function = SORTSUBJECT; pgm.next = &pgm2; pgm2.function = SORTDATE; - if (lst = (*sorter) (stream,charset,spg,&pgm,flags & ~(SE_FREE | SE_UID))){ + if ((lst = (*sorter) (stream,charset,spg,&pgm,flags & ~(SE_FREE | SE_UID))) != NULL){ if (*(ls = lst)) { /* create thread */ /* note first subject */ cur = top = thr = mail_newthreadnode @@ -4945,7 +4945,7 @@ THREADNODE *mail_thread_references (MAILSTREAM *stream,char *charset, /* still missing data? */ if (!s->date || !s->subject || !s->message_id || !s->references) { /* try to load data from envelope */ - if (env = mail_fetch_structure (stream,s->num,NIL,NIL)) { + if ((env = mail_fetch_structure (stream,s->num,NIL,NIL)) != NULL) { if (!s->date && env->date && mail_parse_date (&telt,env->date)) s->date = mail_longdate (&telt); if (!s->subject && env->subject) @@ -4993,7 +4993,7 @@ THREADNODE *mail_thread_references (MAILSTREAM *stream,char *charset, /* Step 1A */ if ((st = (s = sc[i])->references) && st->text.data) for (con = hash_lookup_and_add (ht,(char *) st->text.data,NIL, - THREADLINKS); st = st->next; con = nxc) { + THREADLINKS); (st = st->next) != NULL; con = nxc) { nxc = hash_lookup_and_add (ht,(char *) st->text.data,NIL,THREADLINKS); /* only if no parent & won't introduce loop */ if (!PARENT (nxc) && !mail_thread_check_child (con,nxc)) { @@ -5231,11 +5231,11 @@ STRINGLIST *mail_thread_parse_references (char *s,long flag) STRINGLIST *ret = NIL; STRINGLIST *cur; /* found first reference? */ - if (t = mail_thread_parse_msgid (s,&s)) { + if ((t = mail_thread_parse_msgid (s,&s)) != NULL) { (ret = mail_newstringlist ())->text.data = (unsigned char *) t; ret->text.size = strlen (t); if (flag) /* parse subsequent references */ - for (cur = ret; t = mail_thread_parse_msgid (s,&s); cur = cur->next) { + for (cur = ret; (t = mail_thread_parse_msgid (s,&s)) != NULL; cur = cur->next) { (cur->next = mail_newstringlist ())->text.data = (unsigned char *) t; cur->next->text.size = strlen (t); } @@ -5337,7 +5337,7 @@ THREADNODE *mail_thread_c2node (MAILSTREAM *stream,container_t con,long flags) /* attach sequence or UID for non-dummy */ if (s) cur->num = (flags & SE_UID) ? mail_uid (stream,s->num) : s->num; /* attach the children */ - if (nxt = CHILD (con)) cur->next = mail_thread_c2node (stream,nxt,flags); + if ((nxt = CHILD (con)) != NULL) cur->next = mail_thread_c2node (stream,nxt,flags); } return ret; } @@ -5488,7 +5488,7 @@ long mail_parse_flags (MAILSTREAM *stream,char *flag,unsigned long *uf) tmp[j] = '\0'; while ((t = n) && *t) { /* parse the flags */ /* find end of flag */ - if (n = strchr (t,' ')) *n++ = '\0'; + if ((n = strchr (t,' ')) != NULL) *n++ = '\0'; if (*t == '\\') { /* system flag? */ if (!compare_cstring (t+1,"SEEN")) f |= fSEEN; else if (!compare_cstring (t+1,"DELETED")) f |= fDELETED; @@ -6256,7 +6256,7 @@ NETSTREAM *net_open_work (NETDRIVER *dv,char *host,char *service, service = NIL; /* yes, override service name */ port = portoverride; /* use that instead of default port */ } - if (tstream = (*dv->open) (host,service,port | flags)) { + if ((tstream = (*dv->open) (host,service,port | flags)) != NULL){ stream = (NETSTREAM *) fs_get (sizeof (NETSTREAM)); stream->stream = tstream; stream->dtb = dv; @@ -6278,7 +6278,7 @@ NETSTREAM *net_aopen (NETDRIVER *dv,NETMBX *mb,char *service,char *user) NETSTREAM *stream = NIL; void *tstream; if (!dv) dv = &tcpdriver; /* default to TCP driver */ - if (tstream = (*dv->aopen) (mb,service,user)) { + if ((tstream = (*dv->aopen) (mb,service,user)) != NULL) { stream = (NETSTREAM *) fs_get (sizeof (NETSTREAM)); stream->stream = tstream; stream->dtb = dv; diff --git a/imap/src/c-client/misc.c b/imap/src/c-client/misc.c index bcbc49e2..0f26a9c3 100644 --- a/imap/src/c-client/misc.c +++ b/imap/src/c-client/misc.c @@ -269,7 +269,7 @@ long ssearch (unsigned char *base,long basec,unsigned char *pat,long patc) for (i = 0; i < patc; i++) mask[pat[i]] = T; /* Boyer-Moore type search */ for (i = --patc, c = pat[i]; i < basec; i += (mask[c] ? 1 : (j + 1))) - for (j = patc,c = base[k = i]; (c == pat[j]); j--,c = base[--k]) + for (j = patc,c = base[k = i]; c == pat[j]; j--,c = base[--k]) if (!j) return T; /* found a match! */ } return NIL; /* pattern not found */ @@ -311,7 +311,7 @@ void hash_reset (HASHTAB *hashtab) size_t i; HASHENT *ent,*nxt; /* free each hash entry */ - for (i = 0; i < hashtab->size; i++) if (ent = hashtab->table[i]) + for (i = 0; i < hashtab->size; i++) if ((ent = hashtab->table[i]) != NULL) for (hashtab->table[i] = NIL; ent; ent = nxt) { nxt = ent->next; /* get successor */ fs_give ((void **) &ent); /* flush this entry */ @@ -328,7 +328,7 @@ unsigned long hash_index (HASHTAB *hashtab,char *key) { unsigned long i,ret; /* polynomial of letters of the word */ - for (ret = 0; i = (unsigned int) *key++; ret += i) ret *= HASHMULT; + for (ret = 0; (i = (unsigned int) *key++) != 0L; ret += i) ret *= HASHMULT; return ret % (unsigned long) hashtab->size; } @@ -447,7 +447,7 @@ int compare_string (unsigned char *s1,unsigned char *s2) int i; if (!s1) return s2 ? -1 : 0; /* empty string cases */ else if (!s2) return 1; - for (; *s1 && *s2; s1++,s2++) if (i = (compare_ulong (*s1,*s2))) return i; + for (; *s1 && *s2; s1++,s2++) if ((i = (compare_ulong (*s1,*s2))) != 0) return i; if (*s1) return 1; /* first string is longer */ return *s2 ? -1 : 0; /* second string longer : strings identical */ } @@ -466,7 +466,7 @@ int compare_cstring (unsigned char *s1,unsigned char *s2) int i; if (!s1) return s2 ? -1 : 0; /* empty string cases */ else if (!s2) return 1; - for (; *s1 && *s2; s1++,s2++) if (i = (compare_uchar (*s1,*s2))) return i; + for (; *s1 && *s2; s1++,s2++) if ((i = (compare_uchar (*s1,*s2))) != 0) return i; if (*s1) return 1; /* first string is longer */ return *s2 ? -1 : 0; /* second string longer : strings identical */ } @@ -486,7 +486,7 @@ int compare_csizedtext (unsigned char *s1,SIZEDTEXT *s2) if (!s1) return s2 ? -1 : 0; /* null string cases */ else if (!s2) return 1; for (s = (char *) s2->data,j = s2->size; *s1 && j; ++s1,++s,--j) - if (i = (compare_uchar (*s1,*s))) return i; + if ((i = (compare_uchar (*s1,*s))) != 0) return i; if (*s1) return 1; /* first string is longer */ return j ? -1 : 0; /* second string longer : strings identical */ } diff --git a/imap/src/c-client/netmsg.c b/imap/src/c-client/netmsg.c index 187e4ebb..4454c3be 100644 --- a/imap/src/c-client/netmsg.c +++ b/imap/src/c-client/netmsg.c @@ -61,7 +61,7 @@ FILE *netmsg_slurp (NETSTREAM *stream,unsigned long *size,unsigned long *hsiz) FILE *f = tmpfile (); if (!f) { sprintf (tmp,".%lx.%lx",(unsigned long) time (0),(unsigned long)getpid ()); - if (f = fopen (tmp,"wb+")) unlink (tmp); + if ((f = fopen (tmp,"wb+")) != NULL) unlink (tmp); else { sprintf (tmp,"Unable to create scratch file: %.80s",strerror (errno)); MM_LOG (tmp,ERROR); @@ -70,7 +70,7 @@ FILE *netmsg_slurp (NETSTREAM *stream,unsigned long *size,unsigned long *hsiz) } *size = 0; /* initially emtpy */ if (hsiz) *hsiz = 0; - while (s = net_getline (stream)) { + while ((s = net_getline (stream)) != NULL) { if (*s == '.') { /* possible end of text? */ if (s[1]) t = s + 1; /* pointer to true start of line */ else { diff --git a/imap/src/c-client/newsrc.c b/imap/src/c-client/newsrc.c index 41f1fd24..ce694c61 100644 --- a/imap/src/c-client/newsrc.c +++ b/imap/src/c-client/newsrc.c @@ -123,9 +123,10 @@ long newsrc_newmessages (FILE *f,MAILSTREAM *stream,char *nl) } else if (j) { /* unread message, ending a range */ /* calculate end of range */ - if (k = elt->private.uid - 1) { + if ((k = elt->private.uid - 1) != 0L) { /* dump range */ - sprintf (tmp,(j == k) ? "%c%ld" : "%c%ld-%ld",c,j,k); + if(j == k) sprintf (tmp, "%c%ld",c,j); + else sprintf (tmp, "%c%ld-%ld",c,j,k); if (fputs (tmp,f) == EOF) return NIL; c = ','; /* need a comma after the first time */ } @@ -133,7 +134,8 @@ long newsrc_newmessages (FILE *f,MAILSTREAM *stream,char *nl) } } if (j) { /* dump trailing range */ - sprintf (tmp,(j == k) ? "%c%ld" : "%c%ld-%ld",c,j,k); + if(j == k) sprintf (tmp, "%c%ld",c,j); + else sprintf (tmp,"%c%ld-%ld",c,j,k); if (fputs (tmp,f) == EOF) return NIL; } } @@ -340,7 +342,7 @@ long newsrc_write (char *group,MAILSTREAM *stream) char *s,tmp[MAILTMPLEN],backup[MAILTMPLEN],nl[3]; FILE *f,*bf; nl[0] = nl[1] = nl[2] = '\0'; /* no newline known yet */ - if (f = fopen (newsrc,"rb")) {/* have existing newsrc file? */ + if ((f = fopen (newsrc,"rb")) != NULL) {/* have existing newsrc file? */ if (!(bf = fopen ((strcat (strcpy (backup,newsrc),OLDFILESUFFIX)),"wb"))) { fclose (f); /* punt input file */ return newsrc_error("Can't create backup news state %.80s",backup,ERROR); @@ -365,7 +367,7 @@ long newsrc_write (char *group,MAILSTREAM *stream) return newsrc_error ("Error closing backup news state %.80s", newsrc,ERROR); if (d == EOF) { /* open for write if empty file */ - if (f = newsrc_create (stream,NIL)) bf = NIL; + if ((f = newsrc_create (stream,NIL)) != NULL) bf = NIL; else return NIL; } else if (!nl[0]) /* make sure newlines valid */ @@ -381,7 +383,7 @@ long newsrc_write (char *group,MAILSTREAM *stream) } } else { /* create new newsrc file */ - if (f = newsrc_create (stream,T)) bf = NIL; + if ((f = newsrc_create (stream,T)) != NULL) bf = NIL; else return NIL; /* can't create newsrc */ } diff --git a/imap/src/c-client/nntp.c b/imap/src/c-client/nntp.c index dd2b8604..8fa32df1 100644 --- a/imap/src/c-client/nntp.c +++ b/imap/src/c-client/nntp.c @@ -352,12 +352,12 @@ void nntp_list (MAILSTREAM *stream,char *ref,char *pat) /* namespace format name? */ if (*(lcl = strchr (strcpy (name,pattern),'}') + 1) == '#') lcl += 6; /* process data until we see final dot */ - while (s = net_getline (LOCAL->nntpstream->netstream)) { + while ((s = net_getline (LOCAL->nntpstream->netstream)) != NULL) { if ((*s == '.') && !s[1]){/* end of text */ fs_give ((void **) &s); break; } - if (t = strchr (s,' ')) { /* tie off after newsgroup name */ + if ((t = strchr (s,' ')) != NULL) { /* tie off after newsgroup name */ *t = '\0'; strcpy (lcl,s); /* make full form of name */ /* report if match */ @@ -396,10 +396,10 @@ void nntp_lsub (MAILSTREAM *stream,char *ref,char *pat) if (ref && *ref) sprintf (mbx,"%s%s",ref,pat); else strcpy (mbx,pat); - if (s = sm_read (tmp,&sdb)) do if (nntp_valid (s) && pmatch (s,mbx)) + if ((s = sm_read (tmp,&sdb)) != NULL) do if (nntp_valid (s) && pmatch (s,mbx)) mm_lsub (stream,NIL,s,NIL); /* until no more subscriptions */ - while (s = sm_read (tmp,&sdb)); + while ((s = sm_read (tmp,&sdb)) != NULL); } /* NNTP canonicalize newsgroup name @@ -430,7 +430,7 @@ long nntp_canonicalize (char *ref,char *pat,char *pattern,char *wildmat) /* don't return wildmat if specials present */ if (strpbrk (wildmat,",?![\\]")) wildmat[0] = '\0'; /* replace all % with * */ - for (s = wildmat; s = strchr (s,'%'); *s = '*'); + for (s = wildmat; (s = strchr (s,'%')) != NULL; *s = '*'); } return ret ? LONGT : NIL; } @@ -556,7 +556,7 @@ long nntp_status (MAILSTREAM *stream,char *mbx,long flags) else if (!(flags & (SA_RECENT | SA_UNSEEN))) status.messages = k; /* have newsrc state? */ - else if (state = newsrc_state (stream,name)) { + else if ((state = newsrc_state (stream,name)) != NULL) { /* yes, get the UID/sequence map */ if (nntp_getmap (stream,name,i,status.uidnext - 1,rnmsgs, status.messages,tmp)) { @@ -938,15 +938,15 @@ long nntp_overview (MAILSTREAM *stream,overview_t ofn) (j <= stream->nmsgs) && (elt = mail_elt (stream,j))->sequence && !elt->private.spare.ptr; j++); /* make NNTP range */ - sprintf (tmp,(i == (j - 1)) ? "%lu" : "%lu-%lu",mail_uid (stream,i), - mail_uid (stream,j - 1)); + if(i == (j - 1)) sprintf (tmp, "%lu", mail_uid (stream,i)); + else sprintf (tmp, "%lu-%lu",mail_uid (stream,i), mail_uid (stream,j - 1)); i = j; /* advance beyond gap */ /* ask server for overview data to cache */ if (nntp_over (stream,tmp)) { while ((s = net_getline (LOCAL->nntpstream->netstream)) && strcmp (s,".")) { /* death to embedded newlines */ - for (t = v = s; c = *v++;) + for (t = v = s; (c = *v++) != '\0';) if ((c != '\012') && (c != '\015')) *t++ = c; *t++ = '\0'; /* tie off string in case it was shortened */ /* cache the overview if found its sequence */ @@ -1056,34 +1056,34 @@ long nntp_parse_overview (OVERVIEW *ov,char *text,MESSAGECACHE *elt) if (!(text && *text)) return NIL; ov->subject = cpystr (text); /* make hackable copy of overview */ /* find end of Subject */ - if (t = strchr (ov->subject,'\t')) { + if ((t = strchr (ov->subject,'\t')) != NULL) { *t++ = '\0'; /* tie off Subject, point to From */ /* find end of From */ - if (ov->date = strchr (t,'\t')) { + if ((ov->date = strchr (t,'\t')) != NULL) { *ov->date++ = '\0'; /* tie off From, point to Date */ /* load internaldate too */ if (!elt->day) mail_parse_date (elt,ov->date); /* parse From */ rfc822_parse_adrlist (&ov->from,t,BADHOST); /* find end of Date */ - if (ov->message_id = strchr (ov->date,'\t')) { + if ((ov->message_id = strchr (ov->date,'\t')) != NULL) { /* tie off Date, point to Message-ID */ *ov->message_id++ = '\0'; /* find end of Message-ID */ - if (ov->references = strchr (ov->message_id,'\t')) { + if ((ov->references = strchr (ov->message_id,'\t')) != NULL) { /* tie off Message-ID, point to References */ *ov->references++ = '\0'; /* fine end of References */ - if (t = strchr (ov->references,'\t')) { + if ((t = strchr (ov->references,'\t')) != NULL) { *t++ = '\0'; /* tie off References, point to octet size */ /* parse size of message in octets */ ov->optional.octets = atol (t); /* find end of size */ - if (t = strchr (t,'\t')) { + if ((t = strchr (t,'\t')) != NULL) { /* parse size of message in lines */ ov->optional.lines = atol (++t); /* find Xref */ - if (ov->optional.xref = strchr (t,'\t')) + if ((ov->optional.xref = strchr (t,'\t')) != NULL) *ov->optional.xref++ = '\0'; } } @@ -1116,7 +1116,7 @@ char *nntp_header (MAILSTREAM *stream,unsigned long msgno,unsigned long *size, /* get header text */ switch (nntp_send (LOCAL->nntpstream,"HEAD",tmp)) { case NNTPHEAD: - if (f = netmsg_slurp (LOCAL->nntpstream->netstream,size,NIL)) { + if ((f = netmsg_slurp (LOCAL->nntpstream->netstream,size,NIL)) != NULL) { fread (elt->private.msg.header.text.data = (unsigned char *) fs_get ((size_t) *size + 3), (size_t) 1,(size_t) *size,f); @@ -1168,8 +1168,8 @@ long nntp_text (MAILSTREAM *stream,unsigned long msgno,STRING *bs,long flags) sprintf (tmp,"%lu",elt->private.uid); switch (nntp_send (LOCAL->nntpstream,"BODY",tmp)) { case NNTPBODY: - if (LOCAL->txt = netmsg_slurp (LOCAL->nntpstream->netstream, - &LOCAL->txtsize,NIL)) break; + if ((LOCAL->txt = netmsg_slurp (LOCAL->nntpstream->netstream, + &LOCAL->txtsize,NIL)) != NULL) break; /* fall into default case */ default: /* failed, mark as deleted */ elt->deleted = T; @@ -1233,7 +1233,7 @@ long nntp_search (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,long flags) OVERVIEW ov; char *msg; /* make sure that charset is good */ - if (msg = utf8_badcharset (charset)) { + if ((msg = utf8_badcharset (charset)) != NULL) { MM_LOG (msg,ERROR); /* output error */ fs_give ((void **) &msg); return NIL; @@ -1286,7 +1286,7 @@ long nntp_search_msg (MAILSTREAM *stream,unsigned long msgno,SEARCHPGM *pgm, if (pgm->msgno || pgm->uid) { /* message set searches */ SEARCHSET *set; /* message sequences */ - if (set = pgm->msgno) { /* must be inside this sequence */ + if ((set = pgm->msgno) != NULL) { /* must be inside this sequence */ while (set) { /* run down until find matching range */ if (set->last ? ((msgno < set->first) || (msgno > set->last)) : msgno != set->first) set = set->next; @@ -1294,7 +1294,7 @@ long nntp_search_msg (MAILSTREAM *stream,unsigned long msgno,SEARCHPGM *pgm, } if (!set) return NIL; /* not found within sequence */ } - if (set = pgm->uid) { /* must be inside this sequence */ + if ((set = pgm->uid) != NULL) { /* must be inside this sequence */ unsigned long uid = mail_uid (stream,msgno); while (set) { /* run down until find matching range */ if (set->last ? ((uid < set->first) || (uid > set->last)) : @@ -1530,7 +1530,7 @@ SORTCACHE **nntp_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm, if (!nntp_over (stream,tmp)) return mail_sort_loadcache (stream,pgm); while ((s = net_getline (LOCAL->nntpstream->netstream)) && strcmp (s,".")){ /* death to embedded newlines */ - for (t = v = s; c = *v++;) if ((c != '\012') && (c != '\015')) *t++ = c; + for (t = v = s; (c = *v++) != '\0';) if ((c != '\012') && (c != '\015')) *t++ = c; *t++ = '\0'; /* tie off resulting string */ /* parse OVER response */ if ((i = mail_msgno (stream,atol (s))) && @@ -1539,14 +1539,14 @@ SORTCACHE **nntp_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm, /* put stripped subject in sortcache */ r = (SORTCACHE *) (*mailcache) (stream,i,CH_SORTCACHE); r->refwd = mail_strip_subject (t,&r->subject); - if (t = strchr (v,'\t')) { + if ((t = strchr (v,'\t')) != NULL) { *t++ = '\0'; /* tie off from */ - if (adr = rfc822_parse_address (&adr,adr,&v,BADHOST,0)) { + if ((adr = rfc822_parse_address (&adr,adr,&v,BADHOST,0)) != NULL) { r->from = adr->mailbox; adr->mailbox = NIL; mail_free_address (&adr); } - if (v = strchr (t,'\t')) { + if ((v = strchr (t,'\t')) != NULL) { *v++ = '\0'; /* tie off date */ if (mail_parse_date (&telt,t)) r->date = mail_longdate (&telt); if ((v = strchr (v,'\t')) && (v = strchr (++v,'\t'))) @@ -1696,10 +1696,10 @@ SENDSTREAM *nntp_open_full (NETDRIVER *dv,char **hostlist,char *service, /* default port */ if (mb.port) port = mb.port; else if (!port) port = nntp_port ? nntp_port : NNTPTCPPORT; - if (netstream = /* try to open ordinary connection */ + if ((netstream = /* try to open ordinary connection */ net_open (&mb,dv,port, (NETDRIVER *) mail_parameters (NIL,GET_SSLDRIVER,NIL), - "*nntps",nntp_sslport ? nntp_sslport : NNTPSSLPORT)) { + "*nntps",nntp_sslport ? nntp_sslport : NNTPSSLPORT)) != NULL) { stream = (SENDSTREAM *) fs_get (sizeof (SENDSTREAM)); /* initialize stream */ memset ((void *) stream,0,sizeof (SENDSTREAM)); @@ -1737,9 +1737,9 @@ SENDSTREAM *nntp_open_full (NETDRIVER *dv,char **hostlist,char *service, mb.tlsflag = T; /* TLS OK, get into TLS at this end */ stream->netstream->dtb = ssld; /* negotiate TLS */ - if (stream->netstream->stream = + if ((stream->netstream->stream = (*stls) (stream->netstream->stream,mb.host, - SSL_MTHD(mb) | (mb.novalidate ? NET_NOVALIDATECERT:NIL))) + SSL_MTHD(mb) | (mb.novalidate ? NET_NOVALIDATECERT:NIL))) != NULL) extok = nntp_extensions (stream,(mb.secflag ? AU_SECURE : NIL) | (mb.authuser[0] ? AU_AUTHUSER : NIL)); else { @@ -1834,7 +1834,7 @@ long nntp_extensions (SENDSTREAM *stream,long flags) while ((t = net_getline (stream->netstream)) && (t[1] || (*t != '.'))) { if (stream->debug) mm_dlog (t); /* get optional capability arguments */ - if (args = strchr (t,' ')) *args++ = '\0'; + if ((args = strchr (t,' ')) != NULL) *args++ = '\0'; if (!compare_cstring (t,"LISTGROUP")) NNTP.ext.listgroup = T; else if (!compare_cstring (t,"OVER")) NNTP.ext.over = T; else if (!compare_cstring (t,"HDR")) NNTP.ext.hdr = T; @@ -1933,7 +1933,7 @@ long nntp_mail (SENDSTREAM *stream,ENVELOPE *env,BODY *body) env->sender ? env->sender->mailbox : (env->from ? env->from->mailbox : "not-for-mail")); /* here's another cretinism */ - if (s = strstr (env->date," (")) *s = NIL; + if ((s = strstr (env->date," (")) != NULL) *s = NIL; do if ((ret = nntp_send_work (stream,"POST",NIL)) == NNTPREADY) /* output data, return success status */ ret = (net_soutr (stream->netstream, @@ -2231,7 +2231,7 @@ long nntp_soutr (void *stream,char *s) /* "." on first line */ if (s[0] == '.') net_soutr (stream,"."); /* find lines beginning with a "." */ - while (t = strstr (s,"\015\012.")) { + while ((t = strstr (s,"\015\012.")) != NULL) { c = *(t += 3); /* remember next character after "." */ *t = '\0'; /* tie off string */ /* output prefix */ diff --git a/imap/src/c-client/pop3.c b/imap/src/c-client/pop3.c index 52573f52..46c050ee 100644 --- a/imap/src/c-client/pop3.c +++ b/imap/src/c-client/pop3.c @@ -273,10 +273,10 @@ void pop3_lsub (MAILSTREAM *stream,char *ref,char *pat) if (ref && *ref) sprintf (mbx,"%s%s",ref,pat); else strcpy (mbx,pat); - if (s = sm_read (tmp,&sdb)) do if (pop3_valid (s) && pmatch (s,mbx)) + if ((s = sm_read (tmp,&sdb)) != NULL) do if (pop3_valid (s) && pmatch (s,mbx)) mm_lsub (stream,NIL,s,NIL); /* until no more subscriptions */ - while (s = sm_read (tmp,&sdb)); + while ((s = sm_read (tmp,&sdb)) != NULL); } @@ -428,7 +428,7 @@ MAILSTREAM *pop3_open (MAILSTREAM *stream) if (mb.notlsflag) strcat (tmp,"/notls"); if (mb.sslflag) strcat (tmp,"/ssl"); if (mb.novalidate) strcat (tmp,"/novalidate-cert"); - if (LOCAL->loser = mb.loser) strcat (tmp,"/loser"); + if ((LOCAL->loser = mb.loser) != 0) strcat (tmp,"/loser"); if (stream->secure) strcat (tmp,"/secure"); sprintf (tmp + strlen (tmp),"/user=\"%s\"}%s",usr,mb.mailbox); stream->inbox = T; /* always INBOX */ @@ -498,7 +498,7 @@ long pop3_capa (MAILSTREAM *stream,long flags) while ((t = net_getline (LOCAL->netstream)) && (t[1] || (*t != '.'))) { if (stream->debug) mm_dlog (t); /* get optional capability arguments */ - if (args = strchr (t,' ')) *args++ = '\0'; + if ((args = strchr (t,' ')) != NULL) *args++ = '\0'; if (!compare_cstring (t,"STLS")) LOCAL->cap.stls = T; else if (!compare_cstring (t,"PIPELINING")) LOCAL->cap.pipelining = T; else if (!compare_cstring (t,"RESP-CODES")) LOCAL->cap.respcodes = T; @@ -509,7 +509,7 @@ long pop3_capa (MAILSTREAM *stream,long flags) LOCAL->cap.implementation = cpystr (args); else if (!compare_cstring (t,"EXPIRE") && args) { LOCAL->cap.expire = T; /* note that it is present */ - if (s = strchr(args,' ')){/* separate time from possible USER */ + if ((s = strchr(args,' ')) != NULL){/* separate time from possible USER */ *s++ = '\0'; /* in case they add something after USER */ if ((strlen (s) > 4) && (s[4] == ' ')) s[4] = '\0'; @@ -520,7 +520,7 @@ long pop3_capa (MAILSTREAM *stream,long flags) } else if (!compare_cstring (t,"LOGIN-DELAY") && args) { LOCAL->cap.logindelay = T;/* note that it is present */ - if (s = strchr(args,' ')){/* separate time from possible USER */ + if ((s = strchr(args,' ')) != NULL){/* separate time from possible USER */ *s++ = '\0'; /* in case they add something after USER */ if ((strlen (s) > 4) && (s[4] == ' ')) s[4] = '\0'; @@ -841,7 +841,7 @@ char *pop3_header (MAILSTREAM *stream,unsigned long msgno,unsigned long *size, &elt->private.msg.header.text.size); } /* otherwise load the cache with the message */ - else if (elt->private.msg.header.text.size = pop3_cache (stream,elt)) + else if ((elt->private.msg.header.text.size = pop3_cache (stream,elt)) != 0L) f = LOCAL->txt; if (f) { /* got it, make sure at start of file */ fseek (f,(unsigned long) 0,SEEK_SET); @@ -945,10 +945,10 @@ long pop3_expunge (MAILSTREAM *stream,char *sequence,long options) MESSAGECACHE *elt; unsigned long i = 1,n = 0; long ret; - if (ret = sequence ? ((options & EX_UID) ? + if ((ret = sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : mail_sequence (stream,sequence)) : - LONGT) { /* build selected sequence if needed */ + LONGT) != 0L) { /* build selected sequence if needed */ while (i <= stream->nmsgs) { elt = mail_elt (stream,i); if (elt->deleted && (sequence ? elt->sequence : T) && diff --git a/imap/src/c-client/rfc822.c b/imap/src/c-client/rfc822.c index 133f9e67..de919b3c 100644 --- a/imap/src/c-client/rfc822.c +++ b/imap/src/c-client/rfc822.c @@ -156,7 +156,7 @@ void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i, } /* find header item type */ - if (t = d = strchr (tmp,':')) { + if ((t = d = strchr (tmp,':')) != NULL) { *d++ = '\0'; /* tie off header item, point at its data */ while (*d == ' ') d++; /* flush whitespace */ while ((tmp < t--) && (*t == ' ')) *t = '\0'; @@ -205,7 +205,7 @@ void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i, if (!strcmp (tmp+1,"ROM")) rfc822_parse_adrlist (&env->from,d,host); else if (!strcmp (tmp+1,"OLLOWUP-TO")) { t = env->followup_to = (char *) fs_get (1 + strlen (d)); - while (c = *d++) if (c != ' ') *t++ = c; + while ((c = *d++) != '\0') if (c != ' ') *t++ = c; *t++ = '\0'; } break; @@ -219,7 +219,7 @@ void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i, env->message_id = cpystr (d); else if (!strcmp (tmp+1,"IME-VERSION")) { /* tie off at end of phrase */ - if (t = rfc822_parse_phrase (d)) *t = '\0'; + if ((t = rfc822_parse_phrase (d)) != NULL) *t = '\0'; rfc822_skipws (&d); /* skip whitespace */ /* known version? */ if (strcmp (d,"1.0") && strcmp (d,"RFC-XXXX")) @@ -230,7 +230,7 @@ void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i, case 'N': /* possible Newsgroups: */ if (!env->newsgroups && !strcmp (tmp+1,"EWSGROUPS")) { t = env->newsgroups = (char *) fs_get (1 + strlen (d)); - while (c = *d++) if (c != ' ') *t++ = c; + while ((c = *d++) != '\0') if (c != ' ') *t++ = c; *t++ = '\0'; } break; @@ -443,7 +443,7 @@ void rfc822_parse_content (BODY *body,STRING *bs,char *h,unsigned long depth, j = strlen (s1) + 2; /* length of cookie and header */ c = '\012'; /* initially at beginning of line */ while (i > j) { /* examine data */ - if (m = GETPOS (bs)) m--; /* get position in front of character */ + if ((m = GETPOS (bs)) != 0L) m--; /* get position in front of character */ switch (c) { /* examine each line */ case '\015': /* handle CRLF form */ if (CHR (bs) == '\012'){/* following LF? */ @@ -453,7 +453,7 @@ void rfc822_parse_content (BODY *body,STRING *bs,char *h,unsigned long depth, if (!(i && i-- && ((c = SNX (bs)) == '-') && i-- && ((c = SNX (bs)) == '-'))) break; /* see if cookie matches */ - if (k = j - 2) for (s = s1; i-- && *s++ == (c = SNX (bs)) && --k;); + if ((k = j - 2) != 0L) for (s = s1; i-- && *s++ == (c = SNX (bs)) && --k;); if (k) break; /* strings didn't match if non-zero */ /* terminating delimiter? */ if ((c = ((i && i--) ? (SNX (bs)) : '\012')) == '-') { @@ -509,7 +509,7 @@ void rfc822_parse_content (BODY *body,STRING *bs,char *h,unsigned long depth, /* parse non-empty body parts */ for (part = body->nested.part; part; part = part->next) { /* part non-empty (header and/or content)? */ - if (i = part->body.mime.text.size) { + if ((i = part->body.mime.text.size) != 0L) { /* move to that part of the body */ SETPOS (bs,part->body.mime.offset); /* until end of header */ @@ -610,7 +610,7 @@ void rfc822_parse_content_header (BODY *body,char *name,char *s) STRINGLIST *stl; rfc822_skipws (&s); /* skip leading comments */ /* flush whitespace */ - if (t = strchr (name,' ')) *t = '\0'; + if ((t = strchr (name,' ')) != NULL) *t = '\0'; switch (*name) { /* see what kind of content */ case 'I': /* possible Content-ID */ if (!(strcmp (name+1,"D") || body->id)) body->id = cpystr (s); @@ -800,7 +800,7 @@ void rfc822_parse_adrlist (ADDRESS **lst,char *string,char *host) } if (!*string) string = NIL; /* punt if ran out of string */ /* got an address? */ - else if (adr = rfc822_parse_address (lst,last,&string,host,0)) { + else if ((adr = rfc822_parse_address (lst,last,&string,host,0)) != NULL) { last = adr; /* new tail address */ if (string) { /* analyze what follows */ rfc822_skipws (&string); @@ -854,9 +854,9 @@ ADDRESS *rfc822_parse_address (ADDRESS **lst,ADDRESS *last,char **string, if (!*string) return NIL; /* no string */ rfc822_skipws (string); /* skip leading WS */ if (!**string) return NIL; /* empty string */ - if (adr = rfc822_parse_group (lst,last,string,defaulthost,depth)) last = adr; + if ((adr = rfc822_parse_group (lst,last,string,defaulthost,depth)) != NULL) last = adr; /* got an address? */ - else if (adr = rfc822_parse_mailbox (string,defaulthost)) { + else if ((adr = rfc822_parse_mailbox (string,defaulthost)) != NULL) { if (!*lst) *lst = adr; /* yes, first time through? */ else last->next = adr; /* no, append to the list */ /* set for subsequent linking */ @@ -902,7 +902,7 @@ ADDRESS *rfc822_parse_group (ADDRESS **lst,ADDRESS *last,char **string, last = adr; /* set for subsequent linking */ *string = p; /* continue after this point */ while (*string && **string && (**string != ';')) { - if (adr = rfc822_parse_address (lst,last,string,defaulthost,depth+1)) { + if ((adr = rfc822_parse_address (lst,last,string,defaulthost,depth+1)) != NULL) { last = adr; /* new tail address */ if (*string) { /* anything more? */ rfc822_skipws (string); /* skip whitespace */ @@ -961,7 +961,7 @@ ADDRESS *rfc822_parse_mailbox (char **string,char *defaulthost) if (*(s = *string) == '<') /* note start, handle case of phraseless RA */ adr = rfc822_parse_routeaddr (s,string,defaulthost); /* otherwise, expect at least one word */ - else if (end = rfc822_parse_phrase (s)) { + else if ((end = rfc822_parse_phrase (s)) != NULL) { if ((adr = rfc822_parse_routeaddr (end,string,defaulthost))) { /* phrase is a personal name */ if (adr->personal) fs_give ((void **) &adr->personal); @@ -1090,7 +1090,7 @@ ADDRESS *rfc822_parse_addrspec (char *string,char **ret,char *defaulthost) string = ++t; /* skip past the dot and any WS */ rfc822_skipws (&string); /* get next word of mailbox */ - if (t = rfc822_parse_word (string,wspecials)) { + if ((t = rfc822_parse_word (string,wspecials)) != NULL) { end = t; /* remember new end of mailbox */ c = *t; /* remember delimiter */ *t = '\0'; /* tie off word */ @@ -1158,7 +1158,7 @@ char *rfc822_parse_domain (char *string,char **end) } } /* search for end of host */ - else if (t = rfc822_parse_word (string,wspecials)) { + else if ((t = rfc822_parse_word (string,wspecials)) != NULL) { c = *t; /* remember delimiter */ *t = '\0'; /* tie off host */ ret = rfc822_cpy (string); /* copy host */ @@ -1168,7 +1168,7 @@ char *rfc822_parse_domain (char *string,char **end) while (*t == '.') { /* some cretin taking RFC 822 too seriously? */ string = ++t; /* skip past the dot and any WS */ rfc822_skipws (&string); - if (string = rfc822_parse_domain (string,&t)) { + if ((string = rfc822_parse_domain (string,&t)) != NULL) { *end = t; /* remember new end of domain */ c = *t; /* remember delimiter */ *t = '\0'; /* tie off host */ @@ -1235,7 +1235,7 @@ char *rfc822_parse_word (char *s,const char *delimiters) case I2CS_94x94_JIS_OLD:/* old JIS (1978) */ case I2CS_94x94_JIS_NEW:/* new JIS (1983) */ str = ++st; /* skip past the shift to JIS */ - while (st = strchr (st,I2C_ESC)) + while ((st = strchr (st,I2C_ESC)) != NULL) if ((*++st == I2C_G0_94) && ((st[1] == I2CS_94_ASCII) || (st[1] == I2CS_94_JIS_ROMAN) || (st[1] == I2CS_94_JIS_BUGROM))) { @@ -1434,7 +1434,7 @@ static long rfc822_output_data (RFC822BUFFER *buf,char *string,long len) { while (len) { /* until request satified */ long i; - if (i = min (len,buf->end - buf->cur)) { + if ((i = min (len,buf->end - buf->cur)) != 0L) { memcpy (buf->cur,string,i); buf->cur += i; /* blat data */ string += i; @@ -1682,7 +1682,7 @@ long rfc822_output_cat (RFC822BUFFER *buf,char *src,const char *specials) /* yes, write as quoted string*/ if (!rfc822_output_char (buf,'"')) return NIL; /* embedded quote characters? */ - for (; s = strpbrk (src,"\\\""); src = s + 1) { + for (; (s = strpbrk (src,"\\\"")) != NULL; src = s + 1) { /* yes, insert quoting */ if (!(rfc822_output_data (buf,src,s-src) && rfc822_output_char (buf,'\\') && @@ -1800,7 +1800,7 @@ void rfc822_encode_body_7bit (ENVELOPE *env,BODY *body) } part = body->nested.part; /* encode body parts */ do rfc822_encode_body_7bit (env,&part->body); - while (part = part->next); /* until done */ + while ((part = part->next) != NULL); /* until done */ break; case TYPEMESSAGE: /* encapsulated message */ switch (body->encoding) { @@ -1868,7 +1868,7 @@ void rfc822_encode_body_8bit (ENVELOPE *env,BODY *body) } part = body->nested.part; /* encode body parts */ do rfc822_encode_body_8bit (env,&part->body); - while (part = part->next); /* until done */ + while ((part = part->next) != NULL); /* until done */ break; case TYPEMESSAGE: /* encapsulated message */ switch (body->encoding) { @@ -2024,7 +2024,7 @@ void *rfc822_base64 (unsigned char *src,unsigned long srcl,unsigned long *len) */ sprintf (tmp,"Possible data truncation in rfc822_base64(): %.80s", (char *) src - 1); - if (s = strpbrk (tmp,"\015\012")) *s = NIL; + if ((s = strpbrk (tmp,"\015\012")) != NULL) *s = NIL; mm_log (tmp,PARSE); srcl = 1; /* don't issue any more messages */ break; diff --git a/imap/src/c-client/smanager.c b/imap/src/c-client/smanager.c index 1f9b508c..437e1079 100644 --- a/imap/src/c-client/smanager.c +++ b/imap/src/c-client/smanager.c @@ -41,9 +41,9 @@ long sm_subscribe (char *mailbox) /* canonicalize INBOX */ if (!compare_cstring (mailbox,"INBOX")) mailbox = "INBOX"; SUBSCRIPTIONFILE (db); /* open subscription database */ - if (f = fopen (db,"r")) { /* make sure not already there */ + if ((f = fopen (db,"r")) != NULL) { /* make sure not already there */ while (fgets (tmp,MAILTMPLEN,f)) { - if (s = strchr (tmp,'\n')) *s = '\0'; + if ((s = strchr (tmp,'\n')) != NULL) *s = '\0'; if (!strcmp (tmp,mailbox)) {/* already subscribed? */ sprintf (tmp,"Already subscribed to mailbox %.80s",mailbox); MM_LOG (tmp,ERROR); @@ -83,7 +83,7 @@ long sm_unsubscribe (char *mailbox) } else { while (fgets (tmp,MAILTMPLEN,f)) { - if (s = strchr (tmp,'\n')) *s = '\0'; + if ((s = strchr (tmp,'\n')) != NULL) *s = '\0'; if (strcmp (tmp,mailbox)) fprintf (tf,"%s\n",tmp); else found = T; /* found the name */ } @@ -113,11 +113,11 @@ char *sm_read (char *sbname,void **sdb) if (!f) { /* first time through? */ SUBSCRIPTIONFILE (sbname); /* open subscription database */ /* make sure not already there */ - if (f = fopen (sbname,"r")) *sdb = (void *) f; + if ((f = fopen (sbname,"r")) != NULL) *sdb = (void *) f; else return NIL; } if (fgets (sbname,MAILTMPLEN,f)) { - if (s = strchr (sbname,'\n')) *s = '\0'; + if ((s = strchr (sbname,'\n')) != NULL) *s = '\0'; return sbname; } fclose (f); /* all done */ diff --git a/imap/src/c-client/smtp.c b/imap/src/c-client/smtp.c index 1a79d28d..405f8738 100644 --- a/imap/src/c-client/smtp.c +++ b/imap/src/c-client/smtp.c @@ -167,10 +167,10 @@ SENDSTREAM *smtp_open_full (NETDRIVER *dv,char **hostlist,char *service, } /* else port argument overrides SMTP port */ else if (!port) port = smtp_port ? smtp_port : SMTPTCPPORT; - if (netstream = /* try to open ordinary connection */ + if ((netstream = /* try to open ordinary connection */ net_open (&mb,dv,port, (NETDRIVER *) mail_parameters (NIL,GET_SSLDRIVER,NIL), - "*smtps",smtp_sslport ? smtp_sslport : SMTPSSLPORT)) { + "*smtps",smtp_sslport ? smtp_sslport : SMTPSSLPORT)) != NULL) { stream = (SENDSTREAM *) memset (fs_get (sizeof (SENDSTREAM)),0, sizeof (SENDSTREAM)); stream->netstream = netstream; @@ -788,7 +788,7 @@ long smtp_soutr (void *stream,char *s) /* "." on first line */ if (s[0] == '.') net_sout (stream,".",1); /* find lines beginning with a "." */ - while (t = strstr (s,"\015\012.")) { + while ((t = strstr (s,"\015\012.")) != NULL) { c = *(t += 3); /* remember next character after "." */ *t = '\0'; /* tie off string */ /* output prefix */ diff --git a/imap/src/c-client/utf8.c b/imap/src/c-client/utf8.c index cad4a7c7..844abefd 100644 --- a/imap/src/c-client/utf8.c +++ b/imap/src/c-client/utf8.c @@ -657,7 +657,7 @@ unsigned short *utf8_rmap_cs (const CHARSET *cs) unsigned short *ret = NIL; if (!cs); /* have charset? */ else if (cs == currmapcs) ret = currmap; - else if (ret = utf8_rmap_gen (cs,currmap)) { + else if ((ret = utf8_rmap_gen (cs,currmap)) != NULL) { currmapcs = cs; currmap = ret; } @@ -789,7 +789,7 @@ long utf8_rmaptext (SIZEDTEXT *text,unsigned short *rmap,SIZEDTEXT *ret, { unsigned long i,u,c; /* get size of buffer */ - if (i = utf8_rmapsize (text,rmap,errch,iso2022jp)) { + if ((i = utf8_rmapsize (text,rmap,errch,iso2022jp)) != 0L) { unsigned char *s = text->data; unsigned char *t = ret->data = (unsigned char *) fs_get (i); ret->size = i - 1; /* number of octets in destination buffer */ @@ -1320,7 +1320,7 @@ unsigned long *utf8_csvalidmap (char *charsets[]) /* substitute EUC-JP for ISO-2022-JP */ if (!compare_cstring (s,"ISO-2022-JP")) s = "EUC-JP"; /* look up charset */ - if (cs = utf8_charset (s)) { + if ((cs = utf8_charset (s)) != NULL) { csb = 1 << csi; /* charset bit */ switch (cs->type) { case CT_ASCII: /* 7-bit ASCII no table */ @@ -2424,7 +2424,7 @@ unsigned long ucs4_decompose (unsigned long c,void **more) struct decomposemore *m; if (c & U8G_ERROR) { /* want to chase more? */ /* do sanity check */ - if (m = (struct decomposemore *) *more) switch (m->type) { + if ((m = (struct decomposemore *) *more) != NULL) switch (m->type) { case MORESINGLE: /* single value */ ret = m->data.single; fs_give (more); /* no more decomposition */ @@ -2447,7 +2447,7 @@ unsigned long ucs4_decompose (unsigned long c,void **more) else if (c == UCS4_BMPLOMIN) ret = ucs4_dbmplotab[0]; else if (c <= UCS4_BMPLOMAX) { /* within range - have a decomposition? */ - if (i = ucs4_dbmploixtab[c - UCS4_BMPLOMIN]) { + if ((i = ucs4_dbmploixtab[c - UCS4_BMPLOMIN]) != 0L) { /* get first value of decomposition */ ret = ucs4_dbmplotab[ix = i & UCS4_BMPLOIXMASK]; /* has continuation? */ @@ -2477,7 +2477,7 @@ unsigned long ucs4_decompose (unsigned long c,void **more) else if (c < UCS4_BMPHIMIN) ret = c; else if (c <= UCS4_BMPHIMAX) { /* within range - have a decomposition? */ - if (i = ucs4_dbmphiixtab[c - UCS4_BMPHIMIN]) { + if ((i = ucs4_dbmphiixtab[c - UCS4_BMPHIMIN]) != 0L) { /* get first value of decomposition */ ret = ucs4_dbmphitab[ix = i & UCS4_BMPHIIXMASK]; /* has continuation? */ @@ -2542,7 +2542,7 @@ unsigned long ucs4_decompose_recursive (unsigned long c,void **more) RECURSIVEMORE *mr; if (c & U8G_ERROR) { /* want to chase more? */ mn = NIL; - if (mr = (RECURSIVEMORE *) *more) switch (mr->more->type) { + if ((mr = (RECURSIVEMORE *) *more) != NULL) switch (mr->more->type) { case MORESINGLE: /* decompose single value */ c = ucs4_decompose_recursive (mr->more->data.single,&mn); *more = mr->next; /* done with this more, remove it */ @@ -2562,7 +2562,7 @@ unsigned long ucs4_decompose_recursive (unsigned long c,void **more) fatal ("invalid more block argument to ucs4_decompose_recursive!"); } else fatal ("no more block provided to ucs4_decompose_recursive!"); - if (mr = mn) { /* did this value recurse on us? */ + if ((mr = mn) != NULL) { /* did this value recurse on us? */ mr->next = *more; /* yes, insert new more at head */ *more = mr; } diff --git a/imap/src/c-client/utf8aux.c b/imap/src/c-client/utf8aux.c index 5138987b..5241b9e1 100644 --- a/imap/src/c-client/utf8aux.c +++ b/imap/src/c-client/utf8aux.c @@ -44,7 +44,7 @@ static void utf8_stringlist (STRINGLIST *st,char *charset) fs_give ((void **) &st->text.data); st->text.data = txt.data; /* transfer this text */ st->text.size = txt.size; - } while (st = st->next); + } while ((st = st->next) != NULL); } @@ -133,7 +133,7 @@ long utf8_mime2text (SIZEDTEXT *src,SIZEDTEXT *dst,long flags) ((te - s) < MAXENCWORD)) { if (mime2_decode (e,t,te,&txt)) { *ce = '\0'; /* temporarily tie off charset */ - if (ls = strchr (cs,'*')) *ls = '\0'; + if ((ls = strchr (cs,'*')) != NULL) *ls = '\0'; /* convert to UTF-8 as best we can */ if (!utf8_text (&txt,cs,&rtxt,flags)) utf8_text (&txt,NIL,&rtxt,flags); if (dst->data) { /* make sure existing buffer fits */ @@ -238,7 +238,7 @@ long mime2_decode (unsigned char *e,unsigned char *t,unsigned char *te, txt->data[txt->size] = '\0'; break; case 'B': case 'b': /* BASE64 */ - if (txt->data = (unsigned char *) rfc822_base64 (t,te - t,&txt->size)) + if ((txt->data = (unsigned char *) rfc822_base64 (t,te - t,&txt->size)) != NULL) break; default: /* any other encoding is unknown */ return NIL; /* syntax error: unknown encoding */ diff --git a/imap/src/dmail/dmail.c b/imap/src/dmail/dmail.c index 25bc547f..cf9bb732 100644 --- a/imap/src/dmail/dmail.c +++ b/imap/src/dmail/dmail.c @@ -27,6 +27,7 @@ #include <stdio.h> #include <pwd.h> #include <errno.h> +#include <ctype.h> extern int errno; /* just in case */ #include <sysexits.h> #include <sys/file.h> @@ -115,7 +116,7 @@ void file_string_setpos (STRING *s,unsigned long i) s->offset = i; /* set new offset */ s->curpos = s->chunk; /* reset position */ /* set size of data */ - if (s->cursize = min (s->chunksize,SIZE (s))) { + if ((s->cursize = min (s->chunksize,SIZE (s))) != 0L) { /* move to that position in the file */ fseek ((FILE *) s->data,s->offset,SEEK_SET); fread (s->curpos,sizeof (char),(unsigned int) s->cursize,(FILE *) s->data); @@ -224,7 +225,7 @@ int deliver (FILE *f,unsigned long msglen,char *user) STRING st; struct stat sbuf; /* have a mailbox specifier? */ - if (mailbox = strchr (user,'+')) { + if ((mailbox = strchr (user,'+')) != NULL) { *mailbox++ = '\0'; /* yes, tie off user name */ if (!*mailbox || !compare_cstring ((unsigned char *) mailbox,"INBOX")) mailbox = NIL; /* user+ and user+INBOX same as user */ diff --git a/imap/src/imapd/imapd.c b/imap/src/imapd/imapd.c index 5f72ac70..980eadec 100644 --- a/imap/src/imapd/imapd.c +++ b/imap/src/imapd/imapd.c @@ -335,7 +335,7 @@ int main (int argc,char *argv[]) if (nntp) { /* desire NNTP proxy? */ if (fgets (proxy,MAILTMPLEN,nntp)) { /* remove newline and set NNTP proxy */ - if (s = strchr (proxy,'\n')) *s = '\0'; + if ((s = strchr (proxy,'\n')) != NULL) *s = '\0'; nntpproxy = cpystr (proxy); /* disable the news driver */ mail_parameters (NIL,DISABLE_DRIVER,"news"); @@ -407,13 +407,13 @@ int main (int argc,char *argv[]) if (lstref) fs_give ((void **) &lstref); while (litsp) fs_give ((void **) &litstk[--litsp]); /* find end of line */ - if (t = strchr (cmdbuf,'\012')) { + if ((t = strchr (cmdbuf,'\012')) != NULL) { /* tie off command termination */ if ((t > cmdbuf) && (t[-1] == '\015')) --t; *t = '\0'; /* tie off LF or CRLF */ } if (!t) { /* probably line too long if not terminated */ - if (t = strchr (cmdbuf,' ')) { + if ((t = strchr (cmdbuf,' ')) != NULL) { if ((t - cmdbuf) > MAXTAG) t = NIL; else *t = '\0'; } @@ -481,7 +481,7 @@ int main (int argc,char *argv[]) unsigned char *cl = cpystr (tcp_clienthost ()); size_t cls; /* get just host name, calculate length */ - if (t = strchr (cl,' ')) { + if ((t = strchr (cl,' ')) != NULL) { *t = '\0'; cls = t - cl; } @@ -561,7 +561,7 @@ int main (int argc,char *argv[]) } else response ="%.80s NO AUTHENTICATE ANONYMOUS failed\015\012"; } - else if (user = cpystr (mail_auth (s,imap_responder,argc,argv))) { + else if ((user = cpystr (mail_auth (s,imap_responder,argc,argv))) != NULL) { pass = cpystr ("*"); state = SELECT; /* make select */ alerttime = 0; /* force alert */ @@ -621,7 +621,7 @@ int main (int argc,char *argv[]) tcp_clienthost ()); } else { /* delimit user from possible admin */ - if (s = strchr (user,'*')) *s++ ='\0'; + if ((s = strchr (user,'*')) != NULL) *s++ ='\0'; /* see if username and password are OK */ if (server_login (user,pass,s,argc,argv)) { state = SELECT; /* make select */ @@ -639,7 +639,7 @@ int main (int argc,char *argv[]) /* start TLS security */ else if (!strcmp (cmd,"STARTTLS")) { if (arg) response = badarg; - else if (lsterr = ssl_start_tls (pgmname)) response = lose; + else if ((lsterr = ssl_start_tls (pgmname)) != NULL) response = lose; } else { response = badcml; @@ -785,7 +785,7 @@ int main (int argc,char *argv[]) else if (!strcmp (s,"CC")) pg->function = SORTCC; else if (!strcmp (s,"SIZE")) pg->function = SORTSIZE; else break; - } while (s = strtok_r (NIL," ",&sstate)); + } while ((s = strtok_r (NIL," ",&sstate)) != NULL); /* bad SORT attribute */ if (s) response = badatt; /* get charset and search criteria */ @@ -795,7 +795,7 @@ int main (int argc,char *argv[]) else if (!parse_criteria (spg = mail_newsearchpgm (),&arg,nmsgs, uidmax (stream),0)) response = badatt; else if (arg && *arg) response = badarg; - else if (slst = mail_sort (stream,cs,spg,pgm,uid ? SE_UID:NIL)) { + else if ((slst = mail_sort (stream,cs,spg,pgm,uid ? SE_UID:NIL)) != NULL) { PSOUT ("* SORT"); for (sl = slst; *sl; sl++) { PBOUT (' '); @@ -825,7 +825,7 @@ int main (int argc,char *argv[]) uidmax (stream),0)) response = badatt; else if (arg && *arg) response = badarg; else { - if (thr = mail_thread (stream,s,cs,spg,uid ? SE_UID : NIL)) { + if ((thr = mail_thread (stream,s,cs,spg,uid ? SE_UID : NIL)) != NULL) { PSOUT ("* THREAD "); pthread (thr); mail_free_threadnode (&thr); @@ -903,7 +903,7 @@ int main (int argc,char *argv[]) ((arg[6] == 'T') || (arg[6] == 't')) && (arg[7] == ' ')) { arg += 8; /* yes, skip over CHARSET token */ - if (s = snarf (&arg)) charset = cpystr (s); + if ((s = snarf (&arg)) != NULL) charset = cpystr (s); else break; /* missing character set */ } /* must have arguments here */ @@ -1049,7 +1049,7 @@ int main (int argc,char *argv[]) /* copy and tie off */ strncpy (tmp,t,i)[i] = '\0'; /* nuke any trailing newline */ - if (t = strpbrk (tmp,"\r\n")) *t = '\0'; + if ((t = strpbrk (tmp,"\r\n")) != NULL) *t = '\0'; /* try to open proxy */ if ((tstream = mail_open (NIL,tmp,f | OP_SILENT)) && (response == win) && tstream->nmsgs) { @@ -1216,7 +1216,7 @@ int main (int argc,char *argv[]) PSOUT (t); CRLF; } - } while (t = strtok_r (NIL," ",&sstate)); + } while ((t = strtok_r (NIL," ",&sstate)) != NULL); ping_mailbox (uid); /* in case the fool did STATUS on open mbx */ PFLUSH (); /* make sure stdout is dumped in case slave */ if (!compare_cstring (s,"INBOX")) s = "INBOX"; @@ -1301,7 +1301,7 @@ int main (int argc,char *argv[]) PARAMETER *p; PSOUT ("* NAMESPACE"); if (ns) for (i = 0; i < 3; i++) { - if (n = ns[i]) { + if ((n = ns[i]) != NULL) { PSOUT (" ("); do { PBOUT ('('); @@ -1321,16 +1321,16 @@ int main (int argc,char *argv[]) break; } /* NAMESPACE extensions are hairy */ - if (p = n->param) do { + if ((p = n->param) != NULL) do { PBOUT (' '); pstring (p->attribute); PSOUT (" ("); do pstring (p->value); while (p->next && !p->next->attribute && (p = p->next)); PBOUT (')'); - } while (p = p->next); + } while ((p = p->next) != NULL); PBOUT (')'); - } while (n = n->next); + } while ((n = n->next) != NULL); PBOUT (')'); } else PSOUT (" NIL"); @@ -1464,7 +1464,7 @@ int main (int argc,char *argv[]) clearerr (stdin); /* clear stdin errors */ status = "discarding unread literal"; /* read literal and discard it */ - while (i = (litplus.size > MAILTMPLEN) ? MAILTMPLEN : litplus.size) { + while ((i = (litplus.size > MAILTMPLEN) ? MAILTMPLEN : litplus.size) != 0L){ if (state == LOGOUT) litplus.size = 0; else { settimeout (INPUTTIMEOUT); @@ -1479,7 +1479,7 @@ int main (int argc,char *argv[]) /* get new command tail */ slurp (tmp,MAILTMPLEN,INPUTTIMEOUT); /* locate end of line */ - if (t = strchr (tmp,'\012')) { + if ((t = strchr (tmp,'\012')) != NULL) { /* back over CR */ if ((t > tmp) && (t[-1] == '\015')) --t; *t = NIL; /* tie off CRLF */ @@ -1583,7 +1583,7 @@ int main (int argc,char *argv[]) syslog (LOG_INFO,"%s user=%.80s host=%.80s",logout, user ? (char *) user : "???",tcp_clienthost ()); /* do logout hook if needed */ - if (lgoh = (logouthook_t) mail_parameters (NIL,GET_LOGOUTHOOK,NIL)) + if ((lgoh = (logouthook_t) mail_parameters (NIL,GET_LOGOUTHOOK,NIL)) != NULL) (*lgoh) (mail_parameters (NIL,GET_LOGOUTDATA,NIL)); _exit (ret); /* all done */ return ret; /* stupid compilers */ @@ -2134,7 +2134,7 @@ unsigned char *parse_astring (unsigned char **arg,unsigned long *size, (*t > ' ') && (*t < 0x7f) && (*t != '(') && (*t != ')') && (*t != '{') && (*t != '%') && (*t != '*') && (*t != '"') && (*t != '\\'); ++t,++i); - if (*size = i) break; /* got atom if non-empty */ + if ((*size = i) != 0L) break; /* got atom if non-empty */ case ')': case '%': case '*': case '\\': case '\0': case ' ': return NIL; /* empty atom is a bogon */ case '"': /* hunt for trailing quote */ @@ -2192,7 +2192,7 @@ unsigned char *parse_astring (unsigned char **arg,unsigned long *size, } break; } - if (*del = *t) { /* have a delimiter? */ + if ((*del = *t) != '\0') { /* have a delimiter? */ *t++ = '\0'; /* yes, stomp on it */ *arg = t; /* update argument pointer */ } @@ -2291,7 +2291,7 @@ unsigned char *snarf_list (unsigned char **arg) for (s = t = *arg, i = 0; (*t > ' ') && (*t != '(') && (*t != ')') && (*t != '{') && (*t != '"') && (*t != '\\'); ++t,++i); - if (c = *t) { /* have a delimiter? */ + if ((c = *t) != '\0') { /* have a delimiter? */ *t++ = '\0'; /* stomp on it */ *arg = t; /* update argument pointer */ } @@ -2333,7 +2333,7 @@ STRINGLIST *parse_stringlist (unsigned char **s,int *list) /* must be end of list */ if (c != ')') mail_free_stringlist (&ret); } - if (t = *s) { /* need to reload strtok state? */ + if ((t = *s) != '\0') { /* need to reload strtok state? */ /* end of a list? */ if (*list && (*t == ')') && !t[1]) *list = NIL; else sstate = t; /* otherwise reset strtok state to s */ @@ -2757,9 +2757,9 @@ void fetch_work (char *t,unsigned long uid,fetchfn_t f[],void *fa[]) else if (!strcmp (t,"FULL")) strcpy (t,"(FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)"); else if (!strcmp (t,"FAST")) strcpy (t,"(FLAGS INTERNALDATE RFC822.SIZE)"); - if (list = (*t == '(')) t++; /* skip open paren */ + if ((list = (*t == '(')) != 0) t++; /* skip open paren */ /* parse attribute list */ - if (s = strtok_r (t," ",&sstate)) do { + if ((s = strtok_r (t," ",&sstate)) != NULL) do { if (list && (i = strlen (s)) && (s[i-1] == ')')) { list = NIL; /* done with list */ s[i-1] = '\0'; /* tie off last item */ @@ -3080,7 +3080,7 @@ void fetch_body_part_binary (unsigned long i,void *args) /* what encoding was used? */ if (body) switch (body->encoding) { case ENCBASE64: - if (cst.data = rfc822_base64 (st.data,st.size,&cst.size)) break; + if ((cst.data = rfc822_base64 (st.data,st.size,&cst.size)) != NULL) break; fetch_uid (i,NIL); /* wrote a space, so must do something */ if (lsterr) fs_give ((void **) &lsterr); lsterr = cpystr ("Undecodable BASE64 contents"); @@ -3088,7 +3088,7 @@ void fetch_body_part_binary (unsigned long i,void *args) fs_give ((void **) &tmp); return; case ENCQUOTEDPRINTABLE: - if (cst.data = rfc822_qprint (st.data,st.size,&cst.size)) break; + if ((cst.data = rfc822_qprint (st.data,st.size,&cst.size)) != NULL) break; fetch_uid (i,NIL); /* wrote a space, so must do something */ if (lsterr) fs_give ((void **) &lsterr); lsterr = cpystr ("Undecodable QUOTED-PRINTABLE contents"); @@ -3284,8 +3284,8 @@ void fetch_flags (unsigned long i,void *args) if (elt->flagged) put_flag (&c,"\\Flagged"); if (elt->answered) put_flag (&c,"\\Answered"); if (elt->draft) put_flag (&c,"\\Draft"); - if (u = elt->user_flags) do /* any user flags? */ - if (t = stream->user_flags[find_rightmost_bit (&u)]) put_flag (&c,t); + if ((u = elt->user_flags) != 0L) do /* any user flags? */ + if ((t = stream->user_flags[find_rightmost_bit (&u)]) != NULL) put_flag (&c,t); while (u); /* until no more user flags */ PBOUT (')'); /* end of flags */ elt->spare2 = NIL; /* we've sent the update */ @@ -3478,7 +3478,7 @@ void pbodystructure (BODY *body) /* multipart type? */ if (body->type == TYPEMULTIPART) { /* print each part */ - if (part = body->nested.part) + if ((part = body->nested.part) != NULL) for (; part; part = part->next) pbodystructure (&(part->body)); else pbodystructure (NIL); PBOUT (' '); /* space delimiter */ @@ -3563,7 +3563,7 @@ void pbody (BODY *body) /* multipart type? */ if (body->type == TYPEMULTIPART) { /* print each part */ - if (part = body->nested.part) + if ((part = body->nested.part) != NULL) for (; part; part = part->next) pbody (&(part->body)); else pbody (NIL); PBOUT (' '); /* space delimiter */ @@ -3617,7 +3617,7 @@ void pparam (PARAMETER *param) pstring (param->attribute); PBOUT (' '); pstring (param->value); - if (param = param->next) PBOUT (' '); + if ((param = param->next) != NULL) PBOUT (' '); } while (param); PBOUT (')'); /* end of parameters */ } @@ -3643,7 +3643,7 @@ void paddr (ADDRESS *a) PBOUT (' '); pnstring (a->host); /* domain name of mailbox's host */ PBOUT (')'); /* terminate address */ - } while (a = a->next); /* until end of address */ + } while ((a = a->next) != NULL); /* until end of address */ PBOUT (')'); /* close address list */ } else PSOUT ("NIL"); /* empty address */ @@ -3662,7 +3662,7 @@ void pset (SEARCHSET **set) PBOUT (':'); pnum (cur->last); } - if (cur = cur->next) PBOUT (','); + if ((cur = cur->next) != NULL) PBOUT (','); } mail_free_searchset (set); /* flush set */ } @@ -3802,7 +3802,7 @@ void pastringlist (STRINGLIST *s) do { psizedastring (&s->text); /* output list member */ if (s->next) PBOUT (' '); - } while (s = s->next); + } while ((s = s->next) != NULL); PBOUT (')'); /* terminate list */ } @@ -3819,7 +3819,7 @@ void pnstringorlist (STRINGLIST *s) do { /* output list member */ psizedstring (&s->text,NIL); if (s->next) PBOUT (' '); - } while (s = s->next); + } while ((s = s->next) != NULL); PBOUT (')'); /* terminate list */ } /* and single-element list as string */ @@ -3877,7 +3877,7 @@ void ptext (SIZEDTEXT *txt,STRING *st) { unsigned char c,*s; unsigned long i = txt->size; - if (s = txt->data) while (i && ((PBOUT ((c = *s++) ? c : 0x80) != EOF))) --i; + if ((s = txt->data) != NULL) while (i && ((PBOUT ((c = *s++) ? c : 0x80) != EOF))) --i; else if (st) while (i && (PBOUT ((c = SNX (st)) ? c : 0x80) != EOF)) --i; /* failed to complete? */ if (i) ioerror (stdout,"writing text"); @@ -3894,7 +3894,7 @@ void pthread (THREADNODE *thr) PBOUT ('('); /* open branch */ if (thr->num) { /* first node message number */ pnum (thr->num); - if (t = thr->next) { /* any subsequent nodes? */ + if ((t = thr->next) != NULL) { /* any subsequent nodes? */ PBOUT (' '); while (t) { /* for each subsequent node */ if (t->branch) { /* branches? */ @@ -3947,7 +3947,7 @@ void pcapability (long flag) } if (flag <= 0) { /* want pre-authentication capabilities? */ PSOUT (" SASL-IR LOGIN-REFERRALS"); - if (s = ssl_start_tls (NIL)) fs_give ((void **) &s); + if ((s = ssl_start_tls (NIL)) != NULL) fs_give ((void **) &s); else PSOUT (" STARTTLS"); /* disable plaintext */ if (!(i = !mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL))) @@ -4142,7 +4142,7 @@ long proxycopy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) if (lsterr) fs_give ((void **) &lsterr); /* c-client clobbers sequence, use spare */ for (i = 1,j = 0,set = mail_newsearchset (); i <= nmsgs; i++) - if (mail_elt (stream,i)->spare = mail_elt (stream,i)->sequence) { + if ((mail_elt (stream,i)->spare = mail_elt (stream,i)->sequence) != 0L) { mail_append_set (set,mail_uid (stream,i)); if (!j) md.msgno = (j = i) - 1; } @@ -4197,7 +4197,7 @@ long proxy_append (MAILSTREAM *stream,void *data,char **flags,char **date, if (elt->flagged) strcat (s," \\Flagged"); if (elt->answered) strcat (s," \\Answered"); if (elt->draft) strcat (s," \\Draft"); - if (i = elt->user_flags) do + if ((i = elt->user_flags) != 0L) do if ((t = md->stream->user_flags[find_rightmost_bit (&i)]) && *t && (strlen (t) < ((size_t) (MAILTMPLEN-((s += strlen (s))+2-tmp))))) { *s++ = ' '; /* space delimiter */ @@ -4229,9 +4229,9 @@ long append_msg (MAILSTREAM *stream,void *data,char **flags,char **date, APPENDDATA *ad = (APPENDDATA *) data; unsigned char *arg = ad->arg; /* flush text of previous message */ - if (t = ad->flags) fs_give ((void **) &ad->flags); - if (t = ad->date) fs_give ((void **) &ad->date); - if (t = ad->msg) fs_give ((void **) &ad->msg); + if ((t = ad->flags) != NULL) fs_give ((void **) &ad->flags); + if ((t = ad->date) != NULL) fs_give ((void **) &ad->date); + if ((t = ad->msg) != NULL) fs_give ((void **) &ad->msg); *flags = *date = NIL; /* assume no flags or date */ if (t) { /* have previous message? */ if (!*arg) { /* if least one message, and no more coming */ diff --git a/imap/src/ipopd/ipop2d.c b/imap/src/ipopd/ipop2d.c index 14cbe52f..58d4d2d5 100644 --- a/imap/src/ipopd/ipop2d.c +++ b/imap/src/ipopd/ipop2d.c @@ -296,7 +296,7 @@ short c_helo (char *t,int argc,char *argv[]) pass = cpystr (tmp); if (!(s = strchr (u,':'))) { /* want remote mailbox? */ /* no, delimit user from possible admin */ - if (s = strchr (u,'*')) *s++ = '\0'; + if ((s = strchr (u,'*')) != NULL) *s++ = '\0'; if (server_login (user = cpystr (u),pass,s,argc,argv)) { syslog (LOG_INFO,"%sLogin user=%.80s host=%.80s",s ? "Admin " : "", user,tcp_clienthost ()); @@ -355,7 +355,7 @@ short c_fold (char *t) } #endif /* open mailbox, note # of messages */ - if (j = (stream = mail_open (stream,t,NIL)) ? stream->nmsgs : 0) { + if ((j = (stream = mail_open (stream,t,NIL)) ? stream->nmsgs : 0) != 0L){ sprintf (tmp,"1:%lu",j); /* fetch fast information for all messages */ mail_fetch_fast (stream,tmp,NIL); msg = (unsigned long *) fs_get ((stream->nmsgs + 1) * @@ -429,7 +429,7 @@ short c_retr (char *t) } fputs (status,stdout); /* yes, output message */ fputs ("\015\012",stdout); /* delimit header from text */ - if (t = mail_fetch_text (stream,msg[current],NIL,&i,FT_RETURNSTRINGSTRUCT)) + if ((t = mail_fetch_text (stream,msg[current],NIL,&i,FT_RETURNSTRINGSTRUCT)) != NULL) while (i) { /* blat the text */ if (!(j = fwrite (t,sizeof (char),i,stdout))) return DONE; if (i -= j) t += j; /* advance to incomplete data */ diff --git a/imap/src/ipopd/ipop3d.c b/imap/src/ipopd/ipop3d.c index 41dd96a6..9cb8bffc 100644 --- a/imap/src/ipopd/ipop3d.c +++ b/imap/src/ipopd/ipop3d.c @@ -192,9 +192,9 @@ int main (int argc,char *argv[]) AUTHENTICATOR *auth; PSOUT ("+OK Capability list follows:\015\012"); PSOUT ("TOP\015\012LOGIN-DELAY 180\015\012UIDL\015\012"); - if (s = ssl_start_tls (NIL)) fs_give ((void **) &s); + if ((s = ssl_start_tls (NIL)) != NULL) fs_give ((void **) &s); else PSOUT ("STLS\015\012"); - if (i = !mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL)) + if ((i = !mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL)) != 0L) PSOUT ("USER\015\012"); /* display secure server authenticators */ for (auth = mail_lookup_auth (1), s = "SASL"; auth; auth = auth->next) @@ -219,7 +219,7 @@ int main (int argc,char *argv[]) if (pass) fs_give ((void **) &pass); s = strtok (t," "); /* get mechanism name */ /* get initial response */ - if (initial = strtok (NIL,"\015\012")) { + if ((initial = strtok (NIL,"\015\012")) != NULL) { if ((*initial == '=') && !initial[1]) ++initial; else if (!*initial) initial = NIL; } @@ -272,7 +272,7 @@ int main (int argc,char *argv[]) else if (!strcmp (s,"RPOP")) PSOUT ("-ERR Nice try, bunkie\015\012"); else if (!strcmp (s,"STLS")) { - if (t = ssl_start_tls (pgmname)) { + if ((t = ssl_start_tls (pgmname)) != NULL) { PSOUT ("-ERR STLS failed: "); PSOUT (t); CRLF; @@ -288,7 +288,7 @@ int main (int argc,char *argv[]) /* skip leading whitespace (bogus clients!) */ while (*t == ' ') ++t; /* remote user name? */ - if (s = strchr (t,':')) { + if ((s = strchr (t,':')) != NULL) { *s++ = '\0'; /* tie off host name */ host = cpystr (t);/* copy host name */ user = cpystr (s);/* copy user name */ @@ -661,7 +661,7 @@ int pass_login (char *t,int argc,char *argv[]) pass = cpystr (t); /* copy password argument */ if (!host) { /* want remote mailbox? */ /* no, delimit user from possible admin */ - if (t = strchr (user,'*')) *t++ ='\0'; + if ((t = strchr (user,'*')) != NULL) *t++ ='\0'; /* attempt the login */ if (server_login (user,pass,t,argc,argv)) { int ret = mbxopen ("INBOX"); @@ -777,7 +777,7 @@ int mbxopen (char *mailbox) goodbye = "-ERR Can't get lock. Mailbox in use\015\012"; else { nmsgs = 0; /* no messages yet */ - if (j = stream->nmsgs) { /* if mailbox non-empty */ + if ((j = stream->nmsgs) != 0L) { /* if mailbox non-empty */ sprintf (tmp,"1:%lu",j); /* fetch fast information for all messages */ mail_fetch_fast (stream,tmp,NIL); } diff --git a/imap/src/mailutil/mailutil.c b/imap/src/mailutil/mailutil.c index cb62290a..2966a59f 100644 --- a/imap/src/mailutil/mailutil.c +++ b/imap/src/mailutil/mailutil.c @@ -284,8 +284,8 @@ int main (int argc,char *argv[]) else if ((i = !strcmp (cmd,"move")) || !strcmp (cmd,"copy")) { if (!src || !dst || merge) printf (usage3,pgm,cmd,usgcpymov,stdsw); - else if (source = mail_open (NIL,src,((i || rwcopyp) ? NIL : OP_READONLY) | - (debugp ? OP_DEBUG : NIL))) { + else if ((source = mail_open (NIL,src,((i || rwcopyp) ? NIL : OP_READONLY) | + (debugp ? OP_DEBUG : NIL))) != NULL) { dest = NIL; /* open destination stream if network */ if ((*dst != '{') || (dest = mail_open (NIL,dst,OP_HALFOPEN | (debugp ? OP_DEBUG : NIL)))) { @@ -295,8 +295,8 @@ int main (int argc,char *argv[]) } else if ((i = !strcmp (cmd,"appenddelete")) || !strcmp (cmd,"append")) { if (!src || !dst || merge) printf (usage3,pgm,cmd,usgappdel,stdsw); - else if (source = mail_open (NIL,src,((i || rwcopyp) ? NIL : OP_READONLY) | - (debugp ? OP_DEBUG : NIL))) { + else if ((source = mail_open (NIL,src,((i || rwcopyp) ? NIL : OP_READONLY) | + (debugp ? OP_DEBUG : NIL))) != NULL) { dest = NIL; /* open destination stream if network */ if ((*dst != '{') || (dest = mail_open (NIL,dst,OP_HALFOPEN | (debugp ? OP_DEBUG : NIL)))) { @@ -376,7 +376,7 @@ int main (int argc,char *argv[]) rewind (f); /* read back mailbox names */ for (retcode = 0; !retcode && (fgets (tmp,MAILTMPLEN-1,f)); ) { - if (t = strchr (tmp+1,'\n')) *t = '\0'; + if ((t = strchr (tmp+1,'\n')) != NULL) *t = '\0'; for (t = mbx,t1 = dest ? dest->mailbox : "",c = NIL; (c != '}') && *t1; *t++ = c= *t1++); for (t1 = dp; *t1; *t++ = *t1++); @@ -384,7 +384,7 @@ int main (int argc,char *argv[]) t1 = source ? (strchr (tmp+1,'}') + 1) : tmp + 1; /* src and mbx have different delimiters? */ if (ddelim && (ddelim != tmp[0])) - while (c = *t1++) { /* swap delimiters then */ + while ((c = *t1++) != '\0') { /* swap delimiters then */ if (c == ddelim) c = tmp[0] ? tmp[0] : 'x'; else if (c == tmp[0]) c = ddelim; *t++ = c; @@ -396,8 +396,8 @@ int main (int argc,char *argv[]) printf ("Copying %s\n => %s\n",tmp+1,mbx); fflush (stdout); } - if (source = mail_open (source,tmp+1,(debugp ? OP_DEBUG : NIL) | - (rwcopyp ? NIL : OP_READONLY))) { + if ((source = mail_open (source,tmp+1,(debugp ? OP_DEBUG : NIL) | + (rwcopyp ? NIL : OP_READONLY))) != NULL) { if (!mbxcopy (source,dest,mbx,T,NIL,merge)) retcode = 1; if (source->dtb->flags & DR_LOCAL) source = mail_close (source); } @@ -595,7 +595,7 @@ int mbxcopy (MAILSTREAM *source,MAILSTREAM *dest,char *dst,int create,int del, fputs ("alternative name: ",stdout); fflush (stdout); fgets (tmp,MAILTMPLEN-1,stdin); - if (s = strchr (tmp,'\n')) *s = '\0'; + if ((s = strchr (tmp,'\n')) != NULL) *s = '\0'; } if (ndst) fs_give ((void **) &ndst); ndst = cpystr (tmp); @@ -624,7 +624,7 @@ int mbxcopy (MAILSTREAM *source,MAILSTREAM *dest,char *dst,int create,int del, char *tail = "\\Deleted)"; char *flags = (char *) fs_get (1 + len + strlen (tail) + 1); s = flags; *s++ = '('; - for (i = 0; i < NUSERFLAGS; ++i) if (t = source->user_flags[i]) { + for (i = 0; i < NUSERFLAGS; ++i) if ((t = source->user_flags[i]) != NULL) { while (*t) *s++ = *t++; *s++ = ' '; } @@ -895,7 +895,7 @@ void mm_login (NETMBX *mb,char *username,char *password,long trial) printf ("%s} username: ",tmp); fgets (username,NETMAXUSER-1,stdin); username[NETMAXUSER-1] = '\0'; - if (s = strchr (username,'\n')) *s = '\0'; + if ((s = strchr (username,'\n')) != NULL) *s = '\0'; s = "password: "; } if(strlen (s = getpass (s)) < MAILTMPLEN) strcpy (password,s); diff --git a/imap/src/mlock/mlock.c b/imap/src/mlock/mlock.c index 1dca40ed..35d6be4d 100644 --- a/imap/src/mlock/mlock.c +++ b/imap/src/mlock/mlock.c @@ -32,6 +32,7 @@ #include <sysexits.h> #include <syslog.h> #include <grp.h> +#include <unistd.h> #include <sys/types.h> #include <sys/file.h> #include <sys/stat.h> @@ -40,6 +41,7 @@ #include <netdb.h> #include <ctype.h> #include <string.h> +#include <time.h> #define LOCKTIMEOUT 5 /* lock timeout in minutes */ #define LOCKPROTECTION 0664 diff --git a/imap/src/mtest/mtest.c b/imap/src/mtest/mtest.c index 8e997d0b..018d1bcd 100644 --- a/imap/src/mtest/mtest.c +++ b/imap/src/mtest/mtest.c @@ -104,7 +104,7 @@ int main () if (pwd) { strcpy (tmp,pwd->pw_gecos); /* dyke out the office and phone poop */ - if (suffix = strchr (tmp,',')) suffix[0] = '\0'; + if ((suffix = strchr (tmp,',')) != NULL) suffix[0] = '\0'; strcpy (personalname,tmp);/* make a permanent copy of it */ } else personalname[0] = '\0'; @@ -125,10 +125,10 @@ int main () puts ("Enter INBOX, mailbox name, or IMAP mailbox as {host}mailbox"); puts ("Known local mailboxes:"); mail_list (NIL,NIL,"%"); - if (s = sm_read (tmpx,&sdb)) { + if ((s = sm_read (tmpx,&sdb)) != NULL) { puts ("Local subscribed mailboxes:"); do (mm_lsub (NIL,NIL,s,NIL)); - while (s = sm_read (tmpx,&sdb)); + while ((s = sm_read (tmpx,&sdb)) != NULL); } puts ("or just hit return to quit"); } @@ -158,7 +158,7 @@ void mm (MAILSTREAM *stream,long debug) while (stream) { prompt ("MTest> ",cmd, sizeof(cmd)); /* prompt user, get command */ /* get argument */ - if (arg = strchr (cmd,' ')) *arg++ = '\0'; + if ((arg = strchr (cmd,' ')) != NULL) *arg++ = '\0'; switch (*ucase (cmd)) { /* dispatch based on command */ case 'B': /* Body command */ if (arg) last = atoi (arg); @@ -198,10 +198,10 @@ void mm (MAILSTREAM *stream,long debug) case 'F': /* Find command */ if (!arg) { arg = "%"; - if (s = sm_read (tmp,&sdb)) { + if ((s = sm_read (tmp,&sdb)) != NULL) { puts ("Local network subscribed mailboxes:"); do if (*s == '{') (mm_lsub (NIL,NIL,s,NIL)); - while (s = sm_read (tmp,&sdb)); + while ((s = sm_read (tmp,&sdb)) != NULL); } } puts ("Subscribed mailboxes:"); @@ -398,7 +398,7 @@ void overview_header (MAILSTREAM *stream,unsigned long uid,OVERVIEW *ov, memcpy (tmp+18,t,(size_t) min (20,(long) strlen (t))); } strcat (tmp," "); - if (i = elt->user_flags) { + if ((i = elt->user_flags) != 0L) { strcat (tmp,"{"); while (i) { strcat (tmp,stream->user_flags[find_rightmost_bit (&i)]); @@ -436,7 +436,7 @@ void header (MAILSTREAM *stream,long msgno) tmp[18] = '\0'; mail_fetchfrom (tmp+18,stream,msgno,(long) 20); strcat (tmp," "); - if (i = cache->user_flags) { + if ((i = cache->user_flags) != 0L) { strcat (tmp,"{"); while (i) { strcat (tmp,stream->user_flags[find_rightmost_bit (&i)]); @@ -473,9 +473,9 @@ void display_body (BODY *body,char *pfx,long i) sprintf (s," %s%ld %s",pfx,++i,body_types[body->type]); if (body->subtype) sprintf (s += strlen (s),"/%s",body->subtype); if (body->description) sprintf (s += strlen (s)," (%s)",body->description); - if (par = body->parameter) do + if ((par = body->parameter) != NULL) do sprintf (s += strlen (s),";%s=%s",par->attribute,par->value); - while (par = par->next); + while ((par = par->next) != NULL); if (body->id) sprintf (s += strlen (s),", id = %s",body->id); switch (body->type) { /* bytes or lines depending upon body type */ case TYPEMESSAGE: /* encapsulated message */ @@ -530,10 +530,10 @@ void status (MAILSTREAM *stream) else s = "IMAP2 (RFC 1064)"; printf ("%s server %s\n",s,imap_host (stream)); if (LEVELIMAP4 (stream)) { - if (i = imap_cap (stream)->auth) { + if ((i = imap_cap (stream)->auth) != 0L) { s = ""; printf ("Mutually-supported SASL mechanisms:"); - while (auth = mail_lookup_auth (find_rightmost_bit (&i) + 1)) { + while ((auth = mail_lookup_auth (find_rightmost_bit (&i) + 1)) != NULL) { printf (" %s",auth->name); if (!strcmp (auth->name,"PLAIN")) s = "\n [LOGIN will not be listed here if PLAIN is supported]"; @@ -579,7 +579,7 @@ void status (MAILSTREAM *stream) putchar ('\n'); } if (LEVELSCAN (stream)) puts (" Mailbox text scan"); - if (i = imap_cap (stream)->extlevel) { + if ((i = imap_cap (stream)->extlevel) != 0L) { printf ("Supported BODYSTRUCTURE extensions:"); switch (i) { case BODYEXTLOC: printf (" location"); @@ -719,7 +719,7 @@ void mm_login (NETMBX *mb,char *user,char *pwd,long trial) printf ("%s} username: ",tmp); fgets (user,NETMAXUSER-1,stdin); user[NETMAXUSER-1] = '\0'; - if (s = strchr (user,'\n')) *s = '\0'; + if ((s = strchr (user,'\n')) != NULL) *s = '\0'; s = "password: "; } if (curusr) fs_give ((void **) &curusr); @@ -810,14 +810,14 @@ void smtptest (long debug) strcpy (msg->date,line); if (msg->to) { puts ("Sending..."); - if (stream = smtp_open (hostlist,debug)) { + if ((stream = smtp_open (hostlist,debug)) != NULL) { if (smtp_mail (stream,"MAIL",msg,body)) puts ("[Ok]"); else printf ("[Failed - %s]\n",stream->reply); } } else { puts ("Posting..."); - if (stream = nntp_open (newslist,debug)) { + if ((stream = nntp_open (newslist,debug)) != NULL) { if (nntp_mail (stream,msg,body)) puts ("[Ok]"); else printf ("[Failed - %s]\n",stream->reply); } diff --git a/imap/src/osdep/unix/dummy.c b/imap/src/osdep/unix/dummy.c index cb3b45bd..07ed4618 100644 --- a/imap/src/osdep/unix/dummy.c +++ b/imap/src/osdep/unix/dummy.c @@ -156,7 +156,7 @@ void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents) if (!pat || !*pat) { /* empty pattern? */ if (dummy_canonicalize (test,ref,"*")) { /* tie off name at root */ - if (s = strchr (test,'/')) *++s = '\0'; + if ((s = strchr (test,'/')) != NULL) *++s = '\0'; else test[0] = '\0'; dummy_listed (stream,'/',test,LATT_NOSELECT,NIL); } @@ -164,13 +164,13 @@ void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents) /* get canonical form of name */ else if (dummy_canonicalize (test,ref,pat)) { /* found any wildcards? */ - if (s = strpbrk (test,"%*")) { + if ((s = strpbrk (test,"%*")) != NULL) { /* yes, copy name up to that point */ strncpy (file,test,i = s - test); file[i] = '\0'; /* tie off */ } else strcpy (file,test); /* use just that name then */ - if (s = strrchr (file,'/')){/* find directory name */ + if ((s = strrchr (file,'/')) != NULL){/* find directory name */ *++s = '\0'; /* found, tie off at that point */ s = file; } @@ -228,7 +228,7 @@ void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat) } } /* until no more subscriptions */ - while (s = sm_read (tmpx,&sdb)); + while ((s = sm_read (tmpx,&sdb)) != NULL); } @@ -277,7 +277,7 @@ void dummy_list_work (MAILSTREAM *stream,char *dir,char *pat,char *contents, size_t len = 0; /* punt if bogus name */ if (!mailboxdir (tmp,dir,NIL)) return; - if (dp = opendir (tmp)) { /* do nothing if can't open directory */ + if ((dp = opendir (tmp)) != NULL) { /* do nothing if can't open directory */ /* see if a non-namespace directory format */ for (drivers = (DRIVER *) mail_parameters (NIL,GET_DRIVERS,NIL), dt = NIL; dir && !dt && drivers; drivers = drivers->next) @@ -289,7 +289,7 @@ void dummy_list_work (MAILSTREAM *stream,char *dir,char *pat,char *contents, dummy_listed (stream,'/',dir,dt ? NIL : LATT_NOSELECT,contents); /* scan directory, ignore . and .. */ - if (!dir || dir[(len = strlen (dir)) - 1] == '/') while (d = readdir (dp)) + if (!dir || dir[(len = strlen (dir)) - 1] == '/') while ((d = readdir (dp)) != NULL) if ((!(dt && (*dt) (d->d_name))) && ((d->d_name[0] != '.') || (((long) mail_parameters (NIL,GET_HIDEDOTFILES,NIL)) ? NIL : @@ -480,7 +480,7 @@ long dummy_create_path (MAILSTREAM *stream,char *path,long dirmode) int wantdir = t && !t[1]; int mask = umask (0); if (wantdir) *t = '\0'; /* flush trailing delimiter for directory */ - if (s = strrchr (path,'/')) { /* found superior to this name? */ + if ((s = strrchr (path,'/')) != NULL) { /* found superior to this name? */ c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -798,7 +798,7 @@ long dummy_canonicalize (char *tmp,char *ref,char *pat) else return NIL; /* unknown namespace */ } /* count wildcards */ - for (i = 0, s = tmp; *s; *s++) if ((*s == '*') || (*s == '%')) ++i; + for (i = 0, s = tmp; *s; s++) if ((*s == '*') || (*s == '%')) ++i; if (i > MAXWILDCARDS) { /* ridiculous wildcarding? */ MM_LOG ("Excessive wildcards in LIST/LSUB",ERROR); return NIL; diff --git a/imap/src/osdep/unix/env_unix.c b/imap/src/osdep/unix/env_unix.c index d1bb1f02..89e50921 100644 --- a/imap/src/osdep/unix/env_unix.c +++ b/imap/src/osdep/unix/env_unix.c @@ -514,7 +514,7 @@ static void do_date (char *date,char *prefix,char *fmt,int suffix) * -1 local time is 1 day behind UTC, offset -24 hours * -36x local time is January 1, UTC is December 31, offset +24 hours */ - if (julian = t->tm_yday -julian) + if ((julian = t->tm_yday -julian) != 0) zone += ((julian < 0) == (abs (julian) == 1)) ? -24*60 : 24*60; if (prefix) { /* want day of week? */ sprintf (date,prefix,days[t->tm_wday]); @@ -672,14 +672,14 @@ static struct passwd *valpwd (char *user,char *pwd,int argc,char *argv[]) struct passwd *pw; struct passwd *ret = NIL; if (auth_md5.server) { /* using CRAM-MD5 authentication? */ - if (s = auth_md5_pwd (user)) { + if ((s = auth_md5_pwd (user)) != NULL) { if (!strcmp (s,pwd) || ((*pwd == ' ') && pwd[1] && !strcmp (s,pwd+1))) ret = pwuser (user); /* validated, get passwd entry for user */ memset (s,0,strlen (s)); /* erase sensitive information */ fs_give ((void **) &s); } } - else if (pw = pwuser (user)) {/* can get user? */ + else if ((pw = pwuser (user)) != NULL) {/* can get user? */ s = cpystr (pw->pw_name); /* copy returned name in case we need it */ if (*pwd && !(ret = checkpw (pw,pwd,argc,argv)) && (*pwd == ' ') && pwd[1] && (ret = pwuser (s))) @@ -1257,7 +1257,7 @@ long dotlock_lock (char *file,DOTLOCK *base,int fd) MM_NOCRITICAL (NIL); /* no longer critical */ /* find directory/file delimiter */ - if (s = strrchr (base->lock,'/')) { + if ((s = strrchr (base->lock,'/')) != NULL) { *s = '\0'; /* tie off at directory */ sprintf(tmp, /* generate default message */ "Mailbox vulnerable - directory %.80s must have 1777 protection", @@ -1588,7 +1588,7 @@ void dorc (char *file,long flag) if (!compare_cstring (s,"set new-mailbox-format") || !compare_cstring (s,"set new-folder-format")) { if (!compare_cstring (k,"same-as-inbox")) { - if (d = mail_valid (NIL,"INBOX",NIL)) { + if ((d = mail_valid (NIL,"INBOX",NIL)) != NULL) { if (!compare_cstring (d->name,"mbox")) d = (DRIVER *) mail_parameters (NIL,GET_DRIVER, (void *) "unix"); @@ -1601,7 +1601,7 @@ void dorc (char *file,long flag) else { /* canonicalize mbox to unix */ if (!compare_cstring (k,"mbox")) k = "unix"; /* see if a driver name */ - if (d = (DRIVER *) mail_parameters (NIL,GET_DRIVER,(void *) k)) + if ((d = (DRIVER *) mail_parameters (NIL,GET_DRIVER,(void *) k)) != NULL) createProto = (*d->open) (NIL); else { /* duh... */ sprintf (tmpx,"Unknown new mailbox format in %s: %s", diff --git a/imap/src/osdep/unix/fdstring.c b/imap/src/osdep/unix/fdstring.c index 7a491f7d..207e4d0b 100644 --- a/imap/src/osdep/unix/fdstring.c +++ b/imap/src/osdep/unix/fdstring.c @@ -91,7 +91,7 @@ static void fd_string_setpos (STRING *s,unsigned long i) s->offset = i; /* set new offset */ s->curpos = s->chunk; /* reset position */ /* set size of data */ - if (s->cursize = min (s->chunksize,SIZE (s))) { + if ((s->cursize = min (s->chunksize,SIZE (s))) != 0L) { /* move to that position in the file */ lseek ((long) s->data,s->data1 + s->offset,L_SET); read ((long) s->data,s->curpos,(size_t) s->cursize); diff --git a/imap/src/osdep/unix/mbx.c b/imap/src/osdep/unix/mbx.c index dc902b20..18c4fa20 100644 --- a/imap/src/osdep/unix/mbx.c +++ b/imap/src/osdep/unix/mbx.c @@ -477,7 +477,7 @@ long mbx_rename (MAILSTREAM *stream,char *old,char *newname) if (newname) { /* want rename? */ /* found superior to destination name? */ - if (s = strrchr (tmp,'/')) { + if ((s = strrchr (tmp,'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* superior name doesn't exist, create it */ @@ -822,11 +822,11 @@ long mbx_ping (MAILSTREAM *stream) /* reparse header if not flagchecking */ if (!LOCAL->flagcheck) ret = mbx_parse (stream); /* sweep mailbox for changed message status */ - else if (ret = mbx_parse (stream)) { + else if ((ret = mbx_parse (stream)) != 0L) { unsigned long recent = 0; LOCAL->filetime = sbuf.st_mtime; for (i = 1; i <= stream->nmsgs; ) - if (elt = mbx_elt (stream,i,LOCAL->expok)) { + if ((elt = mbx_elt (stream,i,LOCAL->expok)) != NULL) { if (elt->recent) ++recent; ++i; } @@ -885,14 +885,14 @@ long mbx_expunge (MAILSTREAM *stream,char *sequence,long options) { long ret; unsigned long nexp,reclaimed; - if (ret = sequence ? ((options & EX_UID) ? + if ((ret = sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) { + mail_sequence (stream,sequence)) : LONGT) != 0L) { if (!mbx_ping (stream)); /* do nothing if stream dead */ else if (stream->rdonly) /* won't do on readonly files! */ MM_LOG ("Expunge ignored on readonly mailbox",WARN); /* if expunged any messages */ - else if (nexp = mbx_rewrite (stream,&reclaimed,sequence ? -1 : 1)) { + else if ((nexp = mbx_rewrite (stream,&reclaimed,sequence ? -1 : 1)) != 0L){ sprintf (LOCAL->buf,"Expunged %lu messages",nexp); MM_LOG (LOCAL->buf,(long) NIL); } @@ -935,7 +935,7 @@ void mbx_snarf (MAILSTREAM *stream) hdr = cpystr (mail_fetchheader_full (sysibx,i,NIL,&hdrlen,NIL)); txt = mail_fetchtext_full (sysibx,i,&txtlen,FT_PEEK); /* if have a message */ - if (j = hdrlen + txtlen) { + if ((j = hdrlen + txtlen) != 0L){ /* build header line */ mail_date (LOCAL->buf,elt = mail_elt (sysibx,i)); sprintf (LOCAL->buf + strlen (LOCAL->buf), @@ -1032,7 +1032,7 @@ long mbx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) mail_date(LOCAL->buf,elt);/* build target header */ /* get target keyword mask */ for (j = elt->user_flags, k = 0; j; ) - if (s = stream->user_flags[find_rightmost_bit (&j)]) + if ((s = stream->user_flags[find_rightmost_bit (&j)]) != NULL) for (m = 0; (m < NUSERFLAGS) && (t = dstream->user_flags[m]); m++) if (!compare_cstring (s,t) && (k |= 1 << m)) break; sprintf (LOCAL->buf+strlen(LOCAL->buf),",%lu;%08lx%04x-%08lx\015\012", @@ -1041,7 +1041,7 @@ long mbx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) (fFLAGGED * elt->flagged) + (fANSWERED * elt->answered) + (fDRAFT * elt->draft)),cu ? ++dstream->uid_last : 0); /* write target header */ - if (ret = (write (fd,LOCAL->buf,strlen (LOCAL->buf)) > 0)) { + if ((ret = (write (fd,LOCAL->buf,strlen (LOCAL->buf)) > 0)) != 0L) { for (k = elt->rfc822_size; ret && (j = min (k,LOCAL->buflen)); k -= j){ read (LOCAL->fd,LOCAL->buf,j); ret = write (fd,LOCAL->buf,j) >= 0; @@ -1641,7 +1641,7 @@ unsigned long mbx_hdrpos (MAILSTREAM *stream,unsigned long msgno, elt->private.special.text.size; if (hdr) *hdr = NIL; /* assume no header returned */ /* is header size known? */ - if (*size = elt->private.msg.header.text.size) return ret; + if ((*size = elt->private.msg.header.text.size) != 0L) return ret; /* paranoia check */ if (LOCAL->buflen < (HDRBUFLEN + SLOP)) fatal ("LOCAL->buf smaller than HDRBUFLEN"); @@ -1733,7 +1733,7 @@ unsigned long mbx_rewrite (MAILSTREAM *stream,unsigned long *reclaimed, MM_CRITICAL (stream); /* go critical */ for (i = 1,delta = 0,pos = ppos = HDRSIZE; i <= stream->nmsgs; ) { /* note if message not at predicted location */ - if (m = (elt = mbx_elt (stream,i,NIL))->private.special.offset - ppos) { + if ((m = (elt = mbx_elt (stream,i,NIL))->private.special.offset - ppos) != 0L) { ppos = elt->private.special.offset; *reclaimed += m; /* note reclaimed message space */ delta += m; /* and as expunge delta */ @@ -1773,7 +1773,7 @@ unsigned long mbx_rewrite (MAILSTREAM *stream,unsigned long *reclaimed, } } /* deltaed file size match position? */ - if (m = (LOCAL->filesize -= delta) - pos) { + if ((m = (LOCAL->filesize -= delta) - pos) != 0L) { *reclaimed += m; /* probably an fEXPUNGED msg */ LOCAL->filesize = pos; /* set correct size */ } @@ -1792,7 +1792,7 @@ unsigned long mbx_rewrite (MAILSTREAM *stream,unsigned long *reclaimed, (*bn) (BLOCK_NONE,NIL); /* do hide-expunge when shared */ if (flags) for (i = 1; i <= stream->nmsgs; ) { - if (elt = mbx_elt (stream,i,T)) { + if ((elt = mbx_elt (stream,i,T)) != NULL) { /* make the message invisible */ if (elt->deleted && ((flags > 0) || elt->sequence)) { mbx_update_status (stream,elt->msgno,LONGT); diff --git a/imap/src/osdep/unix/mh.c b/imap/src/osdep/unix/mh.c index 005000d6..ac71b6ba 100644 --- a/imap/src/osdep/unix/mh.c +++ b/imap/src/osdep/unix/mh.c @@ -251,7 +251,7 @@ char *mh_path (char *tmp) /* parse profile file */ for (s = strtok_r (t,"\r\n",&r); s && *s; s = strtok_r (NIL,"\r\n",&r)) { /* found space in line? */ - if (v = strpbrk (s," \t")) { + if ((v = strpbrk (s," \t")) != NULL) { *v++ = '\0'; /* tie off, is keyword "Path:"? */ if (!compare_cstring (s,"Path:")) { /* skip whitespace */ @@ -324,7 +324,7 @@ long mh_dirfmttest (char *s) if (strcmp (s,MHSEQUENCE) && strcmp (s,MHSEQUENCES)) { if (*s == MHCOMMA) ++s; /* else comma + all numeric name */ /* success if all-numeric */ - while (c = *s++) if (!isdigit (c)) return NIL; + while ((c = *s++) != '\0') if (!isdigit (c)) return NIL; } return LONGT; } @@ -343,7 +343,7 @@ void mh_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents) if (!pat || !*pat) { /* empty pattern? */ if (mh_canonicalize (test,ref,"*")) { /* tie off name at root */ - if (s = strchr (test,'/')) *++s = '\0'; + if ((s = strchr (test,'/')) != NULL) *++s = '\0'; else test[0] = '\0'; mm_list (stream,'/',test,LATT_NOSELECT); } @@ -356,14 +356,14 @@ void mh_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents) } if (test[3] == '/') { /* looking down levels? */ /* yes, found any wildcards? */ - if (s = strpbrk (test,"%*")) { + if ((s = strpbrk (test,"%*")) != NULL) { /* yes, copy name up to that point */ strncpy (file,test+4,i = s - (test+4)); file[i] = '\0'; /* tie off */ } else strcpy (file,test+4);/* use just that name then */ /* find directory name */ - if (s = strrchr (file,'/')) { + if ((s = strrchr (file,'/')) != NULL) { *s = '\0'; /* found, tie off at that point */ s = file; } @@ -401,7 +401,7 @@ void mh_lsub (MAILSTREAM *stream,char *ref,char *pat) /* get canonical form of name */ if (mh_canonicalize (test,ref,pat) && (s = sm_read (tmp,&sdb))) { do if (pmatch_full (s,test,'/')) mm_lsub (stream,'/',s,NIL); - while (s = sm_read (tmp,&sdb)); /* until no more subscriptions */ + while ((s = sm_read (tmp,&sdb)) != NULL); /* until no more subscriptions */ } } @@ -425,8 +425,8 @@ void mh_list_work (MAILSTREAM *stream,char *dir,char *pat,long level) if (!mh_file (curdir,name)) return; cp = curdir + strlen (curdir);/* end of directory name */ np = name + strlen (name); /* end of MH name */ - if (dp = opendir (curdir)) { /* open directory */ - while (d = readdir (dp)) /* scan, ignore . and numeric names */ + if ((dp = opendir (curdir)) != NULL) { /* open directory */ + while ((d = readdir (dp)) != NULL) /* scan, ignore . and numeric names */ if ((d->d_name[0] != '.') && !mh_select (d)) { strcpy (cp,d->d_name); /* make directory name */ if (!stat (curdir,&sbuf) && ((sbuf.st_mode & S_IFMT) == S_IFDIR)) { @@ -510,10 +510,10 @@ long mh_delete (MAILSTREAM *stream,char *mailbox) } /* get name of directory */ i = strlen (mh_file (tmp,mailbox)); - if (dirp = opendir (tmp)) { /* open directory */ + if ((dirp = opendir (tmp)) != NULL) { /* open directory */ tmp[i++] = '/'; /* now apply trailing delimiter */ /* massacre all mh owned files */ - while (d = readdir (dirp)) if (mh_dirfmttest (d->d_name)) { + while ((d = readdir (dirp)) != NULL) if (mh_dirfmttest (d->d_name)) { strcpy (tmp + i,d->d_name); unlink (tmp); /* sayonara */ } @@ -550,7 +550,7 @@ long mh_rename (MAILSTREAM *stream,char *old,char *newname) newname); /* success if can rename the directory */ else { /* found superior to destination name? */ - if (s = strrchr (mh_file (tmp1,newname),'/')) { + if ((s = strrchr (mh_file (tmp1,newname),'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -734,7 +734,7 @@ void mh_load_message (MAILSTREAM *stream,unsigned long msgno,long flags) switch (c = SNX (&bs)) { case '\015': /* unlikely carriage return */ *t++ = c; - if ((CHR (&bs) == '\012')) { + if (CHR (&bs) == '\012') { *t++ = SNX (&bs); i++; } @@ -760,7 +760,7 @@ void mh_load_message (MAILSTREAM *stream,unsigned long msgno,long flags) switch (c = SNX (&bs)) { case '\015': /* unlikely carriage return */ *t++ = c; - if ((CHR (&bs) == '\012')) { + if (CHR (&bs) == '\012') { *t++ = SNX (&bs); i++; } @@ -883,7 +883,7 @@ long mh_ping (MAILSTREAM *stream) fs_give ((void **) &names[i]); } /* free directory */ - if (s = (void *) names) fs_give ((void **) &s); + if ((s = (void *) names) != NULL) fs_give ((void **) &s); } /* if INBOX, snarf from system INBOX */ @@ -934,7 +934,7 @@ long mh_ping (MAILSTREAM *stream) unlink (LOCAL->buf);/* flush this file */ } sprintf (tmp,"Message copy to MH mailbox failed: %.80s", - s,strerror (errno)); + strerror (errno)); mm_log (tmp,ERROR); r = 0; /* stop the snarf in its tracks */ } @@ -977,9 +977,9 @@ long mh_expunge (MAILSTREAM *stream,char *sequence,long options) unsigned long i = 1; unsigned long n = 0; unsigned long recent = stream->recent; - if (ret = sequence ? ((options & EX_UID) ? + if ((ret = sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) { + mail_sequence (stream,sequence)) : LONGT) != 0L) { mm_critical (stream); /* go critical */ while (i <= stream->nmsgs) {/* for each message */ elt = mail_elt (stream,i);/* if deleted, need to trash it */ @@ -1132,7 +1132,7 @@ long mh_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data) fs_give ((void **) &names[i]); } else last = 0; /* no messages here yet */ - if (s = (void *) names) fs_give ((void **) &s); + if ((s = (void *) names) != NULL) fs_give ((void **) &s); mm_critical (stream); /* go critical */ do { @@ -1195,7 +1195,7 @@ int mh_select (struct direct *name) { char c; char *s = name->d_name; - while (c = *s++) if (!isdigit (c)) return NIL; + while ((c = *s++) != '\0') if (!isdigit (c)) return NIL; return T; } @@ -1258,7 +1258,7 @@ long mh_canonicalize (char *pattern,char *ref,char *pat) else strcpy (pattern,pat); /* just have basic name */ if (mh_isvalid (pattern,tmp,T)) { /* count wildcards */ - for (i = 0, s = pattern; *s; *s++) if ((*s == '*') || (*s == '%')) ++i; + for (i = 0, s = pattern; *s; s++) if ((*s == '*') || (*s == '%')) ++i; /* success if not too many */ if (i <= MAXWILDCARDS) return LONGT; mm_log ("Excessive wildcards in LIST/LSUB",ERROR); diff --git a/imap/src/osdep/unix/mix.c b/imap/src/osdep/unix/mix.c index 63009bb2..c53cabc0 100644 --- a/imap/src/osdep/unix/mix.c +++ b/imap/src/osdep/unix/mix.c @@ -331,7 +331,7 @@ long mix_scan_contents (char *name,char *contents,unsigned long csiz, fs_give ((void **) &names[i]); } /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); return ret; } @@ -475,10 +475,10 @@ long mix_delete (MAILSTREAM *stream,char *mailbox) close (fd); /* close descriptor on deleted metadata */ /* get directory name */ *(s = strrchr (tmp,'/')) = '\0'; - if (dirp = opendir (tmp)) { /* open directory */ + if ((dirp = opendir (tmp)) != NULL) { /* open directory */ *s++ = '/'; /* restore delimiter */ /* massacre messages */ - while (d = readdir (dirp)) if (mix_dirfmttest (d->d_name)) { + while ((d = readdir (dirp)) != NULL) if (mix_dirfmttest (d->d_name)) { strcpy (s,d->d_name); /* make path */ unlink (tmp); /* sayonara */ } @@ -526,7 +526,7 @@ long mix_rename (MAILSTREAM *stream,char *old,char *newname) /* easy if not INBOX */ if (compare_cstring (old,"INBOX")) { /* found superior to destination name? */ - if (s = strrchr (tmp1,'/')) { + if ((s = strrchr (tmp1,'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -564,7 +564,7 @@ long mix_rename (MAILSTREAM *stream,char *old,char *newname) fs_give ((void **) &names[i]); } /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); if (lasterror) errno = lasterror; else { close (fd); /* close descriptor on metadata */ @@ -631,7 +631,7 @@ MAILSTREAM *mix_open (MAILSTREAM *stream) stream->sequence++; /* bump sequence number */ /* parse mailbox */ stream->nmsgs = stream->recent = 0; - if (silent = stream->silent) LOCAL->internal = T; + if ((silent = stream->silent) != 0) LOCAL->internal = T; stream->silent = T; if (mix_ping (stream)) { /* do initial ping */ /* try burping in case we are exclusive */ @@ -749,7 +749,7 @@ char *mix_header (MAILSTREAM *stream,unsigned long msgno,unsigned long *length, else { /* document the problem */ LOCAL->buf[100] = '\0'; /* tie off buffer at no more than 100 octets */ /* or at newline, whichever is first */ - if (s = strpbrk (LOCAL->buf,"\015\012")) *s = '\0'; + if ((s = strpbrk (LOCAL->buf,"\015\012")) != NULL) *s = '\0'; sprintf (tmp,"Error reading mix message header, uid=%lx, s=%.0lx, h=%s", elt->private.uid,elt->rfc822_size,LOCAL->buf); MM_LOG (tmp,ERROR); @@ -960,7 +960,7 @@ long mix_ping (MAILSTREAM *stream) flags[0] = '('; strcat (flags,")"); INIT (&msg,mail_string,message,msglen); - if (snarfok = mail_append_full (stream,"INBOX",flags,date,&msg)) { + if ((snarfok = mail_append_full (stream,"INBOX",flags,date,&msg)) != 0L) { char sequence[15]; sprintf (sequence,"%lu",i); mail_flag (sysibx,sequence,"\\Deleted",ST_SET); @@ -985,8 +985,8 @@ long mix_ping (MAILSTREAM *stream) /* expunging OK if global flag set */ if (mail_parameters (NIL,GET_EXPUNGEATPING,NIL)) LOCAL->expok = T; /* process metadata/index/status */ - if (statf = mix_parse (stream,&idxf,LONGT, - (LOCAL->internal ? NIL : LONGT))) { + if ((statf = mix_parse (stream,&idxf,LONGT, + (LOCAL->internal ? NIL : LONGT))) != NULL) { fclose (statf); /* just close the status file */ ret = LONGT; /* declare success */ } @@ -1033,8 +1033,8 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options) mail_uid_sequence (stream,sequence) : mail_sequence (stream,sequence))) || stream->rdonly); /* read index and open status exclusive */ - else if (statf = mix_parse (stream,&idxf,LONGT, - LOCAL->internal ? NIL : LONGT)) { + else if ((statf = mix_parse (stream,&idxf,LONGT, + LOCAL->internal ? NIL : LONGT)) != NULL) { /* expunge unless just burping */ if (!burponly) for (i = 1; i <= stream->nmsgs;) { elt = mail_elt (stream,i);/* need to expunge this message? */ @@ -1111,7 +1111,7 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options) } else MM_LOG ("No mix message files found during expunge",WARN); /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); } /* either way, re-acquire shared lock */ @@ -1120,7 +1120,7 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options) /* Do this step even if ret is NIL (meaning some burp problem)! */ if (nexp || reclaimed) { /* rewrite index and status if changed */ LOCAL->indexseq = mix_modseq (LOCAL->indexseq); - if (ret = mix_index_update (stream,idxf,NIL)) { + if ((ret = mix_index_update (stream,idxf,NIL)) != 0L){ LOCAL->statusseq = mix_modseq (LOCAL->statusseq); /* set failure if update fails */ ret = mix_status_update (stream,statf,NIL); @@ -1237,7 +1237,7 @@ long mix_burp (MAILSTREAM *stream,MIXBURP *burp,unsigned long *reclaimed) /* if matches range then no burp needed! */ if (burp->set.last == sbuf.st_size) ret = LONGT; /* just need to remove cruft at end */ - else if (ret = !truncate (LOCAL->buf,burp->set.last)) + else if ((ret = !truncate (LOCAL->buf,burp->set.last)) != 0L) *reclaimed += sbuf.st_size - burp->set.last; else { sprintf (LOCAL->buf,truncerr,burp->name,strerror (errno)); @@ -1341,7 +1341,7 @@ long mix_burp_check (SEARCHSET *set,size_t size,char *file) file,size,set->last); MM_LOG (tmp,ERROR); return NIL; /* don't burp this file at all */ - } while (set = set->next); + } while ((set = set->next) != NULL); return LONGT; } @@ -1379,11 +1379,11 @@ long mix_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) else if (!(ret = ((options & CP_UID) ? mail_uid_sequence (stream,sequence) : mail_sequence (stream,sequence)))); /* acquire stream to append */ - else if (ret = ((astream = mail_open (NIL,mailbox,OP_SILENT)) && + else if ((ret = ((astream = mail_open (NIL,mailbox,OP_SILENT)) && !astream->rdonly && (((MIXLOCAL *) astream->local)->expok = T) && (statf = mix_parse (astream,&idxf,LONGT,NIL))) ? - LONGT : NIL) { + LONGT : NIL) != 0L) { int fd; unsigned long i; MESSAGECACHE *elt; @@ -1405,7 +1405,7 @@ long mix_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) if ((elt = mail_elt (stream,i))->sequence) newsize += hdrsize + elt->rfc822_size; /* open data file */ - if (msgf = mix_data_open (astream,&fd,&size,newsize)) { + if ((msgf = mix_data_open (astream,&fd,&size,newsize)) != NULL) { char *t; unsigned long j,uid,uidv; copyuid_t cu = (copyuid_t) mail_parameters (NIL,GET_COPYUID,NIL); @@ -1434,7 +1434,7 @@ long mix_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) INIT (&st,fd_string,&d,elt->rfc822_size); /* init flag string */ tmp[0] = tmp[1] = '\0'; - if (j = elt->user_flags) do + if ((j = elt->user_flags) != 0L) do if ((t = stream->user_flags[find_rightmost_bit (&j)]) && *t) strcat (strcat (tmp," "),t); while (j); @@ -1457,8 +1457,8 @@ long mix_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) fclose (msgf); /* all good, close the msg file now */ /* write new metadata, index, and status */ local->metaseq = local->indexseq = local->statusseq = seq; - if (ret = (mix_meta_update (astream) && - mix_index_update (astream,idxf,LONGT))) { + if ((ret = (mix_meta_update (astream) && + mix_index_update (astream,idxf,LONGT))) != 0L){ /* success, delete if doing a move */ if (options & CP_MOVE) for (i = 1; i <= stream->nmsgs; i++) @@ -1521,8 +1521,8 @@ long mix_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data) if (!stream) stream = user_flags (&mixproto); if (!ret) switch (errno) { /* if not valid mailbox */ case ENOENT: /* no such file? */ - if (ret = compare_cstring (mailbox,"INBOX") ? - NIL : mix_create (NIL,"INBOX")) + if ((ret = compare_cstring (mailbox,"INBOX") ? + NIL : mix_create (NIL,"INBOX")) != 0L) break; MM_NOTIFY (stream,"[TRYCREATE] Must create mailbox before append",NIL); break; @@ -1538,11 +1538,11 @@ long mix_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data) FILE *idxf = NIL; FILE *msgf = NIL; FILE *statf = NIL; - if (ret = ((astream = mail_open (NIL,mailbox,OP_SILENT)) && + if ((ret = ((astream = mail_open (NIL,mailbox,OP_SILENT)) && !astream->rdonly && (((MIXLOCAL *) astream->local)->expok = T) && (statf = mix_parse (astream,&idxf,LONGT,NIL))) ? - LONGT : NIL) { + LONGT : NIL) != 0l) { int fd; unsigned long size,hdrsize; MESSAGECACHE elt; @@ -1558,7 +1558,7 @@ long mix_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data) MM_CRITICAL (astream); /* go critical */ astream->silent = T; /* no events here */ /* open data file */ - if (msgf = mix_data_open (astream,&fd,&size,hdrsize + SIZE (message))) { + if ((msgf = mix_data_open (astream,&fd,&size,hdrsize + SIZE (message))) != NULL){ appenduid_t au = (appenduid_t) mail_parameters (NIL,GET_APPENDUID,NIL); SEARCHSET *dst = au ? mail_newsearchset () : NIL; while (ret && message) {/* while good to go and have messages */ @@ -1747,14 +1747,14 @@ FILE *mix_parse (MAILSTREAM *stream,FILE **idxf,long iflags,long sflags) } /* slurp metadata */ - else if (s = mix_meta_slurp (stream,&i)) { + else if ((s = mix_meta_slurp (stream,&i)) != NULL) { unsigned long j = 0; /* non-zero if UIDVALIDITY/UIDLAST changed */ if (i != LOCAL->metaseq) { /* metadata changed? */ char *t,*k; LOCAL->metaseq = i; /* note new metadata sequence */ while (s && *s) { /* parse entire metadata file */ /* locate end of line */ - if (s = strstr (t = s,"\015\012")) { + if ((s = strstr (t = s,"\015\012")) != NULL) { *s = '\0'; /* tie off line */ s += 2; /* skip past CRLF */ switch (*t++) { /* parse line */ @@ -1783,7 +1783,7 @@ FILE *mix_parse (MAILSTREAM *stream,FILE **idxf,long iflags,long sflags) break; case 'K': /* new keyword list */ for (i = 0; t && *t && (i < NUSERFLAGS); ++i) { - if (t = strchr (k = t,' ')) *t++ = '\0'; + if ((t = strchr (k = t,' ')) != NULL) *t++ = '\0'; /* make sure keyword non-empty */ if (*k && (strlen (k) <= MAXUSERFLAG)) { /* in case value changes (shouldn't happen) */ @@ -2455,7 +2455,7 @@ FILE *mix_data_open (MAILSTREAM *stream,int *fd,long *size, } if (*fd >= 0) { /* have a data file? */ /* yes, get stdio and set position */ - if (msgf = fdopen (*fd,"r+b")) fseek (msgf,*size,SEEK_SET); + if ((msgf = fdopen (*fd,"r+b")) != NULL)fseek (msgf,*size,SEEK_SET); else close (*fd); /* fdopen() failed? */ } return msgf; /* return results */ @@ -2519,7 +2519,7 @@ FILE *mix_sortcache_open (MAILSTREAM *stream) /* ignore expansion values */ if (*s++ == ':') { - if (i = mail_msgno (stream,uid)) { + if ((i = mail_msgno (stream,uid)) != 0L) { sc = (SORTCACHE *) (*mc) (stream,i,CH_SORTCACHE); sc->size = (elt = mail_elt (stream,i))->rfc822_size; sc->date = sentdate; @@ -2698,7 +2698,7 @@ long mix_sortcache_update (MAILSTREAM *stream,FILE **sortcache) SORTCACHE *s = (SORTCACHE *) (*mc) (stream,i,CH_SORTCACHE); STRINGLIST *sl; s->dirty = NIL; /* no longer dirty */ - if (sl = s->references) /* count length of references */ + if ((sl = s->references) != NULL) /* count length of references */ for (j = 1; sl && sl->text.data; sl = sl->next) j += 10 + sl->text.size; else j = 0; /* no references yet */ @@ -2753,7 +2753,7 @@ char *mix_read_record (FILE *f,char *buf,unsigned long buflen,char *type) /* ensure string tied off */ buf[buflen-2] = buf[buflen-1] = '\0'; while (fgets (buf,buflen-1,f)) { - if (s = strchr (buf,'\012')) { + if ((s = strchr (buf,'\012')) != NULL) { if ((s != buf) && (s[-1] == '\015')) --s; *s = '\0'; /* tie off buffer */ if (s != buf) return buf; /* return if non-empty buffer */ diff --git a/imap/src/osdep/unix/mmdf.c b/imap/src/osdep/unix/mmdf.c index e962434e..994c34a3 100644 --- a/imap/src/osdep/unix/mmdf.c +++ b/imap/src/osdep/unix/mmdf.c @@ -537,12 +537,13 @@ long mmdf_rename (MAILSTREAM *stream,char *old,char *newname) MM_CRITICAL (stream); /* get the c-client lock */ if (!dummy_file (file,old) || (newname && (!((s = mailboxfile (tmp,newname)) && *s) || - ((s = strrchr (tmp,'/')) && !s[1])))) - sprintf (tmp,newname ? - "Can't rename mailbox %.80s to %.80s: invalid name" : - "Can't delete mailbox %.80s: invalid name", - old,newname); - /* lock out other c-clients */ + ((s = strrchr (tmp,'/')) && !s[1])))){ + if(newname) sprintf (tmp, + "Can't rename mailbox %.80s to %.80s: invalid name", + old,newname); + else + sprintf (tmp, "Can't delete mailbox %.80s: invalid name", old); + } /* lock out other c-clients */ else if ((ld = lockname (lock,file,LOCK_EX|LOCK_NB,&i)) < 0) sprintf (tmp,"Mailbox %.80s is in use by another process",old); @@ -554,7 +555,7 @@ long mmdf_rename (MAILSTREAM *stream,char *old,char *newname) else { if (newname) { /* want rename? */ /* found superior to destination name? */ - if (s = strrchr (s,'/')) { + if ((s = strrchr (s,'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -981,9 +982,9 @@ long mmdf_expunge (MAILSTREAM *stream,char *sequence,long options) unsigned long i; DOTLOCK lock; char *msg = NIL; - if (ret = (sequence ? ((options & EX_UID) ? + if ((ret = (sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) && + mail_sequence (stream,sequence)) : LONGT) != 0L) && LOCAL && (LOCAL->ld >= 0) && !stream->lock && mmdf_parse (stream,&lock,LOCK_EX)) { /* check expunged messages if not dirty */ @@ -1391,10 +1392,10 @@ int mmdf_append_msgs (MAILSTREAM *stream,FILE *sf,FILE *df,SEARCHSET *set) if (i < (j = strlen (tmp))) fatal ("mmdf_append_msgs overrun"); i -= j; /* number of bytes left */ /* squish out ^A and CRs (note copies NUL) */ - for (x = tmp; x = strpbrk (x,"\01\r"); --j) memmove (x,x+1,j-(x-tmp)); + for (x = tmp; (x = strpbrk (x,"\01\r")) != NULL; --j) memmove (x,x+1,j-(x-tmp)); if (!j) continue; /* do nothing if line emptied */ /* start of line? */ - if ((c == '\n')) switch (tmp[0]) { + if (c == '\n') switch (tmp[0]) { case 'S': case 's': /* possible "Status:" */ if (hdrp && (j > 6) && ((tmp[1] == 't') || (tmp[1] == 'T')) && ((tmp[2] == 'a') || (tmp[2] == 'A')) && @@ -1609,7 +1610,7 @@ int mmdf_parse (MAILSTREAM *stream,DOTLOCK *lock,int op) } /* new data? */ - else if (i = sbuf.st_size - LOCAL->filesize) { + else if ((i = sbuf.st_size - LOCAL->filesize) != 0L) { d.fd = LOCAL->fd; /* yes, set up file descriptor */ d.pos = LOCAL->filesize; /* get to that position in the file */ d.chunk = LOCAL->buf; /* initial buffer chunk */ @@ -1931,7 +1932,7 @@ int mmdf_parse (MAILSTREAM *stream,DOTLOCK *lock,int op) char err[MAILTMPLEN]; sprintf (err,"Discarding bogus continuation in msg %lu: %.80s", elt->msgno,(char *) s); - if (u = strpbrk (err,"\r\n")) *u = '\0'; + if ((u = strpbrk (err,"\r\n")) != NULL) *u = '\0'; MM_LOG (err,WARN); break; /* different case or something */ } @@ -2175,7 +2176,7 @@ unsigned long mmdf_xstatus (MAILSTREAM *stream,char *status,MESSAGECACHE *elt, while (n /= 10); /* pop UID last digits from stack */ while (t > stack) *s++ = *--t; - for (n = 0; n < NUSERFLAGS; ++n) if (t = stream->user_flags[n]) + for (n = 0; n < NUSERFLAGS; ++n) if ((t = stream->user_flags[n]) != NULL) for (*s++ = ' '; *t; *s++ = *t++); *s++ = '\n'; pad += 30; /* increased padding if have IMAPbase */ @@ -2197,7 +2198,7 @@ unsigned long mmdf_xstatus (MAILSTREAM *stream,char *status,MESSAGECACHE *elt, if (sticky) { /* only do this if UIDs sticky */ *s++ = 'X'; *s++ = '-'; *s++ = 'K'; *s++ = 'e'; *s++ = 'y'; *s++ = 'w'; *s++ = 'o'; *s++ = 'r'; *s++ = 'd'; *s++ = 's'; *s++ = ':'; - if (n = elt->user_flags) do { + if ((n = elt->user_flags) != 0L) do { *s++ = ' '; for (t = stream->user_flags[find_rightmost_bit (&n)]; *t; *s++ = *t++); } while (n); @@ -2261,7 +2262,7 @@ long mmdf_rewrite (MAILSTREAM *stream,unsigned long *nexp,DOTLOCK *lock, size = mmdf_pseudo (stream,LOCAL->buf); } /* extend the file as necessary */ - if (ret = mmdf_extend (stream,size)) { + if ((ret = mmdf_extend (stream,size)) != 0L){ /* Set up buffered I/O file structure * curpos current position being written through buffering * filepos current position being written physically to the disk @@ -2454,7 +2455,7 @@ void mmdf_write (MMDFFILE *f,char *buf,unsigned long size) if (buf) { /* doing buffered write? */ i = f->bufpos - f->buf; /* yes, get size of current buffer data */ /* yes, have space in current buffer chunk? */ - if (j = i ? ((f->buflen - i) % OVERFLOWBUFLEN) : f->buflen) { + if ((j = i ? ((f->buflen - i) % OVERFLOWBUFLEN) : f->buflen) != 0L) { /* yes, fill up buffer as much as we can */ memcpy (f->bufpos,buf,k = min (j,size)); f->bufpos += k; /* new buffer position */ @@ -2470,7 +2471,7 @@ void mmdf_write (MMDFFILE *f,char *buf,unsigned long size) * chunks that will fit in unprotected space. */ /* any unprotected space we can write to? */ - if (j = min (i,f->protect - f->filepos)) { + if ((j = min (i,f->protect - f->filepos)) != 0L) { /* yes, filepos not at chunk boundary? */ if ((k = f->filepos % OVERFLOWBUFLEN) && ((k = OVERFLOWBUFLEN - k) < j)) j -= k; /* yes, and can write out partial chunk */ diff --git a/imap/src/osdep/unix/mtx.c b/imap/src/osdep/unix/mtx.c index 8e6f76e8..4346eceb 100644 --- a/imap/src/osdep/unix/mtx.c +++ b/imap/src/osdep/unix/mtx.c @@ -287,10 +287,11 @@ long mtx_rename (MAILSTREAM *stream,char *old,char *newname) if (!mtx_file (file,old) || (newname && (!((s = mailboxfile (tmp,newname)) && *s) || ((s = strrchr (tmp,'/')) && !s[1])))) { - sprintf (tmp,newname ? - "Can't rename mailbox %.80s to %.80s: invalid name" : - "Can't delete mailbox %.80s: invalid name", - old,newname); + if(newname) + sprintf (tmp, + "Can't rename mailbox %.80s to %.80s: invalid name", old,newname); + else + sprintf (tmp, "Can't delete mailbox %.80s: invalid name", old); MM_LOG (tmp,ERROR); return NIL; } @@ -314,7 +315,7 @@ long mtx_rename (MAILSTREAM *stream,char *old,char *newname) } if (newname) { /* want rename? */ - if (s = strrchr (tmp,'/')) {/* found superior to destination name? */ + if ((s = strrchr (tmp,'/')) != NULL) {/* found superior to destination name? */ c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -680,7 +681,7 @@ void mtx_snarf (MAILSTREAM *stream) hdr = cpystr (mail_fetchheader_full (sysibx,i,NIL,&hdrlen,NIL)); txt = mail_fetchtext_full (sysibx,i,&txtlen,FT_PEEK); /* if have a message */ - if (j = hdrlen + txtlen) { + if ((j = hdrlen + txtlen) != 0L) { /* calculate header line */ mail_date (LOCAL->buf,elt = mail_elt (sysibx,i)); sprintf (LOCAL->buf + strlen (LOCAL->buf), diff --git a/imap/src/osdep/unix/mx.c b/imap/src/osdep/unix/mx.c index 45495279..10d56b0a 100644 --- a/imap/src/osdep/unix/mx.c +++ b/imap/src/osdep/unix/mx.c @@ -239,7 +239,7 @@ long mx_dirfmttest (char *name) int c; /* success if index name or all-numberic */ if (strcmp (name,MXINDEXNAME+1)) - while (c = *name++) if (!isdigit (c)) return NIL; + while ((c = *name++) != '\0') if (!isdigit (c)) return NIL; return LONGT; } @@ -286,7 +286,7 @@ long mx_scan_contents (char *name,char *contents,unsigned long csiz, fs_give ((void **) &names[i]); } /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); return ret; } @@ -392,10 +392,10 @@ long mx_delete (MAILSTREAM *stream,char *mailbox) mailbox,strerror (errno)); else { /* get directory name */ *(s = strrchr (tmp,'/')) = '\0'; - if (dirp = opendir (tmp)) { /* open directory */ + if ((dirp = opendir (tmp)) != NULL) { /* open directory */ *s++ = '/'; /* restore delimiter */ /* massacre messages */ - while (d = readdir (dirp)) if (mx_select (d)) { + while ((d = readdir (dirp)) != NULL) if (mx_select (d)) { strcpy (s,d->d_name); /* make path */ unlink (tmp); /* sayonara */ } @@ -438,7 +438,7 @@ long mx_rename (MAILSTREAM *stream,char *old,char *newname) /* easy if not INBOX */ if (compare_cstring (old,"INBOX")) { /* found superior to destination name? */ - if (s = strrchr (mx_file (tmp1,newname),'/')) { + if ((s = strrchr (mx_file (tmp1,newname),'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -466,7 +466,7 @@ long mx_rename (MAILSTREAM *stream,char *old,char *newname) fs_give ((void **) &names[i]); } /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); if (lasterror || mx_rename_work (tmp,srcl,tmp1,dstl,MXINDEXNAME+1)) errno = lasterror; else return mx_create (NIL,"INBOX"); @@ -749,7 +749,7 @@ long mx_ping (MAILSTREAM *stream) fs_give ((void **) &names[i]); } /* free directory */ - if (s = (void *) names) fs_give ((void **) &s); + if ((s = (void *) names) != NULL) fs_give ((void **) &s); } stream->nmsgs = nmsgs; /* don't upset mail_uid() */ @@ -801,7 +801,7 @@ long mx_ping (MAILSTREAM *stream) unlink (LOCAL->buf);/* flush this file */ } sprintf (tmp,"Message copy to MX mailbox failed: %.80s", - s,strerror (errno)); + strerror (errno)); MM_LOG (tmp,ERROR); r = 0; /* stop the snarf in its tracks */ } @@ -844,9 +844,9 @@ long mx_expunge (MAILSTREAM *stream,char *sequence,long options) unsigned long i = 1; unsigned long n = 0; unsigned long recent = stream->recent; - if (ret = (sequence ? ((options & EX_UID) ? + if ((ret = (sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) && + mail_sequence (stream,sequence)) : LONGT) != 0L) && mx_lockindex (stream)) { /* lock the index */ MM_CRITICAL (stream); /* go critical */ while (i <= stream->nmsgs) {/* for each message */ @@ -936,8 +936,8 @@ long mx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) SEARCHSET *dest = cu ? mail_newsearchset () : NIL; for (i = 1,uid = uidv = 0; ret && (i <= stream->nmsgs); i++) if ((elt = mail_elt (stream,i))->sequence) { - if (ret = ((fd = open (mx_fast_work (stream,elt),O_RDONLY,NIL)) - >= 0)) { + if ((ret = ((fd = open (mx_fast_work (stream,elt),O_RDONLY,NIL)) + >= 0)) != 0L) { fstat (fd,&sbuf); /* get size of message */ d.fd = fd; /* set up file descriptor */ d.pos = 0; /* start of file */ @@ -946,8 +946,8 @@ long mx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) INIT (&st,fd_string,&d,sbuf.st_size); /* init flag string */ tmp[0] = tmp[1] = '\0'; - if (j = elt->user_flags) do - if (t = stream->user_flags[find_rightmost_bit (&j)]) + if ((j = elt->user_flags) != 0L) do + if ((t = stream->user_flags[find_rightmost_bit (&j)]) != NULL) strcat (strcat (tmp," "),t); while (j); if (elt->seen) strcat (tmp," \\Seen"); @@ -957,7 +957,7 @@ long mx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) if (elt->draft) strcat (tmp," \\Draft"); tmp[0] = '('; /* open list */ strcat (tmp,")"); /* close list */ - if (ret = mx_append_msg (astream,tmp,elt,&st,dest)) { + if ((ret = mx_append_msg (astream,tmp,elt,&st,dest)) != 0L) { /* add to source set if needed */ if (source) mail_append_set (source,mail_uid (stream,i)); /* delete if doing a move */ @@ -1114,7 +1114,7 @@ int mx_select (struct direct *name) { char c; char *s = name->d_name; - while (c = *s++) if (!isdigit (c)) return NIL; + while ((c = *s++) != '\0') if (!isdigit (c)) return NIL; return T; } @@ -1186,7 +1186,7 @@ long mx_lockindex (MAILSTREAM *stream) break; case 'K': /* keyword */ /* find end of keyword */ - if (s = strchr (t = ++s,'\n')) { + if ((s = strchr (t = ++s,'\n')) != NULL) { *s++ = '\0'; /* tie off keyword */ /* copy keyword */ if ((k < NUSERFLAGS) && !stream->user_flags[k] && diff --git a/imap/src/osdep/unix/news.c b/imap/src/osdep/unix/news.c index 4cf5bb70..1af24273 100644 --- a/imap/src/osdep/unix/news.c +++ b/imap/src/osdep/unix/news.c @@ -215,7 +215,7 @@ void news_list (MAILSTREAM *stream,char *ref,char *pat) if (!pat || !*pat) { /* empty pattern? */ if (news_canonicalize (ref,"*",pattern)) { /* tie off name at root */ - if (s = strchr (pattern,'.')) *++s = '\0'; + if ((s = strchr (pattern,'.')) != NULL) *++s = '\0'; else pattern[0] = '\0'; mm_list (stream,'.',pattern,LATT_NOSELECT); } @@ -231,7 +231,7 @@ void news_list (MAILSTREAM *stream,char *ref,char *pat) strcpy (name,"#news."); /* write initial prefix */ i = strlen (pattern); /* length of pattern */ if (pattern[--i] != '%') i = 0; - if (t = strtok_r (s,"\n",&r)) do if (u = strchr (t,' ')) { + if ((t = strtok_r (s,"\n",&r)) != NULL) do if ((u = strchr (t,' ')) != NULL) { *u = '\0'; /* tie off at end of name */ strcpy (name + 6,t); /* make full form of name */ if (pmatch_full (name,pattern,'.')) mm_list (stream,'.',name,NIL); @@ -240,7 +240,7 @@ void news_list (MAILSTREAM *stream,char *ref,char *pat) if (pmatch_full (name,pattern,'.')) mm_list (stream,'.',name,LATT_NOSELECT); } - } while (t = strtok_r (NIL,"\n",&r)); + } while ((t = strtok_r (NIL,"\n",&r)) != NULL); fs_give ((void **) &s); } } @@ -283,7 +283,7 @@ long news_canonicalize (char *ref,char *pat,char *pattern) if ((pattern[0] == '#') && (pattern[1] == 'n') && (pattern[2] == 'e') && (pattern[3] == 'w') && (pattern[4] == 's') && (pattern[5] == '.') && !strchr (pattern,'/')) { /* count wildcards */ - for (i = 0, s = pattern; *s; *s++) if ((*s == '*') || (*s == '%')) ++i; + for (i = 0, s = pattern; *s; s++) if ((*s == '*') || (*s == '%')) ++i; /* success if not too many */ if (i <= MAXWILDCARDS) return LONGT; MM_LOG ("Excessive wildcards in LIST/LSUB",ERROR); @@ -365,7 +365,7 @@ MAILSTREAM *news_open (MAILSTREAM *stream) /* build directory name */ sprintf (s = tmp,"%s/%s",(char *) mail_parameters (NIL,GET_NEWSSPOOL,NIL), stream->mailbox + 6); - while (s = strchr (s,'.')) *s = '/'; + while ((s = strchr (s,'.')) != NULL) *s = '/'; /* scan directory */ if ((nmsgs = scandir (tmp,&names,news_select,news_numsort)) >= 0) { mail_exists (stream,nmsgs); /* notify upper level that messages exist */ @@ -406,7 +406,7 @@ int news_select (struct direct *name) { char c; char *s = name->d_name; - while (c = *s++) if (!isdigit (c)) return NIL; + while ((c = *s++) != '\0') if (!isdigit (c)) return NIL; return T; } @@ -566,7 +566,7 @@ void news_load_message (MAILSTREAM *stream,unsigned long msgno,long flags) switch (c = SNX (&bs)) { case '\015': /* unlikely carriage return */ *t++ = c; - if ((CHR (&bs) == '\012')) *t++ = SNX (&bs); + if (CHR (&bs) == '\012') *t++ = SNX (&bs); break; case '\012': /* line feed? */ *t++ = '\015'; @@ -586,7 +586,7 @@ void news_load_message (MAILSTREAM *stream,unsigned long msgno,long flags) switch (c = SNX (&bs)) { case '\015': /* unlikely carriage return */ *t++ = c; - if ((CHR (&bs) == '\012')) *t++ = SNX (&bs); + if (CHR (&bs) == '\012') *t++ = SNX (&bs); break; case '\012': /* line feed? */ *t++ = '\015'; diff --git a/imap/src/osdep/unix/nl_unix.c b/imap/src/osdep/unix/nl_unix.c index b2d5616a..5ae96b08 100644 --- a/imap/src/osdep/unix/nl_unix.c +++ b/imap/src/osdep/unix/nl_unix.c @@ -46,7 +46,7 @@ unsigned long strcrlfcpy (unsigned char **dst,unsigned long *dstl, if (i > *dstl) fs_give ((void **) dst); } /* make a new buffer if needed */ - if (!*dst) *dst = (char *) fs_get ((*dstl = i) + 1); + if (!*dst) *dst = (unsigned char *) fs_get ((*dstl = i) + 1); d = *dst; /* destination string */ if (srcl) do { /* main copy loop */ if ((c = *src++) < '\016') { diff --git a/imap/src/osdep/unix/phile.c b/imap/src/osdep/unix/phile.c index ce72d0a9..85aa8cbb 100644 --- a/imap/src/osdep/unix/phile.c +++ b/imap/src/osdep/unix/phile.c @@ -289,7 +289,7 @@ MAILSTREAM *phile_open (MAILSTREAM *stream) t = localtime(&sbuf.st_mtime);/* get local time */ /* calculate time delta */ i = t->tm_hour * 60 + t->tm_min - i; - if (k = t->tm_yday - k) i += ((k < 0) == (abs (k) == 1)) ? -24*60 : 24*60; + if ((k = t->tm_yday - k) != 0) i += ((k < 0) == (abs (k) == 1)) ? -24*60 : 24*60; k = abs (i); /* time from UTC either way */ elt->hours = t->tm_hour; elt->minutes = t->tm_min; elt->seconds = t->tm_sec; elt->day = t->tm_mday; elt->month = t->tm_mon + 1; @@ -306,7 +306,7 @@ MAILSTREAM *phile_open (MAILSTREAM *stream) /* fill in From field from file owner */ LOCAL->env->from = mail_newaddr (); - if (pw = getpwuid (sbuf.st_uid)) strcpy (tmp,pw->pw_name); + if ((pw = getpwuid (sbuf.st_uid)) != NULL) strcpy (tmp,pw->pw_name); else sprintf (tmp,"User-Number-%ld",(long) sbuf.st_uid); LOCAL->env->from->mailbox = cpystr (tmp); LOCAL->env->from->host = cpystr (mylocalhost ()); @@ -318,7 +318,7 @@ MAILSTREAM *phile_open (MAILSTREAM *stream) buf->data[buf->size] = '\0'; close (fd); /* close the file */ /* analyze data type */ - if (i = phile_type (buf->data,buf->size,&j)) { + if ((i = phile_type (buf->data,buf->size,&j)) != 0){ LOCAL->body->type = TYPETEXT; LOCAL->body->subtype = cpystr ("PLAIN"); if (!(i & PTYPECRTEXT)) { /* change Internet newline format as needed */ diff --git a/imap/src/osdep/unix/tcp_unix.c b/imap/src/osdep/unix/tcp_unix.c index 4fe8194d..339c968c 100644 --- a/imap/src/osdep/unix/tcp_unix.c +++ b/imap/src/osdep/unix/tcp_unix.c @@ -176,7 +176,7 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port) if (host[0] == '[' && host[(strlen (host))-1] == ']') { strcpy (tmp,host+1); /* yes, copy number part */ tmp[(strlen (tmp))-1] = '\0'; - if (adr = ip_stringtoaddr (tmp,&adrlen,&family)) { + if ((adr = ip_stringtoaddr (tmp,&adrlen,&family)) != NULL) { (*bn) (BLOCK_TCPOPEN,NIL); /* get an open socket for this system */ sock = tcp_socket_open (family,adr,adrlen,port,tmp,ctrp, @@ -223,7 +223,7 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port) /* init sockets */ stream->tcpsi = stream->tcpso = sock; /* stash in the snuck-in byte */ - if (stream->ictr = ctr) *(stream->iptr = stream->ibuf) = tmp[0]; + if ((stream->ictr = ctr) != 0) *(stream->iptr = stream->ibuf) = tmp[0]; stream->host = hostname; /* copy official host name */ if (tcpdebug) mm_log ("Stream open and ready for read",TCPDEBUG); } @@ -371,7 +371,7 @@ TCPSTREAM *tcp_aopen (NETMBX *mb,char *service,char *usrbuf) strcpy (host,mb->host+1); /* yes, copy without brackets */ host[i-1] = '\0'; /* validate domain literal */ - if (adr = ip_stringtoaddr (host,&len,&i)) fs_give ((void **) &adr); + if ((adr = ip_stringtoaddr (host,&len,&i)) != NULL) fs_give ((void **) &adr); else { sprintf (tmp,"Bad format domain-literal: %.80s",host); mm_log (tmp,ERROR); @@ -550,7 +550,7 @@ long tcp_getbuffer (TCPSTREAM *stream,unsigned long size,char *s) /* make sure socket still alive */ if (stream->tcpsi < 0) return NIL; /* can transfer bytes from buffer? */ - if (n = min (size,stream->ictr)) { + if ((n = min (size,stream->ictr)) != 0L) { memcpy (s,stream->iptr,n); /* yes, slurp as much as we can from it */ s += n; /* update pointer */ stream->iptr +=n; @@ -871,7 +871,7 @@ char *tcp_clienthost () if ((s = getenv (t = "SSH_CLIENT")) || (s = getenv (t = "KRB5REMOTEADDR")) || (s = getenv (t = "SSH2_CLIENT"))) { - if (v = strchr (s,' ')) *v = '\0'; + if ((v = strchr (s,' ')) != NULL) *v = '\0'; sprintf (v = tmp,"%.80s=%.80s",t,s); } else v = "UNKNOWN"; @@ -1000,7 +1000,7 @@ char *tcp_name (struct sockaddr *sadr,long flag) (*bn) (BLOCK_DNSLOOKUP,NIL);/* quell alarms */ data = (*bn) (BLOCK_SENSITIVE,NIL); /* translate address to name */ - if (t = tcp_name_valid (ip_sockaddrtoname (sadr,buf))) { + if ((t = tcp_name_valid (ip_sockaddrtoname (sadr,buf))) != NULL) { /* produce verbose form if needed */ if (flag) sprintf (ret = tmp,"%s %s",t,adr); else ret = t; diff --git a/imap/src/osdep/unix/tenex.c b/imap/src/osdep/unix/tenex.c index eee61fba..8815fee1 100644 --- a/imap/src/osdep/unix/tenex.c +++ b/imap/src/osdep/unix/tenex.c @@ -294,10 +294,13 @@ long tenex_rename (MAILSTREAM *stream,char *old,char *newname) if (!tenex_file (file,old) || (newname && (!((s = mailboxfile (tmp,newname)) && *s) || ((s = strrchr (tmp,'/')) && !s[1])))) { - sprintf (tmp,newname ? - "Can't rename mailbox %.80s to %.80s: invalid name" : - "Can't delete mailbox %.80s: invalid name", + if(newname) + sprintf (tmp, + "Can't rename mailbox %.80s to %.80s: invalid name", old,newname); + else + sprintf (tmp, + "Can't delete mailbox %.80s: invalid name", old); MM_LOG (tmp,ERROR); return NIL; } @@ -321,7 +324,7 @@ long tenex_rename (MAILSTREAM *stream,char *old,char *newname) } if (newname) { /* want rename? */ - if (s = strrchr (tmp,'/')) {/* found superior to destination name? */ + if ((s = strrchr (tmp,'/')) != NULL) {/* found superior to destination name? */ c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -769,7 +772,7 @@ void tenex_snarf (MAILSTREAM *stream) hdr = cpystr (mail_fetchheader_full(sysibx,i,NIL,&hdrlen,FT_INTERNAL)); txt = mail_fetchtext_full (sysibx,i,&txtlen,FT_INTERNAL|FT_PEEK); /* if have a message */ - if (j = hdrlen + txtlen) { + if ((j = hdrlen + txtlen) != 0L) { /* calculate header line */ mail_date (LOCAL->buf,elt = mail_elt (sysibx,i)); sprintf (LOCAL->buf + strlen (LOCAL->buf), diff --git a/imap/src/osdep/unix/unix.c b/imap/src/osdep/unix/unix.c index be3c437b..8bca508c 100644 --- a/imap/src/osdep/unix/unix.c +++ b/imap/src/osdep/unix/unix.c @@ -415,7 +415,7 @@ long unix_rename (MAILSTREAM *stream,char *old,char *newname) else { if (newname) { /* want rename? */ /* found superior to destination name? */ - if (s = strrchr (s,'/')) { + if ((s = strrchr (s,'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -842,9 +842,9 @@ long unix_expunge (MAILSTREAM *stream,char *sequence,long options) DOTLOCK lock; char *msg = NIL; /* parse and lock mailbox */ - if (ret = (sequence ? ((options & EX_UID) ? + if ((ret = (sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) && + mail_sequence (stream,sequence)) : LONGT) != 0L) && LOCAL && (LOCAL->ld >= 0) && !stream->lock && unix_parse (stream,&lock,LOCK_EX)) { /* check expunged messages if not dirty */ @@ -1254,10 +1254,10 @@ int unix_append_msgs (MAILSTREAM *stream,FILE *sf,FILE *df,SEARCHSET *set) if (i < (j = strlen (tmp))) fatal ("unix_append_msgs overrun"); i -= j; /* number of bytes left */ /* squish out CRs (note also copies NUL) */ - for (x = tmp; x = strchr (x,'\r'); --j) memmove (x,x+1,j-(x-tmp)); + for (x = tmp; (x = strchr (x,'\r')) != NULL; --j) memmove (x,x+1,j-(x-tmp)); if (!j) continue; /* do nothing if line emptied */ /* start of line? */ - if ((c == '\n')) switch (tmp[0]) { + if (c == '\n') switch (tmp[0]) { case 'F': /* possible "From " (case counts here) */ if ((j > 4) && (tmp[0] == 'F') && (tmp[1] == 'r') && (tmp[2] == 'o') && (tmp[3] == 'm') && (tmp[4] == ' ')) { @@ -1480,7 +1480,7 @@ int unix_parse (MAILSTREAM *stream,DOTLOCK *lock,int op) } /* new data? */ - else if (i = sbuf.st_size - LOCAL->filesize) { + else if ((i = sbuf.st_size - LOCAL->filesize) != 0L) { d.fd = LOCAL->fd; /* yes, set up file descriptor */ d.pos = LOCAL->filesize; /* get to that position in the file */ d.chunk = LOCAL->buf; /* initial buffer chunk */ @@ -1767,7 +1767,7 @@ int unix_parse (MAILSTREAM *stream,DOTLOCK *lock,int op) char err[MAILTMPLEN]; sprintf (err,"Discarding bogus continuation in msg %lu: %.80s", elt->msgno,(char *) s); - if (u = strpbrk (err,"\r\n")) *u = '\0'; + if ((u = strpbrk (err,"\r\n")) != NULL) *u = '\0'; MM_LOG (err,WARN); break; /* different case or something */ } @@ -2012,7 +2012,7 @@ unsigned long unix_xstatus (MAILSTREAM *stream,char *status,MESSAGECACHE *elt, while (n /= 10); /* pop UID last digits from stack */ while (t > stack) *s++ = *--t; - for (n = 0; n < NUSERFLAGS; ++n) if (t = stream->user_flags[n]) + for (n = 0; n < NUSERFLAGS; ++n) if ((t = stream->user_flags[n]) != NULL) for (*s++ = ' '; *t; *s++ = *t++); *s++ = '\n'; pad += 30; /* increased padding if have IMAPbase */ @@ -2034,7 +2034,7 @@ unsigned long unix_xstatus (MAILSTREAM *stream,char *status,MESSAGECACHE *elt, if (sticky) { /* only do this if UIDs sticky */ *s++ = 'X'; *s++ = '-'; *s++ = 'K'; *s++ = 'e'; *s++ = 'y'; *s++ = 'w'; *s++ = 'o'; *s++ = 'r'; *s++ = 'd'; *s++ = 's'; *s++ = ':'; - if (n = elt->user_flags) do { + if ((n = elt->user_flags) != 0L) do { *s++ = ' '; for (t = stream->user_flags[find_rightmost_bit (&n)]; *t; *s++ = *t++); } while (n); @@ -2098,7 +2098,7 @@ long unix_rewrite (MAILSTREAM *stream,unsigned long *nexp,DOTLOCK *lock, size = unix_pseudo (stream,LOCAL->buf); } /* extend the file as necessary */ - if (ret = unix_extend (stream,size)) { + if ((ret = unix_extend (stream,size)) != 0L) { /* Set up buffered I/O file structure * curpos current position being written through buffering * filepos current position being written physically to the disk @@ -2308,7 +2308,7 @@ void unix_write (UNIXFILE *f,char *buf,unsigned long size) if (buf) { /* doing buffered write? */ i = f->bufpos - f->buf; /* yes, get size of current buffer data */ /* yes, have space in current buffer chunk? */ - if (j = i ? ((f->buflen - i) % OVERFLOWBUFLEN) : f->buflen) { + if ((j = i ? ((f->buflen - i) % OVERFLOWBUFLEN) : f->buflen) != 0L) { /* yes, fill up buffer as much as we can */ memcpy (f->bufpos,buf,k = min (j,size)); f->bufpos += k; /* new buffer position */ @@ -2324,7 +2324,7 @@ void unix_write (UNIXFILE *f,char *buf,unsigned long size) * chunks that will fit in unprotected space. */ /* any unprotected space we can write to? */ - if (j = min (i,f->protect - f->filepos)) { + if ((j = min (i,f->protect - f->filepos)) != 0L) { /* yes, filepos not at chunk boundary? */ if ((k = f->filepos % OVERFLOWBUFLEN) && ((k = OVERFLOWBUFLEN - k) < j)) j -= k; /* yes, and can write out partial chunk */ diff --git a/imap/src/tmail/tmail.c b/imap/src/tmail/tmail.c index 923a98a9..273db40a 100644 --- a/imap/src/tmail/tmail.c +++ b/imap/src/tmail/tmail.c @@ -26,6 +26,7 @@ #include <stdio.h> #include <pwd.h> #include <errno.h> +#include <ctype.h> extern int errno; /* just in case */ #include <sysexits.h> #include <sys/file.h> @@ -115,7 +116,7 @@ void file_string_setpos (STRING *s,unsigned long i) s->offset = i; /* set new offset */ s->curpos = s->chunk; /* reset position */ /* set size of data */ - if (s->cursize = min (s->chunksize,SIZE (s))) { + if ((s->cursize = min (s->chunksize,SIZE (s))) != 0L) { /* move to that position in the file */ fseek ((FILE *) s->data,s->offset,SEEK_SET); fread (s->curpos,sizeof (char),(unsigned int) s->cursize,(FILE *) s->data); @@ -600,7 +601,7 @@ int fail (char *string,int code) char *getusername (char *s,char **t) { - if (*t = strchr (s,'+')) { /* have a mailbox specifier? */ + if ((*t = strchr (s,'+')) != NULL) { /* have a mailbox specifier? */ *(*t)++ = '\0'; /* yes, tie off user name */ /* forbid overlong name */ if (strlen (*t) > NETMAXMBX) return NIL; diff --git a/include/config.h.in b/include/config.h.in index edb0db6d..59a6ccd6 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -472,9 +472,6 @@ /* Enable keyboard lock support */ #undef KEYBOARD_LOCK -/* Define if you use OpenLDAP 2.3.x deprecated functions */ -#undef LDAP_DEPRECATED - /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR diff --git a/pico/pico.c b/pico/pico.c index 24123ccd..d93798c4 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -952,12 +952,13 @@ stripwhitespace(void) if(!(cur_line->l_used == 3 && lgetc(cur_line, 0).c == '-' && lgetc(cur_line, 1).c == '-' && - lgetc(cur_line, 2).c == ' ')) + lgetc(cur_line, 2).c == ' ')){ for(i = cur_line->l_used - 1; i >= 0; i--) if(ucs4_isspace(lgetc(cur_line, i).c)) cur_line->l_used--; else break; + } }while((cur_line = lforw(cur_line)) != curbp->b_linep); return 0; } diff --git a/pith/adrbklib.c b/pith/adrbklib.c index a9135d8b..fc7803fb 100644 --- a/pith/adrbklib.c +++ b/pith/adrbklib.c @@ -4108,7 +4108,7 @@ delete_ab_entry(AdrBk *ab, a_c_arg_t delete_this_one, int save_it) * #DELETED-YY/MM/DD# * to the nickname. */ - now = time((time_t) 0); + now = time((time_t *) NULL); tm_now = localtime(&now); oldnick = ae_deleted->nickname; diff --git a/pith/conf.c b/pith/conf.c index e8c1ceb9..7f450be8 100644 --- a/pith/conf.c +++ b/pith/conf.c @@ -1701,9 +1701,24 @@ init_vars(struct pine *ps, void (*cmds_f) (struct pine *, char **)) GLO_SPELLER = cpystr(DF_VAR_SPELLER); #endif #ifdef SMIME - GLO_PUBLICCERT_DIR = cpystr(DF_PUBLICCERT_DIR); - GLO_PRIVATEKEY_DIR = cpystr(DF_PRIVATEKEY_DIR); - GLO_CACERT_DIR = cpystr(DF_CACERT_DIR); + if(ps->smimedir){ + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s/public", ps->smimedir); + tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; + GLO_PUBLICCERT_DIR = cpystr(tmp_20k_buf); + + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s/private", ps->smimedir); + tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; + GLO_PRIVATEKEY_DIR = cpystr(tmp_20k_buf); + + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s/ca", ps->smimedir); + tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; + GLO_CACERT_DIR = cpystr(tmp_20k_buf); + } + else{ + GLO_PUBLICCERT_DIR = cpystr(DF_PUBLICCERT_DIR); + GLO_PRIVATEKEY_DIR = cpystr(DF_PRIVATEKEY_DIR); + GLO_CACERT_DIR = cpystr(DF_CACERT_DIR); + } #endif /* SMIME */ /* diff --git a/pith/flag.c b/pith/flag.c index 890feb56..5381aaf4 100644 --- a/pith/flag.c +++ b/pith/flag.c @@ -585,7 +585,7 @@ set_lflag(MAILSTREAM *stream, MSGNO_S *msgs, long int n, int f, int v) int was_invisible, is_invisible; int chk_thrd_cnt = 0, thrd_was_visible, was_hidden, is_hidden; - if((*(peltp = (PINELT_S **) &mc->sparep) == NULL)){ + if(*(peltp = (PINELT_S **) &mc->sparep) == NULL){ *peltp = (PINELT_S *) fs_get(sizeof(PINELT_S)); memset(*peltp, 0, sizeof(PINELT_S)); } @@ -702,12 +702,13 @@ copy_lflags(MAILSTREAM *stream, MSGNO_S *msgmap, int from, int to) set_lflags(stream, msgmap, to, 0); - if(any_lflagged(msgmap, from)) + if(any_lflagged(msgmap, from)){ for(i = 1L; i <= mn_get_total(msgmap); i++) if(get_lflag(stream, msgmap, i, from)) set_lflag(stream, msgmap, i, to, 1); else if(hide) set_lflag(stream, msgmap, i, MN_HIDE, 1); + } } diff --git a/pith/folder.c b/pith/folder.c index 5373bdfb..63f1b1d8 100644 --- a/pith/folder.c +++ b/pith/folder.c @@ -871,7 +871,7 @@ update_bboard_spec(char *bboard, char *buf, size_t buflen) if(*bboard == '*') bboard++; - if(!nntp) + if(!nntp){ /* * See if path portion looks newsgroup-ish while being aware * of the "view" portion of the spec... @@ -891,6 +891,7 @@ update_bboard_spec(char *bboard, char *buf, size_t buflen) } else if(!(isalnum((unsigned char) *p) || strindex(".-", *p))) break; + } snprintf(buf, buflen-(buf-origbuf), "%s%s%s", (!nntp && *p) ? "#public" : "#news.", diff --git a/pith/icache.c b/pith/icache.c index 07152652..d7d5989d 100644 --- a/pith/icache.c +++ b/pith/icache.c @@ -261,7 +261,7 @@ fetch_ice(MAILSTREAM *stream, long unsigned int rawno) /* * any private elt data yet? */ - if((*(peltp = (PINELT_S **) &mc->sparep) == NULL)){ + if(*(peltp = (PINELT_S **) &mc->sparep) == NULL){ *peltp = (PINELT_S *) fs_get(sizeof(PINELT_S)); memset(*peltp, 0, sizeof(PINELT_S)); } @@ -291,7 +291,7 @@ fetch_ice_ptr(MAILSTREAM *stream, long unsigned int rawno) /* * any private elt data yet? */ - if((*(peltp = (PINELT_S **) &mc->sparep) == NULL)){ + if(*(peltp = (PINELT_S **) &mc->sparep) == NULL){ *peltp = (PINELT_S *) fs_get(sizeof(PINELT_S)); memset(*peltp, 0, sizeof(PINELT_S)); } diff --git a/pith/ldap.c b/pith/ldap.c index cb7ff363..411b0516 100644 --- a/pith/ldap.c +++ b/pith/ldap.c @@ -402,7 +402,7 @@ ldap_lookup(LDAP_SERV_S *info, char *string, CUSTOM_FILT_S *cust, char *mailattr, *snattr, *gnattr, *cnattr; int we_cancel = 0, we_turned_on = 0; LDAP_SERV_RES_S *serv_res = NULL; - LDAP *ld; + LDAP *ld = NULL; long pwdtrial = 0L; int ld_errnum; char *ld_errstr; @@ -472,8 +472,15 @@ ldap_lookup(LDAP_SERV_S *info, char *string, CUSTOM_FILT_S *cust, if((ld = ldap_init(serv, info->port)) == NULL) #else #if (LDAPAPI >= 11) +#ifdef _WINDOWS if((ld = ldap_init(serv, info->port)) == NULL) #else + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "ldap://%s:%d", serv, info->port); + tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; + + if(ldap_initialize(&ld, tmp_20k_buf) != LDAP_SUCCESS) +#endif +#else if((ld = ldap_open(serv, info->port)) == NULL) #endif #endif @@ -498,7 +505,11 @@ ldap_lookup(LDAP_SERV_S *info, char *string, CUSTOM_FILT_S *cust, else if(!ps_global->intr_pending){ int proto = 3, tlsmustbail = 0; char pwd[NETMAXPASSWD], user[NETMAXUSER]; +#ifdef _WINDOWS char *passwd = NULL; +#else + struct berval passwd = { 0 }; +#endif char hostbuf[1024]; NETMBX mb; #ifndef _WINDOWS @@ -573,7 +584,12 @@ try_password_again: snprintf(pmt, sizeof(pmt), " %s", (info->nick && *info->nick) ? info->nick : serv); mm_login_work(&mb, user, pwd, pwdtrial, pmt, info->binddn); if(pwd && pwd[0]) +#ifdef _WINDOWS passwd = pwd; +#else + passwd.bv_len = strlen(pwd); + passwd.bv_val = pwd; +#endif } } @@ -583,7 +599,12 @@ try_password_again: * to tell the server we're v3 if the server supports v3, and if the * server doesn't support v3 the bind is required. */ - if(tlsmustbail || ldap_simple_bind_s(ld, info->binddn, passwd) != LDAP_SUCCESS){ + if(tlsmustbail +#ifdef _WINDOWS + || ldap_simple_bind_s(ld, info->binddn, passwd) != LDAP_SUCCESS){ +#else + || ldap_sasl_bind_s(ld, info->binddn, LDAP_SASL_SIMPLE, &passwd, NULL, NULL, NULL) != LDAP_SUCCESS){ +#endif wp_err->wp_err_occurred = 1; ld_errnum = our_ldap_get_lderrno(ld, NULL, &ld_errstr); @@ -606,8 +627,11 @@ try_password_again: if(we_cancel) cancel_busy_cue(-1); - +#ifdef _WINDOWS ldap_unbind(ld); +#else + ldap_unbind_ext(ld, NULL, NULL); +#endif wp_err->error = cpystr(ebuf); q_status_message(SM_ORDER, 3, 5, wp_err->error); display_message('x'); @@ -831,11 +855,22 @@ try_password_again: else{ int msgid; time_t start_time; + struct timeval tv = {0}, *tvp = NULL; + + memset((void *)&tv, 0, sizeof(struct timeval)); + tv.tv_sec = info->time; + tvp = &tv; start_time = time((time_t *)0); dprint((6, "ldap_lookup: calling ldap_search\n")); +#ifdef _WINDOWS msgid = ldap_search(ld, base, info->scope, filter, NULL, 0); +#else + if(ldap_search_ext(ld, base, info->scope, filter, NULL, 0, + NULL, NULL, tvp, info->size, &msgid) != LDAP_SUCCESS) + msgid = -1; +#endif if(msgid == -1) srch_res = our_ldap_get_lderrno(ld, NULL, NULL); @@ -863,7 +898,11 @@ try_password_again: } else if(lres == 0){ /* timeout, no results available */ if(intr_happened){ +#ifdef _WINDOWS ldap_abandon(ld, msgid); +#else + ldap_abandon_ext(ld, msgid, NULL, NULL); +#endif srch_res = LDAP_PROTOCOL_ERROR; if(our_ldap_get_lderrno(ld, NULL, NULL) == LDAP_SUCCESS) our_ldap_set_lderrno(ld, LDAP_PROTOCOL_ERROR, NULL, NULL); @@ -882,7 +921,11 @@ try_password_again: } else{ if(lres == 0) +#ifdef _WINDOWS ldap_abandon(ld, msgid); +#else + ldap_abandon_ext(ld, msgid, NULL, NULL); +#endif srch_res = LDAP_TIMEOUT; if(our_ldap_get_lderrno(ld, NULL, NULL) == LDAP_SUCCESS) @@ -898,9 +941,25 @@ try_password_again: } } else{ +#ifdef _WINDOWS srch_res = ldap_result2error(ld, res, 0); dprint((6, "lres=0x%x, srch_res=%d\n", lres, srch_res)); +#else + int err; + char *dn, *text, **ref; + LDAPControl **srv; + + dn = text = NULL; ref = NULL; srv = NULL; + srch_res = ldap_parse_result(ld, res, + &err, &dn, &text, &ref, &srv, 0); + dprint((6, "lres=0x%x, srch_res=%d, dn=%s, text=%s\n", lres, + srch_res, dn ? dn : "", text ? text : "")); + if(dn) ber_memfree(dn); + if(text) ber_memfree(text); + if(ref) ber_memvfree((void **) ref); + if(srv) ldap_controls_free(srv); +#endif } }while(lres == 0 && !(intr_happened || @@ -925,7 +984,11 @@ try_password_again: if(res) ldap_msgfree(res); if(ld) +#ifdef _WINDOWS ldap_unbind(ld); +#else + ldap_unbind_ext(ld, NULL, NULL); +#endif res = NULL; ld = NULL; } @@ -957,8 +1020,12 @@ try_password_again: if(res) ldap_msgfree(res); if(ld) +#ifdef _WINDOWS ldap_unbind(ld); - +#else + ldap_unbind_ext(ld, NULL, NULL); +#endif + res = NULL; ld = NULL; } else{ @@ -1043,7 +1110,11 @@ try_password_again: if(res) ldap_msgfree(res); if(ld) +#ifdef _WINDOWS ldap_unbind(ld); +#else + ldap_unbind_ext(ld, NULL, NULL); +#endif res = NULL; ld = NULL; } @@ -1184,41 +1255,41 @@ address_from_ldap(LDAP_CHOOSE_S *winning_e) a = ldap_next_attribute(winning_e->ld, winning_e->selected_entry, ber)){ int i; char *p; - char **vals; + struct berval **vals; dprint((9, "attribute: %s\n", a ? a : "?")); if(!ret_a->personal && strcmp(a, winning_e->info_used->cnattr) == 0){ dprint((9, "Got cnattr:")); - vals = ldap_get_values(winning_e->ld, winning_e->selected_entry, a); - for(i = 0; vals[i] != NULL; i++) + vals = ldap_get_values_len(winning_e->ld, winning_e->selected_entry, a); + for(i = 0; i < ldap_count_values_len(vals); i++) dprint((9, " %s\n", - vals[i] ? vals[i] : "?")); + vals[i] ? vals[i]->bv_val : "?")); - if(vals && vals[0]) - ret_a->personal = cpystr(vals[0]); + if(ALPINE_LDAP_can_use(vals)) + ret_a->personal = cpystr(vals[0]->bv_val); - ldap_value_free(vals); + ldap_value_free_len(vals); } else if(!ret_a->mailbox && strcmp(a, winning_e->info_used->mailattr) == 0){ dprint((9, "Got mailattr:")); - vals = ldap_get_values(winning_e->ld, winning_e->selected_entry, a); - for(i = 0; vals[i] != NULL; i++) + vals = ldap_get_values_len(winning_e->ld, winning_e->selected_entry, a); + for(i = 0; i < ldap_count_values_len(vals); i++) dprint((9, " %s\n", - vals[i] ? vals[i] : "?")); + vals[i] ? vals[i]->bv_val : "?")); /* use first one */ - if(vals && vals[0]){ - if((p = strindex(vals[0], '@')) != NULL){ + if(ALPINE_LDAP_can_use(vals)){ + if((p = strindex(vals[0]->bv_val, '@')) != NULL){ ret_a->host = cpystr(p+1); *p = '\0'; } - ret_a->mailbox = cpystr(vals[0]); + ret_a->mailbox = cpystr(vals[0]->bv_val); } - ldap_value_free(vals); + ldap_value_free_len(vals); } our_ldap_memfree(a); @@ -1569,7 +1640,11 @@ free_ldap_result_list(LDAP_SERV_RES_S **r) if((*r)->res) ldap_msgfree((*r)->res); if((*r)->ld) +#ifdef _WINDOWS ldap_unbind((*r)->ld); +#else + ldap_unbind_ext((*r)->ld, NULL, NULL); +#endif if((*r)->info_used) free_ldap_server_info(&(*r)->info_used); if((*r)->serv) @@ -1794,5 +1869,24 @@ ldap_translate(char *a, LDAP_SERV_S *info_used) return(a); } +char ** +berval_to_array(struct berval **v) +{ + char **rv = NULL; + int i, len; + + if(v == NULL) return rv; + len = ldap_count_values_len(v); + + rv = fs_get((len+1)*sizeof(char *)); + for(i = 0; i < len; i++) + if(ALPINE_LDAP_can_use_num(v, i)) + rv[i] = cpystr(v[i]->bv_val); + else + rv[i] = NULL; + rv[len] = NULL; + + return rv; +} #endif /* ENABLE_LDAP */ diff --git a/pith/ldap.h b/pith/ldap.h index 43a5120d..ee9b8b87 100644 --- a/pith/ldap.h +++ b/pith/ldap.h @@ -67,7 +67,7 @@ typedef struct ldap_serv { * ldap_get_dn * ldap_first_attribute * ldap_next_attribute - * ldap_get_values + * ldap_get_values_len * We call those from a half dozen functions. We could fix it by * having a directory-character-set per server and passing that around * in the LDAP_SERV_RES_S structure, I think. For now, let's go with @@ -114,6 +114,14 @@ typedef enum {AlwaysDisplay, DisplayForURL } LDAPLookupStyle; +#define ALPINE_LDAP_can_use_num(X, Y) \ + ((X) != NULL && (X)[(Y)] != NULL \ + && (X)[(Y)]->bv_val != NULL \ + && (X)[(Y)]->bv_val[0] != '\0') + +#define ALPINE_LDAP_can_use(X) ALPINE_LDAP_can_use_num((X), 0) +#define ALPINE_LDAP_usable(X, Y) ((Y) < ldap_count_values_len((X)) \ + && ALPINE_LDAP_can_use_num((X), (Y))) #define LDAP_TYPE_CN 0 #define LDAP_TYPE_SUR 1 @@ -162,6 +170,7 @@ ADDRESS *wp_lookups(char *, WP_ERR_S *, int); int ldap_lookup_all(char *, int, int, LDAPLookupStyle, CUSTOM_FILT_S *, LDAP_CHOOSE_S **, WP_ERR_S *, LDAP_SERV_RES_S **); char *ldap_translate(char *, LDAP_SERV_S *); +char **berval_to_array(struct berval **); ADDRESS *address_from_ldap(LDAP_CHOOSE_S *); LDAP_SERV_S *break_up_ldap_server(char *); void free_ldap_server_info(LDAP_SERV_S **); diff --git a/pith/mailindx.c b/pith/mailindx.c index c3e035b2..a1e889e0 100644 --- a/pith/mailindx.c +++ b/pith/mailindx.c @@ -2945,7 +2945,7 @@ format_index_index_line(INDEXDATA_S *idata) if(!ifield->ielem){ ielem = new_ielem(&ifield->ielem); - if(color = hdr_color(itokens[itokensinv[cdesc->ctype].ctype].name, NULL, ps_global->index_token_colors)){ + if((color = hdr_color(itokens[itokensinv[cdesc->ctype].ctype].name, NULL, ps_global->index_token_colors)) != NULL){ if(pico_usingcolor()){ ielem->color = new_color_pair(color->fg, color->bg); ielem->type = eTypeCol; diff --git a/pith/mimedesc.c b/pith/mimedesc.c index 097f5cda..80d2f840 100644 --- a/pith/mimedesc.c +++ b/pith/mimedesc.c @@ -222,7 +222,7 @@ describe_mime(struct mail_bodystruct *body, char *prefix, int num, (description && description[0]) ? ", \"" : "", (description && description[0]) ? description : "", (description && description[0]) ? "\"": ""); - string[sizeof(string)-1] =- '\0'; + string[sizeof(string)-1] = '\0'; a->description = cpystr(string); a->body = body; diff --git a/pith/osdep/mimedisp.c b/pith/osdep/mimedisp.c index b1462685..2ee99293 100644 --- a/pith/osdep/mimedisp.c +++ b/pith/osdep/mimedisp.c @@ -28,6 +28,7 @@ static char rcsid[] = "$Id: mimedisp.c 942 2008-03-04 18:21:33Z hubert@u.washing #include "mimedisp.h" #include "../charconv/utf8.h" #ifdef OSX_TARGET +#include "../../pith/osdep/collate.h" /* for strucmp */ #include <Security/AuthSession.h> #endif diff --git a/pith/pine.hlp b/pith/pine.hlp index bbce2c3d..b568f2c4 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any reasonable place to be called from. Dummy change to get revision in pine.hlp ============= h_revision ================= -Alpine Commit 81 2015-05-17 19:13:29 +Alpine Commit 82 2015-07-24 22:13:48 ============= h_news ================= <HTML> <HEAD> @@ -243,6 +243,11 @@ Additions include: be transformed to UTF-8 for further transformation through internal and user defined filters for saving. + <LI> Add command line argument -smimedir, which allows to specify + the default path for a directory that contains the public, private, + and ca directories. This is useful in case a user has a backup of + old certificates that cannot be installed in the ~/.alpine-smime + dir. </UL> diff --git a/pith/send.c b/pith/send.c index c0337aea..1ba6266f 100644 --- a/pith/send.c +++ b/pith/send.c @@ -5701,7 +5701,7 @@ pine_pipe_soutr_nl (void *stream, char *s) size_t n; while(*s && rv){ - if((n = (p = strstr(s, "\015\012")) ? p - s : strlen(s)) != 0) + if((n = (p = strstr(s, "\015\012")) ? p - s : strlen(s)) != 0){ while((rv = write(((PIPE_S *)stream)->out.d, s, n)) != n) if(rv < 0){ if(errno != EINTR){ @@ -5713,6 +5713,7 @@ pine_pipe_soutr_nl (void *stream, char *s) s += rv; n -= rv; } + } if(p && rv){ s = p + 2; /* write UNIX EOL */ diff --git a/pith/smkeys.c b/pith/smkeys.c index 35228914..bb77b030 100644 --- a/pith/smkeys.c +++ b/pith/smkeys.c @@ -285,7 +285,7 @@ resort_certificates(CertList **data, WhichCerts ctype) for(i = 0; cl; cl = cl->next, i++) if(ctype != Private){ /* ctype == Public or ctype == CACerts */ - for(t = s = cl->name; t = strstr(s, ".crt"); s = t+1); + for(t = s = cl->name; (t = strstr(s, ".crt")) != NULL; s = t+1); if (s) *(s-1) = '\0'; } j = i; diff --git a/pith/state.h b/pith/state.h index bfbe7973..4c908106 100644 --- a/pith/state.h +++ b/pith/state.h @@ -355,6 +355,7 @@ struct pine { PRINT_S *print; #ifdef SMIME + char *smimedir; SMIME_STUFF_S *smime; #ifdef PASSFILE void *pwdcert; /* this is of type PERSONAL_CERT */ diff --git a/pith/stream.c b/pith/stream.c index de7c1ea0..cfdcc9a5 100644 --- a/pith/stream.c +++ b/pith/stream.c @@ -3293,7 +3293,7 @@ streams_died(void) else{ if(!sp_noticed_dead_stream(m)){ sp_set_noticed_dead_stream(m, 1); - folder = STREAMNAME(m); + folder = (unsigned char *) STREAMNAME(m); /* * If a cached stream died and then we tried to use it * it could cause problems. We could warn about it here diff --git a/pith/takeaddr.c b/pith/takeaddr.c index 1fb22ef6..233a6987 100644 --- a/pith/takeaddr.c +++ b/pith/takeaddr.c @@ -1804,7 +1804,7 @@ detach_vcard_att(MAILSTREAM *stream, long int msgno, struct mail_bodystruct *bod if(dtext) fs_give((void **)&dtext); - res[count] = '\0'; + res[count] = NULL; return(res); } diff --git a/po/Makefile.in b/po/Makefile.in index 5f5c7387..07cc6c64 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -11,7 +11,7 @@ # Origin: gettext-0.16 PACKAGE = alpine -VERSION = 2.20.8 +VERSION = 2.20.9 PACKAGE_BUGREPORT = chappa@washington.edu SHELL = /bin/sh @@ -34,12 +34,12 @@ INSTALL_DATA = ${INSTALL} -m 644 # We use $(mkdir_p). # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, -# ${SHELL} /run/media/chappa/Alpine/alpine/alpinegit/install-sh does not start with $(SHELL), so we add it. +# ${SHELL} /run/media/echappa/Alpine/alpine/alpinegit/install-sh does not start with $(SHELL), so we add it. # In automake >= 1.10, $(MKDIR_P) is derived from ${MKDIR_P}, which is defined # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake # versions, $(mkinstalldirs) and $(install_sh) are unused. -mkinstalldirs = $(SHELL) ${SHELL} /run/media/chappa/Alpine/alpine/alpinegit/install-sh -d -install_sh = $(SHELL) ${SHELL} /run/media/chappa/Alpine/alpine/alpinegit/install-sh +mkinstalldirs = $(SHELL) ${SHELL} /run/media/echappa/Alpine/alpine/alpinegit/install-sh -d +install_sh = $(SHELL) ${SHELL} /run/media/echappa/Alpine/alpine/alpinegit/install-sh MKDIR_P = /usr/bin/mkdir -p mkdir_p = $(MKDIR_P) @@ -51,12 +51,12 @@ MSGFMT_ = /usr/bin/msgfmt MSGFMT_no = /usr/bin/msgfmt MSGFMT_yes = /usr/bin/msgfmt MSGFMT = $(MSGFMT_$(USE_MSGCTXT)) -XGETTEXT_ = : -XGETTEXT_no = : -XGETTEXT_yes = : +XGETTEXT_ = /usr/bin/xgettext +XGETTEXT_no = /usr/bin/xgettext +XGETTEXT_yes = /usr/bin/xgettext XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT)) MSGMERGE = msgmerge -MSGMERGE_UPDATE = : --update +MSGMERGE_UPDATE = /usr/bin/msgmerge --update MSGINIT = msginit MSGCONV = msgconv MSGFILTER = msgfilter diff --git a/web/src/alpined.d/alpined.c b/web/src/alpined.d/alpined.c index f75f03da..6936de9d 100644 --- a/web/src/alpined.d/alpined.c +++ b/web/src/alpined.d/alpined.c @@ -450,7 +450,7 @@ char **sml_getmsgs(void); void sml_seen(void); #ifdef ENABLE_LDAP int peLdapQueryResults(Tcl_Interp *); -int peLdapStrlist(Tcl_Interp *, Tcl_Obj *, char **); +int peLdapStrlist(Tcl_Interp *, Tcl_Obj *, struct berval **); int init_ldap_pname(struct pine *); #endif /* ENABLE_LDAP */ char *strqchr(char *, int, int *, int); @@ -10815,7 +10815,7 @@ peLoadConfig(struct pine *pine_state) peInitVars(pine_state); - if(s = peAuthException()) + if((s = peAuthException()) != NULL) return(s); else if(ps_global->c_client_error[0]) return(ps_global->c_client_error); @@ -11763,7 +11763,7 @@ peDoPost(METAENV *metaenv, BODY *body, char *fcc, CONTEXT_S **fcc_cntxtp, char * if((recipients = (metaenv->env->to || metaenv->env->cc || metaenv->env->bcc)) && call_mailer(metaenv, body, NULL, 0, NULL, NULL) < 0){ - if(s = peAuthException()){ + if((s = peAuthException()) != NULL){ strcpy(errp, s); } else if(ps_global->last_error[0]){ @@ -12396,7 +12396,7 @@ peMsgCollector(Tcl_Interp *interp, priority = "Lowest"; if(priority){ - if(pf = set_priority_header(md.metaenv, priority)) + if((pf = set_priority_header(md.metaenv, priority)) != NULL) pf->text = &pf->textbuf; } } @@ -15209,7 +15209,8 @@ PELdapCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST ob * {"dn" {{attrib {val, ...}}, ...}} */ char *whichrec = Tcl_GetStringFromObj(objv[3], NULL); - char *tmpstr, *tmp, *tmp2, **vals, *a; + char *tmpstr, *tmp, *tmp2, *a; + struct berval **vals; WPLDAPRES_S *curres; LDAP_CHOOSE_S *winning_e = NULL; LDAP_SERV_RES_S *trl; @@ -15280,14 +15281,14 @@ PELdapCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST ob winning_e->info_used), -1)) != TCL_OK) return(TCL_ERROR); resObj = Tcl_NewListObj(0, NULL); - vals = ldap_get_values(winning_e->ld, winning_e->selected_entry, a); + vals = ldap_get_values_len(winning_e->ld, winning_e->selected_entry, a); if(vals){ for(i = 0; vals[i]; i++){ if(Tcl_ListObjAppendElement(interp, resObj, - Tcl_NewStringObj(vals[i], -1)) != TCL_OK) + Tcl_NewStringObj(vals[i]->bv_val, -1)) != TCL_OK) return(TCL_ERROR); } - ldap_value_free(vals); + ldap_value_free_len(vals); if(Tcl_ListObjAppendElement(interp, secObj, resObj) != TCL_OK) return(TCL_ERROR); } @@ -15517,7 +15518,7 @@ peLdapQueryResults(Tcl_Interp *interp) e != NULL; e = ldap_next_entry(trl->ld, e)){ char *dn; - char **cn, **org, **unit, **title, **mail, **sn; + struct berval **cn, **org, **unit, **title, **mail, **sn; dn = NULL; cn = org = title = unit = mail = sn = NULL; @@ -15527,15 +15528,15 @@ peLdapQueryResults(Tcl_Interp *interp) &mail, &sn); if(cn){ if(Tcl_ListObjAppendElement(interp, itemObj, - Tcl_NewStringObj(cn[0], -1)) != TCL_OK) + Tcl_NewStringObj(cn[0]->bv_val, -1)) != TCL_OK) return(TCL_ERROR); - ldap_value_free(cn); + ldap_value_free_len(cn); } else if(sn){ if(Tcl_ListObjAppendElement(interp, itemObj, - Tcl_NewStringObj(sn[0], -1)) != TCL_OK) + Tcl_NewStringObj(sn[0]->bv_val, -1)) != TCL_OK) return(TCL_ERROR); - ldap_value_free(sn); + ldap_value_free_len(sn); } else{ dn = ldap_get_dn(trl->ld, e); @@ -15563,13 +15564,13 @@ peLdapQueryResults(Tcl_Interp *interp) if(Tcl_ListObjAppendElement(interp, resObj, itemObj) != TCL_OK) return(TCL_ERROR); if(title) - ldap_value_free(title); + ldap_value_free_len(title); if(unit) - ldap_value_free(unit); + ldap_value_free_len(unit); if(org) - ldap_value_free(org); + ldap_value_free_len(org); if(mail) - ldap_value_free(mail); + ldap_value_free_len(mail); } } if(Tcl_ListObjAppendElement(interp, secObj, resObj) != TCL_OK) @@ -15582,16 +15583,16 @@ peLdapQueryResults(Tcl_Interp *interp) } int -peLdapStrlist(Tcl_Interp *interp, Tcl_Obj *itemObj, char **strl) +peLdapStrlist(Tcl_Interp *interp, Tcl_Obj *itemObj, struct berval **strl) { Tcl_Obj *strlObj; int i; strlObj = Tcl_NewListObj(0, NULL); if(strl){ - for(i = 0; strl[i] && strl[i][0]; i++){ + for(i = 0; ALPINE_LDAP_usable(strl, i); i++){ if(Tcl_ListObjAppendElement(interp, strlObj, - Tcl_NewStringObj(strl[i], -1)) != TCL_OK) + Tcl_NewStringObj(strl[i]->bv_val, -1)) != TCL_OK) return(TCL_ERROR); } } @@ -16265,7 +16266,7 @@ peRssFetch(Tcl_Interp *interp, char *link) so_puts(feed_so, p); } else{ /* in header, grok fields */ - if(q = strchr(p,':')){ + if((q = strchr(p,':')) != NULL){ int l = q - p; *q++ = '\0'; diff --git a/web/src/alpined.d/ldap.c b/web/src/alpined.d/ldap.c index 3e6bf99f..4107b375 100644 --- a/web/src/alpined.d/ldap.c +++ b/web/src/alpined.d/ldap.c @@ -40,7 +40,8 @@ ldap_addr_select(ps, ac, result, style, wp_err, srchstr) { LDAP_SERV_RES_S *res_list, *tmp_rl; LDAPMessage *e, *tmp_e; - char **mail = NULL, *a; + struct berval **mail = NULL; + char *a; int got_n_entries = 0, retval = -5; BerElement *ber; @@ -59,11 +60,11 @@ ldap_addr_select(ps, ac, result, style, wp_err, srchstr) a != NULL; a = ldap_next_attribute(tmp_rl->ld, tmp_e, ber)){ if(strcmp(a, tmp_rl->info_used->mailattr) == 0){ - mail = ldap_get_values(tmp_rl->ld, tmp_e, a); + mail = ldap_get_values_len(tmp_rl->ld, tmp_e, a); break; } } - if(mail && mail[0] && mail[0][0]){ + if(ALPINE_LDAP_can_use(mail)){ retval = 0; if(result){ (*result) = @@ -91,7 +92,8 @@ peLdapPname(mailbox, host) char *host; { char *retstr = NULL; - char adrstr[1024], **cn; + char adrstr[1024]; + struct berval **cn = NULL; int ecnt; CUSTOM_FILT_S *filter; WP_ERR_S wp_err; @@ -125,8 +127,8 @@ peLdapPname(mailbox, host) peLdapEntryParse(trl, e, &cn, NULL, NULL, NULL, NULL, NULL); if(cn){ - retstr = cpystr(cn[0]); - ldap_value_free(cn); + retstr = cpystr(cn[0]->bv_val); + ldap_value_free_len(cn); } } } @@ -138,14 +140,15 @@ peLdapEntryParse(trl, e, ret_cn, ret_org, ret_unit, ret_title, ret_mail, ret_sn) LDAP_SERV_RES_S *trl; LDAPMessage *e; - char ***ret_cn; - char ***ret_org; - char ***ret_unit; - char ***ret_title; - char ***ret_mail; - char ***ret_sn; + struct berval ***ret_cn; + struct berval ***ret_org; + struct berval ***ret_unit; + struct berval ***ret_title; + struct berval ***ret_mail; + struct berval ***ret_sn; { - char *a, **cn, **org, **unit, **title, **mail, **sn; + char *a; + struct berval **cn, **org, **unit, **title, **mail, **sn; BerElement *ber; cn = org = title = unit = mail = sn = NULL; @@ -156,28 +159,28 @@ peLdapEntryParse(trl, e, ret_cn, ret_org, ret_unit, dprint((9, " %s", a)); if(strcmp(a, trl->info_used->cnattr) == 0){ if(!cn) - cn = ldap_get_values(trl->ld, e, a); + cn = ldap_get_values_len(trl->ld, e, a); - if(cn && !(cn[0] && cn[0][0])){ - ldap_value_free(cn); + if(cn && !ALPINE_LDAP_can_use(cn)){ + ldap_value_free_len(cn); cn = NULL; } } else if(strcmp(a, trl->info_used->mailattr) == 0){ if(!mail) - mail = ldap_get_values(trl->ld, e, a); + mail = ldap_get_values_len(trl->ld, e, a); } else if(strcmp(a, "o") == 0){ if(!org) - org = ldap_get_values(trl->ld, e, a); + org = ldap_get_values_len(trl->ld, e, a); } else if(strcmp(a, "ou") == 0){ if(!unit) - unit = ldap_get_values(trl->ld, e, a); + unit = ldap_get_values_len(trl->ld, e, a); } else if(strcmp(a, "title") == 0){ if(!title) - title = ldap_get_values(trl->ld, e, a); + title = ldap_get_values_len(trl->ld, e, a); } our_ldap_memfree(a); @@ -190,10 +193,10 @@ peLdapEntryParse(trl, e, ret_cn, ret_org, ret_unit, if(strcmp(a, trl->info_used->snattr) == 0){ if(!sn) - sn = ldap_get_values(trl->ld, e, a); + sn = ldap_get_values_len(trl->ld, e, a); - if(sn && !(sn[0] && sn[0][0])){ - ldap_value_free(sn); + if(sn && !ALPINE_LDAP_can_use(sn)){ + ldap_value_free_len(sn); sn = NULL; } } @@ -202,22 +205,22 @@ peLdapEntryParse(trl, e, ret_cn, ret_org, ret_unit, } if(ret_cn) (*ret_cn) = cn; - else if(cn) ldap_value_free(cn); + else if(cn) ldap_value_free_len(cn); if(ret_org) (*ret_org) = org; - else if(org) ldap_value_free(org); + else if(org) ldap_value_free_len(org); if(ret_unit) (*ret_unit) = unit; - else if(unit) ldap_value_free(unit); + else if(unit) ldap_value_free_len(unit); if(ret_title) (*ret_title) = title; - else if(title) ldap_value_free(title); + else if(title) ldap_value_free_len(title); if(ret_mail) (*ret_mail) = mail; - else if(mail) ldap_value_free(mail); + else if(mail) ldap_value_free_len(mail); if(ret_sn) (*ret_sn) = sn; - else if(sn) ldap_value_free(sn); + else if(sn) ldap_value_free_len(sn); return 0; } diff --git a/web/src/alpined.d/ldap.h b/web/src/alpined.d/ldap.h index 2ada2908..6084c7c2 100644 --- a/web/src/alpined.d/ldap.h +++ b/web/src/alpined.d/ldap.h @@ -39,8 +39,9 @@ extern WPLDAP_S *wpldap_global; char *peLdapPname(char *, char *); int peLdapEntryParse(LDAP_SERV_RES_S *, LDAPMessage *, - char ***, char ***, char ***, char ***, - char ***, char ***); + struct berval ***, struct berval ***, + struct berval ***, struct berval ***, + struct berval ***, struct berval ***); WPLDAPRES_S *free_wpldapres(WPLDAPRES_S *); #endif /* ENABLE_LDAP */ |