- 论坛徽章:
- 0
|
/*
* Send the requested file.
*/
void
sendfile(int fd, char *name, char *mode)
{
register struct tftphdr *ap; /* data and ack packets */
struct tftphdr *dp;
volatile int size = 0;
volatile u_int16_t block = 0;
int n;
volatile unsigned long amount = 0;
struct sockaddr_in from;
socklen_t fromlen;
volatile int convert; /* true if doing nl->;crlf conversion */
FILE *file;
volatile int firsttrip = 1;
startclock(); /* start stat's clock */
dp = r_init(); /* reset fillbuf/read-ahead code */
ap = (struct tftphdr *)ackbuf;
file = fdopen(fd, "r" ;
convert = !strcmp(mode, "netascii" ;
mysignal(SIGALRM, timer);
do {
if (firsttrip) {
size = makerequest(WRQ, name, dp, mode) - 4;
}
else {
/* size = read(fd, dp->;th_data, SEGSIZE); */
size = readit(file, &dp, convert);
if (size < 0) {
nak(errno + 100);
break;
}
dp->;th_opcode = htons((u_short)DATA);
dp->;th_block = htons((u_short)block);
}
timeout = 0;
(void) sigsetjmp(timeoutbuf, 1);
send_data:
我不解的是,为什么需要加volatile 限定?因为我觉得没有发现其他地方对这
几个变量做了修改啊,还是我眼睛花了。
这个是netkit-tftp包的 tftp.c文件
apt-get source tftp 得到的。
请高手指教 |
|