From 5fd7c5b7856f6d0ddce676a02b5f35dd074ece62 Mon Sep 17 00:00:00 2001 From: root <> Date: Sun, 8 Feb 2009 18:28:31 +0000 Subject: *** empty log message *** --- src/Makefile.am | 5 ++++- src/cgm.c | 31 +++++++++++++++++++---------- src/contour.c | 20 +++++++++---------- src/ext_prototypes.h | 34 +++++++++++++++++++++++++++++++ src/fortran.h | 1 + src/jwg-head.h.in | 13 +++--------- src/libjwg.c | 48 ++++++++++++++++++++++++-------------------- src/project.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/prototypes.h | 45 +++++++++++++++++++++++++++++++++++++++++ src/xfig.c | 29 +++++++++++++++++---------- 10 files changed, 220 insertions(+), 62 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index bdcdee9..af68d29 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,6 +8,9 @@ # $Id$ # # $Log$ +# Revision 1.7 2009/02/08 18:28:31 root +# *** empty log message *** +# # Revision 1.6 2009/02/08 18:05:29 root # *** empty log message *** # @@ -32,7 +35,7 @@ INCLUDES = ${LIBGOBJ_INC} -SRCS= libjwg.c version.c cgm.c contour.c version.c xfig.c +SRCS= libjwg.c version.c cgm.c contour.c version.c xfig.c util.c cd/cd.c CPROTO=cproto JWGSRCS=${SRCS} diff --git a/src/cgm.c b/src/cgm.c index c0bcac4..bf9ae1f 100644 --- a/src/cgm.c +++ b/src/cgm.c @@ -2,6 +2,10 @@ #include "cd/cd.h" +struct CGMc_struct; +static void (*CGMc_default_constructor)(struct CGMc_struct *); +static void (*CGMc_default_destructor)(struct CGMc_struct *); + OBJECT(CGMc, int r; int g; @@ -9,8 +13,15 @@ OBJECT(CGMc, int n; ); -CONSTRUCTOR(CGMc)=GObj_DefaultConstructor; -DESTRUCTOR(CGMc)=GObj_DefaultDestructor; + +static CONSTRUCTOR(CGMc)=GObj_DefaultConstructor; +static DESTRUCTOR(CGMc)=GObj_DefaultDestructor; + + + +struct Private_struct; +static void (*Private_default_constructor)(struct Private_struct *); +static void (*Private_default_destructor)(struct Private_struct *); OBJECT(Private, CGMc_list cgmcs; @@ -22,10 +33,10 @@ OBJECT(Private, static void private_constructor(Private); static void private_destructor(Private); -CONSTRUCTOR(Private)=private_constructor; -DESTRUCTOR(Private)=private_destructor; +static CONSTRUCTOR(Private)=private_constructor; +static DESTRUCTOR(Private)=private_destructor; -int cgm_sortout_color(Private p,int r,int g,int b) +static int cgm_sortout_color(Private p,int r,int g,int b) { CGMc c; @@ -78,7 +89,7 @@ free(p); -void cgm_init_private(Handle h) +INTERNAL void cgm_init_private(Handle h) { Private p; @@ -91,7 +102,7 @@ h->private=(void *) p; -void cgm_do_line(Handle h,Jwgline *line) +INTERNAL void cgm_do_line(Handle h,Jwgline *line) { Private p=(Private) h->private; int i,c; @@ -133,7 +144,7 @@ free(base); } -void cgm_init_xform(Handle h) +INTERNAL void cgm_init_xform(Handle h) { /* this should map 1000,1414.21 to an A4 page */ @@ -148,7 +159,7 @@ h->transform.c=0.0; } -void cgm_do_poly(Handle h,Jwgline *line) +INTERNAL void cgm_do_poly(Handle h,Jwgline *line) { int i,c; int r,g,b; @@ -181,7 +192,7 @@ free(base); } -void cgm_do_text(Handle h,Jwgpos pos,char *str) +INTERNAL void cgm_do_text(Handle h,Jwgpos pos,char *str) { int color,r,g,b; Transform t=h->transform; diff --git a/src/contour.c b/src/contour.c index 8022adb..813d6ef 100644 --- a/src/contour.c +++ b/src/contour.c @@ -36,13 +36,13 @@ typedef struct contour_struct { -void +static void cont_reset_point(Contour c) { c->current_line.npts = 0; } -void +static void cont_add_point(Contour c, Jwgpos pos) { Jwgpos *ptr; @@ -73,7 +73,7 @@ cont_add_point(Contour c, Jwgpos pos) } -unsigned char +static unsigned char find_direction(Point p1, Point p2) { p2.x -= p1.x; @@ -113,7 +113,7 @@ find_direction(Point p1, Point p2) } -Point +static Point add_direction(Point p, int d) { Point dirs[8] = {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}}; @@ -125,13 +125,13 @@ add_direction(Point p, int d) } -int +static int points_marked(Contour c, Point p1, Point p2) { return (c->fcol[p1.y])[p1.x] & find_direction(p1, p2); } -void +static void mark_points(Contour c, Point p1, Point p2) { (c->fcol[p1.y])[p1.x] |= find_direction(p1, p2); @@ -140,7 +140,7 @@ mark_points(Contour c, Point p1, Point p2) -trace(Contour c, Point p1, Point p2, Point pl, float level) +static void trace(Contour c, Point p1, Point p2, Point pl, float level) { Point pn; float v1, v2, vn; @@ -241,7 +241,7 @@ fflush(stdout); -possible(Contour c, int x1, int y1, int x2, int y2, int xl, int yl, float level) +static void possible(Contour c, int x1, int y1, int x2, int y2, int xl, int yl, float level) { Point p1, p2, pl; @@ -261,7 +261,7 @@ possible(Contour c, int x1, int y1, int x2, int y2, int xl, int yl, float level) } -contour(Contour c, float level) +static void contour(Contour c, float level) { int x, y; float **c0, **c1; @@ -304,7 +304,7 @@ contour(Contour c, float level) -void +INTERNAL void do_contour(Handle h, float level, int side, int lp) { Contour c = (Contour) malloc(sizeof(struct contour_struct)); diff --git a/src/ext_prototypes.h b/src/ext_prototypes.h index e69de29..05722e9 100644 --- a/src/ext_prototypes.h +++ b/src/ext_prototypes.h @@ -0,0 +1,34 @@ +/* libjwg.c */ +void (*Data_default_constructor)(Data); +void (*Data_default_destructor)(Data); +void (*Handle_default_constructor)(Handle); +void (*Handle_default_destructor)(Handle); +int jwg_create_handle__(int *format, char *fname, int len); +void jwg_pass_data__(int *serial, float *ptr, int *w, int *h, int *l); +void jwg_destroy_data__(int *serial); +void jwg_set_xform__(int *serial, float *xc, float *yc, float *a, float *b, float *c, float *d); +void jwg_add_xform__(int *serial, float *xc, float *yc, float *a, float *b, float *c, float *d); +void jwg_add_rotation__(int *serial, float *th); +void jwg_def_xform__(int *serial); +void jwg_set_brush__(int *serial, float *r, float *g, float *b, float *density); +void jwg_set_pen__(int *serial, float *r, float *g, float *b, float *width); +void jwg_set_textcolor__(int *serial, float *r, float *g, float *b); +void jwg_set_textheight__(int *serial, float *height); +void jwg_contour__(int *serial, float *level, int *side, int *lp); +void jwg_draw_line__(int *serial, float *x, float *y, int *n); +void jwg_draw_polygon__(int *serial, float *x, float *y, int *n); +void jwg_reset_point__(int *serial); +void jwg_add_point__(int *serial, float *x, float *y); +void jwg_close_polygon__(int *serial); +void jwg_close_line__(int *serial); +void jwg_destroy_handle__(int *serial); +void jwg_push_state__(int *serial); +void jwg_pop_state__(int *serial); +void jwg_draw_text__(int *serial, float *x, float *y, char *str, int len); +void jwg_draw_text_matrix__(int *serial, float *x, float *y, float *a, float *b, float *c, float *d, char *str, int len); +/* version.c */ +/* cgm.c */ +/* contour.c */ +/* version.c */ +/* xfig.c */ +/* util.c */ diff --git a/src/fortran.h b/src/fortran.h index 22c2cd1..7d0c2cd 100644 --- a/src/fortran.h +++ b/src/fortran.h @@ -22,3 +22,4 @@ #define jwg_set_textcolor FORT(jwg_set_textcolor) #define jwg_set_textheight FORT(jwg_set_textheight) #define jwg_draw_text_matrix FORT(jwg_draw_text_matrix) +#define jwg_add_rotation FORT(jwg_add_rotation) diff --git a/src/jwg-head.h.in b/src/jwg-head.h.in index 65d5213..08c28ba 100644 --- a/src/jwg-head.h.in +++ b/src/jwg-head.h.in @@ -12,6 +12,9 @@ /* * $Log$ + * Revision 1.3 2009/02/08 18:28:31 root + * *** empty log message *** + * * Revision 1.2 2009/02/08 17:25:48 root * *** empty log message *** * @@ -78,12 +81,6 @@ OBJECT(Data, int l; float *data; ); - -extern void Data_Destructor(Data); - -CONSTRUCTOR(Data)=GObj_DefaultConstructor; -DESTRUCTOR(Data)=Data_Destructor; - typedef struct { float r,g,b; } Color; @@ -130,8 +127,4 @@ OBJECT(Handle, void *private; ); -extern void Handle_Destructor(Handle); -CONSTRUCTOR(Handle)=GObj_DefaultConstructor; -DESTRUCTOR(Handle)=Handle_Destructor; - diff --git a/src/libjwg.c b/src/libjwg.c index 63541e8..b86fbda 100644 --- a/src/libjwg.c +++ b/src/libjwg.c @@ -4,14 +4,23 @@ /* Kludgy stuff to handle fortran */ -Handle_list handle_list; -int list_created=0; -int serial; +static Handle_list handle_list; +static int list_created=0; +static int serial; +static void Data_Destructor(Data data); +static void Handle_Destructor(Handle handle); + +CONSTRUCTOR(Data)=GObj_DefaultConstructor; +DESTRUCTOR(Data)=Data_Destructor; + +CONSTRUCTOR(Handle)=GObj_DefaultConstructor; +DESTRUCTOR(Handle)=Handle_Destructor; + /* Destructors */ -void Data_Destructor(Data data) +static void Data_Destructor(Data data) { if (data->data) free(data->data); @@ -19,7 +28,7 @@ printf("JWG: Freeing data at %08x\n",(unsigned int) data->data); } -void Handle_Destructor(Handle handle) +static void Handle_Destructor(Handle handle) { printf("JWG: Destroying handle %d\n",handle->serial); @@ -35,10 +44,7 @@ free(handle); } - - - -Handle handle_from_serial(int serial) +static Handle handle_from_serial(int serial) { Handle ret; @@ -59,7 +65,7 @@ return(ret); /* C visible stuff */ -char * jwg_fiddle_text(char *str,int len) +static char * jwg_fiddle_text(char *str,int len) { char *s,*ptr; @@ -83,7 +89,7 @@ return(s); } -void jwg_xform(Handle h,Jwgpos *pos) +static void jwg_xform(Handle h,Jwgpos *pos) { float x,y; @@ -96,7 +102,7 @@ pos->y=h->transform.yc+(h->transform.c*x)+(h->transform.d*y); } -void jwg_recalc_det(Handle h) +static void jwg_recalc_det(Handle h) { Transform t=h->transform; @@ -114,7 +120,7 @@ if (h->transform.det==0.0) { /* N describes the handedness of the devices */ /* coord system 1=left handed (assumes y is inverted) */ -float jwg_decompose_matrix(Transform t,int n) +static float jwg_decompose_matrix(Transform t,int n) { float m1,m2,r; float th; @@ -156,7 +162,7 @@ th=atan2(t.c,t.a); return(th); } -Transform jwg_unitize(Transform t) +static Transform jwg_unitize(Transform t) { Transform ret; @@ -174,7 +180,7 @@ return(ret); -void init_pen(Pen *pen) +static void init_pen(Pen *pen) { pen->width=0.0; pen->color.r=0.0; @@ -182,7 +188,7 @@ pen->color.g=0.0; pen->color.b=0.0; } -void init_brush(Brush *brush) +static void init_brush(Brush *brush) { brush->density=1.0; brush->color.r=0.0; @@ -191,7 +197,7 @@ brush->color.b=0.0; } -void init_ink(Ink *ink) +static void init_ink(Ink *ink) { ink->font=0; ink->color.r=0.0; @@ -200,7 +206,7 @@ ink->color.b=0.0; ink->height=10.0; } -void init_transform(Handle h) +static void init_transform(Handle h) { @@ -232,7 +238,7 @@ h->ink.height*=h->transform.det; } -void jwg_write_line(Handle h,Jwgline *line) +static void jwg_write_line(Handle h,Jwgline *line) { @@ -249,7 +255,7 @@ case 1: } -void jwg_write_polygon(Handle h,Jwgline *line) +static void jwg_write_polygon(Handle h,Jwgline *line) { switch (h->format) { @@ -267,7 +273,7 @@ case 1: } -jwg_print_transform(Transform t) +static void jwg_print_transform(Transform t) { printf("/%03.3f %03.3f %03.3f\\\n",t.a,t.b,t.xc); printf("|%03.3f %03.3f %03.3f|\n",t.c,t.d,t.yc); diff --git a/src/project.h b/src/project.h index 7f4ce23..ef0570c 100644 --- a/src/project.h +++ b/src/project.h @@ -1,3 +1,45 @@ +#ifndef __PROJECT_H__ +#define __PROJECT_H__ + +#include "config.h" + +#ifdef TM_IN_SYS_TIME +#include +#ifdef TIME_WITH_SYS_TIME +#include +#endif +#else +#ifdef TIME_WITH_SYS_TIME +#include +#endif +#include +#endif + +#include +#include + +#ifdef HAVE_MALLOC_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_STRINGS_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#if defined(HAVE_STDINT_H) +#include +#elif defined(HAVE_SYS_INT_TYPES_H) +#include +#endif + #include #include #include @@ -10,6 +52,20 @@ #include +#ifdef INT_PROTOS +#define INTERNAL +#define EXTERNAL +#else +#ifdef EXT_PROTOS +#define INTERNAL static +#define EXTERNAL +#else +#define INTERNAL +#define EXTERNAL +#endif +#endif +#endif + #include "fortran.h" #include "jwg.h" diff --git a/src/prototypes.h b/src/prototypes.h index e69de29..998a157 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -0,0 +1,45 @@ +/* libjwg.c */ +void (*Data_default_constructor)(Data); +void (*Data_default_destructor)(Data); +void (*Handle_default_constructor)(Handle); +void (*Handle_default_destructor)(Handle); +int jwg_create_handle__(int *format, char *fname, int len); +void jwg_pass_data__(int *serial, float *ptr, int *w, int *h, int *l); +void jwg_destroy_data__(int *serial); +void jwg_set_xform__(int *serial, float *xc, float *yc, float *a, float *b, float *c, float *d); +void jwg_add_xform__(int *serial, float *xc, float *yc, float *a, float *b, float *c, float *d); +void jwg_add_rotation__(int *serial, float *th); +void jwg_def_xform__(int *serial); +void jwg_set_brush__(int *serial, float *r, float *g, float *b, float *density); +void jwg_set_pen__(int *serial, float *r, float *g, float *b, float *width); +void jwg_set_textcolor__(int *serial, float *r, float *g, float *b); +void jwg_set_textheight__(int *serial, float *height); +void jwg_contour__(int *serial, float *level, int *side, int *lp); +void jwg_draw_line__(int *serial, float *x, float *y, int *n); +void jwg_draw_polygon__(int *serial, float *x, float *y, int *n); +void jwg_reset_point__(int *serial); +void jwg_add_point__(int *serial, float *x, float *y); +void jwg_close_polygon__(int *serial); +void jwg_close_line__(int *serial); +void jwg_destroy_handle__(int *serial); +void jwg_push_state__(int *serial); +void jwg_pop_state__(int *serial); +void jwg_draw_text__(int *serial, float *x, float *y, char *str, int len); +void jwg_draw_text_matrix__(int *serial, float *x, float *y, float *a, float *b, float *c, float *d, char *str, int len); +/* version.c */ +/* cgm.c */ +void cgm_init_private(Handle h); +void cgm_do_line(Handle h, Jwgline *line); +void cgm_init_xform(Handle h); +void cgm_do_poly(Handle h, Jwgline *line); +void cgm_do_text(Handle h, Jwgpos pos, char *str); +/* contour.c */ +void do_contour(Handle h, float level, int side, int lp); +/* version.c */ +/* xfig.c */ +void xfig_init_private(Handle h); +void xfig_do_line(Handle h, Jwgline *line); +void xfig_init_xform(Handle h); +void xfig_do_poly(Handle h, Jwgline *line); +void xfig_do_text(Handle h, Jwgpos pos, char *str); +/* util.c */ diff --git a/src/xfig.c b/src/xfig.c index 913ba26..8870541 100644 --- a/src/xfig.c +++ b/src/xfig.c @@ -1,5 +1,10 @@ #include "project.h" + +struct Xfc_struct; +static void (*Xfc_default_constructor)(struct Xfc_struct *); +static void (*Xfc_default_destructor)(struct Xfc_struct *); + OBJECT(Xfc, int r; int g; @@ -7,8 +12,12 @@ OBJECT(Xfc, int n; ); -CONSTRUCTOR(Xfc)=GObj_DefaultConstructor; -DESTRUCTOR(Xfc)=GObj_DefaultDestructor; +static CONSTRUCTOR(Xfc)=GObj_DefaultConstructor; +static DESTRUCTOR(Xfc)=GObj_DefaultDestructor; + +struct Private_struct; +static void (*Private_default_constructor)(struct Private_struct *); +static void (*Private_default_destructor)(struct Private_struct *); OBJECT(Private, Xfc_list xfcs; @@ -20,8 +29,8 @@ OBJECT(Private, static void private_constructor(Private); static void private_destructor(Private); -CONSTRUCTOR(Private)=private_constructor; -DESTRUCTOR(Private)=private_destructor; +static CONSTRUCTOR(Private)=private_constructor; +static DESTRUCTOR(Private)=private_destructor; static void private_constructor(Private p) { @@ -82,7 +91,7 @@ free(p); -void xfig_init_private(Handle h) +INTERNAL void xfig_init_private(Handle h) { Private p; @@ -98,7 +107,7 @@ h->private=(void *) p; } -int xfig_sortout_color(Handle h,int r,int g,int b) +static int xfig_sortout_color(Handle h,int r,int g,int b) { Private p=(Private) h->private; Xfc c; @@ -128,7 +137,7 @@ GObj_InsertTail(p->xfcs,c); return(c->n); } -void xfig_do_line(Handle h,Jwgline *line) +INTERNAL void xfig_do_line(Handle h,Jwgline *line) { Private p=(Private) h->private; int i,c; @@ -167,7 +176,7 @@ fprintf(p->tmpfile,"\n"); } -void xfig_init_xform(Handle h) +INTERNAL void xfig_init_xform(Handle h) { h->transform.xc=0.0; @@ -181,7 +190,7 @@ h->transform.c=0.0; } -xfig_do_poly(Handle h,Jwgline *line) +INTERNAL void xfig_do_poly(Handle h,Jwgline *line) { int i,c; int r,g,b; @@ -218,7 +227,7 @@ fprintf(p->tmpfile,"\n"); } -void xfig_do_text(Handle h,Jwgpos pos,char *str) +INTERNAL void xfig_do_text(Handle h,Jwgpos pos,char *str) { int c,r,g,b; int x,y; -- cgit v1.2.3