summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0df8582)
raw | patch | inline | side by side (parent: 0df8582)
author | Ivan Pang <i-pang@ti.com> | |
Fri, 14 Oct 2011 21:11:12 +0000 (17:11 -0400) | ||
committer | Ivan Pang <i-pang@ti.com> | |
Fri, 14 Oct 2011 21:11:12 +0000 (17:11 -0400) |
diff --git a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.c
index c3c07fd13667b9e3e8f68e744612d2baacf08dfb..685cf462890c79c12890a52a7dc2ad4ad23f91ea 100644 (file)
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
-#include <windows.h>
+
#include <stdio.h>
+#include <stdlib.h>
#include <time.h>
-#include <winsock.h>
+#ifdef __WIN32__
+ #include <windows.h>
+ #include <winsock.h>
+#else
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <netdb.h>
+#endif
+
#define UDP_LOW 42
#define UDP_HIGH 1504 // Note: Windows FRAGMENTS higher UDP sizes
int main( int argc, char *argv[] )
{
+
+#ifdef __WIN32__
WORD wVersionRequested;
WSADATA wsaData;
SOCKET s;
+#else
+ int s;
+#endif
+
struct sockaddr_in sin;
unsigned char *pBuf = 0;
int tmp1,tmp2,tmp3,tmp4;
fgets (iline, 131, strin);
fgets (iline, 131, strin);
+#ifdef __WIN32__
wVersionRequested = MAKEWORD(1, 1);
tmp2 = WSAStartup(wVersionRequested, &wsaData);
if (tmp2 != 0)
printf("\r\nUnable to initialize WinSock for host info");
exit(0);
}
+#endif
s = socket( AF_INET, SOCK_DGRAM, 0 );
if( s < 0 )
{
+#ifdef __WIN32__
printf("failed connect (%d)\n",WSAGetLastError());
+#else
+ perror("failed connect");
+#endif
goto end;
}
if ( bind( s, (struct sockaddr *)&sin, sizeof(sin) ) < 0 )
{
+#ifdef __WIN32__
printf("failed bind (%d)\n",WSAGetLastError());
+#else
+ perror("failed bind");
+#endif
goto end;
}
/* send out the packet */
if( sendto( s, pBuf, length, 0, (struct sockaddr *)&sin, sizeof(sin) ) < 0 )
{
- printf("send failed (%d)\n",WSAGetLastError());
+#ifdef __WIN32__
+ printf("send failed (%d)\n",WSAGetLastError());
+#else
+ perror("send failed");
+#endif
break;
}
}
tn = time(0) - ts;
- printf("Exiting . Time = %d seconds, Total Packets = %d",tn,packetno);
+ printf("Exiting . Time = %d seconds, Total Packets = %d\n",(int)tn,packetno);
/* clean up */
end:
if( pBuf )
free( pBuf );
if( s >= 0 )
+#ifdef __WIN32__
closesocket( s );
+#else
+ shutdown(s,SHUT_RDWR);
+#endif
+#ifdef __WIN32__
WSACleanup();
+#endif
}
diff --git a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe
index 4e7173d428eeac02a97b55c37fac03471272d44f..ca463fde3aaf20379b1a7a0930c09daa99c1adda 100644 (file)
Binary files a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe and b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe differ
Binary files a/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe and b/boot_loader/examples/ethernet/Ethernet_boot/pcsendpkt.exe differ
index a6d7a5b06254f39e88d26f176a6c020163a6a57f..765821fca0add009c1baa84d172d3c08d2d4d490 100644 (file)
{
if (fgets(line_hdr, 200, in_hdr) != NULL)
{
- if (fputs(line_hdr, out) != 0)
+ if (fputs(line_hdr, out) < 0)
{
printf ("fputs %s error\n", line_hdr);
goto error;
strcat (line, (const char *)(*argv++));
strcat (line, "[] = {\n");
- if (fputs(line, out) != 0)
+ if (fputs(line, out) < 0)
{
printf ("fputs %s error\n", line);
goto error;
{
if (fgets(line, 200, in) != NULL)
{
- if (fputs(line, out) != 0)
+ if (fputs(line, out) < 0)
{
printf ("fputs %s error\n", fputs);
goto error;
}
}
- if (fputs("};\n", out) != 0)
+ if (fputs("};\n", out) < 0)
{
printf ("fputs %s error\n", fputs);
goto error;
fclose(out);
return (-1);
-}
\ No newline at end of file
+}
index ae5053064e7717c1bd52a22a21f6152638e44ec6..85820334ca58b45456fa90b4f632bdee040bc511 100644 (file)
Binary files a/hfile2array/hfile2array.exe and b/hfile2array/hfile2array.exe differ
Binary files a/hfile2array/hfile2array.exe and b/hfile2array/hfile2array.exe differ