Deleted Added
full compact
tftp.c (38452) tftp.c (39468)
1/* $NetBSD: tftp.c,v 1.4 1997/09/17 16:57:07 drochner Exp $ */
2
3/*
4 * Copyright (c) 1996
5 * Matthias Drochner. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 44 unchanged lines hidden (view full) ---

53#include <string.h>
54
55#include "stand.h"
56#include "net.h"
57#include "netif.h"
58
59#include "tftp.h"
60
1/* $NetBSD: tftp.c,v 1.4 1997/09/17 16:57:07 drochner Exp $ */
2
3/*
4 * Copyright (c) 1996
5 * Matthias Drochner. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 44 unchanged lines hidden (view full) ---

53#include <string.h>
54
55#include "stand.h"
56#include "net.h"
57#include "netif.h"
58
59#include "tftp.h"
60
61static int tftp_open(char *path, struct open_file *f);
61static int tftp_open(const char *path, struct open_file *f);
62static int tftp_close(struct open_file *f);
63static int tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid);
64static int tftp_write(struct open_file *f, void *buf, size_t size, size_t *resid);
65static off_t tftp_seek(struct open_file *f, off_t offset, int where);
66static int tftp_stat(struct open_file *f, struct stat *sb);
67
68struct fs_ops tftp_fsops = {
69 "tftp", tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat

--- 161 unchanged lines hidden (view full) ---

231 h->validsize = res;
232 if (res < SEGSIZE)
233 h->islastblock = 1; /* EOF */
234 return (0);
235}
236
237static int
238tftp_open(path, f)
62static int tftp_close(struct open_file *f);
63static int tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid);
64static int tftp_write(struct open_file *f, void *buf, size_t size, size_t *resid);
65static off_t tftp_seek(struct open_file *f, off_t offset, int where);
66static int tftp_stat(struct open_file *f, struct stat *sb);
67
68struct fs_ops tftp_fsops = {
69 "tftp", tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat

--- 161 unchanged lines hidden (view full) ---

231 h->validsize = res;
232 if (res < SEGSIZE)
233 h->islastblock = 1; /* EOF */
234 return (0);
235}
236
237static int
238tftp_open(path, f)
239 char *path;
239 const char *path;
240 struct open_file *f;
241{
242 struct tftp_handle *tftpfile;
243 struct iodesc *io;
244 int res;
245
246 tftpfile = (struct tftp_handle *) malloc(sizeof(*tftpfile));
247 if (!tftpfile)
248 return (ENOMEM);
249
250 tftpfile->iodesc = io = socktodesc(*(int *) (f->f_devdata));
251 io->destip = servip;
252 tftpfile->off = 0;
240 struct open_file *f;
241{
242 struct tftp_handle *tftpfile;
243 struct iodesc *io;
244 int res;
245
246 tftpfile = (struct tftp_handle *) malloc(sizeof(*tftpfile));
247 if (!tftpfile)
248 return (ENOMEM);
249
250 tftpfile->iodesc = io = socktodesc(*(int *) (f->f_devdata));
251 io->destip = servip;
252 tftpfile->off = 0;
253 tftpfile->path = path; /* XXXXXXX we hope it's static */
253 tftpfile->path = strdup(path);
254 if (tftpfile->path == NULL) {
255 free(tftpfile);
256 return(ENOMEM);
257 }
254
255 res = tftp_makereq(tftpfile, path);
256
257 if (res) {
258
259 res = tftp_makereq(tftpfile, path);
260
261 if (res) {
262 free(tftpfile->path);
258 free(tftpfile);
259 return (res);
260 }
261 f->f_fsdata = (void *) tftpfile;
262 return (0);
263}
264
265static int

--- 74 unchanged lines hidden (view full) ---

340tftp_close(f)
341 struct open_file *f;
342{
343 struct tftp_handle *tftpfile;
344 tftpfile = (struct tftp_handle *) f->f_fsdata;
345
346 /* let it time out ... */
347
263 free(tftpfile);
264 return (res);
265 }
266 f->f_fsdata = (void *) tftpfile;
267 return (0);
268}
269
270static int

--- 74 unchanged lines hidden (view full) ---

345tftp_close(f)
346 struct open_file *f;
347{
348 struct tftp_handle *tftpfile;
349 tftpfile = (struct tftp_handle *) f->f_fsdata;
350
351 /* let it time out ... */
352
348 if (tftpfile)
353 if (tftpfile) {
354 free(tftpfile->path);
349 free(tftpfile);
355 free(tftpfile);
356 }
350 return (0);
351}
352
353static int
354tftp_write(f, start, size, resid)
355 struct open_file *f;
356 void *start;
357 size_t size;

--- 43 unchanged lines hidden ---
357 return (0);
358}
359
360static int
361tftp_write(f, start, size, resid)
362 struct open_file *f;
363 void *start;
364 size_t size;

--- 43 unchanged lines hidden ---