该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
}
list->tail->next = obj;
list->tail = obj;
return obj;
}
void cc_arg_list_free(cc_arg_list *list)
{
cc_arg_obj *head = list->head;
while(head)
{
cc_arg_obj *next = head->next;
cc_arg_obj_free(head);
head = next;
}
}
void cc_arg_list_show_all_args(cc_arg_list *list)
{
cc_arg_obj *head = list->head;
while (head != NULL)
{
printf("arg:%s", head->str);
head = head->next;
}
}
buf_to_arglist.h:[cpp] view plaincopy
#ifndef CCSH_BUF_TO_ARGLIST_H
#define CCSH_BUF_TO_ARGLIST_H
#include "arglist.h"
cc_arg_list *cc_buf_to_arglist(const char *buf);
#endif
buf_to_arglist.c:[cpp] view plaincopy
#include
#include "buf_to_arglist.h"
#include
#include "error.h"
#include "str_process.h"
cc_arg_list *cc_buf_to_arglist(const char *buf)
{
char *temp = (char *)buf;
cc_arg_list *list = cc_arg_list_make(NULL);
if(!list)
{
cc_err(CC_ERR_NOMEM);
return NULL;
}
while (*temp)
{
char *next_blank = cc_get_next_blank(temp);
if(temp != next_blank)
{
size_t len = next_blank - temp;
cc_arg_obj *obj = cc_arg_obj_make(temp, len, NULL, temp);
if(!obj)
{
cc_err(CC_ERR_NOMEM);
cc_arg_list_free(list);
return NULL;
}
cc_arg_list_append(list, obj);
}
temp = next_blank;
cc_skip_blank(&temp);
}
return list;
}
另外,common.h:[cpp] view plaincopy
#ifndef CCSH_COMMON_H
#define CCSH_COMMON_H
#include
#include
#include
#endif
error.h:[cpp] view plaincopy
#ifndef CCSH_ERROR_H
#define CCSH_ERROR_H
typedef enum
{
CC_OK,
CC_ERR_NOMEM
}CC_ERR;
typedef struct
{
CC_ERR err_no;
char *err_str;
}cc_err_info;
extern cc_err_info errs[];
// global error number
extern int errno;
void cc_err(CC_ERR err_no);
#endif
error.c:[cpp] view plaincopy
#include
#include "error.h"
cc_err_info errs[] =
{
{ CC_OK, "no error"},
{ CC_ERR_NOMEM, "no enough mem"}
};
int errno;
void cc_err(CC_ERR err_no)
{
printf("%s\n", errs[err_no].err_str);
errno = CC_ERR_NOMEM;
}
A: 文件中函数前面的cc是什么?