|
@@ -57,10 +57,10 @@ char *step_thru_file(FILE *fd)
|
|
|
fgets(tempBuf, sizeof(tempBuf), fd);
|
|
fgets(tempBuf, sizeof(tempBuf), fd);
|
|
|
if (!feof(fd)) {
|
|
if (!feof(fd)) {
|
|
|
if (retStr == NULL) {
|
|
if (retStr == NULL) {
|
|
|
- retStr = (char *) my_calloc(1, strlen(tempBuf) + 2);
|
|
|
|
|
|
|
+ retStr = (char *) calloc(1, strlen(tempBuf) + 2);
|
|
|
strcpy(retStr, tempBuf);
|
|
strcpy(retStr, tempBuf);
|
|
|
} else {
|
|
} else {
|
|
|
- retStr = (char *) my_realloc(retStr, strlen(retStr) + strlen(tempBuf));
|
|
|
|
|
|
|
+ retStr = (char *) realloc(retStr, strlen(retStr) + strlen(tempBuf));
|
|
|
strcat(retStr, tempBuf);
|
|
strcat(retStr, tempBuf);
|
|
|
}
|
|
}
|
|
|
if (retStr[strlen(retStr)-1] == '\n') {
|
|
if (retStr[strlen(retStr)-1] == '\n') {
|
|
@@ -116,7 +116,7 @@ int my_cmp (const cmds *c1, const cmds *c2)
|
|
|
|
|
|
|
|
int parse_help(char *infile, char *outfile) {
|
|
int parse_help(char *infile, char *outfile) {
|
|
|
FILE *in = NULL, *out = NULL;
|
|
FILE *in = NULL, *out = NULL;
|
|
|
- char *buffer = NULL, my_buf[BUFSIZE] = "", *fulllist = (char *) my_calloc(1, 1);
|
|
|
|
|
|
|
+ char *buffer = NULL, my_buf[BUFSIZE] = "", *fulllist = (char *) calloc(1, 1);
|
|
|
int skip = 0, line = 0, i = 0, leaf = 0, hub = 0;
|
|
int skip = 0, line = 0, i = 0, leaf = 0, hub = 0;
|
|
|
|
|
|
|
|
if (!(in = fopen(infile, "r"))) {
|
|
if (!(in = fopen(infile, "r"))) {
|
|
@@ -131,7 +131,7 @@ int parse_help(char *infile, char *outfile) {
|
|
|
if (strchr(buffer, '\n')) *(char*)strchr(buffer, '\n') = 0;
|
|
if (strchr(buffer, '\n')) *(char*)strchr(buffer, '\n') = 0;
|
|
|
if ((skipline(buffer, &skip))) continue;
|
|
if ((skipline(buffer, &skip))) continue;
|
|
|
if (buffer[0] == ':') { //New cmd
|
|
if (buffer[0] == ':') { //New cmd
|
|
|
- char *ifdef = (char *) my_calloc(1, strlen(buffer) + 1), *p;
|
|
|
|
|
|
|
+ char *ifdef = (char *) calloc(1, strlen(buffer) + 1), *p;
|
|
|
|
|
|
|
|
buffer++;
|
|
buffer++;
|
|
|
strcpy(ifdef, buffer);
|
|
strcpy(ifdef, buffer);
|
|
@@ -147,7 +147,7 @@ int parse_help(char *infile, char *outfile) {
|
|
|
/* finish last command */
|
|
/* finish last command */
|
|
|
if (my_buf && my_buf[0]) {
|
|
if (my_buf && my_buf[0]) {
|
|
|
my_buf[strlen(my_buf)] = 0;
|
|
my_buf[strlen(my_buf)] = 0;
|
|
|
- cmdlist[cmdi].txt = (char *) my_calloc(1, strlen(my_buf) + 1);
|
|
|
|
|
|
|
+ cmdlist[cmdi].txt = (char *) calloc(1, strlen(my_buf) + 1);
|
|
|
strcpy(cmdlist[cmdi].txt, my_buf);
|
|
strcpy(cmdlist[cmdi].txt, my_buf);
|
|
|
i++;
|
|
i++;
|
|
|
cmdi++;
|
|
cmdi++;
|
|
@@ -168,7 +168,7 @@ int parse_help(char *infile, char *outfile) {
|
|
|
my_buf[0] = 0;
|
|
my_buf[0] = 0;
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- cmdlist[cmdi].name = (char *) my_calloc(1, strlen(p) + 1);
|
|
|
|
|
|
|
+ cmdlist[cmdi].name = (char *) calloc(1, strlen(p) + 1);
|
|
|
strcpy(cmdlist[cmdi].name, p);
|
|
strcpy(cmdlist[cmdi].name, p);
|
|
|
} else { /* END */
|
|
} else { /* END */
|
|
|
break;
|
|
break;
|
|
@@ -188,7 +188,7 @@ int parse_help(char *infile, char *outfile) {
|
|
|
qsort(cmdlist, cmdi, sizeof(cmds), (int (*)(const void *, const void *)) &my_cmp);
|
|
qsort(cmdlist, cmdi, sizeof(cmds), (int (*)(const void *, const void *)) &my_cmp);
|
|
|
|
|
|
|
|
for (i = 0; i < cmdi; i++ ) {
|
|
for (i = 0; i < cmdi; i++ ) {
|
|
|
- fulllist = (char *) my_realloc(fulllist, strlen(fulllist) + strlen(cmdlist[i].name) + 2);
|
|
|
|
|
|
|
+ fulllist = (char *) realloc(fulllist, strlen(fulllist) + strlen(cmdlist[i].name) + 2);
|
|
|
strcat(fulllist, cmdlist[i].name);
|
|
strcat(fulllist, cmdlist[i].name);
|
|
|
strcat(fulllist, " ");
|
|
strcat(fulllist, " ");
|
|
|
fprintf(out, ":");
|
|
fprintf(out, ":");
|
|
@@ -211,9 +211,9 @@ int main(int argc, char **argv) {
|
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (argc < 3) return 1;
|
|
if (argc < 3) return 1;
|
|
|
- in = (char *) my_calloc(1, strlen(argv[1]) + 1);
|
|
|
|
|
|
|
+ in = (char *) calloc(1, strlen(argv[1]) + 1);
|
|
|
strcpy(in, argv[1]);
|
|
strcpy(in, argv[1]);
|
|
|
- out = (char *) my_calloc(1, strlen(argv[2]) + 1);
|
|
|
|
|
|
|
+ out = (char *) calloc(1, strlen(argv[2]) + 1);
|
|
|
strcpy(out, argv[2]);
|
|
strcpy(out, argv[2]);
|
|
|
ret = parse_help(in, out);
|
|
ret = parse_help(in, out);
|
|
|
free(in);
|
|
free(in);
|