📄 cmdlist.lst
字号:
C51 COMPILER V8.06 CMDLIST 01/31/2008 22:24:26 PAGE 1
C51 COMPILER V8.06, COMPILATION OF MODULE CMDLIST
OBJECT MODULE PLACED IN cmdlist.OBJ
COMPILER INVOKED BY: C:\Program Files\Keil\C51\BIN\C51.EXE cmdlist.c OPTIMIZE(9,SPEED) MODDP2 INCDIR(C:\Cypress\USB\Targ
-et\Inc) DEFINE(__USE_USB__) DEBUG OBJECTEXTEND
line level source
1 //-----------------------------------------------------------------------------
2 // Contents: main module of a simple firmware
3 //
4 // Copyright: Inventec Electronics(Tianjin) Co., Ltd.
5 // $Archive: cmdlist.c
6 // $Date: 2007-08-06
7 // $Revision: 1.00
8 //
9 //-----------------------------------------------------------------------------
10 // Copyright 2006, xsh.han@itc.inventec
11 //-----------------------------------------------------------------------------
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16
17 #include "cmdlist.h"
18
19 //global variable
20 struct command_list * g_cmdlist = NULL;
21 struct command_list * g_retlist = NULL;
22
23 //--------------------------------------------------------------------------------
24 //get command list tail
25 //--------------------------------------------------------------------------------
26 struct command_list * get_cmdlist_tail()
27 {
28 1 struct command_list *plist;
29 1
30 1 plist=g_cmdlist;
31 1 if (plist!=NULL){
32 2 while(plist->next!=NULL)
33 2 plist=plist->next;
34 2 }
35 1
36 1 return plist;
37 1 }
38
39
40 //--------------------------------------------------------------------------------
41 //add a command to list
42 //--------------------------------------------------------------------------------
43 struct command_list * add_to_cmdlist(char * cmd)
44 {
45 1 struct command_list *plist;
46 1 struct command_list *ptemp;
47 1
48 1 if (strlen(cmd)>=MAX_CMD_LENGTH) //too long
49 1 return NULL;
50 1
51 1 ptemp=malloc(sizeof(struct command_list));
52 1 if(ptemp==NULL) //alloc error
53 1 return NULL;
54 1
C51 COMPILER V8.06 CMDLIST 01/31/2008 22:24:26 PAGE 2
55 1 memset(ptemp,0,sizeof(struct command_list));
56 1 strcpy(ptemp->message,cmd);
57 1 plist=get_cmdlist_tail();
58 1 if (plist==NULL){
59 2 g_cmdlist=ptemp;
60 2 }else{
61 2 plist->next=ptemp;
62 2 }
63 1 return ptemp;
64 1 }
65
66
67 //--------------------------------------------------------------------------------
68 //free command list
69 //--------------------------------------------------------------------------------
70 void free_cmdlist()
71 {
72 1 struct command_list *plist;
73 1
74 1 plist=g_cmdlist;
75 1 while(plist!=NULL){
76 2 g_cmdlist=g_cmdlist->next;
77 2 free(plist);
78 2 plist=g_cmdlist;
79 2 }
80 1 g_cmdlist = NULL;
81 1 return;
82 1 }
83
84
85 //=============================================================================
86 /*
87 * The Interface description:
88 * get ret_msg_list tail pointer
89 * Parameters:
90 * <none>
91 * Return Value:
92 * pointer for g_cmd_info.cmd_msg
93 * Remark:
94 *
95 */
96 //=============================================================================
97 struct command_list * get_retlist_tail()
98 {
99 1 struct command_list *plist;
100 1
101 1 plist = g_retlist;
102 1 if (plist != NULL){
103 2 while(plist->next!=NULL) {
104 3 plist=plist->next;
105 3 }
106 2 }
107 1
108 1 return plist;
109 1 }
110
111 //=============================================================================
112 /*
113 * The Interface description:
114 * add return message to g_cmd_info.ret_msg_list
115 * for output to cli as echo message
116 * Parameters:
C51 COMPILER V8.06 CMDLIST 01/31/2008 22:24:26 PAGE 3
117 * cmd[in]: cmd string from cli,
118 * Return Value:
119 * pointer for new message_st, NULL if error
120 * Remark:
121 *
122 */
123 //=============================================================================
124 struct command_list * add_to_retlist(char * cmd)
125 {
126 1 struct command_list *plist;
127 1 struct command_list *ptemp;
128 1
129 1 if (strlen(cmd) > MAX_CMD_LENGTH) {//too long
130 2 return NULL;
131 2 }
132 1
133 1 ptemp = malloc(sizeof(struct command_list));
134 1 if(ptemp == NULL) {//alloc error
135 2 return NULL;
136 2 }
137 1
138 1 memset(ptemp,0,sizeof(struct command_list));
139 1 strcpy(ptemp->message,cmd);
140 1 plist = get_retlist_tail();
141 1
142 1 if (plist == NULL){
143 2 g_retlist = ptemp;
144 2 }else{
145 2 plist->next = ptemp;
146 2 }
147 1 return ptemp;
148 1 }
149
150
151
152 //=============================================================================
153 /*
154 * The Interface description:
155 * free g_cmd_info.ret_msg_list
156 * Parameters:
157 * <none>
158 * Return Value:
159 * <none>
160 * Remark:
161 *
162 */
163 //=============================================================================
164 void free_retlist()
165 {
166 1 struct command_list *plist;
167 1
168 1 plist = g_retlist;
169 1 while(plist != NULL){
170 2 g_retlist=g_retlist->next;
171 2 free(plist);
172 2 plist = g_retlist;
173 2 }
174 1
175 1 g_retlist = NULL;
176 1 return;
177 1 }
178
C51 COMPILER V8.06 CMDLIST 01/31/2008 22:24:26 PAGE 4
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 492 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 6 30
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -