TFTP_C.C
资源名称:ertos.rar [点击查看]
上传用户:sunrenlu
上传日期:2022-06-13
资源大小:1419k
文件大小:1k
源码类别:
操作系统开发
开发平台:
DOS
- /*
- * tftp_c.c - sample tftp client
- */
- #include <rtos.h>
- #include <net.h>
- #include <process.h>
- #include <string.h>
- #include <tftp.h>
- main(int argc, char **argv)
- {
- DWORD host;
- int put;
- char *filename;
- char *hostname;
- int result;
- kdebug = 1;
- rt_init( 100 );
- sock_init();
- if ( argc < 4 ) {
- cprintf("%s GET|PUT hostname filenamern", argv[0]);
- exit( 3 );
- }
- put = !stricmp( argv[1], "put");
- hostname = argv[2];
- host = resolve( hostname );
- filename = argv[3];
- if ( host == 0 ) {
- cprintf("ERROR: unable to resolve %srn", hostname );
- exit( 3 );
- }
- if ( put ) {
- cprintf("rnUploading %s to %s...", filename, hostname );
- result = tftp( host, TFTP_PUT, filename );
- } else {
- cprintf("rnDownloading %s from %s...", filename, hostname );
- result = tftp( host, TFTP_GET, filename );
- }
- cprintf( "%srn", result ? "failed" : "success");
- return( result ? 2 : 0 );
- }