免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1978 | 回复: 1
打印 上一主题 下一主题

[C] source code debugging 错误求助 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-08-20 17:50 |只看该作者 |倒序浏览
  1. /*
  2. * tftp - Trivial File Transfer Program.  Client side.
  3. *
  4. * See RFC 783 for details.  Also see the "Requirements for Internet Hosts"
  5. * RFC for additional explanations and clarifications.
  6. */

  7. #include        "defs.h"
  8. #include <signal.h>
  9. #include <sys/types.h>
  10. #include <sys/socket.h>
  11. #include <netdb.h>
  12. #include <string.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <unistd.h>




  17. int main(int argc, char *argv[])
  18. {
  19.         register int        i;
  20.         register char        *s;
  21.         register FILE        *fp;


  22.         pname = argv[0];

  23.         while (--argc > 0 && (*++argv)[0] == '-')
  24.                 for (s = argv[0]+1; *s != '\0'; s++)
  25.                         switch (*s) {

  26.                         case 'h':                /* specify host name */
  27.                                 if (--argc <= 0)
  28.                                    err_quit("-h requires another argument");
  29.                                 strcpy(hostname, *++argv);
  30.                                 break;

  31.                         case 't':
  32.                                 traceflag = 1;
  33.                                 break;

  34.                         case 'v':
  35.                                 verboseflag = 1;
  36.                                 break;

  37.                         default:
  38.                                 err_quit("unknown command line option: %c", *s);
  39.                         }

  40.         /*
  41.          * For each filename argument, execute the tftp commands in
  42.          * that file.  If no filename arguments were specified on the
  43.          * command line, we process the standard input by default.
  44.          */

  45.         i = 0;
  46.         fp = stdin;
  47.         do {
  48.                 if (argc > 0 && (fp = fopen(argv[i], "r")) == NULL) {
  49.                         err_sys("%s: can't open %s for reading", argv[i]);
  50.                 }

  51.                 mainloop(fp);                /* process a given file */

  52.         } while (++i < argc);

  53.         exit(0);
  54. }

  55. mainloop(fp)
  56. FILE        *fp;

  57. int main(void)
  58. {
  59.         int sig_intr();

  60.         if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  61.                 signal(SIGINT, sig_intr);

  62.         /*
  63.          * Main loop.  Read a command and execute it.
  64.          * This loop is terminated by a "quit" command, or an
  65.          * end-of-file on the command stream.
  66.          */

  67.         if (setjmp(jmp_mainloop) < 0) {
  68.                 err_ret("Timeout");
  69.         }

  70.         if (interactive)
  71.                 printf("%s", prompt);

  72.         char *chTemp = NULL;
  73.         int nTemp  = 0;        
  74.        while (getline (&chTemp,&nTemp,fp)) {                                                                                                        if (gettoken(command) != NULL)                        docmd(command);                if (interactive)                        printf("%s", prompt);        }

  75. /*
  76. * INTR signal handler.  Just return to the main loop above.
  77. * In case we were waiting for a read to complete, turn off any possible
  78. * alarm clock interrupts.
  79. *
  80. * Note that with TFTP, if the client aborts a file transfer (such as with
  81. * the interrupt signal), the server is not notified.  The protocol counts
  82. * on the server eventually timing out and exiting.
  83. */

  84. int sig_intr()
  85. {
  86.         signal(SIGALRM, SIG_IGN);        /* first ignore the signal */
  87.         alarm(0);                        /* then assure alarm is off */

  88.         longjmp(jmp_mainloop, 1);
  89.         /* NOTREACHED */
  90. }
复制代码
运行 make -f makefile
后出现如下错误,请高手帮看看,谢谢
------------------------------

test@ubuntu:~/Desktop/mytftp$ make
cc    -c -o client.o client.c
client.c: In function ‘mainloop’:
client.c:77: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
make: *** [client.o] Error 1
test@ubuntu:~/Desktop/mytftp$
------------------------------

论坛徽章:
0
2 [报告]
发表于 2011-08-21 14:19 |只看该作者
checking   第73 行 ...
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP