现在的位置: 首页 > 综合 > 正文

库中调用user function

2013年09月13日 ⁄ 综合 ⁄ 共 597字 ⁄ 字号 评论关闭

1在库函数中添加userfunc的好处,方便用户在库的适当时候处理接收到的数据,例如iphandler,和tftptick中都有调用userfunc

 

typedef struct tftp_state {
 int    (*udhandler)(); 
 unsigned char tcmode;   
 byte   state;   
};

 

if ( (ts->udhandler == NULL) || ((ts->tcmode & TFTP_USER_COPY) == 0) )
    {
     if (newlen < ts->buf_used || newlen > ts->buf_len) { // Buffer overflow?
      len = ts->buf_len - ts->buf_used;
      ts->flags |= TFTP_F_TRUNC | TFTP_F_EXIT;
     }
     if (len > 0) {
      root2xmem(ts->buf_addr + ts->buf_used, tp.u.d.data, (unsigned)len);
      ts->buf_used += len;
     }
     if (ts->udhandler != NULL)
      udrc = ts->udhandler(ts, &len, DATA_IN); 
    }

2 在线升级,启动代码很有意思,原来可以这样跳转程序。

抱歉!评论已关闭.