#include <errno.h>
#include <regex.h>
Include dependency graph for template.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Data Structures | |
| struct | templatenode_t |
| Associates a class with its source and adherent hash. More... | |
| struct | template_t |
| template root and vector More... | |
Defines | |
| #define | TE_NULL '\0' |
Enumerations | |
| enum | etemplate { TE_REGDEF = 0, TE_REGOK = 0, TE_WORDDEF = 0, TE_WORDOK = 0, TE_MATCH = 2, TE_INDEX = 1, TE_ERR = EINVAL } |
Functions | |
| int | template (template_t *) |
Populates a template_t with classes and sources according to the inc folder's files. | |
| void | templatefree (template_t *) |
| Destructs template. | |
| char * | pcdigest (char *, template_t *) |
| Also, mir ja gar nicht bekannt; 'raus. | |
Definition in file template.h.
|
|
null character Definition at line 10 of file template.h. Referenced by template(). |
|
|
regular expression constants
Definition at line 13 of file template.h. 00013 {
00014 TE_REGDEF = 0,
00015 TE_REGOK = 0,
00016 TE_WORDDEF = 0,
00017 TE_WORDOK = 0,
00018 TE_MATCH = 2,
00019 TE_INDEX = 1,
00020 TE_ERR = EINVAL
00021 };
|
|
||||||||||||
|
Also, mir ja gar nicht bekannt; 'raus.
Definition at line 84 of file template.c. References template_t::i, and template_t::pten. Referenced by math(), and serialize(). 00085 {
00086 int i;
00087 const int imatch = 0;
00088 for (i = 0; i < pte->i; i++) {
00089 if (strcmp(pctemplate, (pte->pten + i)->pctemplate) == imatch) {
00090 return (pte->pten + i)->pctemplate; /* perma-mem */
00091 }
00092 }
00093 return NULL;
00094 }
|
|
|
Populates a
Definition at line 21 of file template.c. References EVAL, in(), templatenode_t::pcclass, templatenode_t::pcdigest, templatenode_t::pctemplate, TE_ERR, TE_INDEX, TE_MATCH, TE_NULL, TE_REGDEF, TE_REGOK, TE_WORDDEF, and TE_WORDOK. 00022 {
00023 int i, ilen, iret = EXIT_SUCCESS;
00024 templatenode_t *pten;
00025 wordexp_t we;
00026 regex_t re;
00027 regmatch_t arm[TE_MATCH];
00028 char **ppc;
00029 FILE *pf = NULL;
00030 const char *pcglob = "inc/*";
00031 const char *pcerr = "template.c template()";
00032 const char *pcmask = "^.*/([^.]+)\\.?.*$";
00033
00034 EVAL(wordexp(pcglob, &we, TE_WORDDEF) != TE_WORDOK, TE_ERR);
00035 pt->i = we.we_wordc;
00036 EVAL((pt->pten = (templatenode_t *) malloc(pt->i * sizeof(templatenode_t))) == NULL, ENOMEM);
00037 EVAL(regcomp(&re, pcmask, REG_EXTENDED) != TE_REGOK, TE_ERR);
00038
00039 for (i = 0, ppc = we.we_wordv, pten = pt->pten; i < we.we_wordc; i++, ppc++, pten++) {
00040 if (regexec(&re, *ppc, TE_MATCH, arm, TE_REGDEF) == TE_REGOK) {
00041 ilen = arm[TE_INDEX].rm_eo - arm[TE_INDEX].rm_so;
00042
00043 EVAL((pten->pcclass = (char *) malloc(ilen + sizeof(TE_NULL))) == NULL, ENOMEM);
00044 strncpy(pten->pcclass, *ppc + arm[TE_INDEX].rm_so, ilen);
00045 *(pten->pcclass + ilen) = TE_NULL;
00046
00047 EVAL((pten->pctemplate = (char *) malloc(strlen(*ppc) + sizeof(TE_NULL))) == NULL, ENOMEM);
00048 strcpy(pten->pctemplate, *ppc);
00049
00050 EVAL((pf = fopen(*ppc, "r")) == NULL, EIO);
00051 EVAL(in(pf, &(pten->pcdigest)) == EXIT_FAILURE, ENOMEM);
00052 } else {
00053 EVAL(1, EINVAL);
00054 pt->i--;
00055 }
00056 }
00057
00058 cleanup:
00059 wordfree(&we);
00060 regfree(&re);
00061 fclose(pf);
00062 return iret;
00063 }
|
Here is the call graph for this function:

|
|
Destructs template.
Definition at line 67 of file template.c. References template_t::i, templatenode_t::pcclass, templatenode_t::pcdigest, templatenode_t::pctemplate, and template_t::pten. Referenced by parse(). 00068 {
00069 int i;
00070 templatenode_t *pten;
00071 for (i = 0, pten = pt->pten; i < pt->i; i++, pten++) {
00072 free(pten->pcclass);
00073 free(pten->pctemplate);
00074 free(pten->pcdigest);
00075 }
00076 free(pt->pten);
00077 pt->i = 0;
00078 }
|
1.3.9.1