打印

如下函数,C18无法编译通过,在线急等

[复制链接]
2442|9
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
eworker|  楼主 | 2008-8-14 17:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式


typedef unsigned char  uint8;
typedef unsigned short uint16;
typedef unsigned int   uint32;

typedef signed char      sint8;
typedef signed short     sint16;
typedef signed int       sint32;

#define MAXOID     20
#define MAXKEY     4
#define MAXKLEN    22
#define MAXVAR     60

#define scompare(a, b) strcmp((const char *)a, (const char *)b)
#define sncompare(a, b, c) strncmp((const char *)a, (const char *)b, c)
#define slength(a) strlen((const char *)a)
#define scopy(a, b) strcpy((char *)a, (const char *)b)
#define sncopy(a, b, c) strncpy((char *)a, (const char *)b, c)

#define Integer     0x02ul
#define String      0x04ul
#define Null        0x05ul
#define Identifier  0x06ul
#define OctetString 0x14ul
#define Sequence    0x30ul
#define IpAddress   0x40ul
#define Counter     0x41ul
#define Counter32   0x41ul
#define Gauge       0x42ul
#define Ticks       0x43ul

#define GetRequest      0xa0ul
#define GetNextRequest  0xa1ul
#define GetResponse     0xa2ul
#define TrapV1          0xa4ul
#define SetRequest      0xa3ul
#define GetBulkRequest  0xa5ul
#define Trap            0xa7ul
#define Report          0xa8ul

/* Version 2 error values */
#define tooBig              1
#define noSuchName          2
#define badValue            3
#define readOnly            4
#define genErr              5
#define noAccess            6
#define wrongType           7
#define wrongLength         8
#define wrongEncoding       9
#define wrongValue          10
#define noCreation          11
#define inconsistentValue   12
#define resourceUnavailable 13
#define commitFailed        14
#define undoFailed          15
#define authorizationError  16
#define notWritable         17
#define inconsistentName    18

#define IMMED     0x01          /* Immediate value in mvp->len */
#define IMMED2    0x02          /* Immediate value in mvp->type + len */
#define BASE1     0x03          /* Base 0 in data space, base 1 in MIB */
#define SCALAR    0x04          /* Table not indexed (no offset) */
#define W         0x08          /* Write allowed */
#define SX        0x10          /* Sequential table index inferred */
#define NWORDER   0x20          /* Network byte ordering for basic type */
#define CAR       0x40          /* Call application after read */
#define CAW       0x80          /* Call application before write */

/* VACM return values */
#define accessAllowed   0
#define noSuchContext   1

struct COUNTER64
{
    uint32 hi, lo;
};

typedef struct
{
    uint8 nlen, name[MAXOID];
} OID;

typedef struct
{
    OID oid;                    /* Object ID name and length */
    uint16 ix;              /* Index values (offsets) */
    uint16 len;                 /* Length of table */
    void *empty;        /* empty flag */
} MIBTAB;

typedef struct
{
    OID oid;                    /* Object ID name and length */
    uint16 opt;                 /* Options (with choice) */
    uint8 type;                 /* Type of variable */
    sint16 len;                 /* Length of pointer field */
    void *ptr;                  /* Pointer to possible variable data */
} MIBVAR;

/* Define SNMP access to a particular MIB */
typedef struct
{
    const MIBVAR *mvp;          /* MIB variables */
    sint16 (*numvars)(void);    /* Number of variables */
    const MIBTAB *mtp;          /* MIB tables */
    sint16 (*numtabs)(void);    /* Number of tables */
    void (*get)(sint16 varix, sint16 tabix, uint8 **vvptr);
    sint16 (*set)(sint16 varix, sint16 tabix);
    sint16 (*index)(sint16 varix, sint16 index);
    void (*init)(uint16 type);  /* Initialize the MIB */
    sint16 (*check)(sint16 varix, sint16 tabix, const uint8 *inp);
} MIB;

typedef struct
{
    const MIB **mibs;               /* Array of pointers to host MIBs */
    uint16 nummibs;                 /* Number of host MIBs */
    uint16 trapv;                    /* Trap version and startup trap type */
} AGENT_CONTEXT;

/* Function prototypes */
void snmpInit(void);
void SnmpRefresh(void);
sint16 inReqOutRep(uint8 **obp, uint16 olen, const uint8 *ibp, uint16 ilen);

/* Mid-level API */
sint16 ussSNMPAgentInit(const AGENT_CONTEXT *ac);
sint16 ussSNMPAgentTrap(uint8 type, uint8 spec, unsigned char*contextName,
    const uint8 *vbs, uint16 len);

/* Utility */
void snmpEncodeIndex(uint8 **pp, const MIB *mibp, const MIBTAB *mtp,
    sint16 tabix);
    
sint32 snmpVCompare(const uint8 *op1, sint16 len1, const uint8 *op2, sint16 len2);

sint32 snmpFindOID(const uint8 **retp, const uint8 *base, sint16 osize,
    sint16 onum, const uint8 *valp, sint16 vlen);
sint32 snmpFindIndex(sint16 *tabixp, const MIBTAB *mtp,
    const MIB *mibp, const MIBVAR *mvp,
    const uint8 *reqixname, uint8 reqixlen, uint8 nflag);
    
void snmpEncodeID(uint8 **pp, uint8 olen, uint32 val);

sint16 snmpReadLength(const uint8 **pp, uint16 type);
sint16 snmpReadInt(uint32 *outp, uint8 olen, const uint8 **inp, uint16 type);
sint16 snmpReadVal(uint8 *outp, uint8 olen, const uint8 **inp, uint16 type);

void snmpRWriteLength(uint8 **pp, uint16 type, sint16 len);
void snmpRWriteInt(uint8 **pp, uint32 val, uint16 type, sint16 len);
void snmpRWriteVal(uint8 **pp, const uint8 *vp, uint16 type, sint16 len);

/* VACM module */
sint16 isAccessAllowed(const uint8 *contextName);  




// snmpFindIndex()    Find a table entry index

sint32 snmpFindIndex(sint16 *tabixp, const MIBTAB *mtp,
    const MIB *mibp, const MIBVAR *mvp,
    const uint8 *reqixname, uint8 reqixlen, uint8 nflag)
{
    
    
    uint8 *cp;
    sint32 sl1, sl2;
    sint16 i1, i3;
    uint8 ixname[MAXKLEN];

       /* Default return values */
    *tabixp = -1;
    sl2 = 0;

       /* Search through each table entry's index for the element */
    for (i1 = 0; ; i1++)
    {
        i3 = mibp->index(mvp - mibp->mvp, i1);
        if (i3 < 0)
            break;      /* -1 -- End of table reached */
        if (i3 == 0)
            continue;   /* 0 -- Skip table entry */

           /* Encode the table entry at the current index */
        cp = ixname + MAXKLEN;
        snmpEncodeIndex(&cp, mibp, mtp, i1);

           /*
        ** Compare agent encoding with requested encoding.
        ** Save the smallest positive difference.
        */
        sl1 = snmpVCompare(cp, (const uint8 *)&ixname[MAXKLEN] - cp,
                           reqixname, reqixlen);
        
           if (nflag)
           {
               if (sl1 >= 255) 
               {
                   sl2 = 1;
                   break;
               }
           }
           else
           {
               if (sl1 == 0)
               {
                   sl2 = 1;
                   break;
               }
           }
    }
    
    *tabixp = i1;

    return sl2;
}
沙发
eworker|  楼主 | 2008-8-14 17:11 | 只看该作者

提示如下错误

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

使用特权

评论回复
板凳
yewuyi| | 2008-8-14 17:21 | 只看该作者

应该是编译器过期了。。。

呵呵,要么掏钱要么。。。(此处省略100字)

使用特权

评论回复
地板
eworker|  楼主 | 2008-8-14 17:24 | 只看该作者

但是编译其他函数没有问题啊

使用特权

评论回复
5
eworker|  楼主 | 2008-8-14 17:33 | 只看该作者

编译一个很大的工程也没有问题。

使用特权

评论回复
6
yewuyi| | 2008-8-14 17:33 | 只看该作者

那就不太清楚了。。。

找MCP的工程师问问把

使用特权

评论回复
7
soso| | 2008-8-14 23:26 | 只看该作者

是编译器时间限制了

    强烈建议,在物有所值的状态下采用正版的软件,MCC18就几百块*币。

使用特权

评论回复
8
eworker|  楼主 | 2008-8-15 11:02 | 只看该作者

具体原因没找到,但今天又可以编译了。

使用特权

评论回复
9
chengqing3968| | 2013-10-9 10:34 | 只看该作者
有点神奇……

使用特权

评论回复
10
chengqing3968| | 2013-10-9 17:07 | 只看该作者
敢问楼主,这个代码是自己写的,还是哪儿找的?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

29

主题

176

帖子

0

粉丝