summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c44
-rw-r--r--boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exebin111616 -> 29256 bytes
-rw-r--r--hfile2array/hfile2array.c10
-rw-r--r--hfile2array/hfile2array.exebin89600 -> 26582 bytes
4 files changed, 45 insertions, 9 deletions
diff --git a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c
index c3c07fd..685cf46 100644
--- a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c
+++ b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c
@@ -30,10 +30,20 @@
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * 31 *
32 *****************************************************************************/ 32 *****************************************************************************/
33#include <windows.h> 33
34#include <stdio.h> 34#include <stdio.h>
35#include <stdlib.h>
35#include <time.h> 36#include <time.h>
36#include <winsock.h> 37#ifdef __WIN32__
38 #include <windows.h>
39 #include <winsock.h>
40#else
41 #include <sys/types.h>
42 #include <sys/socket.h>
43 #include <netinet/in.h>
44 #include <netdb.h>
45#endif
46
37 47
38#define UDP_LOW 42 48#define UDP_LOW 42
39#define UDP_HIGH 1504 // Note: Windows FRAGMENTS higher UDP sizes 49#define UDP_HIGH 1504 // Note: Windows FRAGMENTS higher UDP sizes
@@ -61,9 +71,15 @@ int toNum(unsigned char c)
61 71
62int main( int argc, char *argv[] ) 72int main( int argc, char *argv[] )
63{ 73{
74
75#ifdef __WIN32__
64 WORD wVersionRequested; 76 WORD wVersionRequested;
65 WSADATA wsaData; 77 WSADATA wsaData;
66 SOCKET s; 78 SOCKET s;
79#else
80 int s;
81#endif
82
67 struct sockaddr_in sin; 83 struct sockaddr_in sin;
68 unsigned char *pBuf = 0; 84 unsigned char *pBuf = 0;
69 int tmp1,tmp2,tmp3,tmp4; 85 int tmp1,tmp2,tmp3,tmp4;
@@ -96,6 +112,7 @@ int main( int argc, char *argv[] )
96 fgets (iline, 131, strin); 112 fgets (iline, 131, strin);
97 fgets (iline, 131, strin); 113 fgets (iline, 131, strin);
98 114
115#ifdef __WIN32__
99 wVersionRequested = MAKEWORD(1, 1); 116 wVersionRequested = MAKEWORD(1, 1);
100 tmp2 = WSAStartup(wVersionRequested, &wsaData); 117 tmp2 = WSAStartup(wVersionRequested, &wsaData);
101 if (tmp2 != 0) 118 if (tmp2 != 0)
@@ -103,11 +120,16 @@ int main( int argc, char *argv[] )
103 printf("\r\nUnable to initialize WinSock for host info"); 120 printf("\r\nUnable to initialize WinSock for host info");
104 exit(0); 121 exit(0);
105 } 122 }
123#endif
106 124
107 s = socket( AF_INET, SOCK_DGRAM, 0 ); 125 s = socket( AF_INET, SOCK_DGRAM, 0 );
108 if( s < 0 ) 126 if( s < 0 )
109 { 127 {
128#ifdef __WIN32__
110 printf("failed connect (%d)\n",WSAGetLastError()); 129 printf("failed connect (%d)\n",WSAGetLastError());
130#else
131 perror("failed connect");
132#endif
111 goto end; 133 goto end;
112 } 134 }
113 135
@@ -117,7 +139,11 @@ int main( int argc, char *argv[] )
117 139
118 if ( bind( s, (struct sockaddr *)&sin, sizeof(sin) ) < 0 ) 140 if ( bind( s, (struct sockaddr *)&sin, sizeof(sin) ) < 0 )
119 { 141 {
142#ifdef __WIN32__
120 printf("failed bind (%d)\n",WSAGetLastError()); 143 printf("failed bind (%d)\n",WSAGetLastError());
144#else
145 perror("failed bind");
146#endif
121 goto end; 147 goto end;
122 } 148 }
123 149
@@ -173,7 +199,11 @@ int main( int argc, char *argv[] )
173 /* send out the packet */ 199 /* send out the packet */
174 if( sendto( s, pBuf, length, 0, (struct sockaddr *)&sin, sizeof(sin) ) < 0 ) 200 if( sendto( s, pBuf, length, 0, (struct sockaddr *)&sin, sizeof(sin) ) < 0 )
175 { 201 {
176 printf("send failed (%d)\n",WSAGetLastError()); 202#ifdef __WIN32__
203 printf("send failed (%d)\n",WSAGetLastError());
204#else
205 perror("send failed");
206#endif
177 break; 207 break;
178 } 208 }
179 209
@@ -193,7 +223,7 @@ int main( int argc, char *argv[] )
193 } 223 }
194 224
195 tn = time(0) - ts; 225 tn = time(0) - ts;
196 printf("Exiting . Time = %d seconds, Total Packets = %d",tn,packetno); 226 printf("Exiting . Time = %d seconds, Total Packets = %d\n",(int)tn,packetno);
197 227
198 /* clean up */ 228 /* clean up */
199end: 229end:
@@ -202,8 +232,14 @@ end:
202 if( pBuf ) 232 if( pBuf )
203 free( pBuf ); 233 free( pBuf );
204 if( s >= 0 ) 234 if( s >= 0 )
235#ifdef __WIN32__
205 closesocket( s ); 236 closesocket( s );
237#else
238 shutdown(s,SHUT_RDWR);
239#endif
206 240
241#ifdef __WIN32__
207 WSACleanup(); 242 WSACleanup();
243#endif
208} 244}
209 245
diff --git a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe
index 4e7173d..ca463fd 100644
--- a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe
+++ b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe
Binary files differ
diff --git a/hfile2array/hfile2array.c b/hfile2array/hfile2array.c
index a6d7a5b..765821f 100644
--- a/hfile2array/hfile2array.c
+++ b/hfile2array/hfile2array.c
@@ -82,7 +82,7 @@ int main(int argc, char **argv)
82 { 82 {
83 if (fgets(line_hdr, 200, in_hdr) != NULL) 83 if (fgets(line_hdr, 200, in_hdr) != NULL)
84 { 84 {
85 if (fputs(line_hdr, out) != 0) 85 if (fputs(line_hdr, out) < 0)
86 { 86 {
87 printf ("fputs %s error\n", line_hdr); 87 printf ("fputs %s error\n", line_hdr);
88 goto error; 88 goto error;
@@ -98,7 +98,7 @@ int main(int argc, char **argv)
98 strcat (line, (const char *)(*argv++)); 98 strcat (line, (const char *)(*argv++));
99 strcat (line, "[] = {\n"); 99 strcat (line, "[] = {\n");
100 100
101 if (fputs(line, out) != 0) 101 if (fputs(line, out) < 0)
102 { 102 {
103 printf ("fputs %s error\n", line); 103 printf ("fputs %s error\n", line);
104 goto error; 104 goto error;
@@ -108,7 +108,7 @@ int main(int argc, char **argv)
108 { 108 {
109 if (fgets(line, 200, in) != NULL) 109 if (fgets(line, 200, in) != NULL)
110 { 110 {
111 if (fputs(line, out) != 0) 111 if (fputs(line, out) < 0)
112 { 112 {
113 printf ("fputs %s error\n", fputs); 113 printf ("fputs %s error\n", fputs);
114 goto error; 114 goto error;
@@ -121,7 +121,7 @@ int main(int argc, char **argv)
121 } 121 }
122 } 122 }
123 123
124 if (fputs("};\n", out) != 0) 124 if (fputs("};\n", out) < 0)
125 { 125 {
126 printf ("fputs %s error\n", fputs); 126 printf ("fputs %s error\n", fputs);
127 goto error; 127 goto error;
@@ -139,4 +139,4 @@ error:
139 fclose(out); 139 fclose(out);
140 140
141 return (-1); 141 return (-1);
142} \ No newline at end of file 142}
diff --git a/hfile2array/hfile2array.exe b/hfile2array/hfile2array.exe
index ae50530..8582033 100644
--- a/hfile2array/hfile2array.exe
+++ b/hfile2array/hfile2array.exe
Binary files differ