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