Go to the source code of this file.
Functions | |
static int | expmem_fileq () |
static void | queue_file (char *dir, char *file, char *from, char *to) |
static void | deq_this (fileq_t *this) |
static void | flush_fileq (char *to) |
static void | send_next_file (char *to) |
static void | show_queued_files (int idx) |
static void | fileq_cancel (int idx, char *par) |
static void deq_this | ( | fileq_t * | this | ) | [static] |
Definition at line 48 of file transferqueue.c.
References zarrf::dir, zarrf::file, fileq, zarrf::next, nfree, and NULL.
Referenced by fileq_cancel(), flush_fileq(), send_next_file(), and transfer_close().
00049 { 00050 fileq_t *q = fileq, *last = NULL; 00051 00052 while (q && q != this) { 00053 last = q; 00054 q = q->next; 00055 } 00056 00057 if (!q) 00058 return; 00059 00060 if (last) 00061 last->next = q->next; 00062 else 00063 fileq = q->next; 00064 nfree(q->dir); 00065 nfree(q->file); 00066 nfree(q); 00067 }
static int expmem_fileq | ( | ) | [static] |
Definition at line 23 of file transferqueue.c.
References zarrf::dir, zarrf::file, fileq, and zarrf::next.
static void fileq_cancel | ( | int | idx, | |
char * | par | |||
) | [static] |
Definition at line 234 of file transferqueue.c.
References at_limit(), dcc, DCC_GET, DCC_GET_PENDING, dcc_total, deq_this(), zarrf::dir, DP_HELP, dprintf, egg_strcasecmp, zarrf::file, fileq, killsock, LOG_FILES, lostdcc, zarrf::next, nfree, zarrf::nick, nrealloc, NULL, putlog, send_next_file(), zarrf::to, TRANSFER_ABORT_DCCSEND, TRANSFER_CANCELLED, TRANSFER_CANCELLED_FILE, TRANSFER_DCC_CANCEL, TRANSFER_NO_MATCHES, TRANSFER_NOTICE_ABORT, wild_match_file(), and wipe_tmp_filename().
Referenced by cmd_cancel().
00235 { 00236 int fnd = 1, matches = 0, atot = 0, i; 00237 fileq_t *q; 00238 char *s = NULL; 00239 00240 while (fnd) { 00241 q = fileq; 00242 fnd = 0; 00243 while (q != NULL) { 00244 if (!egg_strcasecmp(dcc[idx].nick, q->nick)) { 00245 s = nrealloc(s, strlen(q->dir) + strlen(q->file) + 3); 00246 if (q->dir[0] == '*') 00247 sprintf(s, "%s/%s", &q->dir[1], q->file); 00248 else 00249 sprintf(s, "/%s%s%s", q->dir, q->dir[0] ? "/" : "", q->file); 00250 if (wild_match_file(par, s)) { 00251 dprintf(idx, TRANSFER_CANCELLED, s, q->to); 00252 fnd = 1; 00253 deq_this(q); 00254 q = NULL; 00255 matches++; 00256 } 00257 if (!fnd && wild_match_file(par, q->file)) { 00258 dprintf(idx, TRANSFER_CANCELLED, s, q->to); 00259 fnd = 1; 00260 deq_this(q); 00261 q = NULL; 00262 matches++; 00263 } 00264 } 00265 if (q != NULL) 00266 q = q->next; 00267 } 00268 } 00269 00270 if (s) 00271 nfree(s); 00272 00273 for (i = 0; i < dcc_total; i++) { 00274 if ((dcc[i].type == &DCC_GET_PENDING || dcc[i].type == &DCC_GET) && 00275 (!egg_strcasecmp(dcc[i].nick, dcc[idx].nick) || 00276 !egg_strcasecmp(dcc[i].u.xfer->from, dcc[idx].nick))) { 00277 char *nfn = strrchr(dcc[i].u.xfer->origname, '/'); 00278 00279 if (nfn == NULL) 00280 nfn = dcc[i].u.xfer->origname; 00281 else 00282 nfn++; 00283 if (wild_match_file(par, nfn)) { 00284 dprintf(idx, TRANSFER_ABORT_DCCSEND, nfn); 00285 if (egg_strcasecmp(dcc[i].nick, dcc[idx].nick)) 00286 dprintf(DP_HELP, TRANSFER_NOTICE_ABORT, dcc[i].nick, nfn, 00287 dcc[idx].nick); 00288 if (dcc[i].type == &DCC_GET) 00289 putlog(LOG_FILES, "*", TRANSFER_DCC_CANCEL, nfn, dcc[i].nick, 00290 dcc[i].status, dcc[i].u.xfer->length); 00291 wipe_tmp_filename(dcc[i].u.xfer->filename, i); 00292 atot++; 00293 matches++; 00294 killsock(dcc[i].sock); 00295 lostdcc(i); 00296 } 00297 } 00298 } 00299 if (!matches) 00300 dprintf(idx, TRANSFER_NO_MATCHES); 00301 else 00302 dprintf(idx, TRANSFER_CANCELLED_FILE, matches, (matches != 1) ? "s" : ""); 00303 for (i = 0; i < atot; i++) 00304 if (!at_limit(dcc[idx].nick)) 00305 send_next_file(dcc[idx].nick); 00306 }
static void flush_fileq | ( | char * | to | ) | [static] |
Definition at line 71 of file transferqueue.c.
References deq_this(), egg_strcasecmp, fileq, zarrf::next, NULL, and zarrf::to.
Referenced by send_next_file().
00072 { 00073 fileq_t *q = fileq; 00074 int fnd = 1; 00075 00076 while (fnd) { 00077 q = fileq; 00078 fnd = 0; 00079 while (q != NULL) { 00080 if (!egg_strcasecmp(q->to, to)) { 00081 deq_this(q); 00082 q = NULL; 00083 fnd = 1; 00084 } 00085 if (q != NULL) 00086 q = q->next; 00087 } 00088 } 00089 }
static void queue_file | ( | char * | dir, | |
char * | file, | |||
char * | from, | |||
char * | to | |||
) | [static] |
Definition at line 34 of file transferqueue.c.
References zarrf::dir, zarrf::file, fileq, zarrf::next, zarrf::nick, nmalloc, and zarrf::to.
00035 { 00036 fileq_t *q = fileq; 00037 00038 fileq = nmalloc(sizeof *fileq); 00039 fileq->next = q; 00040 fileq->dir = nmalloc(strlen(dir) + 1); 00041 fileq->file = nmalloc(strlen(file) + 1); 00042 strcpy(fileq->dir, dir); 00043 strcpy(fileq->file, file); 00044 strcpy(fileq->nick, from); 00045 strcpy(fileq->to, to); 00046 }
static void send_next_file | ( | char * | to | ) | [static] |
Definition at line 91 of file transferqueue.c.
References copy_to_tmp, copyfile, DCCSEND_FEMPTY, DCCSEND_FULL, DCCSEND_NOSOCK, DCCSEND_OK, deq_this(), DP_HELP, dprintf, egg_strcasecmp, fileq, flush_fileq(), LOG_FILES, LOG_MISC, zarrf::next, nfree, nmalloc, nrealloc, NULL, putlog, raw_dcc_send(), tempdir, zarrf::to, TRANSFER_COPY_FAILED, TRANSFER_FILE_ARRIVE, TRANSFER_FILESYS_BROKEN, TRANSFER_LOG_CONFULL, TRANSFER_LOG_FILEEMPTY, TRANSFER_LOG_SOCKERR, TRANSFER_NOTICE_CONFULL, TRANSFER_NOTICE_FILEEMPTY, TRANSFER_NOTICE_SOCKERR, and wipe_tmp_filename().
Referenced by fileq_cancel().
00092 { 00093 fileq_t *q, *this = NULL; 00094 char *s, *s1; 00095 int x; 00096 00097 for (q = fileq; q; q = q->next) 00098 if (!egg_strcasecmp(q->to, to)) 00099 this = q; 00100 00101 if (this == NULL) 00102 return; 00103 00104 if (this->dir[0] == '*') { /* Absolute path */ 00105 s = nmalloc(strlen(&this->dir[1]) + strlen(this->file) + 2); 00106 sprintf(s, "%s/%s", &this->dir[1], this->file); 00107 } else { 00108 char *p = strchr(this->dir, '*'); 00109 00110 if (p == NULL) { 00111 send_next_file(to); 00112 return; 00113 } 00114 00115 p++; 00116 s = nmalloc(strlen(p) + strlen(this->file) + 2); 00117 sprintf(s, "%s%s%s", p, p[0] ? "/" : "", this->file); 00118 strcpy(this->dir, &(p[atoi(this->dir)])); 00119 } 00120 if (copy_to_tmp) { 00121 s1 = nmalloc(strlen(tempdir) + strlen(this->file) + 1); 00122 sprintf(s1, "%s%s", tempdir, this->file); 00123 if (copyfile(s, s1) != 0) { 00124 putlog(LOG_FILES | LOG_MISC, "*", TRANSFER_COPY_FAILED, this->file, 00125 tempdir); 00126 dprintf(DP_HELP, TRANSFER_FILESYS_BROKEN, this->to); 00127 strcpy(s, this->to); 00128 flush_fileq(s); 00129 nfree(s1); 00130 nfree(s); 00131 return; 00132 } 00133 } else { 00134 s1 = nmalloc(strlen(s) + 1); 00135 strcpy(s1, s); 00136 } 00137 if (this->dir[0] == '*') { 00138 s = nrealloc(s, strlen(&this->dir[1]) + strlen(this->file) + 2); 00139 sprintf(s, "%s/%s", &this->dir[1], this->file); 00140 } else { 00141 s = nrealloc(s, strlen(this->dir) + strlen(this->file) + 2); 00142 sprintf(s, "%s%s%s", this->dir, this->dir[0] ? "/" : "", this->file); 00143 } 00144 x = raw_dcc_send(s1, this->to, this->nick, s); 00145 if (x == DCCSEND_OK) { 00146 if (egg_strcasecmp(this->to, this->nick)) 00147 dprintf(DP_HELP, TRANSFER_FILE_ARRIVE, this->to, this->nick); 00148 deq_this(this); 00149 nfree(s); 00150 nfree(s1); 00151 return; 00152 } 00153 wipe_tmp_filename(s1, -1); 00154 if (x == DCCSEND_FULL) { 00155 putlog(LOG_FILES, "*", TRANSFER_LOG_CONFULL, s1, this->nick); 00156 dprintf(DP_HELP, TRANSFER_NOTICE_CONFULL, this->to); 00157 strcpy(s, this->to); 00158 flush_fileq(s); 00159 } else if (x == DCCSEND_NOSOCK) { 00160 putlog(LOG_FILES, "*", TRANSFER_LOG_SOCKERR, s1, this->nick); 00161 dprintf(DP_HELP, TRANSFER_NOTICE_SOCKERR, this->to); 00162 strcpy(s, this->to); 00163 flush_fileq(s); 00164 } else { 00165 if (x == DCCSEND_FEMPTY) { 00166 putlog(LOG_FILES, "*", TRANSFER_LOG_FILEEMPTY, this->file); 00167 dprintf(DP_HELP, TRANSFER_NOTICE_FILEEMPTY, this->to, this->file); 00168 } 00169 deq_this(this); 00170 } 00171 nfree(s); 00172 nfree(s1); 00173 00174 return; 00175 }
static void show_queued_files | ( | int | idx | ) | [static] |
Definition at line 177 of file transferqueue.c.
References dcc, DCC_GET, DCC_GET_PENDING, dcc_total, zarrf::dir, dprintf, egg_strcasecmp, zarrf::file, fileq, HANDLEN, zarrf::next, zarrf::nick, NULL, spaces, zarrf::to, TRANSFER_DONE, TRANSFER_LINES, TRANSFER_QUEUED_UP, TRANSFER_SEND_TO, TRANSFER_TOTAL, and TRANSFER_WAITING.
Referenced by cmd_pending().
00178 { 00179 int i, cnt = 0, len; 00180 char spaces[] = " "; 00181 fileq_t *q; 00182 00183 for (q = fileq; q; q = q->next) { 00184 if (!egg_strcasecmp(q->nick, dcc[idx].nick)) { 00185 if (!cnt) { 00186 spaces[HANDLEN - 9] = 0; 00187 dprintf(idx, TRANSFER_SEND_TO, spaces); 00188 dprintf(idx, TRANSFER_LINES, spaces); 00189 spaces[HANDLEN - 9] = ' '; 00190 } 00191 cnt++; 00192 spaces[len = HANDLEN - strlen(q->to)] = 0; 00193 if (q->dir[0] == '*') 00194 dprintf(idx, " %s%s %s/%s\n", q->to, spaces, &q->dir[1], q->file); 00195 else 00196 dprintf(idx, " %s%s /%s%s%s\n", q->to, spaces, q->dir, 00197 q->dir[0] ? "/" : "", q->file); 00198 spaces[len] = ' '; 00199 } 00200 } 00201 for (i = 0; i < dcc_total; i++) { 00202 if ((dcc[i].type == &DCC_GET_PENDING || dcc[i].type == &DCC_GET) && 00203 (!egg_strcasecmp(dcc[i].nick, dcc[idx].nick) || 00204 !egg_strcasecmp(dcc[i].u.xfer->from, dcc[idx].nick))) { 00205 char *nfn; 00206 00207 if (!cnt) { 00208 spaces[HANDLEN - 9] = 0; 00209 dprintf(idx, TRANSFER_SEND_TO, spaces); 00210 dprintf(idx, TRANSFER_LINES, spaces); 00211 spaces[HANDLEN - 9] = ' '; 00212 } 00213 nfn = strrchr(dcc[i].u.xfer->origname, '/'); 00214 if (nfn == NULL) 00215 nfn = dcc[i].u.xfer->origname; 00216 else 00217 nfn++; 00218 cnt++; 00219 spaces[len = HANDLEN - strlen(dcc[i].nick)] = 0; 00220 if (dcc[i].type == &DCC_GET_PENDING) 00221 dprintf(idx, TRANSFER_WAITING, dcc[i].nick, spaces, nfn); 00222 else 00223 dprintf(idx, TRANSFER_DONE, dcc[i].nick, spaces, nfn, (100.0 * 00224 ((float) dcc[i].status / (float) dcc[i].u.xfer->length))); 00225 spaces[len] = ' '; 00226 } 00227 } 00228 if (!cnt) 00229 dprintf(idx, TRANSFER_QUEUED_UP); 00230 else 00231 dprintf(idx, TRANSFER_TOTAL, cnt); 00232 }