1: /* qu2bb_send.c - manager for qu --> bb */ 2: 3: #include "util.h" 4: #include "mmdf.h" 5: 6: /* */ 7: 8: extern struct ll_struct *logptr; 9: 10: struct rp_construct rp_aend = { /* end of address list */ 11: RP_OK, 12: 'b', 'b', 'o', 'a', 'r', 'd', 's', ' ', 'e', 'n', 'd', ' ', 13: 'o', 'f', ' ', 'a', 'd', 'd', 'r', ' ', 'l', 'i', 's', 't', 14: NULL 15: }; 16: 17: struct rp_construct rp_badr = { /* no such bboard */ 18: RP_USER, 19: 'u', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'b', 'b', 'o', 'a', 'r', 'd', 20: NULL 21: }; 22: 23: struct rp_construct rp_err = { /* error, retry later */ 24: RP_AGN, 25: 'u', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r', 26: NULL 27: }; 28: 29: /* */ 30: 31: qu2bb_send () { 32: short result; 33: char info[LINESIZE], 34: sender[LINESIZE]; 35: 36: #ifdef DEBUG 37: ll_log (logptr, LLOGBTR, "qu2bb_send()"); 38: #endif 39: 40: if (rp_isbad (result = qu_pkinit ())) 41: return result; 42: if (rp_isbad (result = bb_sbinit ())) 43: return result; 44: 45: while (rp_gval ((result = qu_rinit (info, sender))) == RP_OK) { 46: #ifdef DEBUG 47: ll_log (logptr, LLOGGEN, "info=%s sender=%s", info, sender); 48: #endif 49: if (rp_isbad (result = bb_winit (info, sender))) 50: return result; 51: if (rp_isbad (result = qu2bb_each (sender))) 52: return result; 53: } 54: 55: if (rp_gval (result) != RP_DONE) { 56: ll_log (logptr, LLOGTMP, "not DONE [%s]", rp_valstr (result)); 57: return RP_RPLY; 58: } 59: 60: qu_pkend (); 61: bb_sbend (); 62: 63: return result; 64: } 65: 66: /* */ 67: 68: qu2bb_each (sender) 69: char *sender; 70: { 71: short result; 72: char adr[LINESIZE], 73: host[LINESIZE]; 74: RP_Buf replyval; 75: 76: #ifdef DEBUG 77: ll_log (logptr, LLOGBTR, "qu2bb_each(sender='%s')", sender); 78: #endif 79: 80: FOREVER { /* loop through the addresses */ 81: if (rp_isbad (result = qu_radr (host, adr))) 82: return result; 83: if (rp_gval (result) == RP_DONE) { 84: qu_wrply ((RP_Buf *) & rp_aend, rp_conlen (rp_aend)); 85: return RP_OK; 86: } 87: 88: switch (replyval.rp_val = bb_wtadr (host, adr)) { 89: case RP_AOK: 90: case RP_OK: 91: switch (replyval.rp_val = bb_txtcpy ()) { 92: case RP_MOK: 93: replyval.rp_line[0] = NULL; 94: break; 95: default: 96: ll_log (logptr, LLOGFAT, "unknown error [%s]", 97: rp_valstr (replyval.rp_val)); 98: blt (&rp_err, (char *) & replyval, sizeof rp_err); 99: break; 100: } 101: break; 102: 103: case RP_USER: 104: ll_log (logptr, LLOGFAT, "unknown bboard '%s'", adr); 105: blt (&rp_badr, (char *) & replyval, sizeof rp_badr); 106: break; 107: 108: default: 109: ll_log (logptr, LLOGFAT, "unknown error [%s]", 110: rp_valstr (replyval.rp_val)); 111: blt (&rp_err, (char *) & replyval, sizeof rp_err); 112: break; 113: } 114: 115: qu_wrply (&replyval, 116: (sizeof replyval.rp_val) + strlen (replyval.rp_line)); 117: } 118: }