first commit

This commit is contained in:
Jose Caban
2025-06-07 01:59:34 -04:00
commit 388ac241f0
3558 changed files with 9116289 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
/parser.c/1.3/Sun Apr 2 10:06:57 2006//
/parser.h/1.3/Sun Apr 2 10:06:57 2006//
D

View File

@@ -0,0 +1,2 @@
/parser.c////*///
/parser.h////*///

View File

@@ -0,0 +1,2 @@
/parser.c////*///
/parser.h////*///

View File

@@ -0,0 +1,3 @@
/parser.c/0/dummy timestamp//
/parser.h/0/dummy timestamp//
D

View File

@@ -0,0 +1 @@
CS4210/Project 3/common/config_parser

View File

@@ -0,0 +1 @@
:ext:asskoala@192.168.0.3:/usr/_CVS

View File

@@ -0,0 +1,85 @@
#include "parser.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
static char* getNextLine(char arr[160], FILE* stream) {
while (fgets(arr, 160, stream)) {
if (arr[0] == '#' || !isalnum(arr[0])) {
continue;
} else {
return arr;
}
}
return NULL;
}
/*
* Load fileName and return a FILE*
*/
ConfigFile* loadFile(char* fileName) {
ConfigFile* newConfig = NULL;
newConfig = malloc(sizeof(ConfigFile));
if (!newConfig) {
printf("Memory Allocation Failed in _FILE_ line: _LINE_\n");
return NULL;
}
newConfig->file = fopen(fileName, "r");
if (!newConfig->file) {
free(newConfig);
printf("Failed to Open File in _FILE_: _LINE_\n");
return NULL;
}
return newConfig;
}
/*
*
*/
void releaseConfig(ConfigFile** configFile) {
if (!configFile) {
return;
}
if ((*configFile)->file) {
fclose((*configFile)->file);
}
free(*configFile);
*configFile = NULL;
}
/*
*
*/
int nextSet(ConfigFile* config) {
char temp[160];
char* pc;
int i;
if (!getNextLine(temp, config->file)) {
return 0;
}
pc = strtok(temp,":");
strncpy(config->currentParamter, pc, 80);
pc = strtok(NULL,":");
for (i=0; pc[i] != '\0'; i++) {
if (isspace(pc[i])) {
pc[i] = '\0';
break;
}
}
strncpy(config->currentValue, pc, 80);
return 1;
}

View File

@@ -0,0 +1,22 @@
#ifndef _PARSER_H_
#define _PARSER_H_
#include <stdio.h>
#include <stdlib.h>
typedef struct SCONFIGFILE {
char currentParamter[80];
char currentValue[80];
FILE* file;
} ConfigFile;
/*
* Load a file
*/
ConfigFile* loadFile(char* fileName);
void releaseConfig(ConfigFile**);
int nextSet(ConfigFile*);
#endif