const char *opt2fn_null(const char *opt, int nfile, const t_filenm fnm[]) { int i; for (i = 0; (i < nfile); i++) { if (strcmp(opt, fnm[i].opt) == 0) { if (IS_OPT(fnm[i]) && !IS_SET(fnm[i])) { return NULL; } else { return fnm[i].fns[0]; } } } fprintf(stderr, "No option %s\n", opt); return NULL; }
const char *ftp2fn_null(int ftp, int nfile, const t_filenm fnm[]) { int i; for (i = 0; (i < nfile); i++) { if (ftp == fnm[i].ftp) { if (IS_OPT(fnm[i]) && !IS_SET(fnm[i])) { return NULL; } else { return fnm[i].fns[0]; } } } fprintf(stderr, "ftp2fn: No filetype %s\n", deffile[ftp].ext); return NULL; }
static SOCKET TftpProcessOACK (void) { struct tftphdr *tpr, *tps; char *pOpt, *pValue; // couples Option/Valeur int Rc; tpr = (struct tftphdr *) sTC.BufRcv; tps = (struct tftphdr *) sTC.BufSnd; // parse options pOpt = tpr->th_stuff ; while (pOpt - tpr->th_stuff < TFTP_SEGSIZE && *pOpt!=0 ) { // find value string (next word) do not use strlen since string is possibly not 0 terminated for (pValue = pOpt ; pValue - tpr->th_stuff < TFTP_SEGSIZE && *pValue != 0 ; pValue++); pValue++; if (pValue - tpr->th_stuff == TFTP_SEGSIZE) return FALSE; if (sTC.opcode==TFTP_RRQ && IS_OPT (pOpt, TFTP_OPT_TSIZE)) { // prendre la valeur et envoyer un ACK du block #0 sTC.dwFileSize = atoi (pValue); tps->th_opcode = htons (TFTP_ACK); tps->th_block = htons (0); SetTimer (hTftpClientWnd, WM_CLIENT_DATA, sTC.dwTimeout, NULL); send (sTC.s, (char *) tps, TFTP_DATA_HEADERSIZE, 0); } // option Tsize if (IS_OPT (pOpt, TFTP_OPT_BLKSIZE)) { // prendre la valeur sTC.nPktSize = atoi (pValue); #ifdef JKKLLKJLKJLKLKJKLLKJ // If read -> send a ack of block #0 if (sTC.opcode==TFTP_RRQ) { tps->th_opcode = htons (TFTP_ACK); tps->th_block = htons (0); SetTimer (hTftpClientWnd, WM_CLIENT_DATA, sTC.dwTimeout, NULL); send (sTC.s, (char *) tps, TFTP_DATA_HEADERSIZE, 0); } #endif } // option BlkSize if (IS_OPT (pOpt, TFTP_OPT_PORT)) {char szServ[NI_MAXSERV]; getnameinfo ( (LPSOCKADDR) & sTC.saFrom, sizeof sTC.saFrom, NULL, 0, szServ, sizeof szServ, NI_NUMERICSERV); LogToMonitor ("Port value is %s should be changed to %s", szServ, pValue); switch (sTC.saFrom.ss_family) { case AF_INET : ( (struct sockaddr_in *) (&sTC.saFrom) )->sin_port = htons (atoi (pValue)); break; case AF_INET6 : ( (struct sockaddr_in6 *) (&sTC.saFrom) )->sin6_port = htons (atoi (pValue)); break; } Rc = connect (sTC.s, (struct sockaddr *) & sTC.saFrom, sizeof sTC.saFrom); LogToMonitor ("re-connect returns %d (%d)", Rc, GetLastError ()); } pOpt = pValue + lstrlen (pValue) + 1; } // next option return TRUE; } // TftpProcessOACK