/* w y s i w y g . c ** ** Copyright (c) 2002 Dennette@WiZ-WORX.com */ #include #include #include #include #include #include #define maxstr 250 typedef struct { int entnum; char *entnam; } NUMNAM; NUMNAM nametabl[] = { { 0, "Null" }, { 100, "Circular Arc" }, { 102, "Composite Curve" }, { 104, "Conic Arc" }, { 106, "Copius Data" }, { 108, "Plane" }, { 110, "Line" }, { 112, "Parametric Spline Curve" }, { 114, "Parametric Spline Surface" }, { 116, "Point" }, { 118, "Ruled Surface" }, { 120, "Surface of Revolution" }, { 122, "Tabulated Cylinder" }, { 123, "Direction" }, { 124, "Transformation Matrix" }, { 125, "Flash" }, { 126, "Rational B-Spline Curve" }, { 128, "Rational B-Spline Surface" }, { 130, "Offset Curve" }, { 132, "Connect Point" }, { 134, "Node" }, { 136, "Finite Element" }, { 138, "Nodal Displacement & Rotation" }, { 141, "Boundary" }, { 140, "Offset Surface" }, { 143, "Bounded Surface" }, { 142, "Curve on a Parametric Surface" }, { 144, "Trimmed (Parametric) Surface" }, { 146, "Nodal Results" }, { 148, "Element Results" }, { 150, "Block" }, { 152, "Right Angular Wedge" }, { 154, "Right Circular Cylinder" }, { 156, "Right Circular Cone Frustum" }, { 158, "Sphere" }, { 160, "Torus" }, { 162, "Solid of Revolution" }, { 164, "Solid of Linear Extrusion" }, { 168, "Ellipsoid" }, { 180, "Boolean Tree" }, { 182, "Selected Component" }, { 184, "Solid Assembly" }, { 186, "Manifold Solid B-Rep Object" }, { 190, "Plane Surface" }, { 192, "Right Circular Cylindrical Surface" }, { 194, "Right Circular Conical Surface" }, { 196, "Spherical Surface" }, { 198, "Toroidal Surface" }, { 202, "Angular Dimension" }, { 204, "Curve Dimension" }, { 206, "Diameter Dimension" }, { 208, "Flag Note" }, { 210, "General Label" }, { 212, "General Note" }, { 213, "New General Note" }, { 214, "Leader (Arrow)" }, { 216, "Linear Dimension" }, { 218, "Ordinate Dimension" }, { 220, "Point Dimension" }, { 222, "Radius Dimension" }, { 228, "General Symbol" }, { 230, "Sectioned Area" }, { 302, "Associativity Definition" }, { 304, "Line Font Definition" }, { 306, "MACRO Definition" }, { 308, "Subfigure Definition" }, { 310, "Text Font Definition" }, { 312, "Text Display Template" }, { 314, "Color Definition" }, { 316, "Units Data" }, { 320, "Network Subfigure Definition" }, { 322, "Attribute Table Definition" }, { 402, "Associativity Instance" }, { 404, "Drawing" }, { 406, "Property" }, { 408, "Singular Subfigure Instance" }, { 410, "View" }, { 412, "Rectangular Array Subfigure Instance" }, { 414, "Circular Array Subfigure Instance" }, { 416, "External Reference" }, { 418, "Nodal Load/Constraint" }, { 420, "Network Subfigure Instance" }, { 422, "Attribute Table Instance" }, { 430, "Solid Instance" }, { 502, "Vertex" }, { 504, "Edge" }, { 508, "Loop" }, { 510, "Face" }, { 514, "Shell" } }; #define TBLSIZ (sizeof(nametabl)/sizeof(NUMNAM)) #define PRI_DFLT printf("") /**********************************************************/ char *enum2nam( int num ) { int k; for (k=0; k"); } /**********************************************************/ void replace(tmp, os, ns) char *tmp, *os, *ns; { char s1[maxstr], *p1; int k1, k2; while ((p1=strstr(tmp, os)) != NULL) { k1 = (int)(p1-tmp); k2 = strlen(os); strncpy(s1, tmp, k1); s1[k1] = '\0'; strcat(s1, ns); strcat(s1, &tmp[k1+k2]); strcpy(tmp, s1); } } /**********************************************************/ void wysiwyg(char *arg1) { char inbuf[maxstr], tmp[maxstr]; char *out_file="a-very-long-name.extension"; char *stencil="_stencil.txt"; char *first="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; char *fileName="a-very-long-name"; FILE *in_fcb, *out_fcb; sprintf(first, "%s", arg1); if ((in_fcb = fopen(stencil, "r")) == NULL) { fprintf(stderr, "\n\acannot open stencil file: '%s'\n", stencil); exit(1); } sprintf(out_file, "%s.shtml", first); if ((out_fcb = fopen(out_file, "w")) == NULL) { fprintf(stderr, "\n\acannot open output file: '%s'\n", out_file); exit(1); } printf("\n***\tprocessing '%s'\n", out_file); for (;;) { fgets(inbuf, maxstr, in_fcb); if (feof(in_fcb)) { fclose(in_fcb); fclose(out_fcb); return; } strcpy(tmp, inbuf); replace(tmp, "$1", first ); if (strcmp(tmp, inbuf)) printf("%s", tmp); fputs(tmp, out_fcb); } } /**********************************************************/ void main(int argc, char **argv) { char *argOne="entity type/form"; if (argc < 2) { printf("\n***\tStyntax: wysiwyg \n"); exit(3); } strcpy(argOne, *++argv); /* first arg */ wysiwyg(argOne); }