]>
Commit | Line | Data |
---|---|---|
04fee52e A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
db839b1d | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
04fee52e | 7 | * |
db839b1d A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
04fee52e A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
db839b1d A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
04fee52e A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * net.c - File System Module for wrapping TFTP. | |
27 | * | |
366defd1 | 28 | * Copyright (c) 1999-2002 Apple Computer, Inc. |
04fee52e A |
29 | * |
30 | * DRI: Josh de Cesare | |
31 | */ | |
32 | ||
33 | #include <sl.h> | |
34 | #include <fs.h> | |
35 | ||
36 | struct NetPartInfo { | |
37 | char devSpec[1024]; | |
38 | }; | |
39 | typedef struct NetPartInfo NetPartInfo, *NetPartInfoPtr; | |
40 | ||
41 | ||
42 | // Public functions | |
43 | ||
44 | CICell NetInitPartition(char *devSpec) | |
45 | { | |
46 | NetPartInfoPtr net; | |
47 | ||
366defd1 | 48 | net = (NetPartInfoPtr)AllocateBootXMemory(sizeof(NetPartInfo)); |
04fee52e A |
49 | if (net == 0) return 0; |
50 | ||
51 | strcpy(net->devSpec, devSpec); | |
52 | ||
53 | return (CICell)net; | |
54 | } | |
55 | ||
56 | long NetLoadFile(CICell ih, char *filePath) | |
57 | { | |
58 | CICell netIH; | |
59 | NetPartInfoPtr net; | |
60 | long ret, length, triesLeft; | |
61 | char fileSpec[2048]; | |
62 | ||
63 | net = (NetPartInfoPtr)ih; | |
64 | ||
65 | sprintf(fileSpec, "%s,%s", net->devSpec, filePath); | |
66 | ||
67 | printf("Opening [%s]...\n", fileSpec); | |
68 | ||
69 | triesLeft = 10; | |
70 | do { | |
71 | netIH = Open(fileSpec); | |
72 | triesLeft--; | |
73 | } while ((netIH == 0) && triesLeft); | |
74 | if (netIH == 0) return -1; | |
75 | ||
76 | triesLeft = 10; | |
77 | do { | |
366defd1 | 78 | ret = CallMethod(1, 1, netIH, "load", kLoadAddr, &length); |
04fee52e A |
79 | if (gOFVersion < kOFVersion3x) { |
80 | if (length == 0) ret = -1; | |
81 | } | |
82 | triesLeft--; | |
83 | } while ((ret != kCINoError) && triesLeft); | |
84 | if (ret != kCINoError) return -1; | |
85 | ||
86 | Close(netIH); | |
87 | ||
88 | return length; | |
89 | } | |
90 | ||
91 | long NetGetDirEntry(CICell ih, char *dirPath, long *dirIndex, | |
92 | char **name, long *flags, long *time) | |
93 | { | |
94 | return -1; | |
95 | } |