update CLI
This commit is contained in:
75
CMDList/printList.c
Normal file
75
CMDList/printList.c
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef PRINTCMDLIST_H
|
||||
#define PRINTCMDLIST_H
|
||||
|
||||
#include "CMDList.h"
|
||||
#include "printList.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void printCMD(CMDList_t* list, char c, char* indent)
|
||||
{
|
||||
char* cmd;
|
||||
if (list->cmd == NULL)
|
||||
{
|
||||
cmd = "(no cmd)";
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = list->cmd->cmd;
|
||||
}
|
||||
|
||||
printf("%s%c -> %s\n", indent, c, cmd);
|
||||
|
||||
char* indent_p = indent;
|
||||
while (*indent_p != 0)
|
||||
{
|
||||
indent_p++;
|
||||
}
|
||||
*indent_p = ' ';
|
||||
*(indent_p+1) = ' ';
|
||||
*(indent_p+2) = 0;
|
||||
|
||||
printCMDList(list, indent);
|
||||
|
||||
*indent_p = 0;
|
||||
}
|
||||
|
||||
void printCMDList(CMDList_t* list, char* indent)
|
||||
{
|
||||
if (indent == NULL)
|
||||
{
|
||||
indent = (char*)malloc(100 * sizeof(char));
|
||||
*indent = 0;
|
||||
}
|
||||
if (list->a != NULL) printCMD((CMDList_t*)list->a, 'a', indent);
|
||||
if (list->b != NULL) printCMD((CMDList_t*)list->b, 'b', indent);
|
||||
if (list->c != NULL) printCMD((CMDList_t*)list->c, 'c', indent);
|
||||
if (list->d != NULL) printCMD((CMDList_t*)list->d, 'd', indent);
|
||||
if (list->e != NULL) printCMD((CMDList_t*)list->e, 'e', indent);
|
||||
if (list->f != NULL) printCMD((CMDList_t*)list->f, 'f', indent);
|
||||
if (list->g != NULL) printCMD((CMDList_t*)list->g, 'g', indent);
|
||||
if (list->h != NULL) printCMD((CMDList_t*)list->h, 'h', indent);
|
||||
if (list->i != NULL) printCMD((CMDList_t*)list->i, 'i', indent);
|
||||
if (list->j != NULL) printCMD((CMDList_t*)list->j, 'j', indent);
|
||||
if (list->k != NULL) printCMD((CMDList_t*)list->k, 'k', indent);
|
||||
if (list->l != NULL) printCMD((CMDList_t*)list->l, 'l', indent);
|
||||
if (list->m != NULL) printCMD((CMDList_t*)list->m, 'm', indent);
|
||||
if (list->n != NULL) printCMD((CMDList_t*)list->n, 'n', indent);
|
||||
if (list->o != NULL) printCMD((CMDList_t*)list->o, 'o', indent);
|
||||
if (list->p != NULL) printCMD((CMDList_t*)list->p, 'p', indent);
|
||||
if (list->q != NULL) printCMD((CMDList_t*)list->q, 'q', indent);
|
||||
if (list->r != NULL) printCMD((CMDList_t*)list->r, 'r', indent);
|
||||
if (list->s != NULL) printCMD((CMDList_t*)list->s, 's', indent);
|
||||
if (list->t != NULL) printCMD((CMDList_t*)list->t, 't', indent);
|
||||
if (list->u != NULL) printCMD((CMDList_t*)list->u, 'u', indent);
|
||||
if (list->v != NULL) printCMD((CMDList_t*)list->v, 'v', indent);
|
||||
if (list->w != NULL) printCMD((CMDList_t*)list->w, 'w', indent);
|
||||
if (list->x != NULL) printCMD((CMDList_t*)list->x, 'x', indent);
|
||||
if (list->y != NULL) printCMD((CMDList_t*)list->y, 'y', indent);
|
||||
if (list->z != NULL) printCMD((CMDList_t*)list->z, 'z', indent);
|
||||
}
|
||||
|
||||
#endif
|
||||
8
CMDList/printList.h
Normal file
8
CMDList/printList.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef PRINTCMDLIST_H
|
||||
#define PRINTCMDLIST_H
|
||||
|
||||
#include "CMDList.h"
|
||||
|
||||
extern void printCMDList(CMDList_t* list, char* indent);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user