--- /dev/null
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+\f
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+\f
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+\f
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+\f
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+\f
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
--- /dev/null
+TODO:
+ documentation
+
+How to install?
+ make
+ su
+ make install
+
+How to test?
+ make
+ make test
+ browse the examples dir tree to see what heppened
+
+Regards, MOP.
--- /dev/null
+-------- includes creation --------
+created [./Obj/grptable.inc]
+-------- objects creation --------
+obj: grptable
+ele:[numraw] virtual
+ele close
+#GRPTABLE_RAW# ele:[raw]
+ #UNO#
+ #DUE#
+ #TRE#
+ele close
+ele:[raw2] virtual
+ #UNO#
+ #DUE#
+ #TRE#
+ele close
+obj close
--- /dev/null
+-------- includes creation --------
+-------- objects creation --------
+obj: grptable
+ele:[numraw] virtual
+ele close
+#GRPTABLE_RAW# ele:[raw]
+ #UNO#
+ #DUE#
+ #TRE#
+ele close
+ele:[raw2] virtual
+ #UNO#
+ #DUE#
+ #TRE#
+ele close
+obj close
--- /dev/null
+-------- includes creation --------
+created [./Obj/soloinc.inc]
+-------- objects creation --------
--- /dev/null
+-------- includes creation --------
+-------- objects creation --------
+obj: subelem
+#SUBELEM_PAPA# ele:[papa]
+ #PAPA_FIGLIO# ele:[papa_figlio]
+ #COLONNAFIGLIO#
+ ele close
+ ele:[papa_figlia] virtual
+ #COLONNAFIGLIA#
+ ele close
+ele close
+obj close
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <title>group admin</title>
+ </head>
+
+ <body>
+ <h1>group admin</h1>
+<table border=1 width="100%">
+<!--MINCL:grptable-->
+<!--MIOBJ:grptable-->
+<!--MO:numraw--><!--2--><!--/MO-->
+
+<!--MI:raw--><tr><td align="center" class="pippo1">#UNO#</td>
+<td align="right" class="pippo2">#DUE#</td></tr>
+<tr><td alogn="center" colspan="2" class="pippo3">#TRE#</td></tr><!--/MO-->
+
+<!--MO:raw2--><tr><td align="center" class="pippo1">#UNO#</td>
+<td align="right" class="pippo2">#DUE#</td></tr>
+<tr><td alogn="center" colspan="2" class="pippo3">#TRE#</td></tr><!--/MO-->
+
+<!--/MIOBJ-->
+<!--/MINCL-->
+</table>
+ <hr>
+ <address><a href="mailto:nastasi@tiscalinet.it">Matteo Nastasi</a></address>
+<!-- Created: Thu Dec 27 23:36:17 CEST 2001 -->
+<!-- hhmts start -->
+Last modified: Tue Mar 26 23:24:48 CEST 2002
+<!-- hhmts end -->
+ </body>
+</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <title>group admin</title>
+ </head>
+
+ <body>
+ <h1>group admin</h1>
+<!--MIGTO:grptable-->
+ <hr>
+ <address><a href="mailto:nastasi@tiscalinet.it">Matteo Nastasi</a></address>
+<!-- Created: Thu Dec 27 23:36:17 CEST 2001 -->
+<!-- hhmts start -->
+Last modified: Sun Dec 30 09:32:31 CEST 2001
+<!-- hhmts end -->
+ </body>
+</html>
--- /dev/null
+<html>
+<body>
+<!--MINCL:soloinc-->Pippo Pluto paperino<br>
+<!--/MINCL-->
+</body>
+</html>
--- /dev/null
+<html>
+<body>
+<table>
+<!--MIOBJ:subelem-->
+<!--MI:papa-->
+<tr><td>
+<table>
+<!--MI:figlio-->
+<tr><td>#COLONNAFIGLIO#</td></tr>
+<!--/MI-->\r
+
+<!--MO:figlia-->
+<tr><td>#COLONNAFIGLIA#</td></tr>
+<!--/MO-->
+</table>
+</td><tr>
+<!--/MI-->
+<!--/MIOBJ-->
+</table>
+</body>
+</html>
--- /dev/null
+/*
+ * ffilter.c
+ * metatemplate Vers. vERSIOn
+ * Copyright (C) cOPYDATe cOPYRIGHt
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * CONTACT: cONTACt
+ * cONTAC2t
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ffilter.h"
+
+static FIFILE **zzh = NULL;
+static int nzzh = 0;
+
+FIFILE *ffopen(char *nome,char **keys)
+{
+ FIFILE *ff;
+ int i;
+
+ for (i = 0 ; i<nzzh ; i++) {
+ if (zzh[i] == NULL)
+ break;
+ }
+ if (i == nzzh) {
+ nzzh++;
+ if ((zzh = (FIFILE **)realloc(zzh,sizeof(FIFILE *)*nzzh)) == NULL)
+ exit(100);
+ zzh[i] = NULL;
+ }
+ if ((ff = (FIFILE *)malloc(sizeof(FIFILE))) == NULL)
+ exit(101);
+ if ((ff->bf[0] = (char *)malloc(FFDIMBUF+1)) == NULL) {
+ free(ff);
+ exit(102);
+ }
+ /* PIPPO */
+ // fprintf(stderr,"NOME %s",nome);
+ if ((ff->fp[0] = fopen(nome,"r")) == NULL) {
+ free(ff->bf[0]);
+ free(ff);
+ exit(103);
+ }
+ ff->nc[0] = 0;
+ ff->nfile = 1;
+ ff->keys = keys;
+ ff->index = i;
+ ff->fkey = -1;
+ ff->noctrlm = 1;
+ // fprintf(stderr,"\nZZH [%d]\n",i);
+ zzh[i] = ff;
+
+ return (ff);
+}
+
+int ffinclude(FIFILE *ff,char *nome)
+{
+
+
+ if (ff == NULL || ff->nfile == FFNESTED)
+ return (0);
+
+ if ((ff->bf[ff->nfile] = (char *)malloc(FFDIMBUF+1)) == NULL)
+ return(0);
+ if ((ff->fp[ff->nfile] = fopen(nome,"r")) == NULL) {
+ free(ff->bf[ff->nfile]);
+ return(0);
+ }
+ ff->nc[ff->nfile] = 0;
+ ff->nfile++;
+
+ return (1);
+}
+
+
+int ffclose(FIFILE *ff) {
+ int i;
+
+ if (ff == NULL || zzh[ff->index] == NULL)
+ return (0);
+
+ zzh[ff->index] = NULL;
+ for (i = 0 ; i < ff->nfile ; i++) {
+ fclose(ff->fp[i]);
+ free(ff->bf[i]);
+ }
+ free(ff);
+
+ return (1);
+}
+
+void ffchankeys(FIFILE *ff,char **keys)
+{
+ ff->keys = keys;
+}
+
+/*
+ * legge file finche' non vengono trovate chiavi
+ */
+
+int ffgetbin(char *bf,int size,FIFILE *ff)
+{
+ FILE *fp;
+ char *p, *ffbf;
+ int i, e, n, nf, minpos = FFDIMBUF,skip = 0,limin;
+
+ /* indice del file corrente */
+ nf = ff->nfile-1;
+ /* file pointer del file corrente */
+ fp = ff->fp[nf];
+ /* buffer del file corrente */
+ ffbf = ff->bf[nf];
+ /* dimensione richiesta decurtata dello spazio per il \0 */
+ size--;
+ /* default della chiave trovata */
+ ff->fkey = -1;
+
+ /* se il numero di caratteri attualmente nel buffer e' attualmente minore
+ della dim totale del buffer e il file non e' finito */
+ while (ff->nc[nf] < FFDIMBUF && !feof(fp)) {
+ /* pointer al primo char libero del buffer */
+ p = &(ffbf[ff->nc[nf]]);
+ /* tenta di riempire il buffer */
+ n = fread(p,1,FFDIMBUF-ff->nc[nf],fp);
+
+ /* se no control M cancella gli
+ eventuali ^M letti ricompattando il buffer */
+ if (ff->noctrlm) {
+ for (i = 0 ; i < n ; i++) {
+ if (p[i] == '\r') {
+ for (e = i ; e < n-1 ; e++)
+ p[e] = p[e+1];
+ n--;
+ i--;
+ }
+ }
+ }
+ /* incrementa il contatore dei caratteri memorizzati nel buffer */
+ ff->nc[nf] += n;
+ /* aggiunge uno \0 in coda al buffer (per stampabilita')*/
+ ffbf[ff->nc[nf]] = '\0';
+ }
+ /* limin viene settato al minimo tra il numero di caratteri letti e la
+ meta della lunghezza del buffer */
+ limin = (ff->nc[nf] < FFMEZBUF ? ff->nc[nf] : FFMEZBUF);
+ /* se la dimensione richiesta e' maggiore di limin viene abbassata a tale
+ valore */
+ if (size > limin)
+ size = limin;
+
+ /* cerca una delle chiavi */
+ for (i = 0 ; ff->keys[i] ; i++) {
+ if ((p = strstr(ffbf,ff->keys[i])) != NULL) {
+ if ((p - ffbf) < minpos) {
+ minpos = p - ffbf;
+ ff->fkey = i;
+ skip = strlen(ff->keys[i]);
+ }
+ }
+ }
+ /* se la prima chiave trovata e' oltre in numero di car richiesti
+ non segnala il fatto che e' stata trovata */
+ if (size < minpos) {
+ ff->fkey = -1;
+ skip = 0;
+ }
+ else
+ size = minpos;
+ /* copia nel buffer i byte richiesti o cio' che precede la chiave */
+ memcpy(bf,ffbf,size);
+ bf[size] = '\0';
+ /* trasla il buffer del numero di byte letti + event. lo skip dato
+ dalla chiave */
+ memmove(ffbf, &(ffbf[size+skip]),FFDIMBUF-(size+skip));
+ /* allinea il numero di byte nel buffer */
+ ff->nc[nf] -= (size+skip);
+
+ /* se sonos stati letti 0 byte e non ci sono chiavi intercettate */
+ if (size == 0 && ff->fkey == -1) {
+ /* se il numero di file nello stack e' maggiore di 1 allora
+ chiude il file corrente e passa quello precedente altrimenti
+ rende -1 per segnalare la fine della poss. di leggere dati */
+ if (ff->nfile > 1) {
+ ff->nfile--;
+ fclose(ff->fp[ff->nfile]);
+ free(ff->bf[ff->nfile]);
+ }
+ else
+ size = -1;
+ }
+ return (size);
+}
+
+int ffkstat(FIFILE *ff) {
+ return (ff->fkey);
+}
+
+char **ffgetkeys(FIFILE *ff) {
+ return (ff->keys);
+}
+
--- /dev/null
+/*
+ * ffilter.h
+ * metatemplate Vers. vERSIOn
+ * Copyright (C) cOPYDATe cOPYRIGHt
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * CONTACT: cONTACt
+ * cONTAC2t
+ *
+ */
+
+#include <stdio.h>
+
+#define FFDIMBUF 1024
+#define FFMEZBUF 512
+#define FFNESTED 16
+
+struct fi_handle_tag {
+ FILE *fp[FFNESTED]; /* pointer ai vari file nidificati */
+ char *bf[FFNESTED]; /* buffer dei vari file */
+ int nc[FFNESTED]; /* numero di char attualmente nel buffer */
+ int nfile; /* numero di file in stack aperti */
+ char **keys; /* chiavi di interruzione */
+ int fkey; /* indice chiave trovata */
+ int index; /* indice nell'array globale dei FIFILE */
+ int noctrlm; /* no control M */
+};
+typedef struct fi_handle_tag FIFILE;
+
+FIFILE *ffopen(char *,char **);
+int ffinclude(FIFILE *,char *);
+int ffclose(FIFILE *);
+void ffchankeys(FIFILE *,char **);
+int ffgetbin(char *,int,FIFILE *);
+int ffkstat(FIFILE *);
+char **ffgetkeys(FIFILE *);
+
+
--- /dev/null
+OBJ=ffilter.o
+MAN=metatemplate.1.gz
+EXE=metatemplate
+
+ALL: $(EXE) $(MAN)
+
+metatemplate: metatemplate.c ffilter.o
+ cc -Wall metatemplate.c ffilter.o -o metatemplate
+
+ffilter.o: ffilter.c ffilter.h
+ cc -c -Wall ffilter.c
+
+metatemplate.1.gz: metatemplate.1
+ gzip -c metatemplate.1 > metatemplate.1.gz
+
+install: $(EXE) $(MAN)
+ cp $(EXE) /usr/local/bin
+ cp $(MAN) /usr/local/man/man1
+
+test:
+ ( cd examples ; \
+ ../metatemplate gruppi.html > Info/gruppi.html ; \
+ ../metatemplate gruppi2.html > Info/gruppi2.html ; \
+ ../metatemplate gruppi3.html > Info/gruppi3.html ; \
+ ../metatemplate subelem.html > Info/subelem.html \
+ )
+
+clean:
+ rm -f *~ $(OBJ) $(EXE) $(MAN) examples/Obj/* examples/Pho/* examples/Template/* examples/Preview/*
--- /dev/null
+#!/bin/bash
+#
+# makerel: script di servizio per generare le rel. dei sorgenti
+#
+coprig="Matteo Nastasi"
+copdat="2002-`date +%Y`"
+contac="nastasi@alternativeoutput.it"
+conta2="matteo.nastasi@milug.org"
+if [ $# -ne 1 ]; then
+ exit 1
+fi
+cw=`pwd`
+nome=`basename $cw`
+cd ..
+newdir="${nome}-$1"
+if [ -d ${newdir} ]; then
+ echo $newdir exist
+ exit 1
+else
+ cp -ar ${nome} $newdir
+fi
+cd $newdir
+for i in `find . -print | grep '\.[ch]$' ; find . -print | grep '\.sh$'`; do
+ cp $i file.tmp
+ cat file.tmp | sed "s/vERSIOn/$1/g;
+s/cOPYRIGHt/$coprig/g;
+s/cOPYDATe/$copdat/g;
+s/cONTACt/$contac/g;
+s/cONTAC2t/$conta2/g" > $i
+ rm file.tmp
+done
+rm makerel
+if [ -d .git ]; then
+ rm -rf .git
+fi
+cd ..
+tar --owner nobody --group nogroup -zcvf ${nome}_${1}.tgz $newdir
+exit 0
--- /dev/null
+.\" /usr/share/misc/man.template:
+.\" The following six lines are required.
+.Dd April 10, 2002
+.Os Linux [4/3]
+.Dt METATEMPLATE 1
+.Sh NAME
+metatemplate \- metatemplate compiler
+.Sh SYNOPSIS
+.Nm metatemplate Ar filename
+.Sh DESCRIPTION
+.Nm metatemplate
+create template and dynamic pieces of php code from a uniq
+html metatemplate.
+.br
+To use metatemplate you need a tree like this:
+.br
+.ft C
+ somedir/
+.br
+ somedir/Obj/
+.br
+ somedir/Pho/
+.br
+ somedir/Preview/
+.br
+ somedir/Template/
+.br
+ somedir/metatempl1.html
+.br
+ somedir/metatempl2.html
+.br
+ somedir/......
+.br
+.ft R
+
+.Nm cd Ar somedir
+.br
+and run
+.br
+.Nm metatemplate Ar metatempl1.html
+.br
+.Nm metatemplate Ar metatempl2.html
+.br
+.Nm metatemplate
+.No ...............
+
+.Sy METATAGS DESCRIPTION
+.br
+.fc # ^
+.ta 2.5i 5i
+
+.Sy "#<!--MINCL:" Ns Ar "includename" Ns Sy "-->#"
+#-\ Open include maker#
+.br
+.Sy "#<!--/MINCL-->#"
+#-\ Close include maker#
+.br
+.Sy "#<!--MIGTO:" Ns Ar "includename" Ns Sy "-->#"
+#-\ Insert include#
+.br
+.Sy "#<!--MIOBJ:" Ns Ar "objectname" Ns Sy "-->#"
+#-\ Open object#
+.br
+.Sy "#<!--/MIOBJ-->#"
+#-\ Close object#
+.br
+.Sy "#<!--MI:" Ns Ar "elementname" Ns Sy "-->#"
+#-\ Open element#
+.br
+.Sy "#<!--/MI-->#"
+#-\ Close element#
+.br
+.Sy "#<!--MO:" Ns Ar "virtelename" Ns Sy "-->#"
+#-\ Open virtual element#
+.br
+.Sy "#<!--/MO-->#"
+#-\ Close virtual element#
+.br
+
+.ta .8i 1.6i 2.4i 3.2i 4i 4.8i 5.6i 6.4i 7.2i 8i
+.fc
+.Sy CREATE INCLUDES
+.br
+You can make an include file named
+.Pa myinc
+putting a:
+.br
+.Sy "\ <!--MINCL:" Ns Ar "myinc" Ns Sy "-->"
+.br
+before the first line that you want into the include
+.br
+and a:
+.br
+.Sy "\ <!--/MINCL-->"
+.br
+after the last.
+.br
+
+.Sy INCLUDE FILES
+.br
+You can include file named
+.Pa myinc
+putting a:
+.br
+.Sy "\ <!--MIGTO:" Ns Ar "myinc" Ns Sy "-->"
+.br
+
+.Sy INCLUDES NOTE
+.br
+You can define an include definition into another include definition nesting
+.Sy 'MINCL' '/MINCL'
+tags.
+.bp
+.Sy NESTIFIED INCLUDES DEFINITION EXAMPLE
+.br
+When compiling this example with
+.Sy metatemplate
+.ft C
+ <!--MINCL:big-->
+.br
+ bla bla
+.br
+ bla bla
+.br
+ <!--MINCL:little-->
+.br
+ ble ble
+.br
+ <!--/MINCL-->
+.br
+ blo blo
+.br
+ blo blo
+.br
+ <!--/MINCL-->
+.br
+.ft R
+you create 2 files named
+.Pa big No :
+.br
+.ft C
+ bla bla
+.br
+ bla bla
+.br
+ ble ble
+.br
+ blo blo
+.br
+ blo blo
+.br
+.ft R
+and
+.Pa little Ns No :
+.br
+.ft C
+ ble ble
+.br
+.ft R
+
+.Sy INCLUDE FILES EXAMPLE
+.br
+If you want to include the file
+.Ar big
+into your metatemplate file you must use:
+.br
+.ft C
+ <!--MIGTO:big-->
+.ft R
+
+.Sy CREATE OBJECTS AND ELEMENTS
+.br
+An object is a collection of elements.
+.br
+Objects aren't nestable.
+.br
+Every object produces a php include file (Pho directory).
+.br
+An element is a piece of the metatemplate file the is enclosed between
+the open and close elements tags, it is put into an element of a
+php associative array named like the parent object, indexed with the
+name of the element perfixed eventually with the names of the parent
+elements and placed into the object-related php include file.
+.br
+If the element is not virtual the element is replaced into the parent
+(template or element) with a tag that is the name of the element prefixed
+with the name of parent object + (eventually) the names of all parents
+elements "_" separated.
+.br
+If the element is virtual it isn't replaced with a tag.
+.br
+Elements are nestable.
+.br
+
+.Sy OBJECTS AND ELEMENTS EXAMPLE
+.br
+When compiling this example name
+.Pa example.html
+with
+.Sy metatemplate
+.br
+.ft C
+ begin of metatemplate
+.br
+
+ <!--MIOBJ:myobj-->
+.br
+ <table>
+.br
+ <!--MI:tbrow-->
+.br
+ <tr><td>#COL1#</td><td>#COL2#</td>
+.br
+ <!--/MI-->
+.br
+ </table>
+.br
+
+ bla bla
+.br
+ <!--MI:ifbranch-->
+.br
+ bli bli
+.br
+ this piece of code is visualized when some test is true
+.br
+ #SOMETAG#
+.br
+ blo blo
+.br
+ <!--/MI-->
+.br
+
+ <!--MO:elsebranch-->
+.br
+ olb olb
+.br
+ elsewhere this piece of code is visualized
+.br
+ #SOMETAG#
+.br
+ <!--MI:elsubele-->
+.br
+ bli bli #SUBTAG#
+.br
+ <!--/MI-->
+.br
+ ilb ilb
+.br
+ <!--/MO-->
+.br
+ <!--/MIOBJ-->
+.br
+
+ end of metatemplate
+.br
+
+.ft R
+.Sy metatemplate
+produces this output on the console:
+.br
+.ft C
+ \-------- includes creation --------
+ \-------- objects creation --------
+ obj: myobj
+ #MYOBJ_TBROW# ele:[tbrow]
+ #COL1#
+ #COL2#
+ ele close
+ #MYOBJ_IFBRANCH# ele:[ifbranch]
+ #SOMETAG#
+ ele close
+ ele:[elsebranch] virtual
+ #SOMETAG#
+ #ELSEBRANCH_ELSUBELE# ele:[elsebranch_elsubele]
+ #SUBTAG#
+ ele close
+ ele close
+ obj close
+.ft R
+
+this php include named
+.Pa myobj.pho
+:
+.ft C
+ <?php /* generated from file "example.html" */
+ $myobj = array();
+ $myobj['tbrow'] = '
+ <tr><td>#COL1#</td><td>#COL2#</td>
+ ';
+ $myobj['ifbranch'] = '
+ bli bli
+ this piece of code is visualized when some test is true
+ #SOMETAG#
+ blo blo
+ ';
+ $myobj['elsebranch_elsubele'] = '
+ bli bli #SUBTAG#
+ ';
+ $myobj['elsebranch'] = '
+ olb olb
+ elsewhere this piece of code is visualized
+ #SOMETAG##ELSEBRANCH_ELSUBELE#ilb ilb
+ ';
+ ?>
+.ft R
+
+and this template named
+.Pa Template/example.tmpl
+:
+.ft C
+ begin of metatemplate
+
+ <table>#MYOBJ_TBROW#</table>
+
+ bla bla #MYOBJ_IFBRANCH#
+ end of metatemplate
+.ft R
+
+
+.\" The following requests should be uncommented and
+.\" used where appropriate. This next request is
+.\" for sections 2 and 3 function return values only.
+.\" .Sh RETURN VALUES
+.\" This next request is for sections 1, 6, 7 & 8 only
+.\" .Sh ENVIRONMENT
+.\" .Sh FILES
+.\" .Sh EXAMPLES
+.\" This next request is for sections 1, 6, 7 & 8 only
+.\" (command return values (to shell) and
+.\" fprintf/stderr type diagnostics)
+.\" .Sh DIAGNOSTICS
+.\" The next request is for sections 2 and 3 error
+.\" and signal handling only.
+.\" .Sh ERRORS
+.\" .Sh SEE ALSO
+.\" .Sh STANDARDS
+.\" .Sh HISTORY
+.Sh AUTHORS
+Matteo Nastasi, Digital Identity (www.digitalidentity.it)
+.br
+m.nastasi@digitalidentity.it
+.br
+nastasi@alternativeoutput.it
+.\" .Sh BUGS
+
--- /dev/null
+/*
+ * metatemplate.c
+ * metatemplate Vers. vERSIOn
+ * Copyright (C) cOPYDATe cOPYRIGHt
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * CONTACT: cONTACt
+ * cONTAC2t
+ *
+ */
+
+/*
+ * TODO:
+ * verificare se e' corretto pensare che il nome del file da includere
+ * e' tirato dentro in una botta sola
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "ffilter.h"
+
+#define OUTPHP "./Pho"
+#define OUTTEM "./Template"
+#define OUTPRE "./Preview"
+#define OUTOBJ "./Obj"
+
+#define ST_FUORI 0
+#define ST_HDINC 1
+#define ST_HDOBJ 2
+#define ST_INOBJ 3
+#define ST_ININC 4
+#define ST_HDELE 5
+#define ST_HDELO 6
+#define ST_INELE 7
+#define ST_HDGTO 8
+
+/*
+ bla bla bla
+<!--MIOBJ:nomeoggetto-->
+ <!--MI:nomeelemento--> elemento <!--/MI-->
+ <!--MI:nomeelemento2--> elemento2 <!--/MI-->
+ <!--MO:nomeelemento2-->Oggetto senza riferimento nel template<!--/MO-->
+ <!--MI:#--> parte solamente per preview <!--/MI-->
+ <!--MI:nomeelemento2--> elemento2 <!--/MI-->
+ ....
+ <!--MI:nomeelementoN--> elementoN <!--/MI-->
+ ble ble ble
+ ...........
+ blu blu blu
+<!--/MIOBJ-->
+ ...........
+<!--MINCL:nomeinclude-->
+ ...........
+ bli bli bli
+<!--/MINCL-->
+ ...........
+ blo blo blo
+<!--MIGTO:nomeoggetto-->
+ blu blu blu
+ ...........
+ */
+
+/* -- primo passaggio per estrarre le include definite nel sorgente -- */
+#define W_PREOPINCL 0
+#define W_PRECLINCL 1
+char *keyprest[] = { "\n<!--MINCL:", "<!--/MINCL-->\n", NULL };
+
+#define W_PRECLOSEI 0
+char *keyprecl[] = { "-->", NULL };
+
+/* -- secondo passaggio per il resto -- */
+#define W_OPENMIGTO 0
+#define W_OPENMINCL 1
+#define W_CLOSMINCL 2
+#define W_OPENMI 3
+#define W_OPENMO 4
+
+#define W_OPENMIOBJ 3
+char *keyout[] = { "\n<!--MIGTO:", "\n<!--MINCL:", "<!--/MINCL-->\n", "\n<!--MIOBJ:", NULL };
+
+#define W_CLOSETAG 0
+char *keyclose[] = { "-->", NULL };
+
+#define W_CLOSMIOBJ 5
+char *keyele[] = { "\n<!--MIGTO:", "\n<!--MINCL:", "<!--/MINCL-->\n",
+ "\n<!--MI:", "\n<!--MO:",
+ "<!--/MIOBJ-->\n", NULL };
+
+#define W_CLOSMI 5
+#define W_CLOSMO 6
+char *keyclele[] = { "\n<!--MIGTO:", "\n<!--MINCL:", "<!--/MINCL-->\n",
+ "\n<!--MI:", "\n<!--MO:",
+ "<!--/MI-->\n", "<!--/MO-->\n", NULL };
+
+#define NMAXFINC 16
+FILE *fobji[NMAXFINC];
+FILE *fobjp[NMAXFINC];
+FILE *fobjt[NMAXFINC];
+int nfinc = 0;
+
+#define NMAXELE 16
+#define LENMXELE (10240 * 50)
+char elem[NMAXELE][LENMXELE];
+char eprefix[256];
+int elempref[NMAXELE],dummy[NMAXELE],nelem = 0;
+
+
+void appendfile(FILE *fap,FILE *fin)
+{
+ int c;
+
+ while ((c = fgetc(fin)) != EOF)
+ fputc(c,fap);
+}
+
+char *addslash(char *s)
+{
+ static char bf[2048];
+ char *p = bf;
+
+ for (; *s ; s++) {
+ if (*s == '\'' || *s == '\\')
+ *p++ = '\\';
+ *p++ = *s;
+ }
+ *p = '\0';
+ // fprintf(stderr,"ADDSLA[%s]\n", bf);
+ return (bf);
+}
+
+char *tomaiu(char *s)
+{
+ static char bf[2048];
+ char *p = bf;
+
+ for (; *s ; s++,p++)
+ *p = toupper(*s);
+ *p = '\0';
+
+ return (bf);
+}
+
+void outspace(FILE *fp,int nele)
+{
+ int i;
+
+ for (i = 0 ; i < (nele*3) ; i++)
+ fputc(' ',fp);
+}
+
+void outtag(FILE *fp,char *s,int nele)
+{
+ static int st = 0, c = 0;
+ static char bf[512];
+ int i;
+
+ for (i = 0 ; s[i] != '\0' ; i++) {
+ switch(st) {
+ case 0:
+ if (s[i] == '#') {
+ bf[0] = '#';
+ c = 1;
+ st = 1;
+ }
+ break;
+ case 1:
+ if (isalnum(s[i]) || s[i] == '_')
+ bf[c++] = s[i];
+ else if (s[i] == '#') {
+ if (c == 1)
+ break;
+ bf[c++] = '#';
+ bf[c++] = '\0';
+ outspace(fp,nele);
+ fprintf(fp,"%s\n",tomaiu(bf));
+ st = 0;
+ }
+ else
+ st = 0;
+ break;
+ }
+ }
+}
+
+int main(int argc, char **argv)
+{
+ FIFILE *ff;
+ FILE *fpho,*ftemp,*fprev;
+ FILE *fpinfo;
+
+ char nome[256],bf[256],srcfile[512],nomefile[512],nomeobj[256],maiuobj[256];
+ int i,n,k,st = ST_FUORI,inobj = 0;
+ int nextst;
+ char **nextkeys;
+
+ fpinfo = stdout;
+
+ if (argc != 2)
+ exit(1);
+
+ eprefix[0] = '\0';
+ strcpy(nome,argv[1]);
+ for (n = 0 ; nome[n] != '.' && nome[n] != '\0' ; n++);
+ if (nome[n] == '\0')
+ sprintf(srcfile,"%s.html",nome);
+ else {
+ strcpy(srcfile,nome);
+ nome[n] = '\0';
+ }
+
+ fprintf(fpinfo,"-------- includes creation --------\n");
+/* -- PRIMO PASSAGGIO PER ESTRARRE LE INCLUDE DEFINITE NEL SORGENTE -- */
+ /* sprintf(nomefile,"%s.html",nome); */
+ if ((ff = ffopen(srcfile,keyprest)) == NULL)
+ exit(2);
+ while ((n = ffgetbin(bf,255,ff)) > -1) {
+ k = ffkstat(ff);
+ switch(st) {
+ case ST_FUORI:
+ for (i = 0 ; i < nfinc ; i++)
+ fprintf(fobji[i],"%s",bf);
+ if (k == W_PREOPINCL) {
+ st = ST_HDINC;
+ ffchankeys(ff,keyprecl);
+ }
+ else if (k == W_PRECLINCL) {
+ if (nfinc == 0)
+ exit(3);
+ nfinc--;
+ fclose(fobji[nfinc]);
+ }
+ break;
+ case ST_HDINC:
+ if (nfinc == NMAXFINC || k != W_PRECLOSEI) {
+ exit(4);
+ }
+ sprintf(nomefile,"%s/%s.inc",OUTOBJ,bf);
+ if ((fobji[nfinc] = fopen(nomefile,"w")) == NULL)
+ exit (5);
+ fprintf(fpinfo,"created [%s]\n",nomefile);
+ nfinc++;
+ st = ST_FUORI;
+ ffchankeys(ff,keyprest);
+ break;
+ }
+ }
+ if (nfinc != 0)
+ exit(6);
+ ffclose(ff);
+
+ /* -- SECONDO PASSAGGIO PER IL RESTO -- */
+ fprintf(fpinfo,"-------- objects creation --------\n");
+ /* sprintf(nomefile,"%s.html",nome); */
+ if ((ff = ffopen(srcfile,keyout)) == NULL)
+ exit(7);
+ sprintf(nomefile,"%s/%s.tmpl",OUTTEM,nome);
+ if ((ftemp = fopen(nomefile,"w")) == NULL)
+ exit(8);
+ sprintf(nomefile,"%s/%s.php",OUTPRE,nome);
+ if ((fprev = fopen(nomefile,"w")) == NULL)
+ exit(9);
+ st = ST_FUORI;
+ while ((n = ffgetbin(bf,255,ff)) > -1) {
+ // fprintf(stderr,"BIN [%s]\n",bf);
+ k = ffkstat(ff);
+ // fprintf(stderr,"BF: [%s] K: %d\n",bf,k);
+
+ switch(st) {
+ case ST_FUORI:
+ outtag(fpinfo,bf,nelem + inobj);
+ fprintf(ftemp,"%s",bf);
+ fprintf(fprev,"%s",bf);
+ if (k == W_OPENMIOBJ) {
+ st = ST_HDOBJ;
+ ffchankeys(ff,keyclose);
+ }
+ else if (k == W_OPENMIGTO || k == W_OPENMINCL) {
+ nextst = st;
+ nextkeys = ffgetkeys(ff);
+ ffchankeys(ff,keyclose);
+ if (k == W_OPENMIGTO)
+ st = ST_HDGTO;
+ else
+ st = ST_HDINC;
+ }
+ break;
+ case ST_HDGTO:
+ sprintf(nomefile,"%s/%s.inc",OUTOBJ,bf);
+ if (!ffinclude(ff,nomefile)) {
+ fprintf(stderr,"Non trovato il file da includere %s\n",nomefile);
+ exit (10);
+ }
+ /* PIPPO CHECK */
+ if (k == W_CLOSETAG) {
+ st = nextst;
+ ffchankeys(ff,nextkeys);
+ }
+ break;
+
+ case ST_HDINC:
+ /* PIPPO CHECK */
+ if (k == W_CLOSETAG) {
+ st = nextst;
+ ffchankeys(ff,nextkeys);
+ }
+ break;
+
+
+ case ST_HDOBJ:
+ strcpy(nomeobj,bf);
+ strcpy(maiuobj,tomaiu(nomeobj));
+ sprintf(nomefile,"%s/%s.pho",OUTPHP,bf);
+ if ((fpho = fopen(nomefile,"w")) == NULL)
+ exit (11);
+ fprintf(fpho,"<?php /* generated from file \"%s.html\" */\n",nome);
+ fprintf(fpho," $%s = array();\n",nomeobj);
+ fprintf(fpinfo,"obj: %s\n",bf);
+ // inobj = 1;
+ /* PIPPO CHECK */
+ if (k == W_CLOSETAG) {
+ st = ST_INOBJ;
+ ffchankeys(ff,keyele);
+ }
+ break;
+ case ST_INOBJ:
+ outtag(fpinfo,bf,nelem + inobj);
+ fprintf(ftemp,"%s",bf);
+ fprintf(fprev,"%s",bf);
+ if (k == W_OPENMI) {
+ st = ST_HDELE;
+ ffchankeys(ff,keyclose);
+ }
+ else if (k == W_OPENMO) {
+ st = ST_HDELO;
+ ffchankeys(ff,keyclose);
+ }
+ else if (k == W_CLOSMIOBJ) {
+ fprintf(fpho,"?>");
+ fclose(fpho);
+
+ st = ST_FUORI;
+ ffchankeys(ff,keyout);
+ inobj = 0;
+ fprintf(fpinfo,"obj close\n");
+ }
+ else if (k == W_OPENMIGTO || k == W_OPENMINCL) {
+ nextst = st;
+ nextkeys = ffgetkeys(ff);
+ ffchankeys(ff,keyclose);
+ if (k == W_OPENMIGTO)
+ st = ST_HDGTO;
+ else
+ st = ST_HDINC;
+ }
+ break;
+ case ST_HDELE:
+ case ST_HDELO:
+ if (!strcmp(bf,"#")) {
+ dummy[nelem] = 1;
+ outspace(fpinfo,nelem + inobj);
+ fprintf(fpinfo,"ele dummy:[%s]\n",bf);
+ }
+ else {
+ dummy[nelem] = 0;
+ elempref[nelem] = strlen(eprefix);
+ if (nelem == 0) {
+ /* strcpy(eprefix,nomeobj);
+ strcat(eprefix,"_"); */
+ strcpy(eprefix,bf);
+ if (st == ST_HDELE) {
+ fprintf(ftemp,"#%s_%s#",maiuobj,tomaiu(eprefix));
+ }
+ outspace(fpinfo,nelem + inobj);
+ if (st == ST_HDELE)
+ printf("#%s_%s# ele:[%s]\n",
+ maiuobj,tomaiu(eprefix),eprefix);
+ else
+ printf("ele:[%s] virtual\n",eprefix);
+ }
+ else {
+ strcat(eprefix,"_");
+ strcat(eprefix,bf);
+ outspace(fpinfo,nelem + inobj);
+ if (st == ST_HDELE)
+ printf("#%s# ele:[%s]\n",
+ tomaiu(eprefix),eprefix);
+ else
+ printf("ele:[%s] virtual\n",eprefix);
+ }
+
+
+ if (nelem > 0) {
+ if (st == ST_HDELE) {
+ sprintf(bf,"#%s#",tomaiu(eprefix));
+ strcat(elem[nelem-1],bf);
+ }
+ }
+ sprintf(elem[nelem]," $%s['%s'] = '",nomeobj,eprefix);
+ }
+ nelem++;
+
+/* magari lo mettiamo nella chiusura
+ if (st == ST_HDELE) {
+ fprintf(ftemp,"#%s_%s#",maiuobj,tomaiu(bf));
+ }
+*/
+ /* PIPPO CHECK */
+ if (k == W_CLOSETAG) {
+ st = ST_INELE;
+ ffchankeys(ff,keyclele);
+ }
+ break;
+ case ST_INELE:
+ outtag(fpinfo,bf,nelem + inobj);
+ fprintf(fprev,"%s",bf);
+ if (!dummy[nelem-1])
+ strcat(elem[nelem-1],addslash(bf));
+
+ if (k == W_OPENMI) {
+ st = ST_HDELE;
+ ffchankeys(ff,keyclose);
+ }
+ else if (k == W_OPENMO) {
+ st = ST_HDELO;
+ ffchankeys(ff,keyclose);
+ }
+ else if (k == W_CLOSMI || k == W_CLOSMO) {
+ nelem--;
+ outspace(fpinfo,nelem + inobj);
+ fprintf(fpinfo,"ele close\n");
+ if (!dummy[nelem]) {
+ strcat(elem[nelem],"';\n");
+ fputs(elem[nelem],fpho);
+ eprefix[elempref[nelem]] = '\0';
+ }
+ if (nelem == 0) {
+ st = ST_INOBJ;
+ ffchankeys(ff,keyele);
+ }
+ }
+ else if (k == W_OPENMIGTO || k == W_OPENMINCL) {
+ nextst = st;
+ nextkeys = ffgetkeys(ff);
+ ffchankeys(ff,keyclose);
+ if (k == W_OPENMIGTO)
+ st = ST_HDGTO;
+ else
+ st = ST_HDINC;
+ }
+ break;
+ }
+ }
+ fclose(ftemp);
+ fclose(fprev);
+ ffclose(ff);
+
+ exit(0);
+ return (1);
+}