Localize file
www.TrSek.com/c/struct.h
// STRUCT.H Copyright (c) TrSek alias Zdeno Sekerak
// Program je sucastou programu Compiler.c
//
// Datum:22.04.96 http://www.trsek.com
typedef struct {
void *pred;
char znaky[maxznak];
void *zani;
} def_riadok;
typedef struct {
void *pred;
char znaky[maxsyn];
void *zani;
} def_syntax;
typedef struct {
void *pred;
char error[maxsyn];
int err;
void *zani;
} def_error;
def_riadok *riadok; /* Natlaci subor */
def_syntax *syntax; /* Natlaci syntax */
def_error *error; /* Objavia sa chyby */
// zaradi riadok do zoznamu
def_riadok *zaradr( def_riadok *pointer, char text[] )
{
def_riadok *pomocny,*pomocny2;
pomocny=malloc(sizeof((*riadok)));
if (pomocny==NULL) return(NULL);
strcpy((*pomocny).znaky,text);
(*pomocny).pred=pointer;
(*pomocny).zani=NULL;
if (pointer!=NULL) {
if ((*pointer).zani!=NULL) {
pomocny2=(*pointer).zani;
(*pointer).zani=pomocny;
(*pomocny).zani=pomocny2;
pomocny2=(*pomocny).zani;
(*pomocny2).pred=pomocny;
}
(*pointer).zani=pomocny;
}
return(pomocny);
}
// vyhodi riadok zo zoznamu
def_riadok *vyhodr( def_riadok *pointer )
{
def_riadok *pomocny;
pomocny=NULL;
if (pointer==NULL) return(NULL);
if ((*pointer).pred!=NULL) {
pomocny=(*pointer).pred;
(*pomocny).zani=(*pointer).zani;
}
if ((*pointer).zani!=NULL) {
pomocny=(*pointer).zani;
(*pomocny).pred=(*pointer).pred;
}
else {
pomocny=(*pointer).pred;
(*pomocny).zani=NULL;
}
free(pointer);
return(pomocny);
}
//
def_syntax *zarads( def_syntax *pointer, char text[] )
{
def_syntax *pomocny,*pomocny2;
pomocny=malloc(sizeof(( * syntax)));
if (pomocny==NULL) return(NULL);
strcpy((*pomocny).znaky,text);
(*pomocny).pred=pointer;
(*pomocny).zani=NULL;
if (pointer!=NULL) {
if ((*pointer).zani!=NULL) {
pomocny2=(*pointer).zani;
(*pointer).zani=pomocny;
(*pomocny).zani=pomocny2;
pomocny2=(*pomocny).zani;
(*pomocny2).pred=pomocny;
}
(*pointer).zani=pomocny;
}
return(pomocny);
}
//
def_syntax *vyhods( def_riadok *pointer )
{
def_syntax *pomocny;
pomocny=NULL;
if (pointer==NULL) return(NULL);
if ((*pointer).pred!=NULL) {
pomocny=(*pointer).pred;
(*pomocny).zani=(*pointer).zani;
}
if ((*pointer).zani!=NULL) {
pomocny=(*pointer).zani;
(*pomocny).pred=(*pointer).pred;
}
else {
pomocny=(*pointer).pred;
(*pomocny).zani=NULL;
}
free(pointer);
return(pomocny);
}
//
def_error *zarade( def_error *pointer, char text[] , int err)
{
def_error *pomocny,*pomocny2;
pomocny=malloc(sizeof(( * error)));
if (pomocny==NULL) return(NULL);
strcpy((*pomocny).error,text);
(*pomocny).err=err;
(*pomocny).pred=pointer;
(*pomocny).zani=NULL;
if (pointer!=NULL) {
if ((*pointer).zani!=NULL) {
pomocny2=(*pointer).zani;
(*pointer).zani=pomocny;
(*pomocny).zani=pomocny2;
pomocny2=(*pomocny).zani;
(*pomocny2).pred=pomocny;
}
(*pointer).zani=pomocny;
}
return(pomocny);
}
//
def_error *vyhode( def_error *pointer )
{
def_error *pomocny;
pomocny=NULL;
if (pointer==NULL) return(NULL);
if ((*pointer).pred!=NULL) {
pomocny=(*pointer).pred;
(*pomocny).zani=(*pointer).zani;
}
if ((*pointer).zani!=NULL) {
pomocny=(*pointer).zani;
(*pomocny).pred=(*pointer).pred;
}
else {
pomocny=(*pointer).pred;
(*pomocny).zani=NULL;
}
free(pointer);
return(pomocny);
}
Copyrigth by Zdeno Sekerak 2007,
http://www.trsek.com