Description: Fixes dfor Werror=implicit-function-declaration
Bug-Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1075664
Author: Alastair McKinstry <mckinstry@debian.org>
Last-Updated: 2024-08-09
Forwarded: no

--- a/src/lib/c/mkerrmsg.c
+++ b/src/lib/c/mkerrmsg.c
@@ -44,13 +44,15 @@
 #include <stdio.h>
 #include <string.h>
 
+char *gets(char *s);
+
 #ifndef lint
     static char	*rcsid	="$Id: mkerrmsg.c,v 2.5.4.1 1993/03/10 19:44:19 steve Exp $";
     static char	*afsid	="$__Header$";
 #endif
 
 
-main()
+int main(int argc, char **argv)
 {
     char            line[1024], dstr[30], estr[30];
     char           *cp;
--- a/src/lib/c/cgm/cgmi.c
+++ b/src/lib/c/cgm/cgmi.c
@@ -251,7 +251,7 @@
 /*
  * Get point parameters.
  */
-mi_point(mi, points, npoint)
+void mi_point(mi, points, npoint)
     mf_cgmi	*mi;
     Gpoint	*points;
     int		npoint;
--- a/src/lib/fortran/error.fc
+++ b/src/lib/fortran/error.fc
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
@@ -60,6 +61,7 @@
  * See also: ANSI standard p. 195
  */
 /*FORTRAN*/
+int
 geclks()
 {
     debug(("emergency close gks \n"));
@@ -85,7 +87,7 @@
  *
  * See also: ANSI standard p. 195
  */
-gerrorhand(errnr, fctid, efp)
+int gerrorhand(errnr, fctid, efp)
     Gint            errnr;
     Gerrmap         fctid;
     Gfile          *efp;
--- a/src/lib/c/xgks.h
+++ b/src/lib/c/xgks.h
@@ -1499,6 +1499,9 @@
 #define GTH_CENTER	GTH_CENTRE
 #define GCOLOR		GCOLOUR
 
+Gint ginqcolorrep (Gint wsid, Gint idx, Gqtype type, Gcobundl *rep);
+Gint ginqcolourrep (Gint wsid, Gint idx, Gqtype type, Gcobundl *rep);
+
 #define	ginqcolorfacil		ginqcolourfacil
 #define	ginqcolorrep		ginqcolourrep
 #define	ginqcolorindices	ginqcolourindices
@@ -1537,7 +1540,14 @@
 #   define PROTO(x)	()
 #endif
 
+extern Gint gerrorhand   PROTO((Gint errnr, Gerrmap fctid, Gfile *efp));
+
 extern void gescsetbackingstore PROTO((Gint ws, Gint i));
 extern void gescsetprogname     PROTO((Gchar *name));
 
+/* Added prototypes */
+void WindowMapping(int map_it);
+int  gescsetdcsize(Gint ws_id, Gpoint size);
+void xProcessEvents(void);
+
 #endif
--- a/src/lib/c/gks_implem.h
+++ b/src/lib/c/gks_implem.h
@@ -63,4 +63,380 @@
 #include "event.h"
 #include "metafile.h"
 
+/* We now enable -Werror=implicit-function-declaration on Debian
+ * so we need to include these prototypes.
+ * Not necessarily the exported API
+ */
+
+Gint gopenws (Gint wsid,const Gchar *connection,const Gchar *ws_type);
+Gint gclosews (Gint wsid);
+Gint gclearws (Gint wsid, Gclrflag control_flag);
+Gint gopengks (Gfile *err_file, Glong memory);
+Gint gclosegks (void);
+Gint gsetasf (Gasfs *asf);
+Gint gsetcolorrep (Gint wsid, Gint idx, Gcobundl *rep);
+Gint ginqcolorrep (Gint wsid, Gint idx, Gqtype type, Gcobundl *rep);
+Gint ginqcolorindices (Gint wsid, Gintlist *indices);
+Gint ginqcolorfacil (Gchar *ws_type, Gcofac *fac);
+Gint ginqpredcolorrep (Gchar *ws_type, Gint index, Gcobundl *rep);
+Gint gactivatews (Gint wsid);
+Gint gdeactivatews (Gint wsid);
+Gint gsetwindow (Gint trans, Glimit *window);
+Gint gsetviewport (Gint trans, Glimit *viewport);
+Gint gsetviewportinputpri (Gint trans, Gint ref_trans, Gvpri priority);
+Gint gselntran (Gint trans);
+Gint gsetclip (Gclip ind);
+Gint gsetwswindow (Gint wsid, Glimit *window);
+Gint gsetwsviewport (Gint wsid, Glimit *viewport);
+Gint gevaltran (Gpoint *ppoint, Gpoint *pshift, Gfloat angle, Gpoint *pscale, Gcsw coord, Gfloat result[2][3]);
+Gint gaccumtran (Gfloat segtran[2][3], Gpoint *ppoint, Gpoint *pshift, Gfloat angle, Gpoint *pscale, Gcsw coord, Gfloat result[2][3]);
+Gint gemergencyclosegks (void);
+Gint gerrorhand (Gint errnum, Gerrmap funcname, Gfile *perrfile);
+Gint gerrorlog (Gint errnum, Gerrmap funcname, Gfile *perrfile);
+Gint gpolyline (Gint num_pts, Gpoint *pts);
+Gint gsetlineind (Gint idx);
+Gint gsetlinetype (Gint type);
+Gint gsetlinewidth (Gfloat width);
+Gint gsetlinecolorind (Gint idx);
+Gint gsetlinerep (Gint wsid, Gint idx, Glnbundl *rep);
+Gint gcreateseg (Gint name);
+Gint gcloseseg (void);
+Gint grenameseg (Gint old, Gint new);
+Gint gdelseg (Gint name);
+Gint gdelsegws (Gint wsid, Gint name);
+Gint gsetsegattr (Gint name, Gsegattr *segattr);
+Gint gsetpickid (Gint pick_id);
+Gint gassocsegws (Gint wsid, Gint seg_id);
+Gint gcopysegws (Gint wsid, Gint seg_id);
+Gint ginsertseg (Gint seg_id, Gfloat segtran[2][3]);
+Gint gredrawsegws (Gint wsid);
+Gint ginqmodsegattr (Gchar *ws_type, Gmodseg *dyn);
+Gint ginqnameopenseg (Gint *seg);
+Gint ginqsegattr (Gsegattr *segattr);
+Gint ginqassocws (Gint seg, Gintlist *asswk);
+Gint ginqsegnames (Gintlist *segs);
+Gint ginqsegnamesws (Gint wsid, Gintlist *segs);
+Gint ginqnumsegpri (Gchar *ws_type, Gint *numpri);
+Gint ginqcurpickid (Gint *pickid);
+Gint gpolymarker (Gint num_pts, Gpoint *pts);
+Gint gsetmarkersize (Gfloat size);
+Gint gsetmarkertype (Gint type);
+Gint gsetmarkercolorind (Gint color);
+Gint gsetmarkerind (Gint idx);
+Gint gsetmarkerrep (Gint wsid, Gint idx, Gmkbundl *rep);
+Gint gfillarea (Gint num_pts, Gpoint *pts);
+Gint gsetfillcolorind (Gint color);
+Gint gsetfillind (Gint idx);
+Gint gsetfillintstyle (Gflinter style);
+Gint gsetfillrep (Gint wsid, Gint idx, Gflbundl *rep);
+Gint gsetfillstyleind (Gint idx);
+Gint gsetpatrep (Gint wsid, Gint idx, Gptbundl *rep);
+Gint gcellarray (Grect *rect, Gipoint *dim, Gint row, Gint *color);
+Gint ginitloc (Gint wsid, Gint dev, Gloc *init, Gint pet, Glimit *area, Glocrec *record);
+Gint gsetlocmode (Gint wsid, Gint dev, Gimode mode, Gesw echo);
+Gint greqloc (Gint wsid, Gint dev, Gqloc *response);
+Gint gsampleloc (Gint wsid, Gint dev, Gloc *response);
+Gint ginqlocst (Gint wsid, Gint dev, Gqtype type, Glocst *state);
+Gint ginqdefloc (Gchar *type, Gint dev, Gdefloc *data);
+Gint gawaitevent (Gfloat timeout, Gevent *event);
+Gint gflushevents (Gint wsid, Giclass class, Gint dev);
+Gint ginqinputoverflow (Gqueue *overflow);
+Gint ginqmoreevents (Gsimultev *events);
+Gint ggetloc (Gloc *response);
+Gint ggetstroke (Gstroke *response);
+Gint ggetchoice (Gchoice *response);
+Gint ggetpick (Gpick *response);
+Gint ggetval (Gfloat *response);
+Gint ggetstring (Gchar *response);
+Gint gupdatews (Gint wsid, Gregen regenflag);
+Gint gsetcharexpan (Gfloat expansion);
+Gint gsetcharheight (Gfloat height);
+Gint gsetcharspace (Gfloat spacing);
+Gint gsetcharup (Gpoint *up_vector);
+Gint gsettextalign (Gtxalign *txalign);
+Gint gsettextcolorind (Gint color);
+Gint gsettextfontprec (Gtxfp *txfp);
+Gint gsettextind (Gint idx);
+Gint gsettextpath (Gtxpath path);
+Gint gsettextrep (Gint wsid, Gint idx, Gtxbundl *bundle);
+Gint gtext (Gpoint *at, Gchar *string);
+Gint ginqtextextent (Gint wsid, Gpoint position, Gchar *string, Gextent *extent);
+Gint gsetdeferst (Gint wsid, Gdefmode deferral_mode, Girgmode regen_mode);
+Gint ginitchoice (Gint wsid, Gint dev, Gchoice *init, Gint pet, Glimit *area, Gchoicerec *record);
+Gint gsetchoicemode (Gint wsid, Gint dev, Gimode mode, Gesw echo);
+Gint greqchoice (Gint wsid, Gint dev, Gchoice *response);
+Gint gsamplechoice (Gint wsid, Gint dev, Gchoice *response);
+Gint ginqchoicest (Gint wsid, Gint dev, Gchoicest *state);
+Gint ginqdefchoice (Gchar *type, Gint dev, Gdefchoice *data);
+Gint ginitpick (Gint wsid, Gint dev, Gpick *init, Gint pet, Glimit *area, Gpickrec *record);
+Gint gsetpickmode (Gint wsid, Gint dev, Gimode mode, Gesw echo);
+Gint greqpick (Gint wsid, Gint dev, Gpick *response);
+Gint gsamplepick (Gint wsid, Gint dev, Gpick *response);
+Gint ginqpickst (Gint wsid, Gint dev, Gqtype type, Gpickst *state);
+Gint ginqdefpick (Gchar *type, Gint dev, Gdefpick *data);
+Gint ginitval (Gint wsid, Gint dev, Gfloat init, Gint pet, Glimit *area, Gvalrec *record);
+Gint gsetvalmode (Gint wsid, Gint dev, Gimode mode, Gesw echo);
+Gint greqval (Gint wsid, Gint dev, Gqval *response);
+Gint gsampleval (Gint wsid, Gint dev, Gfloat *response);
+Gint ginqvalst (Gint wsid, Gint dev, Gvalst *state);
+Gint ginqdefval (Gchar *type, Gint dev, Gdefval *data);
+Gint ginitstring (Gint wsid, Gint dev, Gchar *init, Gint pet, Glimit *area, Gstringrec *record);
+Gint gsetstringmode (Gint wsid, Gint dev, Gimode mode, Gesw echo);
+Gint greqstring (Gint wsid, Gint dev, Gqstring *response);
+Gint gsamplestring (Gint wsid, Gint dev, Gchar *response);
+Gint ginqstringst (Gint wsid, Gint dev, Gstringst *state);
+Gint ginqdefstring (Gchar *type, Gint dev, Gdefstring *data);
+Gint ginitstroke (Gint wsid, Gint dev, Gstroke *init, Gint pet, Glimit *area, Gstrokerec *record);
+Gint gsetstrokemode (Gint wsid, Gint dev, Gimode mode, Gesw echo);
+Gint greqstroke (Gint wsid, Gint dev, Gqstroke *response);
+Gint gsamplestroke (Gint wsid, Gint dev, Gstroke *response);
+Gint ginqstrokest (Gint wsid, Gint dev, Gqtype type, Gstrokest *state);
+Gint ginqdefstroke (Gchar *type, Gint dev, Gdefstroke *data);
+Gint ginqlinefacil (Gchar *ws_type, Glnfac *fac);
+Gint ginqpredlinerep (Gchar *ws_type, Gint idx, Glnbundl *rep);
+Gint ginqlineindices (Gint wsid, Gintlist *idxlist);
+Gint ginqlinerep (Gint wsid, Gint idx, Gqtype type, Glnbundl *rep);
+Gint ginqmarkerfacil (Gchar *ws_type, Gmkfac *fac);
+Gint ginqpredmarkerrep (Gchar *ws_type, Gint idx, Gmkbundl *rep);
+Gint ginqmarkerindices (Gint wsid, Gintlist *idxlist);
+Gint ginqmarkerrep (Gint wsid, Gint idx, Gqtype type, Gmkbundl *rep);
+Gint ginqfillfacil (Gchar *ws_type, Gflfac *fac);
+Gint ginqpredfillrep (Gchar *ws_type, Gint idx, Gflbundl *rep);
+Gint ginqfillindices (Gint wsid, Gintlist *idxlist);
+Gint ginqfillrep (Gint wsid, Gint idx, Gqtype type, Gflbundl *rep);
+Gint ginqpatfacil (Gchar *ws_type, Gint *fac);
+Gint ginqpredpatrep (Gchar *ws_type, Gint idx, Gptbundl *rep);
+Gint ginqpatindices (Gint wsid, Gintlist *idxlist);
+Gint ginqpatrep (Gint wsid, Gint idx, Gqtype type, Gptbundl *rep);
+Gint gmessage (Gint wsid, Gchar *string);
+Gint gescinqxattr (Gint wsid, Display **dpy, Window *win, GC *gc);
+void gescsetbackingstore (Gint wsid, Gint i);
+void gescsetprogname (char *name);
+Gint gescsetcolormask (Gint wsid, unsigned long mask);
+Gint gescsetdcsize (Gint wsid, Gpoint size);
+Gint gescstoreprimi (Gint wsid, Gstore store);
+Gint gescredrawnotify (Gint wsid, Gint (*funcp)(Gint wsid, Gredraw who));
+Gint ginqtextfacil (Gchar *ws_type, Gtxfac *fac);
+Gint ginqpredtextrep (Gchar *ws_type, Gint idx, Gtxbundl *rep);
+Gint ginqtextindices (Gint wsid, Gintlist *idxlist);
+Gint ginqtextrep (Gint wsid, Gint idx, Gqtype type, Gtxbundl *rep);
+Gint ginqavailwstypes (Gstrlist *wstypes);
+Gint ginqdisplayspacesize (Gchar *ws_type, Gdspsize *dspsz);
+Gint ginqwscategory (Gchar *ws_type, Gwscat *cat);
+Gint ginqwsclass (Gchar *ws_type, Gwsclass *class);
+Gint ginqmodwsattr (Gchar *ws_type, Gmodws *dyn);
+Gint ginqdefdeferst (Gchar *ws_type, Gdefer *def);
+Gint ginqmaxwssttables (Gchar *ws_type, Gwstables *tables);
+Gint ginqnumavailinput (Gchar *ws_type, Gnumdev *num);
+Gint ginqwsconntype (Gint wsid, Gwsct *ct);
+Gint ginqwsst (Gint wsid, Gwsstate *state);
+Gint ginqwsdeferupdatest (Gint wsid, Gwsdus *du);
+Gint ginqopst (Gos *state);
+Gint ginqlevelgks (Glevel *lev);
+Gint ginqwsmaxnum (Gwsmax *maxws);
+Gint ginqopenws (Gintlist *wsids);
+Gint ginqactivews (Gintlist *wsids);
+Gint ginqprimattr (Gpriattr *primattr);
+Gint ginqindivattr (Gindattr *indivattr);
+Gint ginqcurntrannum (Gint *tran);
+Gint ginqntrannum (Gintlist *tranlist);
+Gint ginqntran (Gint num, Gwstran *tran);
+Gint ginqclip (Gcliprec *clipping);
+Gint ginqmaxntrannum (Gint *maxtran);
+Gint ginqwstran (Gint wsid, Gwsti *wstran);
+Gint ginqpixelarraydim (Gint wsid, Grect *rect, Gipoint *dim);
+Gint ginqpixelarray (Gint wsid, Gpoint *point, Gipoint *dimen, Gpxarray *pxarr);
+Gint ginqpixel (Gint wsid, Gpoint *ppoint, Gint *pix);
+Gint gwritegksm (Gint wsid, Gint type, Gint length, Gchar *data);
+Gint ggetgksm (Gint wsid, Ggksmit *result);
+Gint greadgksm (Gint wsid, Gint length, Gchar *record);
+Gint ginterpret (Ggksmit *recInfo, Gchar *data);
+
+int g_gdp(Gint npoints, Gpoint *points, Gint function,
+                                   Ggdprec *data);
+
+int gerlog_(int *errnr, int *fctid, int *lun);
+int gerhnd_(int *errnr, int *fctid, int *errfil);
+int ginqavailgdp(Gchar *type,Ggdplist *gdps);
+int gprecc(int il,int *ia,int rl,float *ra,int sl,int *lstr,char **str,int  mldr,int *errind,int *ldr,char *datarec);
+void perr(int i, char *s);
+
+#if 0
+Gint ginqclip (Gcliprec *clipping);
+Gint ginqcolourindices(Gint ws_id, Gintlist       *indices);
+Gint gsetcolourrep(Gint ws_id,Gint idx, Gcobundl *rep);
+Gint gsetcolorrep(Gint ws_id,Gint idx, Gcobundl *rep);
+
+
+
+int gopenws(Gint ws_id , const Gchar * connection ,
+                                   const Gchar * ws_type);
+int gclosews(Gint ws_id);
+int gactivatews(Gint ws_id);
+int gdeactivatews(Gint ws_id);
+int gclearws(Gint ws_id , Gclrflag control_flag);
+int gredrawsegws(Gint ws_id);
+int gupdatews(Gint ws_id, Gregen regenflag);
+int gsetdeferst(Gint ws_id, Gdefmode deferral_mode,
+                                   Girgmode regen_mode);
+int gpolyline(Gint num_pts, Gpoint *pts);
+int gpolymarker(Gint num_pts, Gpoint *pts);
+int gfillarea(Gint num_pts, Gpoint *pts);
+/*int gcellarray(xgks_Grect *rect, Gipoint *dim, Gint row,
+  Gint *colour); */
+int gsetlineind(Gint idx);
+int gsetlinetype(Gint type);
+int gsetlinewidth(Gfloat width);
+int gsetlinecolourind(Gint idx);
+int gsetmarkerind(Gint idx);
+int gsetmarkertype(Gint type);
+int gsetmarkersize(Gfloat size);
+int gsetmarkercolourind(Gint colour);
+int gsettextind(Gint idx);
+int gsettextfontprec(Gtxfp *txfp);
+int gflushevents(Gint ws_id,Giclass class,Gint dev);
+void gescsetbackingstore(Gint ws, Gint i);
+void gescsetprogname(Gchar *name);
+
+int  gcloseseg(void);
+
+Gint gsetpatsize(Gpoint *siz);
+Gint gsetfillind(Gint idx);
+Gint gsetfillstyleind(Gint idx);
+Gint gsettextcolourind(Gint colour);
+Gint gsettextpath(Gtxpath path);
+Gint gsetfillintstyle(Gflinter style);
+Gint gsetfillcolourind(Gint colour);
+Gint gsetpatrefpt(Gpoint *ref);
+Gint gsetpickid(Gint pick_id);
+Gint gcreateseg(Gint name);
+Gint gdelseg(Gint name);
+Gint gsettextalign(Gtxalign *txalign);
+Gint grenameseg(Gint old,Gint new);
+Gint ginqsegattr(Gsegattr *segattr);
+Gint gmessage(Gint ws_id,Gchar *string);
+Gint gsetsegattr(Gint name,Gsegattr *segattr);
+Gint gtext(Gpoint *at,Gchar *string);
+Gint gsetcharexpan(Gfloat expansion);
+Gint gsetcharspace(Gfloat spacing);
+Gint gsetasf(Gasfs *asf);
+Gint gsetlinerep(Gint ws_id,Gint idx,Glnbundl *rep);
+Gint gsetmarkerrep(Gint ws_id,Gint idx,Gmkbundl *rep);
+Gint gsettextrep(Gint ws_id,Gint idx,Gtxbundl *bundle);
+Gint gsetfillrep(Gint ws_id,Gint idx,Gflbundl *rep);
+Gint gsetpatrep(Gint ws_id,Gint idx,Gptbundl *rep);
+Gint gsetwswindow(Gint ws_id,Glimit *window);
+Gint gsetwsviewport(Gint ws_id,Glimit *viewport);
+Gint gsetwindow(Gint trans,Glimit *window);
+#endif
+
+int  PSmoSetLandscape(Metafile *mf);
+Gint gsetpatsize(Gpoint *siz);
+Gint gsetpatrefpt(Gpoint *ref);
+int  XgksXDrawLines(Display *dpy,Drawable win,GC gc,XPoint *xpts,int npts,int mode);
+Gint XgksFindNTransNpts(int num,Gpoint *ndcpts,Gint *ntrans,Gpoint *wcpts);
+int  xXgksInqTextExtent(WS_STATE_PTR ws,TEXT_ST *tx,Gpoint ndc_points[5]);
+void XgksUpdatePrimiBound(OUT_PRIMI *primi,Glimit *bound);
+void XgksProcessPrimi(OUT_PRIMI *primi);
+void XgksOutputToWs(OUT_PRIMI *primi);
+void XgksMiniMax(Glimit *bound,Gpoint *pt);
+void XgksAppendWsPrimi(OUT_PRIMI *primi);
+void XgksAppendSegClip(void);
+void XgksAppendWsClip(Glimit *rec);
+int  xXgksHighLight(WS_STATE_PTR  ws,Gpoint bd[5]);
+void XgksGReDrawWs(WS_STATE_PTR ws);
+void XgksReDrawSeg(WS_STATE_PTR ws,Gint seg_id);
+void XgksReDrawSegWs(WS_STATE_PTR ws);
+int  xXgksClearWs(WS_STATE_PTR wk);
+void XgksInsertPrimi(OUT_PRIMI **insert_pt,OUT_PRIMI *elm);
+void XgksUnpendPendingTrans(WS_STATE_PTR ws);
+void XgksReDrawWs(WS_STATE_PTR ws,OUT_PRIMI *primi);
+void XgksUpdateWsSegList(WS_STATE_PTR ws);
+void XgksReDrawSegWs(WS_STATE_PTR ws);
+void XgksWsWinInterset(WS_STATE_PTR ws,Glimit *v,Glimit *clip);
+int  xXgksPolyMarker(WS_STATE_PTR ws,PMARK_ST *pmk_ptr);
+int  xXgksFillArea(WS_STATE_PTR ws,FILL_AREA_ST *fill_ptr);
+int  xXgksCloseWs(WS_STATE_PTR ws);
+Gint xXgksOpenWs(WS_STATE_PTR wk);
+void XgksDeletePrimi(OUT_PRIMI *head,OUT_PRIMI **insert_pt);
+int  xXgksCellarray(WS_STATE_PTR ws,CELL_ARRAY_ST *cell_ptr);
+void XgksInitIDev(WS_STATE_ENTRY *ws);
+void XgksInitWssTrans(WS_STATE_PTR ws);
+void XgksIDevDelete(WS_STATE_ENTRY *ws);
+void XgksDeleteAllSeg(WS_STATE_PTR ws);
+Gint xXgksOpenWs(WS_STATE_PTR wk);
+int  xXgksText(WS_STATE_PTR ws,TEXT_ST *tx);
+int  xXgksMesg(WS_STATE_PTR ws,MESG_ST *mesg);
+void XgksInitWssPmarkers(WS_STATE_PTR ws);
+int  xXgksPolyLine(WS_STATE_PTR ws, PLINE_ST *plin_ptr);
+void xXgksUpdateClip(WS_STATE_PTR ws);
+void XgksInitWssPlines(WS_STATE_PTR ws);
+int  XgksInitWssFillArea(WS_STATE_PTR ws);
+void XgksDrawToWs(WS_STATE_PTR ws,OUT_PRIMI *primi);
+int  XgksInsertMesgPrimi(WS_STATE_PTR ws,OUT_PRIMI *primi);
+void XgksCleanUpWsSegList(WS_STATE_PTR ws);
+void XgksInitGksAsf(void);
+void XgksInitGksPlines(void);
+void XgksInitGksPmarkers(void);
+void XgksInitGksFillArea(void);
+void XgksInitWssText(WS_STATE_PTR ws);
+void XgksInitGksSegments(void);
+void XgksInitGksText(void);
+void XgksInitGksTrans(void);
+void XgksComputeVec(Gpoint *up_vec, Gpoint *base_vec);
+int  XgksSIGIO_OFF(Display *dpy);
+int  XgksSIGIO_ON(Display *dpy);
+int  xXgksXReDrawWs(WS_STATE_PTR    ws);
+void XgksXReDrawWs (WS_STATE_PTR    ws);
+int  sockspgrp(int fd,pid_t pid);
+int  sockasync(int fd, int yes);
+int sio_on(void (*handler)());
+int sio_off(void);
+void XgksIDevDisable(WS_STATE_ENTRY *ws);
+void xXgksUpdateTrans(WS_STATE_PTR    ws);
+void XgksIProcessXEvent(XEvent *xev,WS_STATE_ENTRY *ws);
+void XgksIDevEnable(WS_STATE_ENTRY *ws);
+void xXgksSetForeground(Display *dpy, GC gc,unsigned long   fg);
+void xXgksSetFillAreaClipRectangles(Display *dpy,GC gc,WS_STATE_PTR ws,XRectangle *rectangle);
+void xXgksSetLineAttributes(Display *dpy,GC gc, unsigned int line_width,int line_style,int cap_style,int join_style);
+void xXgksSetStipple(Display *dpy,GC gc,Pixmap stipple);
+void xXgksSetFillStyle(Display *dpy,GC gc,int fill_style);
+void xXgksSetTile(Display *dpy,GC gc,Pixmap tile);
+void XcCopy(WS_STATE_PTR toWs,WS_STATE_PTR fromWs);
+void xXgksSetDashes(Display *dpy,GC gc,WS_STATE_PTR ws, Gint i);
+void xXgksSetPlineClipRectangles(Display *dpy,GC gc,WS_STATE_PTR ws,XRectangle *rectangle);
+void XgksDrawMarkers(Display *dpy,Window win,GC gc,XPoint *pe,int n,int type,float s);
+void xXgksSetPmarkerClipRectangles(Display *dpy,GC gc,WS_STATE_PTR ws,XRectangle  *rectangle);
+void xXgksSetTextClipRectangles(Display *dpy,GC gc,WS_STATE_PTR ws,XRectangle *rectangle);
+int  XgksMoDeactivateWs(WS_STATE_PTR    ws);
+void XgksProcessPrimi(OUT_PRIMI      *primi);
+int  XgksAwaitEvent(WS_STATE_ENTRY **wslist,int nws, double timeout);
+int  XgksEnqueueEvent(Gint ws,Gint dev, Giclass class,char *data, int event_id);
+int  xXgksSetColourRep(WS_STATE_PTR ws,int idx,Gcobundl *rep);
+int  xXgksInqColourRep(WS_STATE_PTR ws,int idx,Gqtype type, Gcobundl *rep);
+int  XgksMaxColours(char *server);
+void XgksReDrawSegWs(WS_STATE_PTR ws);
+void XgksUpdateWsClip(WS_STATE_PTR ws,Glimit *bound);
+int  XgksChoUpdatePrompt(WS_STATE_ENTRY *ws,INPUT_DEV *idev,PromptStatus pstate,XMotionEvent *xmev,int event_id);
+int  XgksLocUpdatePrompt(WS_STATE_ENTRY *ws,INPUT_DEV *idev,PromptStatus pstate,Gpoint *newdcpt,XMotionEvent *xmev,int event_id);
+int  XgksPicUpdatePrompt(WS_STATE_ENTRY *ws,INPUT_DEV *idev,Gpoint *newdcpt,XMotionEvent *xmev,int event_id);
+int  XgksStrUpdatePrompt(WS_STATE_ENTRY *ws,INPUT_DEV *idev,PromptStatus pstate,XKeyPressedEvent *xev,int event_id);
+int  XgksStkUpdatePrompt(WS_STATE_ENTRY *ws,INPUT_DEV *idev,PromptStatus pstate,Gpoint *newdcpt,XMotionEvent *xmev,int event_id);
+int  XgksValUpdatePrompt(WS_STATE_ENTRY *ws,INPUT_DEV *idev,PromptStatus pstate,Gpoint *newdcpt,XMotionEvent *xmev, int event_id);
+void XgksPicDelete(WS_STATE_ENTRY *ws,INPUT_DEV *idev);
+void XgksLocDelete(WS_STATE_ENTRY *ws,INPUT_DEV *idev);
+void XgksStrDelete(WS_STATE_ENTRY *ws,INPUT_DEV *idev);
+void XgksStkDelete(WS_STATE_ENTRY *ws,INPUT_DEV *idev);
+void XgksChoDelete(WS_STATE_ENTRY *ws,INPUT_DEV *idev);
+void XgksValDelete(WS_STATE_ENTRY *ws,INPUT_DEV *idev);
+int  xXgksInqPixelarrayDim(WS_STATE_PTR ws,Grect *rect,Gipoint *dim);
+int  xXgksInqPixel(WS_STATE_PTR ws,Gpoint *ppoint,Gint *pix);
+int  xXgksInqPixelarray(WS_STATE_PTR ws,Gpoint *point,Gipoint *dim, Gpxarray *pxarr);
+Bool XgksFindNTrans(Gpoint *ndcpt,Gloc *gloc);
+void XgksProcessClip(Glimit *rec);
+void XgksSetLineAttrMo(WS_STATE_PTR ws,Glnattr *lnattr);
+void XgksSetMarkAttrMo(WS_STATE_PTR ws,Gmkattr *mkattr);
+void XgksSetTextAttrMo(WS_STATE_PTR ws,Gtxattr *txattr,CHATTR *chattr);
+void XgksSetFillPatAttrMo(WS_STATE_PTR ws,Gflattr *flattr,PTATTR *ptattr);
+    
 #endif	/* XGKS_GKS_IMPLEM_H not defined */
--- a/src/lib/c/colours.c
+++ b/src/lib/c/colours.c
@@ -41,6 +41,7 @@
 
 #include "udposix.h"
 #include <stdlib.h>
+#include <string.h>
 #include "gks_implem.h"
 
 /* LINTLIBRARY */
@@ -67,6 +68,7 @@
  *
  * See also: ANSI Standard p.105
  */
+Gint
 gsetcolourrep(ws_id, idx, rep)
     Gint            ws_id;
     Gint            idx;
@@ -146,6 +148,7 @@
  *
  * See also: ANSI Standard p.164
  */
+Gint
 ginqcolourrep(ws_id, idx, type, rep)
     Gint            ws_id;
     Gint            idx;
@@ -219,6 +222,7 @@
  *
  * See also: ANSI Standard p.164
  */
+Gint
 ginqcolourindices(ws_id, indices)
     Gint            ws_id;
     Gintlist       *indices;
@@ -258,6 +262,7 @@
  *
  * See also: ANSI Standard p.180
  */
+Gint
 ginqcolourfacil(ws_type, fac)
     Gchar          *ws_type;
     Gcofac         *fac;
@@ -294,7 +299,8 @@
 static Display	*CprevDpy = NULL;
 static int	Cncolours = 0;
 static XColor	*Xcolours = NULL;
- 
+
+Gint
 ginqpredcolourrep(ws_type, index, rep)
     Gchar          *ws_type;
     Gint            index;
@@ -427,6 +433,7 @@
  * find the number of colour table entries supported by an X server.
  * returns the number of entries or -1 if the server does not respond.
  */
+int
 XgksMaxColours(server)
     char           *server;
 {
--- a/src/lib/c/wslist.h
+++ b/src/lib/c/wslist.h
@@ -422,4 +422,13 @@
 				       unsigned long PixelValue));
 extern int	XcEnd		PROTO((WS_STATE_PTR XcWs));
 
+/* Added prototypes */
+int  GIFFlush(Metafile *mf, char *filename);
+int  GIFFlusht0(Metafile *mf, char *filename);
+int  GIFFlusht1(Metafile *mf, char *filename);
+void GIFresize(WS_STATE_PTR ws, Gpoint size);
+void PSresize(WS_STATE_PTR ws, Gpoint size);
+void XgksDrawSegToWs(WS_STATE_PTR);
+
+
 #endif					/* WSLIST_H not defined */
--- a/src/lib/c/cgm/cgmo.c
+++ b/src/lib/c/cgm/cgmo.c
@@ -879,7 +879,7 @@
 
 	assert(IS_IN_PICTURE(cgmo[ii]));
 
-	if (ginqcolourrep(cgmo[ii]->ws->ws_id, 0, GSET, &rep) == OK) {
+	if (ginqcolorrep(cgmo[ii]->ws->ws_id, 0, GSET, &rep) == OK) {
 	    mo_header(PIC_DESCRIPTOR_CL, BACKCOLR_ID);
 	    mo_direct_color(cgmo+ii, 1, &rep);
 	    mo_flush(cgmo+ii, 1, 0);
--- a/src/lib/c/x/xopws.c
+++ b/src/lib/c/x/xopws.c
@@ -164,7 +164,7 @@
 /*
  * Insure a connection to the display.
  */
-    static
+static int
 InsureConn(wk)
     WS_STATE_PTR    wk;
 {
@@ -218,7 +218,7 @@
  *	Indicate whether a boolean resource is set.  Returns -1 if the
  *	resource doesn't exist, 0 if it's false, and 1 if it's true.
  */
-    static int
+static int
 BoolResource(prog, name, class, rDB)
     char           *prog;		/* program name */
     char           *name;		/* resource name */
@@ -260,7 +260,7 @@
 /*
  * Create an XGKS window -- with all its associated attributes.
  */
-    static
+static int
 CreateWindow(name, rDB, wk)
     char           *name;		/* program name */
     XrmDatabase     rDB;		/* resource database */
@@ -662,7 +662,7 @@
  * Initialize our local resource manager.  Taken from "X11R4/contrib/
  * examples/OReilly/Xlib/basecalc/basecalc.c".
  */
-    static
+    static int
 InitDefaults(name, dpy, rDB)
     char           *name;		/* name of application */
     Display        *dpy;
@@ -708,7 +708,7 @@
  *
  * NB: Document any changes to the following algorithm in xgks.3.
  */
-    static
+    static int
 GetUsersDatabase(prog, rDB, dpy)
     char           *prog;
     XrmDatabase    *rDB;		/* resource database */
@@ -817,6 +817,7 @@
 /*
  *  xXgksClearWs(wk) --- clear the corresponding x-window
  */
+int
 xXgksClearWs(wk)
     WS_STATE_PTR    wk;
 {
@@ -835,6 +836,7 @@
 /*
  * xXgksCloseWs(ws) --- close the corresponding x-window
  */
+int
 xXgksCloseWs(ws)
     WS_STATE_PTR    ws;
 {
@@ -857,6 +859,7 @@
 /*
  * xXgksHighLight(ws, bd) --- heighlight a primitive
  */
+int
 xXgksHighLight(ws, bd)
     Gpoint          bd[5];
     WS_STATE_PTR    ws;
--- a/src/lib/c/x/xpmarker.c
+++ b/src/lib/c/x/xpmarker.c
@@ -52,6 +52,7 @@
 #endif
 
 
+int
 xXgksPolyMarker(ws, pmk_ptr)
     WS_STATE_PTR    ws;
     PMARK_ST       *pmk_ptr;
@@ -165,6 +166,7 @@
 /*
  * Output polymarkers
  */
+void
 XgksDrawMarkers(dpy, win, gc, pe, n, type, s)
     Display        *dpy;
     Window          win;
--- a/src/lib/c/x/xtext.c
+++ b/src/lib/c/x/xtext.c
@@ -45,6 +45,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <unistd.h>
 #include <math.h>
 #include "gks_implem.h"
 #include "font.h"
@@ -95,7 +96,7 @@
 static int      xMultMatrix();
 
 
-    static 
+static  void
 xComputeText(ws, tx)
     WS_STATE_PTR    ws;
     TEXT_ST        *tx;
@@ -186,6 +187,7 @@
  * Note: this function will output tabs, form feeds, line feeds, and like 
  * control characters as a special symbol.
  */
+int
 xXgksText(ws, tx)
     WS_STATE_PTR    ws;
     TEXT_ST        *tx;
@@ -501,7 +503,7 @@
  *
  * returns nothing.
  */
-    static
+static int
 xPlotStrokeChar(cvp)
     struct vcharst *cvp;
 {
@@ -671,7 +673,7 @@
  * a matrix is an array of six REALs which specify the first two columns
  * of a 3x3 2D transformation matrix.
  */
-    static
+    static int
 xIdentityMatrix(m)
     Gfloat          m[];
 {
@@ -730,7 +732,7 @@
 #endif	/* TDEBUG defined */
 
 
-    static
+    static int
 xTransMatrix(m, tx, ty)
     Gfloat          m[];
     Gfloat          tx, ty;
@@ -746,7 +748,7 @@
 }
 
 
-    static
+    static int
 xCopyMatrix(dest, src)
     Gfloat          dest[], src[];
 {
@@ -761,7 +763,7 @@
 /*
  * matrix multiply: a * b = c
  */
-    static
+    static int
 xMultMatrix(a, b, c)
     Gfloat          a[], b[], c[];
 {
@@ -792,7 +794,7 @@
 #endif	/* TDEBUG defined */
 
 
-    static
+    static int
 ck_ranges(cdef, Xmin, Xmax, Ymin, Ymax)
     struct vcharst *cdef;
     Gfloat         *Xmin, *Xmax, *Ymin, *Ymax;
@@ -825,7 +827,7 @@
 }
 
 
-    static
+    static int
 ApplyMatrix(m, in, out)
     Gfloat          m[];
     Gpoint         *in, *out;
@@ -840,6 +842,7 @@
  * xXgksInqTextExtent () -- X's text inquire extent routine
  *
  */
+int
 xXgksInqTextExtent(ws, tx, ndc_points)
     WS_STATE_PTR    ws;
     TEXT_ST        *tx;
@@ -1286,7 +1289,7 @@
 
 #define MAX(a, b) (((a)>(b))?(a):(b))
 
-
+int
 xXgksMesg(ws, mesg)
     WS_STATE_PTR    ws;
     MESG_ST        *mesg;
--- a/src/lib/c/act_ws.c
+++ b/src/lib/c/act_ws.c
@@ -54,7 +54,7 @@
  * XgksNoActiveWs() - return 1 if no open workstations are active
  *	else return 0;
  */
-    static
+    static int
 XgksNoActiveWs()
 {
     Gint            i;
@@ -76,7 +76,7 @@
  * return INVALID if there's no empty slot
  *
  */
-    static
+    static int
 XgksAllocActiveWs (ws_id,ws)
     Gint ws_id;
     WS_STATE_PTR ws;
@@ -129,7 +129,7 @@
  *
  * See also: ANSI standard p.76
  */
-
+int
 gactivatews(ws_id)
     Gint ws_id;
 {
@@ -182,6 +182,7 @@
  *
  * See also: ANSI standard p.76
  */
+int
 gdeactivatews(ws_id)
     Gint            ws_id;
 {
--- a/src/lib/c/x/xupdate.c
+++ b/src/lib/c/x/xupdate.c
@@ -57,7 +57,7 @@
     static char rcsid[]	= "$Id: xupdate.c,v 2.5.4.1 1993/03/10 19:44:27 steve Exp $";
 #endif
 
-
+void
 xXgksUpdateTrans(ws)
     WS_STATE_PTR    ws;
 {
@@ -131,6 +131,7 @@
  * in X pixel-space from the transformed boundaries of the GKS clip window.
  * space.
  */
+void
 xXgksUpdateClip(ws)
     WS_STATE_PTR    ws;
 {
--- a/src/lib/c/choice.c
+++ b/src/lib/c/choice.c
@@ -69,6 +69,7 @@
 #define MenuPadV 4
 #define MenuPadH MenuPadV
 
+int
 ginitchoice(ws_id, dev, init, pet, area, record)
     Gint            ws_id;
     Gint            dev;
@@ -331,6 +332,7 @@
  * returns: 0, 7, 20, 25, 38, 140, 143
  */
  
+int
 gsetchoicemode(ws_id, dev, mode, echo)
     Gint            ws_id;
     Gint            dev;
@@ -447,6 +449,7 @@
  *
  * returns: 0, 7, 20, 25, 38, 140, 141
  */
+int
 greqchoice(ws_id, dev, response)
     Gint            ws_id;
     Gint            dev;
@@ -569,6 +572,7 @@
  *
  * returns: 0, 7, 20, 25, 38, 140, 142
  */
+int
 gsamplechoice(ws_id, dev, response)
     Gint            ws_id;
     Gint            dev;
@@ -622,6 +626,7 @@
  *
  * See Also: ANSI Standard p.168
  */
+int
 ginqchoicest(ws_id, dev, state)
     Gint            ws_id;
     Gint            dev;
@@ -711,6 +716,7 @@
  *
  * See Also: ANSI Standard p.187
  */
+int
 ginqdefchoice(type, dev, data)
     Gchar          *type;
     Gint            dev;
@@ -785,7 +791,7 @@
 	((str) != NULL) ? strlen(str) : 0); \
 )
 
- 
+int 
 XgksChoUpdatePrompt(ws, idev, pstate, xmev, event_id)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
@@ -976,6 +982,7 @@
 /*
  * Delete all structures used to maintain a choice logical input device.
  */
+void
 XgksChoDelete(ws, idev)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
--- a/src/lib/c/escape.c
+++ b/src/lib/c/escape.c
@@ -55,6 +55,7 @@
 /*
  * INQUIRE X ATTRIBUTES
  */
+int
 gescinqxattr(ws_id, dpy, win, gc)
     Gint            ws_id;
     Display       **dpy;
@@ -96,6 +97,7 @@
  * Gint ws_id;			workstation identifier.
  * unsigned long mask;		the desired colour plane mask.
  */
+int
 gescsetcolourmask(ws_id, mask)
     Gint            ws_id;
     unsigned long   mask;
@@ -132,6 +134,7 @@
  * Gint ws_id;			workstation identifier.
  * Gpoint size;			the size of workstation DC space.
  */
+int
 gescsetdcsize(ws_id, size)
     Gint            ws_id;
     Gpoint          size;
@@ -193,6 +196,7 @@
  * Gint ws_id;			workstation identifier.
  * Gstore store;		
  */
+int
 gescstoreprimi(ws_id, store)
     Gint            ws_id;
     Gstore          store;
@@ -230,6 +234,7 @@
  * Gint ws_id;			workstation identifier.
  * Gint (*funcp)();		the pointer of redraw notifying function.
  */
+int
 gescredrawnotify(ws_id, funcp)
     Gint            ws_id;
     Gint          (*funcp) ();
--- a/src/lib/c/gdp.c
+++ b/src/lib/c/gdp.c
@@ -49,6 +49,7 @@
  * See also: ANSI standard p.181
  *
  */
+int
 ginqavailgdp(type, gdps)
     Gchar          *type;		/* workstation type    */
     Ggdplist       *gdps;		/* OUT list of GDP's */
@@ -90,6 +91,7 @@
  *
  */
 /*ARGSUSED*/
+int
 ginqgdp(type, function, fac)
     Gchar          *type;
     Gint            function;
@@ -128,6 +130,7 @@
  * names (notably under NeXTOS).  Hence, we have both the Fortran and C ggdp()
  * functions call this one.
  */
+int
 g_gdp(npoints, points, function, data)
     Gint            npoints;		/* number of points        */
     Gpoint         *points;		/* points array            */
--- a/src/lib/c/fillarea.c
+++ b/src/lib/c/fillarea.c
@@ -36,7 +36,7 @@
  * fillarea.c - functions and data for gks fill areas.
  *		gfillarea ()
  *		gsetfillcolourind ()
- *		gsetfillind ()
+gsetfillind *		gsetfillind ()
  *		gsetfillintstyle ()
  *		gsetfillrep ()
  *		gsetfillstyleind ()
@@ -70,6 +70,7 @@
 /* 
  * XgksInitGksFillArea: initialise gks state list fill area stuff
  */
+void
 XgksInitGksFillArea()
 {
     xgks_state.gks_flattr.fill = 1;		/* fill index */
@@ -92,6 +93,7 @@
  * XgksInitWssFillArea(ws) - send predefined attributes and Bundle index to
  * newly opened workstation ws;
  */
+int
 XgksInitWssFillArea(ws)
     WS_STATE_PTR    ws;
 {
@@ -136,6 +138,7 @@
  * 
  * See Also: ANSI Standard p.83
  */
+Gint
 gfillarea(num_pts, pts)
     Gint            num_pts;
     Gpoint         *pts;
@@ -192,6 +195,7 @@
  * 
  * See Also: ANSI Standard p.98
  */
+Gint
 gsetfillcolourind(colour)
     Gint            colour;
 {
@@ -220,6 +224,7 @@
  * 
  * See Also: ANSI Standard p.96
  */
+Gint
 gsetfillind(idx)
     Gint            idx;
 {
@@ -249,6 +254,7 @@
  * 
  * See Also: ANSI Standard p.96
  */
+Gint
 gsetfillintstyle(style)
     Gflinter        style;
 {
@@ -280,6 +286,7 @@
  * 
  * See Also: ANSI Standard p.103
  */
+Gint
 gsetfillrep(ws_id, idx, rep)
     Gint            ws_id;
     Gint            idx;
@@ -344,6 +351,7 @@
  * 
  * See Also: ANSI Standard p.97
  */
+Gint
 gsetfillstyleind(idx)
     Gint            idx;
 {
@@ -373,6 +381,7 @@
  * See Also: ANSI Standard p.98
  */
 
+Gint
 gsetpatrefpt(ref)
     Gpoint         *ref;
 {
@@ -398,6 +407,7 @@
  * 
  * See Also: ANSI Standard p.98
  */
+Gint
 gsetpatsize(siz)
     Gpoint         *siz;
 {
@@ -431,6 +441,7 @@
  * 
  * See Also: ANSI Standard p.104
  */
+Gint
 gsetpatrep(ws_id, idx, rep)
     Gint            ws_id;
     Gint            idx;
--- a/src/lib/c/gerhnd.fc
+++ b/src/lib/c/gerhnd.fc
@@ -41,6 +41,9 @@
 #include "xgks.h"
 #include "../fortran/fortxgks.h"
 
+
+int gerlog_(int *errnr, int *fctid, int *lun);
+
 FILE	*errfp			= NULL;	/* error file */
 
 
@@ -56,6 +59,7 @@
  * See also: ANSI standard p. 195
  */
 /*FORTRAN*/
+int
 gerhnd(int *errnr, int *fctid, int *errfil)
 {
     FC_NAME(gerlog)(errnr, fctid, errfil);
--- a/src/lib/c/event.c
+++ b/src/lib/c/event.c
@@ -62,6 +62,7 @@
  * enqueue an event.  Memory pointed to by data must be malloc'ed by the
  * caller but NOT freeed.
  */
+int
 XgksEnqueueEvent(ws, dev, class, data, event_id)
     Gint            ws;
     Gint            dev;
@@ -223,6 +224,7 @@
  *
  * Returns: 0, 7, 20, 25, 38, 140, 147
  */
+int
 gflushevents(ws_id, class, dev)
     Gint            ws_id;
     Giclass         class;
@@ -283,6 +285,7 @@
  *
  * Returns: 0, 7, 148, 149
  */
+int
 ginqinputoverflow(overflow)
     Gqueue         *overflow;
 {
@@ -302,6 +305,7 @@
  *
  * Errors: 0, 7
  */
+int
 ginqmoreevents(events)
     Gsimultev      *events;
 {
@@ -329,6 +333,7 @@
  *
  * returns 0, 7, 150
  */
+int
 ggetloc(response)
     Gloc           *response;
 {
@@ -354,6 +359,7 @@
  *
  * returns 0, 7, 150
  */
+int
 ggetstroke(response)
     Gstroke        *response;
 {
@@ -380,6 +386,7 @@
  *
  * returns 0, 7, 150
  */
+int
 ggetchoice(response)
     Gchoice        *response;
 {
@@ -405,6 +412,7 @@
  * 
  * returns 0, 7, 150
  */
+int
 ggetpick(response)
     Gpick          *response;
 {
@@ -430,6 +438,7 @@
  * 
  * returns 0, 7, 150
  */
+int
 ggetval(response)
     Gfloat         *response;
 {
@@ -455,6 +464,7 @@
  * 
  * returns 0, 7, 150
  */
+int
 ggetstring(response)
     Gchar          *response;
 {
--- a/src/lib/c/deferral_ws.c
+++ b/src/lib/c/deferral_ws.c
@@ -59,6 +59,7 @@
  *
  * See also: ANSI standard p.79
  */
+int
 gsetdeferst(ws_id, deferral_mode, regen_mode)
     Gint            ws_id;
     Gdefmode        deferral_mode;
--- a/src/lib/c/gks_error.c
+++ b/src/lib/c/gks_error.c
@@ -62,7 +62,7 @@
  *
  * See also: Ansi standard p. 193
  */
-gemergencyclosegks()
+int gemergencyclosegks(void)
 {
     int             i;
 
@@ -91,6 +91,7 @@
 /*
  *  ERROR LOGGING
  */
+int
 gerrorlog(errnum, funcname, perrfile)
     Gint            errnum;		/* number for the error that was
 					 * detected. */
--- a/src/lib/c/input.c
+++ b/src/lib/c/input.c
@@ -61,6 +61,7 @@
 /*
  * Initialise the input device list
  */
+void
 XgksInitIDev(ws)
     WS_STATE_ENTRY *ws;
 {
@@ -88,6 +89,7 @@
  * This routine will free up all memory assoicated with input device structure
  *
  */
+void
 XgksIDevDelete(ws)
     WS_STATE_ENTRY *ws;
 {
@@ -176,6 +178,7 @@
  *
  * XEvent can be one of: MotionNotify
  */
+void
 XgksIProcessXEvent(xev, ws)
     XEvent         *xev;
     WS_STATE_ENTRY *ws;
@@ -354,8 +357,9 @@
  *	Basically, just get their prompts off the screen so that GKS can
  *	produce some output.
  */
-static          DisCount = 0;
+static int          DisCount = 0;
 
+void
 XgksIDevDisable(ws)
     WS_STATE_ENTRY *ws;
 {
@@ -452,6 +456,7 @@
 /*
  * Enable all input devices for a given workstation.
  */
+void
 XgksIDevEnable(ws)
     WS_STATE_ENTRY *ws;
 {
--- a/src/lib/c/pick.c
+++ b/src/lib/c/pick.c
@@ -80,6 +80,7 @@
  *
  * See Also: ANSI Standard p.127
  */
+int
 ginitpick(ws_id, dev, init, pet, area, record)
     Gint            ws_id, dev, pet;
     Gpick          *init;
@@ -162,6 +163,7 @@
  *
  * See Also: ANSI Standard p.130
  */
+int
 gsetpickmode(ws_id, dev, mode, echo)
     Gint            ws_id, dev;
     Gimode          mode;
@@ -244,6 +246,7 @@
  *
  * See Also: ANSI Standard p.134
  */
+int
 greqpick(ws_id, dev, response)
     Gint            ws_id, dev;
     Gpick          *response;
@@ -353,6 +356,7 @@
  *
  * See Also: ANSI Standard p.137
  */
+int
 gsamplepick(ws_id, dev, response)
     Gint            ws_id, dev;
     Gpick          *response;
@@ -413,6 +417,7 @@
  *
  * See Also: ANSI Standard p.169
  */
+int
 ginqpickst(ws_id, dev, type, state)
     Gint            ws_id, dev;
     Gqtype          type;
@@ -477,6 +482,7 @@
  *
  * See Also: ANSI Standard p.188
  */
+int
 ginqdefpick(type, dev, data)
     Gchar          *type;
     Gint            dev;
@@ -527,6 +533,7 @@
 /*
  * XgksPicUpdatePrompt - update the locator prompt
  */
+int
 XgksPicUpdatePrompt(ws, idev, newdcpt, xmev, event_id)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
@@ -617,6 +624,7 @@
  *             BUT, BUT not the pointer to the structure itself
  *            calling program still needs that
  */
+void
 XgksPicDelete(ws, idev)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
--- a/src/lib/c/stroke.c
+++ b/src/lib/c/stroke.c
@@ -124,6 +124,7 @@
  *
  * See Also: ANSI Standard p.121
  */
+int
 ginitstroke(ws_id, dev, init, pet, area, record)
     Gint            ws_id;
     Gint            dev;
@@ -335,6 +336,7 @@
  *
  * See Also: ANSI Standard p.129
  */
+int
 gsetstrokemode(ws_id, dev, mode, echo)
     Gint            ws_id;
     Gint            dev;
@@ -425,6 +427,7 @@
  *
  * See Also: ANSI Standard p.132
  */
+Gint
 greqstroke(ws_id, dev, response)
     Gint            ws_id;
     Gint            dev;
@@ -556,6 +559,7 @@
  *
  * See Also: ANSI Standard p.135
  */
+Gint
 gsamplestroke(ws_id, dev, response)
     Gint            ws_id;
     Gint            dev;
@@ -620,6 +624,7 @@
  *
  * See Also: ANSI Standard p.167
  */
+Gint
 ginqstrokest(ws_id, dev, type, state)
     Gint            ws_id;
     Gint            dev;
@@ -683,6 +688,7 @@
  *
  * See Also: ANSI Standard p.186
  */
+Gint
 ginqdefstroke(type, dev, data)
     Gchar          *type;
     Gint            dev;
@@ -730,6 +736,7 @@
 /*
  * XgksStkUpdatePrompt - update the stroke prompt
  */
+int
 XgksStkUpdatePrompt(ws, idev, pstate, newdcpt, xmev, event_id)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
@@ -934,6 +941,7 @@
 /*
  * free all memory associate with a stroke logical input device
  */
+void
 XgksStkDelete(ws, idev)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
@@ -987,6 +995,7 @@
  * and be able to erase it without leaving trash behind.  So... this
  * function will make multiple calls to XDrawLine. 
  */
+int
 XgksXDrawLines(dpy, win, gc, xpts, npts, mode)
     Display        *dpy;
     Drawable        win;
--- a/src/lib/c/x/xport.c
+++ b/src/lib/c/x/xport.c
@@ -94,6 +94,7 @@
  * Register the SIGIO signal-handler.  This routine is non-portable because
  * not every platform has SIGIO.
  */
+int
 sio_on(handler)
     void	(*handler)();
 {
@@ -120,6 +121,7 @@
  * Ignore SIGIO signals.  This routine is non-portable because
  * not every platform has SIGIO.
  */
+int
 sio_off()
 {
 #ifdef SIGIO
@@ -143,6 +145,7 @@
  * Set the process-group ID of a socket.  This routine is non-portable because
  * not every platform has sockets.
  */
+int
 sockspgrp(fd, pid)
     int		fd;
     pid_t	pid;
@@ -162,6 +165,7 @@
  * Make I/O on a socket asynchronous or not.  This routine is non-portable 
  * because not every platform has sockets.
  */
+int
 sockasync(fd, yes)
     int		fd;
     int		yes;
--- a/src/lib/c/valuator.c
+++ b/src/lib/c/valuator.c
@@ -164,6 +164,7 @@
  *
  * See Also: ANSI Standard p.123
  */
+int
 ginitval(ws_id, dev, init, pet, area, record)
     Gint            ws_id, dev, pet;
     Gfloat          init;
@@ -269,6 +270,7 @@
  *
  * See Also: ANSI Standard p.129
  */
+int
 gsetvalmode(ws_id, dev, mode, echo)
     Gint            ws_id, dev;
     Gimode          mode;
@@ -363,6 +365,7 @@
  *
  * See Also: ANSI Standard p.133
  */
+int
 greqval(ws_id, dev, response)
     Gint            ws_id, dev;
     Gqval          *response;
@@ -477,6 +480,7 @@
  *
  * See Also: ANSI Standard p.136
  */
+int
 gsampleval(ws_id, dev, response)
     Gint            ws_id, dev;
     Gfloat         *response;
@@ -530,6 +534,7 @@
  *
  * See Also: ANSI Standard p.168
  */
+int
 ginqvalst(ws_id, dev, state)
     Gint            ws_id, dev;
     Gvalst         *state;
@@ -619,6 +624,7 @@
  *
  * See Also: ANSI Standard p.186
  */
+int
 ginqdefval(type, dev, data)
     Gchar          *type;
     Gint            dev;
@@ -707,6 +713,7 @@
 /*
  * XgksValUpdatePrompt - update the locator prompt
  */
+int
 XgksValUpdatePrompt(ws, idev, pstate, newdcpt, xmev, event_id)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
@@ -873,6 +880,7 @@
  *             BUT, BUT not the pointer to the structure itself
  *            calling program still needs that
  */
+void
 XgksValDelete(ws, idev)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
--- a/src/lib/c/locator.c
+++ b/src/lib/c/locator.c
@@ -58,6 +58,7 @@
  * Returns: 0, 7, 25, 38, 51, 60, 64, 65, 80, 83, 85, 93, 140, 141, 144, 145, 
  *	    300, 2000
  */
+int
 ginitloc(ws_id, dev, init, pet, area, record)
     Gint            ws_id;		/* workstation identifier */
     Gint            dev;		/* locator device number */
@@ -384,6 +385,7 @@
  *
  * Returns: 0, 7, 25, 38, 140, 300, 2000
  */
+int
 gsetlocmode(ws_id, dev, mode, echo)
     Gint            ws_id;		/* workstation identifier */
     Gint            dev;		/* locator device number */
@@ -485,6 +487,7 @@
  *
  * Returns: 0, 7, 20, 25, 38, 140, 141, 300
  */
+int
 greqloc(ws_id, dev, response)
     Gint            ws_id;		/* workstation identifier */
     Gint            dev;		/* locator device number */
@@ -607,6 +610,7 @@
  *
  * returns 0=ok or 7, 20, 25, 38, 140, 142
  */
+int
 gsampleloc(ws_id, dev, response)
     Gint            ws_id;		/* workstation identifier */
     Gint            dev;		/* locator device number */
@@ -658,6 +662,7 @@
  * Errors: 0, 7, 20, 25, 38, 140, 2000
  *
  */
+int
 ginqlocst(ws_id, dev, type, state)
     Gint            ws_id;		/* workstation identifier */
     Gint            dev;		/* locator device number */
@@ -720,6 +725,7 @@
  * data->pets.integers are malloc'ed by GKS;
  * it is the user's responsibility to free these structures.
  */
+int
 ginqdefloc(type, dev, data)
     Gchar          *type;		/* worsktation type string */
     Gint            dev;		/* locator device number */
@@ -773,6 +779,7 @@
 /*
  *  XgksLocUpdatePrompt - update the locator prompt
  */
+int
 XgksLocUpdatePrompt(ws, idev, pstate, newdcpt, xmev, event_id)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
@@ -1049,6 +1056,7 @@
 /*
  * free all memory associate with a locator logical input device
  */
+void
 XgksLocDelete(ws, idev)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
--- a/src/lib/c/string.c
+++ b/src/lib/c/string.c
@@ -140,6 +140,7 @@
  *
  * Returns: 0, 7, 20, 25, 38, 51, 140, 141, 144, 145, 146, 152, 300
  */
+Gint
 ginitstring(ws_id, dev, init, pet, area, record)
     Gint            ws_id;
     Gint            dev;
@@ -219,6 +220,7 @@
  *
  * Returns: 0, 7, 20, 25, 38, 140, 143, 500
  */
+Gint
 gsetstringmode(ws_id, dev, mode, echo)
     Gint            ws_id;
     Gint            dev;
@@ -280,6 +282,7 @@
  *
  * Returns: 0, 7, 20, 25, 38, 140, 141
  */
+Gint
 greqstring(ws_id, dev, response)
     Gint            ws_id;
     Gint            dev;
@@ -355,6 +358,7 @@
  *    large as the buffer size specified in the call to ginitstring() or
  *    the default size DEF_STR_BUFSIZ.
  */
+Gint
 gsamplestring(ws_id, dev, response)
     Gint            ws_id;
     Gint            dev;
@@ -400,6 +404,7 @@
  *
  * NOTE: state->string is malloc'ed by GKS and must be freed by the user.
  */
+Gint
 ginqstringst(ws_id, dev, state)
     Gint            ws_id;
     Gint            dev;
@@ -445,6 +450,7 @@
  *
  * Errors: 0, 8, 22, 23, 38, 140
  */
+Gint
 ginqdefstring(type, dev, data)
     Gchar          *type;
     Gint            dev;
@@ -496,6 +502,7 @@
 /*
  * XgksStrUpdatePrompt
  */
+int
 XgksStrUpdatePrompt(ws, idev, pstate, xev, event_id)
  /* PTR c1133 */
     WS_STATE_ENTRY *ws;
@@ -724,6 +731,7 @@
 /*
  * Delete all structures used to maintain a string logical input device.
  */
+void
 XgksStrDelete(ws, idev)
     WS_STATE_ENTRY *ws;
     INPUT_DEV      *idev;
--- a/src/lib/c/inqpixel.c
+++ b/src/lib/c/inqpixel.c
@@ -45,6 +45,7 @@
 #include "gks_implem.h"
 
 
+Gint
 ginqpixelarraydim(ws_id, rect, dim)
     Gint            ws_id;
     Grect          *rect;
@@ -85,6 +86,7 @@
  *
  * See also: ANSI standard p.191
  */
+Gint
 ginqpixelarray(ws_id, point, dimen, pxarr)
     Gint            ws_id;
     Gpoint         *point;
@@ -128,6 +130,7 @@
  *
  * See also: ANSI standard p.191
  */
+Gint
 ginqpixel(ws_id, ppoint, pix)
     Gint            ws_id;
     Gpoint         *ppoint;
--- a/src/lib/c/x/xinqpixel.c
+++ b/src/lib/c/x/xinqpixel.c
@@ -56,6 +56,7 @@
  * Grect *rect;			rectangele pointer.
  * Gipoint *dim;		OUT dimensions of the pixel array.
  */
+int
 xXgksInqPixelarrayDim(ws, rect, dim)
     WS_STATE_PTR    ws;			/* workstation */
     Grect          *rect;		/* rectangle of region of interest */
@@ -92,6 +93,7 @@
  * Gpxarray *pxarr;		OUT pixel array.
  *
  */
+int
 xXgksInqPixelarray(ws, point, dim, pxarr)
     WS_STATE_PTR    ws;			/* workstation */
     Gpoint         *point;		/* WC origin of desired pixel-array */
@@ -243,6 +245,7 @@
  * Gint *pix;  			OUT pixel colour.
  *
  */
+int
 xXgksInqPixel(ws, ppoint, pix)
     WS_STATE_PTR    ws;			/* workstation */
     Gpoint         *ppoint;		/* desired-pixel position in WC */
--- a/src/lib/c/inqfillareas.c
+++ b/src/lib/c/inqfillareas.c
@@ -59,6 +59,7 @@
  *
  * See also: ANSI standard p.177
  */
+Gint
 ginqfillfacil(ws_type, fac)
     Gchar          *ws_type;
     Gflfac         *fac;
@@ -108,6 +109,7 @@
  *
  * See also: ANSI standard p.178
  */
+Gint
 ginqpredfillrep(ws_type, idx, rep)
     Gchar          *ws_type;
     Gint            idx;
@@ -142,6 +144,7 @@
  *
  * See also: ANSI standard p.161
  */
+Gint
 ginqfillindices(ws_id, idxlist)
     Gint            ws_id;
     Gintlist       *idxlist;
@@ -184,6 +187,7 @@
  * See also: ANSI standard p.162
  */
 /*ARGSUSED*/
+Gint
 ginqfillrep(ws_id, idx, type, rep)
     Gint            ws_id;
     Gint            idx;
@@ -225,6 +229,7 @@
  *
  * See also: ANSI standard p.179
  */
+Gint
 ginqpatfacil(ws_type, fac)
     Gchar          *ws_type;
     Gint           *fac;
@@ -253,6 +258,7 @@
  *
  * See also: ANSI standard p.179
  */
+Gint
 ginqpredpatrep(ws_type, idx, rep)
     Gchar          *ws_type;
     Gint            idx;
@@ -292,6 +298,7 @@
  *
  * See also: ANSI standard p.162
  */
+Gint
 ginqpatindices(ws_id, idxlist)
     Gint            ws_id;
     Gintlist       *idxlist;
@@ -334,6 +341,7 @@
  * See also: ANSI standard p.152
  */
 /*ARGSUSED*/
+Gint
 ginqpatrep(ws_id, idx, type, rep)
     Gint            ws_id;
     Gint            idx;
--- a/src/lib/c/inquiries.c
+++ b/src/lib/c/inquiries.c
@@ -62,6 +62,7 @@
 /*
  * INQUIRE OPERATING STATE VALUE
  */
+int
 ginqopst(state)
     Gos            *state;
 {
@@ -78,6 +79,7 @@
 /*
  * INQUIRE LEVEL OF GKS
  */
+int
 ginqlevelgks(lev)
     Glevel         *lev;
 {
@@ -96,6 +98,7 @@
  *
  * errors 0, 8
  */
+int
 ginqwsmaxnum(maxws)
     Gwsmax         *maxws;
 {
@@ -120,6 +123,7 @@
  *
  * errors 0, 8
  */
+int
 ginqopenws(wsids)
     Gintlist       *wsids;
 {
@@ -153,6 +157,7 @@
  *
  * errors 0, 8
  */
+int
 ginqactivews(wsids)
     Gintlist       *wsids;
 {
@@ -188,6 +193,7 @@
  *
  * errors 0, 8
  */
+int
 ginqprimattr(primattr)
     Gpriattr       *primattr;
 {
@@ -218,6 +224,7 @@
  *
  * errors 0, 8.
  */
+int
 ginqindivattr(indivattr)
     Gindattr       *indivattr;
 {
--- a/src/lib/c/inqtransform.c
+++ b/src/lib/c/inqtransform.c
@@ -59,6 +59,7 @@
  *
  * See also: ANSI Standard p.147
  */
+int
 ginqcurntrannum(tran)
     Gint           *tran;
 {
@@ -83,6 +84,7 @@
  *
  * See also: ANSI Standard p.147
  */
+int
 ginqntrannum(tranlist)
     Gintlist       *tranlist;
 {
@@ -115,6 +117,7 @@
  *
  * See also: ANSI Standard p.148
  */
+int
 ginqntran(num, tran)
     Gint            num;
     Gwstran        *tran;
@@ -142,6 +145,7 @@
  *
  * See also: ANSI Standard p.148
  */
+int
 ginqclip(clipping)
     Gcliprec       *clipping;
 {
@@ -179,6 +183,7 @@
  *
  * See also: ANSI Standard p.144
  */
+int
 ginqmaxntrannum(maxtran)
     Gint           *maxtran;
 {
@@ -208,6 +213,7 @@
  *
  * See also: ANSI Standard p.162
  */
+int
 ginqwstran(ws_id, wstran)
     Gint            ws_id;
     Gwsti          *wstran;
--- a/src/lib/c/inqWDT.c
+++ b/src/lib/c/inqWDT.c
@@ -61,6 +61,7 @@
  *
  * See Also: ANSI Standard p.145
  */
+Gint
 ginqavailwstypes(wstypes)
     Gstrlist       *wstypes;
 {
@@ -91,6 +92,7 @@
  *
  * See Also: ANSI Standard p.171
  */
+Gint
 ginqdisplayspacesize(ws_type, dspsz)
     Gchar          *ws_type;
     Gdspsize       *dspsz;
@@ -129,6 +131,7 @@
  *
  * See Also: ANSI Standard p.170
  */
+Gint
 ginqwscategory(ws_type, cat)
     Gchar          *ws_type;
     Gwscat         *cat;
@@ -173,6 +176,7 @@
  *
  * See Also: ANSI Standard p.171
  */
+Gint
 ginqwsclass(ws_type, class)
     Gchar          *ws_type;
     Gwsclass       *class;
@@ -207,6 +211,7 @@
  *
  * See Also: ANSI Standard p.172
  */
+Gint
 ginqmodwsattr(ws_type, dyn)
     Gchar          *ws_type;
     Gmodws         *dyn;
@@ -243,6 +248,7 @@
  *
  * See Also: ANSI Standard p.173
  */
+Gint
 ginqdefdeferst(ws_type, def)
     Gchar          *ws_type;
     Gdefer         *def;
@@ -276,6 +282,7 @@
  *
  * See Also: ANSI Standard p.182
  */
+Gint
 ginqmaxwssttables(ws_type, tables)
     Gchar          *ws_type;
     Gwstables      *tables;
@@ -315,6 +322,7 @@
  *
  * See Also: ANSI Standard p.184
  */
+Gint
 ginqnumavailinput(ws_type, num)
     Gchar          *ws_type;
     Gnumdev        *num;
@@ -358,6 +366,7 @@
  *
  * See Also: ANSI Standard p.153
  */
+Gint
 ginqwsconntype(ws_id, ct)
     Gint            ws_id;
     Gwsct          *ct;
@@ -397,6 +406,7 @@
  *
  * See Also: ANSI Standard p.153
  */
+Gint
 ginqwsst(ws_id, state)
     Gint            ws_id;
     Gwsstate       *state;
@@ -436,6 +446,7 @@
  *
  * See Also: ANSI Standard p.154
  */
+Gint
 ginqwsdeferupdatest(ws_id, du)
     Gint            ws_id;
     Gwsdus         *du;
--- a/src/lib/c/text.c
+++ b/src/lib/c/text.c
@@ -74,6 +74,7 @@
 /*
  * XgksInitGksText --  gks state list text stuff
  */
+void
 XgksInitGksText()
 {
     xgks_state.gks_txattr.text = 1;		/* text indx */
@@ -117,6 +118,7 @@
  * XgksInitWssText(ws) - send the current INDIVIDUAL attributes and BUNDLE
  *	index to the newly opened workstation ws.
  */
+void
 XgksInitWssText(ws)
     WS_STATE_PTR    ws;
 {
@@ -145,6 +147,7 @@
  *
  * See Also: ANSI Standard p.93
  */
+Gint
 gsetcharexpan(expansion)
     Gfloat          expansion;
 {
@@ -176,6 +179,7 @@
  *
  * Note : gks_chattr.chwidth is also set here to "height"
  */
+Gint
 gsetcharheight(height)
     Gfloat          height;
 {
@@ -206,6 +210,7 @@
  *
  * See Also: ANSI Standard p.94
  */
+Gint
 gsetcharspace(spacing)
     Gfloat          spacing;
 {
@@ -235,6 +240,7 @@
  * (in this implementation to, 1.0) at a right angle in the clockwise direction
  * to the value specified by the parameter
  */
+int
 gsetcharup(up_vector)
     Gpoint         *up_vector;
 {
@@ -278,6 +284,7 @@
  *
  * Note: horizontal is not saying it is NORMAL to be LEFT of CENTRE.
  */
+Gint
 gsettextalign(txalign)
     Gtxalign       *txalign;
 {
@@ -313,6 +320,7 @@
  *
  * See Also: ANSI Standard p.94
  */
+Gint
 gsettextcolourind(colour)
     Gint            colour;
 {
@@ -344,6 +352,7 @@
  *
  * See Also: ANSI Standard p.93
  */
+Gint
 gsettextfontprec(txfp)
     Gtxfp          *txfp;
 {
@@ -377,6 +386,7 @@
  *
  * See Also: ANSI Standard p.92
  */
+Gint
 gsettextind(idx)
     Gint            idx;
 {
@@ -406,6 +416,7 @@
  *
  * See Also: ANSI Standard p.95
  */
+Gint
 gsettextpath(path)
     Gtxpath         path;
 {
@@ -437,6 +448,7 @@
  *
  * See Also: ANSI Standard p.102
  */
+Gint
 gsettextrep(ws_id, idx, bundle)
     Gint            ws_id;
     Gint            idx;
@@ -499,6 +511,7 @@
  *   NOTE : 	These vectors contain information of both direction and
  *		magnitude
  */
+void
 XgksComputeVec(up_vec, base_vec)
     Gpoint         *up_vec, *base_vec;
 {
@@ -546,6 +559,7 @@
  * See Also: ANSI Standard p.83
  *
  */
+Gint
 gtext(at, string)
     Gpoint         *at;
     Gchar          *string;
@@ -607,6 +621,7 @@
  *
  * See also: ANSI standard p.158
  */
+Gint
 ginqtextextent(ws_id, position, string, extent)
     Gint            ws_id;
     Gpoint          position;
--- a/src/lib/c/segments.c
+++ b/src/lib/c/segments.c
@@ -1051,7 +1051,7 @@
  *
  *  Will redraw the workstation if necessary
  */
-    static
+static int
 XgksDelAssocWs(seg, ws_id)
     SEG_STATE_PTR   seg;
     Gint            ws_id;
@@ -1173,7 +1173,7 @@
  * XgksSetHighLight(ws, seg)	setting/unsetting segment highlight on
  *				specified workstations.
  */
-    static 
+static  void
 XgksSetHighLight(ws, seg)
     WS_STATE_PTR    ws;
     SEG_STATE_PTR   seg;
@@ -1216,7 +1216,7 @@
  * XgksOutputSeg (ws, seg)	Output all primitive in the seg->primi_list to 
  *				ws.
  */
-    static 
+static void
 XgksOutputSeg(ws, seg)
     WS_STATE_PTR    ws;
     SEG_STATE_PTR   seg;
@@ -1245,7 +1245,7 @@
  *
  * NOTE: This  function will not redraw on WISS (that is if WISS, skip )
  */
-    static 
+static void
 XgksReDrawAssocWs(seg)
     SEG_STATE_PTR   seg;
 {
@@ -1269,7 +1269,7 @@
  *    ->vis: if old != new     return TRUE
  *    ->pri: if different      return TRUE
  */
-    static 
+    static  int
 XgksIrgNec(old, new)
     Gsegattr       *old, *new;
 {
@@ -1293,7 +1293,7 @@
 /*
  *   XgksNewSeg() - will return a pointer to an empty segment structure
  */
-    static SEG_STATE_PTR 
+static SEG_STATE_PTR 
 XgksNewSeg()
 {
     SEG_STATE_PTR   new;
@@ -1329,7 +1329,7 @@
  *   XgksInstallSeg(seg) -
  *       SEG_STATE_PTR  seg  install seg-> into the segment state hash table
  */
-    static 
+static  void
 XgksInstallSeg(seg)
     SEG_STATE_PTR   seg;
 {
@@ -1342,7 +1342,7 @@
  * XgksNewWsSeg()	allocate memory for workstation segment list return 
  *			pointer to the entry
  */
-    static WS_SEG_LIST *
+static WS_SEG_LIST *
 XgksNewWsSeg()
 {
     WS_SEG_LIST    *new;
@@ -1361,7 +1361,7 @@
  * The lowest possible priority is 0. The highest priority is 1.	c1032
  *
  */
-    static 
+static void
 XgksInsertWsSeg(ws, seg_id)
     WS_STATE_PTR    ws;
     Gint            seg_id;
@@ -1387,7 +1387,7 @@
  *		INVALID if undefined
  *		else return the name of the deleted segment
  */
-    static
+static int
 XgksDeleteWsSeg(ws, seg_id)
     WS_STATE_PTR    ws;
     Gint            seg_id;
@@ -1410,7 +1410,7 @@
  * XgksRenameWsSeg (ws, old, new) - rename the segment name in ws->seglist
  *
  */
-    static 
+static  void
 XgksRenameWsSeg(ws, old, new)
     WS_STATE_PTR    ws;
     Gint            old, new;
@@ -1458,6 +1458,7 @@
 /*
  * XgksInitGksSegments() - utility function to initialize GKS segment data.
  */
+void
 XgksInitGksSegments()
 {
     Gint            i;
@@ -1478,6 +1479,7 @@
  *
  * See Also: ANSI Standard p.111
  */
+int
 gcreateseg(name)
     Gint            name;
 {
@@ -1535,6 +1537,7 @@
  *
  * See Also: ANSI Standard p.111
  */
+int
 gcloseseg()
 {
     /* STEP 1: check for errors */
@@ -1563,6 +1566,7 @@
  *
  * See also: ANSI standard p.111
  */
+int
 grenameseg(old, new)
     Gint            old, new;
 {
@@ -1619,6 +1623,7 @@
  *
  * See Also: ANSI Standard p.112
  */
+int
 gdelseg(name)
     Gint            name;
 {
@@ -1675,6 +1680,7 @@
  *
  * See Also: ANSI Standard p.112
  */
+int
 gdelsegws(ws_id, name)
     Gint            ws_id;
     Gint            name;
@@ -1736,6 +1742,7 @@
  *	detectability  : .. same ..  (ANSI standard p117)
  *	priority       : 7, 120, 122, 126 (ANSI standard p117)
  */
+int
 gsetsegattr(name, segattr)
     Gint            name;
     Gsegattr       *segattr;
@@ -1836,6 +1843,7 @@
  *
  * See Also: ANSI Standard p.99
  */
+int
 gsetpickid(pick_id)
     Gint            pick_id;
 {
@@ -1866,6 +1874,7 @@
  *
  * See also: ANSI standard p.113
  */
+Gint
 gassocsegws(ws_id, seg_id)
     Gint            ws_id, seg_id;
 {
@@ -1962,6 +1971,7 @@
  *
  * See also: ANSI standard p.113
  */
+Gint
 gcopysegws(ws_id, seg_id)
     Gint            ws_id, seg_id;
 {
@@ -2053,6 +2063,7 @@
  *
  * See also: ANSI standard p.114
  */
+Gint
 ginsertseg(seg_id, segtran)
     Gint            seg_id;
     Gfloat          segtran[2][3];
@@ -2138,6 +2149,7 @@
  *
  * See also: ANSI standard p.77
  */
+Gint
 gredrawsegws(ws_id)
     Gint            ws_id;
 {
@@ -2208,6 +2220,7 @@
  * XgksDeleteAllSeg (ws)	delete all segments from the workstation
  *
  */
+void
 XgksDeleteAllSeg(ws)
     WS_STATE_PTR    ws;
 {
@@ -2286,6 +2299,7 @@
  *			clip->rec; else build one with value = clip->rec
  *			append to list.
  */
+void
 XgksAppendSegClip()
 {
     SEG_STATE_PTR   seg;
@@ -2398,6 +2412,7 @@
  *				this function should only be called be re-draw
  *				initialted.
  */
+void
 XgksReDrawSeg(ws, seg_id)
     WS_STATE_PTR    ws;
     Gint            seg_id;
@@ -2430,6 +2445,7 @@
 /*
  * XgksShowPick -- bound or unbound the picked segment for 1 second
  */
+void
 XgksShowPick(ws, seg)
     WS_STATE_PTR    ws;
     SEG_STATE_PTR   seg;
@@ -2545,6 +2561,7 @@
  * Do gredrawsegws() - with no error checking and no MO output
  *
  */
+void
 XgksReDrawSegWs(ws)
     WS_STATE_PTR    ws;
 {
@@ -2563,6 +2580,7 @@
 }
 
 
+void
 XgksSetLineAttrMo(ws, lnattr)
     WS_STATE_PTR    ws;
     Glnattr        *lnattr;
@@ -2573,7 +2591,7 @@
     XgksMoSetGraphicAttrOnWs(ws, 24, lnattr->bundl.colour);
 }
 
-
+void
 XgksSetMarkAttrMo(ws, mkattr)
     WS_STATE_PTR    ws;
     Gmkattr        *mkattr;
@@ -2584,7 +2602,7 @@
     XgksMoSetGraphicAttrOnWs(ws, 28, mkattr->bundl.colour);
 }
 
-
+void
 XgksSetTextAttrMo(ws, txattr, chattr)
     WS_STATE_PTR    ws;
     Gtxattr        *txattr;
@@ -2606,6 +2624,7 @@
 }
 
 
+void
 XgksSetFillPatAttrMo(ws, flattr, ptattr)
     WS_STATE_PTR    ws;
     Gflattr        *flattr;
@@ -2633,6 +2652,7 @@
  *
  * See Also: ANSI Standard p.184
  */
+Gint
 ginqmodsegattr(ws_type, dyn)
     Gchar          *ws_type;
     Gmodseg        *dyn;
@@ -2672,6 +2692,7 @@
  *
  * See Also: ANSI Standard p.151
  */
+Gint
 ginqnameopenseg(seg)
     Gint           *seg;
 {
@@ -2694,6 +2715,7 @@
  *
  * See Also: ANSI Standard p.189
  */
+Gint
 ginqsegattr(segattr)
     Gsegattr       *segattr;
 {
@@ -2727,6 +2749,7 @@
  *
  * See Also: ANSI Standard p.189
  */
+Gint
 ginqassocws(seg, asswk)
     Gint            seg;
     Gintlist       *asswk;
@@ -2769,6 +2792,7 @@
  *
  * See Also: ANSI Standard p.152
  */
+Gint
 ginqsegnames(segs)
     Gintlist       *segs;
 {
@@ -2824,6 +2848,7 @@
  *
  * See Also: ANSI Standard p.166
  */
+Gint
 ginqsegnamesws(ws_id, segs)
     Gint            ws_id;
     Gintlist       *segs;
@@ -2869,6 +2894,7 @@
  *
  * See Also: ANSI Standard p.183
  */
+Gint
 ginqnumsegpri(ws_type, numpri)
     Gchar          *ws_type;
     Gint           *numpri;
@@ -2901,6 +2927,7 @@
  *
  * See Also: ANSI Standard p.148
  */
+Gint
 ginqcurpickid(pickid)
     Gint           *pickid;
 {
--- a/src/lib/c/inqtext.c
+++ b/src/lib/c/inqtext.c
@@ -62,6 +62,7 @@
  *
  * See also: ANSI standard p.171
  */
+Gint
 ginqtextfacil(ws_type, fac)
     Gchar          *ws_type;
     Gtxfac         *fac;
@@ -114,7 +115,7 @@
  *
  * See also: ANSI standard p.171
  */
-
+Gint
 ginqpredtextrep(ws_type, idx, rep)
     Gchar          *ws_type;
     Gint            idx;
@@ -155,6 +156,7 @@
  *
  * See also: ANSI standard p.152
  */
+Gint
 ginqtextindices(ws_id, idxlist)
     Gint            ws_id;
     Gintlist       *idxlist;
@@ -203,6 +205,7 @@
  * See also: ANSI standard p.152
  */
 /*ARGSUSED*/
+Gint
 ginqtextrep(ws_id, idx, type, rep)
     Gint            ws_id;
     Gint            idx;
--- a/src/lib/c/aspect_flags.c
+++ b/src/lib/c/aspect_flags.c
@@ -56,6 +56,7 @@
  *
  * See Also: ANSI Standard p.101
  */
+Gint
 gsetasf(asf)
     Gasfs          *asf;
 {
@@ -87,6 +88,7 @@
 /*
  * XgksInitGksAsf() - give gks_asfs the value GINDIVIDUAL.
  */
+void
 XgksInitGksAsf()
 {
     xgks_state.gks_lnattr.type = GINDIVIDUAL;
--- a/src/lib/c/inqpolylines.c
+++ b/src/lib/c/inqpolylines.c
@@ -62,6 +62,7 @@
  *
  * See also: ANSI standard p.173
  */
+Gint
 ginqlinefacil(ws_type, fac)
     Gchar          *ws_type;
     Glnfac         *fac;
@@ -115,6 +116,7 @@
  *
  * See also: ANSI standard p.171
  */
+Gint
 ginqpredlinerep(ws_type, idx, rep)
     Gchar          *ws_type;
     Gint            idx;
@@ -153,6 +155,7 @@
  *
  * See also: ANSI standard p.154
  */
+Gint
 ginqlineindices(ws_id, idxlist)
     Gint            ws_id;
     Gintlist       *idxlist;
@@ -201,6 +204,7 @@
  * See also: ANSI standard p.152
  */
 /*ARGSUSED*/
+Gint
 ginqlinerep(ws_id, idx, type, rep)
     Gint            ws_id;
     Gint            idx;
--- a/src/lib/c/transforms.c
+++ b/src/lib/c/transforms.c
@@ -149,7 +149,8 @@
 /*
  * XgksInitGksTrans -- initialise gks state list transformation stuff
  */
-XgksInitGksTrans()
+void
+XgksInitGksTrans(void)
 {
     Gint            i;			/* Loop counter */
     Glimit          tmp;		/* temporary limit variable */
@@ -198,6 +199,7 @@
  * XgksInitWssTrans(ws) -- initialize workstation transformation stuff
  *  WS_STATE_PTR ws;
  */
+void
 XgksInitWssTrans(ws)
     WS_STATE_PTR    ws;
 {
@@ -242,6 +244,7 @@
  *
  * See also: ANSI Standard p.107
  */
+Gint
 gsetwindow(trans, window)
     Gint            trans;
     Glimit         *window;
@@ -290,6 +293,7 @@
  *
  * See also: ANSI Standard p.107
  */
+Gint
 gsetviewport(trans, viewport)
     Gint            trans;
     Glimit         *viewport;
@@ -345,6 +349,7 @@
  *
  * See also: ANSI Standard p.107
  */
+Gint
 gsetviewportinputpri(trans, ref_trans, priority)
     Gint            trans, ref_trans;
     Gvpri           priority;
@@ -397,6 +402,7 @@
  *
  * See also: ANSI Standard p.108
  */
+Gint
 gselntran(trans)
     Gint            trans;
 {
@@ -429,6 +435,7 @@
  *
  * See also: ANSI Standard p.108
  */
+Gint
 gsetclip(ind)
     Gclip           ind;
 {
@@ -460,6 +467,7 @@
  *
  * See also: ANSI Standard p.109
  */
+Gint
 gsetwswindow(ws_id, window)
     Gint            ws_id;
     Glimit         *window;
@@ -521,6 +529,7 @@
  * <current.v> are always the same.
  */
 
+Gint
 gsetwsviewport(ws_id, viewport)
     Gint            ws_id;
     Glimit         *viewport;
@@ -572,6 +581,7 @@
  *	current.
  *  WS_STATE_PTR ws;
  */
+void
 XgksUnpendPendingTrans(ws)
     WS_STATE_PTR    ws;
 {
@@ -655,6 +665,7 @@
  *	and world coordinates associated with the viewport that ALL ndcpts
  *	appears in, taking account for the veiwport priority.
  */
+Gint
 XgksFindNTransNpts(num, ndcpts, ntrans, wcpts)
     int             num;		/* Number of points */
     Gpoint         *ndcpts;		/* those points in NDC space */
@@ -729,6 +740,7 @@
  *
  *			  this is done on ALL openedws[]
  */
+void
 XgksUpdateWsClip(ws, bound)
     WS_STATE_PTR    ws;
     Glimit         *bound;
@@ -746,6 +758,7 @@
  * WS_STATE_PTR ws;
  * Glimit *v, *clip
  */
+void
 XgksWsWinInterset(ws, v, clip)
     WS_STATE_PTR    ws;
     Glimit         *v, *clip;
@@ -805,6 +818,7 @@
  *
  * see also : ANSI Standard p.193
  */
+Gint
 gevaltran(ppoint, pshift, angle, pscale, coord, result)
     Gpoint         *ppoint;		/* pointer to the reference point */
     Gpoint         *pshift;		/* Shift vector, w.r.t reference
@@ -893,6 +907,7 @@
  *
  * see also : ANSI Standard p.193
  */
+Gint
 gaccumtran(segtran, ppoint, pshift, angle, pscale, coord, result)
     Gfloat          segtran[2][3];	/* input segment transformation */
     Gpoint         *ppoint;		/* pointer to the reference point */
--- a/src/lib/c/x/xcolours.c
+++ b/src/lib/c/x/xcolours.c
@@ -175,7 +175,7 @@
     if (XcMap_malloc(map, size))
     {
 	/* Initialize mapping table. */
-	register        i;
+	register int       i;
 	for (i = 0; i < map->length; ++i)
 	    map->Xpixels[i] = map->GKSindexes[i] = i;
 
@@ -476,6 +476,7 @@
  *
  * @return		0 if and only if failure.
  */
+int
 XcInit(ws)
     WS_STATE_PTR	ws;		/* the GKS workstation (in/out) */
 {
@@ -560,6 +561,7 @@
  *		 0	Error
  *		 1	Success
  */
+Gint
 XcSetColour(ws, GKSindex, GKSrep)
     WS_STATE_PTR    ws;			/* the GKS workstation */
     Gint            GKSindex;		/* GKS color-index */
@@ -653,6 +655,7 @@
  * OUTPUT: Success flag and modified workstation structure with NULL mapping-
  *	   tables.
  */
+int
 XcEnd(ws)
     WS_STATE_PTR    ws;			/* the GKS workstation */
 {
--- a/src/lib/c/x/xcellarray.c
+++ b/src/lib/c/x/xcellarray.c
@@ -54,6 +54,7 @@
 #endif
 
 
+int
 xXgksCellarray(ws, cell_ptr)
     WS_STATE_PTR    ws;
     CELL_ARRAY_ST  *cell_ptr;
--- a/src/lib/c/inqpmarker.c
+++ b/src/lib/c/inqpmarker.c
@@ -62,6 +62,7 @@
  *
  * See also: ANSI standard p.171
  */
+Gint
 ginqmarkerfacil(ws_type, fac)
     Gchar          *ws_type;
     Gmkfac         *fac;
@@ -111,6 +112,7 @@
  *
  * See also: ANSI standard p.171
  */
+Gint
 ginqpredmarkerrep(ws_type, idx, rep)
     Gchar          *ws_type;
     Gint            idx;
@@ -149,6 +151,7 @@
  *
  * See also: ANSI standard p.152
  */
+Gint
 ginqmarkerindices(ws_id, idxlist)
     Gint            ws_id;
     Gintlist       *idxlist;
@@ -197,6 +200,7 @@
  * See also: ANSI standard p.152
  */
 /*ARGSUSED*/
+Gint
 ginqmarkerrep(ws_id, idx, type, rep)
     Gint            ws_id;
     Gint            idx;
--- a/src/lib/c/x/xSet.c
+++ b/src/lib/c/x/xSet.c
@@ -45,6 +45,7 @@
 #endif
 
 
+void
 xXgksSetForeground(dpy, gc, fg)
     Display        *dpy;
     GC              gc;
@@ -54,6 +55,7 @@
 }
 
 
+void
 xXgksSetLineAttributes(dpy, gc, line_width, line_style, cap_style, join_style)
     Display        *dpy;
     GC              gc;
@@ -66,6 +68,7 @@
 }
 
 
+void
 xXgksSetStipple(dpy, gc, stipple)
     Display        *dpy;
     GC              gc;
@@ -75,6 +78,7 @@
 }
 
 
+void
 xXgksSetDashes(dpy, gc, ws, i)
     Display        *dpy;
     GC              gc;
@@ -86,7 +90,7 @@
 }
 
 
-
+void
 xXgksSetTile(dpy, gc, tile)
     Display        *dpy;
     GC              gc;
@@ -96,6 +100,7 @@
 }
 
 
+void
 xXgksSetClipMask(dpy, gc, pixmap)
     Display        *dpy;
     GC              gc;
@@ -105,6 +110,7 @@
 }
 
 
+void
 xXgksSetPlineClipRectangles(dpy, gc, ws, rectangle)
     Display        *dpy;
     GC              gc;
@@ -121,6 +127,7 @@
 }
 
 
+void
 xXgksSetPmarkerClipRectangles(dpy, gc, ws, rectangle)
     Display        *dpy;
     GC              gc;
@@ -137,6 +144,7 @@
 }
 
 
+void
 xXgksSetFillAreaClipRectangles(dpy, gc, ws, rectangle)
     Display        *dpy;
     GC              gc;
@@ -153,6 +161,7 @@
 }
 
 
+void
 xXgksSetTextClipRectangles(dpy, gc, ws, rectangle)
     Display        *dpy;
     GC              gc;
@@ -169,6 +178,7 @@
 }
 
 
+void
 xXgksSetFillStyle(dpy, gc, fill_style)
     Display        *dpy;
     GC              gc;
--- a/src/lib/c/open_ws.c
+++ b/src/lib/c/open_ws.c
@@ -60,7 +60,7 @@
  *          return TRUE if there is at least one open ws
  *          else return FALSE
  */
-    static
+    static int
 XgksOneOpenWs()
 {
     Gint            i;
@@ -104,7 +104,7 @@
  *
  * set the entry in openedws[].ws_id = ws_id  of gkslist to corresponding ptr
  */
-    static 
+    static  int
 XgksSetWsPtr(ws_id, ws)
     Gint            ws_id;
     WS_STATE_PTR    ws;
@@ -129,7 +129,7 @@
  *
  * return INVALID if there's no empty slot
  */
-    static 
+    static int
 XgksAllocNewWs(ws_id)
     Gint            ws_id;
 {
@@ -196,10 +196,11 @@
  *
  * See also: ANSI standard p.74
  */
+Gint
 gopenws(ws_id, connection, ws_type)
     Gint            ws_id;
-    Gchar          *connection;
-    Gchar          *ws_type;
+    const Gchar          *connection;
+    const Gchar          *ws_type;
 {
     WS_STATE_PTR    ws;			/* workstation state list */
     EWSTYPE         ewstype;		/* corresponding enum-valued ws_type */
@@ -323,6 +324,7 @@
  *
  * See also: ANSI standard p.75
  */
+Gint
 gclosews(ws_id)
     Gint            ws_id;
 {
@@ -431,6 +433,7 @@
  *
  * See also: ANSI standard p.77
  */
+Gint
 gclearws(ws_id, control_flag)
     Gint            ws_id;
     Gclrflag        control_flag;
@@ -551,6 +554,7 @@
  * XgksXReDrawWs (ws)
  *  WS_STATE_PTR ws;        this is an X initiated redraw.
  */
+void
 XgksXReDrawWs(ws)
     WS_STATE_PTR    ws;
 {
@@ -601,6 +605,7 @@
  *
  *	--Steve Emmerson 11/20/91
  */
+void
 XgksGReDrawWs(ws)
     WS_STATE_PTR    ws;
 {
@@ -663,6 +668,7 @@
  *			 workstations
  *
  */
+void
 XgksOutputToWs(primi)
     OUT_PRIMI      *primi;
 {
@@ -690,6 +696,7 @@
  *
  * Will not disable any input devices
  */
+void
 XgksReDrawWs(ws, primi)
     WS_STATE_PTR    ws;
     OUT_PRIMI      *primi;
@@ -740,6 +747,7 @@
  *
  * Well disable all input devices before output and Enable them AFTER output
  */
+void
 XgksDrawToWs(ws, primi)
     WS_STATE_PTR    ws;
     OUT_PRIMI      *primi;
@@ -791,6 +799,7 @@
  *			   segment list
  *
  */
+void
 XgksAppendWsPrimi(primi)
     OUT_PRIMI      *primi;
 {
@@ -816,6 +825,7 @@
  *               if yes, update clip.rec to cliprec.rec, else
  *               append a new CLIP_REC to the list
  */
+void
 XgksAppendWsClip(rec)
     Glimit         *rec;
 {
--- a/src/lib/c/x/xfillarea.c
+++ b/src/lib/c/x/xfillarea.c
@@ -52,6 +52,7 @@
 #endif
 
 
+int
 xXgksFillArea(ws, fill_ptr)
     WS_STATE_PTR    ws;
     FILL_AREA_ST   *fill_ptr;
--- a/src/lib/c/x/xpline.c
+++ b/src/lib/c/x/xpline.c
@@ -197,7 +197,7 @@
     }						/* input points loop */
 }
 
-
+int
 xXgksPolyLine(ws, plin_ptr)
     WS_STATE_PTR    ws;
     PLINE_ST       *plin_ptr;
--- a/src/lib/c/polylines.c
+++ b/src/lib/c/polylines.c
@@ -65,7 +65,8 @@
 /* 
  * XgksInitGksPlines() -- initialise gks state table polyline stuff
  */
-XgksInitGksPlines()
+void
+XgksInitGksPlines(void)
 {
     xgks_state.gks_lnattr.line = 1;		/* line indx */
     xgks_state.gks_lnattr.type = GINDIVIDUAL;	/* type ASF */
@@ -82,6 +83,7 @@
 /*
  * XgksInitWssPlines(ws) - Initialize workstation line bundle talbe
  */
+void
 XgksInitWssPlines(ws)
     WS_STATE_PTR    ws;
 {
@@ -111,6 +113,7 @@
  *
  * See also: ANSI standard p.82
  */
+Gint
 gpolyline(num_pts, pts)
     Gint            num_pts;
     Gpoint         *pts;
@@ -166,6 +169,7 @@
  *
  * See also: ANSI Standard p.89
  */
+Gint
 gsetlineind(idx)
     Gint            idx;
 {
@@ -195,6 +199,7 @@
  *
  * See also: ANSI Standard p.89
  */
+Gint
 gsetlinetype(type)
     Gint            type;
 {
@@ -224,6 +229,7 @@
  *
  * See also: ANSI Standard p.90
  */
+Gint
 gsetlinewidth(width)
     Gfloat          width;
 {
@@ -253,6 +259,7 @@
  *
  * See also: ANSI Standard p.90
  */
+Gint
 gsetlinecolourind(idx)
     Gint            idx;
 {
@@ -283,6 +290,7 @@
  *
  * See also: ANSI Standard p.100
  */
+Gint
 gsetlinerep(ws_id, idx, rep)
     Gint            ws_id;
     Gint            idx;
--- a/src/lib/c/open_gks.c
+++ b/src/lib/c/open_gks.c
@@ -76,6 +76,7 @@
  *
  * See also: Ansi standard p. 74
  */
+int
 gopengks(err_file, memory)
     Gfile          *err_file;
     /*ARGSUSED*/
@@ -110,6 +111,7 @@
  *
  * See also: ANSI standard p.74
  */
+int
 gclosegks()
 {
     /* check for proper state */
--- a/src/lib/c/cellarray.c
+++ b/src/lib/c/cellarray.c
@@ -61,6 +61,7 @@
  *
  * See also: ANSI standard p.85
  */
+int
 gcellarray(rect, dim, row, colour)
     Grect          *rect;
     Gipoint        *dim;
--- a/src/lib/c/ggdp.c
+++ b/src/lib/c/ggdp.c
@@ -26,6 +26,7 @@
  *
  * See also: ANSI standard p.86
  */
+int
 ggdp(npoints, points, function, data)
     Gint            npoints;		/* number of points        */
     Gpoint         *points;		/* points array            */
--- a/src/lib/c/message.c
+++ b/src/lib/c/message.c
@@ -73,6 +73,7 @@
  *
  * See also: ANSI standard p.80
  */
+Gint
 gmessage(ws_id, string)
     Gint            ws_id;
     Gchar          *string;
--- a/src/port/acsite.m4
+++ b/src/port/acsite.m4
@@ -2120,7 +2120,7 @@
 cat << UD_EOF_CONFTEST_C > conftest.c
 changequote(<<,>>)dnl
 #include <stdio.h>
-main()
+int main(int argc, char **argv)
 {
     return readsub((char*)NULL) ? 0 : 1;
 }
--- a/src/lib/c/polymarkers.c
+++ b/src/lib/c/polymarkers.c
@@ -65,6 +65,7 @@
 /* 
  * XgksInitGksPmarkers-- initialise gks state list polymarker stuff
  */
+void
 XgksInitGksPmarkers()
 {
     xgks_state.gks_mkattr.mark = 1;		/* mark indx */
@@ -83,6 +84,7 @@
  * XgksInitWssPmarkers(ws) - send the current INDIVIDUAL attributes and BUNDLE
  *	index to the newly opened workstation ws.
  */
+void
 XgksInitWssPmarkers(ws)
     WS_STATE_PTR    ws;
 {
@@ -112,6 +114,7 @@
  *
  * See Also: ANSI Standard p.82
  */
+Gint
 gpolymarker(num_pts, pts)
     Gint            num_pts;
     Gpoint         *pts;
@@ -167,6 +170,7 @@
  *
  * See Also: ANSI Standard p.92
  */
+Gint
 gsetmarkersize(size)
     Gfloat          size;
 {
@@ -195,6 +199,7 @@
  *
  * See Also: ANSI Standard p.91
  */
+Gint
 gsetmarkertype(type)
     Gint            type;
 {
@@ -223,6 +228,7 @@
  *
  * See Also: ANSI Standard p.92
  */
+Gint
 gsetmarkercolourind(colour)
     Gint            colour;
 {
@@ -251,6 +257,7 @@
  *
  * See Also: ANSI Standard p.91
  */
+Gint
 gsetmarkerind(idx)
     Gint            idx;
 {
@@ -281,6 +288,7 @@
  *
  * See Also: ANSI Standard p.101
  */
+Gint
 gsetmarkerrep(ws_id, idx, rep)
     Gint            ws_id;
     Gint            idx;
--- a/src/lib/c/prmgr.c
+++ b/src/lib/c/prmgr.c
@@ -102,6 +102,7 @@
  *			      primitive with the text for the new one, because
  *			      there should only be one message in the list.
  */
+int
 XgksInsertMesgPrimi(ws, primi)
     WS_STATE_PTR    ws;
     OUT_PRIMI      *primi;
@@ -156,6 +157,7 @@
  *				for the list and copy content of elm over.
  *       OUT_PRIMI *insert_pt	insertion point on the primitive list
  */
+void
 XgksInsertPrimi(insert_pt, elm)
     OUT_PRIMI     **insert_pt, *elm;
 {
@@ -175,6 +177,7 @@
  *			   and will "FREE" all memory associated with them.
  *			   Set head to NULL
  */
+void
 XgksDeletePrimi(head, insert_pt)
     OUT_PRIMI      *head, **insert_pt;
 {
@@ -204,6 +207,7 @@
  *			  to to open segment or should it be append to ws non
  *			  segment primitive list
  */
+void
 XgksProcessPrimi(primi)
     OUT_PRIMI      *primi;
 {
@@ -232,6 +236,7 @@
  *			      corresponding x-calls, they are merely there for
  *			      redraw purpose
  */
+void
 XgksProcessClip(rec)
     Glimit         *rec;
 {
@@ -247,6 +252,7 @@
  * XgksPrimiDump (head)
  *
  */
+void
 XgksPrimiDump(head)
     OUT_PRIMI      *head;
 {
@@ -267,6 +273,7 @@
  *
  * NOTE : everything is in NDC space
  */
+void
 XgksUpdatePrimiBound(primi, bound)
     OUT_PRIMI      *primi;
     Glimit         *bound;
@@ -319,6 +326,7 @@
  *					bound.ymax if pt.y > bound->ymax
  *					bound.ymin if pt.y < bound->ymin
  */
+void
 XgksMiniMax(bound, pt)
     Glimit         *bound;
     Gpoint         *pt;
--- a/src/lib/c/update.c
+++ b/src/lib/c/update.c
@@ -56,6 +56,7 @@
  *
  * See also: ANSI standard p.78
  */
+int
 gupdatews(ws_id, regenflag)
     Gint            ws_id;
     Gregen          regenflag;
--- a/src/lib/fortran/control.fc
+++ b/src/lib/fortran/control.fc
@@ -55,6 +55,7 @@
 #include <limits.h>
 #include "xgks.h"
 #include "gks_defines.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifdef lint
--- a/src/lib/fortran/finqpixel.fc
+++ b/src/lib/fortran/finqpixel.fc
@@ -41,6 +41,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/inputevent.fc
+++ b/src/lib/fortran/inputevent.fc
@@ -50,6 +50,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifdef lint
--- a/src/lib/fortran/inputinit.fc
+++ b/src/lib/fortran/inputinit.fc
@@ -51,6 +51,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 #include "pdrutils.h"
 
@@ -90,6 +91,7 @@
  * See also: ANSI standard p.74
  */
 /*FORTRAN*/
+void
 ginlc(
     int            *wkid,
     int            *lcdnr,
@@ -229,6 +231,7 @@
  * See also: ANSI standard p.74
  */
 /*FORTRAN*/
+void
 ginsk(
     int            *wkid,
     int            *skdnr,
@@ -420,6 +423,7 @@
  * See also: ANSI standard p.74
  */
 /*FORTRAN*/
+void
 ginvl(
     int            *wkid,
     int            *vldnr,
@@ -492,6 +496,7 @@
  * See also: ANSI standard p.74
  */
 /*FORTRAN*/
+void
 ginch(
     int            *wkid,
     int            *chdnr,
@@ -606,6 +611,7 @@
  * See also: ANSI standard p.74
  */
 /*FORTRAN*/
+void
 ginpk(
     int            *wkid,
     int            *pkdnr,
@@ -677,6 +683,7 @@
  * See also: ANSI standard
  */
 /*FORTRAN*/
+void
 ginst(
     int            *wkid,
     int            *stdnr,
@@ -745,6 +752,7 @@
  * See also: ANSI standard
  */
 /*FORTRAN*/
+void
 ginsts(
     int            *wkid,
     int            *stdnr,
--- a/src/lib/fortran/escapes.fc
+++ b/src/lib/fortran/escapes.fc
@@ -94,6 +94,7 @@
  * See also: ANSI standard p.80
  */
 /*FORTRAN*/
+void
 gessdc(int *wsid, float *xsize, float *ysize)
 {
     Gpoint          dcsize;
@@ -116,6 +117,7 @@
  * See also: ANSI standard p.80
  */
 /*FORTRAN*/
+void
 gessrp(int *wsid, int *store)
 {
     STOREAGEFLAG(*store, errgescstoreprimi);
@@ -133,6 +135,7 @@
  *
  */
 /*FORTRAN*/
+void
 gessrn(int *wsid, int (*func)())
 {
     (void) gescredrawnotify(*wsid, func);
@@ -145,6 +148,7 @@
  * char *conid		- server connection identifier
  */
 /*FORTRAN*/
+void
 gescid(
     char     *conid
 )
--- a/src/lib/fortran/inputmode.fc
+++ b/src/lib/fortran/inputmode.fc
@@ -46,6 +46,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/inputreq.fc
+++ b/src/lib/fortran/inputreq.fc
@@ -49,6 +49,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifdef lint
--- a/src/lib/fortran/inputsamp.fc
+++ b/src/lib/fortran/inputsamp.fc
@@ -48,6 +48,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifdef lint
--- a/src/lib/fortran/inqerrlist.fc
+++ b/src/lib/fortran/inqerrlist.fc
@@ -40,6 +40,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/inqgksdesc.fc
+++ b/src/lib/fortran/inqgksdesc.fc
@@ -41,6 +41,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/inqgkslist.fc
+++ b/src/lib/fortran/inqgkslist.fc
@@ -74,6 +74,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/inqseglist.fc
+++ b/src/lib/fortran/inqseglist.fc
@@ -40,6 +40,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/inqstate.fc
+++ b/src/lib/fortran/inqstate.fc
@@ -39,6 +39,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/inqwsdesc.fc
+++ b/src/lib/fortran/inqwsdesc.fc
@@ -59,6 +59,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifdef lint
--- a/src/lib/fortran/inqwslist.fc
+++ b/src/lib/fortran/inqwslist.fc
@@ -53,6 +53,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifdef lint
--- a/src/lib/fortran/meta.fc
+++ b/src/lib/fortran/meta.fc
@@ -41,6 +41,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/output.fc
+++ b/src/lib/fortran/output.fc
@@ -46,6 +46,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifdef lint
--- a/src/lib/fortran/rep.fc
+++ b/src/lib/fortran/rep.fc
@@ -44,6 +44,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifdef lint
--- a/src/lib/fortran/segattr.fc
+++ b/src/lib/fortran/segattr.fc
@@ -43,6 +43,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/segment.fc
+++ b/src/lib/fortran/segment.fc
@@ -46,6 +46,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/transform.fc
+++ b/src/lib/fortran/transform.fc
@@ -44,6 +44,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/lib/fortran/utils.fc
+++ b/src/lib/fortran/utils.fc
@@ -41,6 +41,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 #include "pdrutils.h"
 
--- a/src/lib/fortran/wsioutattr.fc
+++ b/src/lib/fortran/wsioutattr.fc
@@ -43,6 +43,7 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "fortxgks.h"
 
 #ifndef lint
--- a/src/fontdb/mkfont.c
+++ b/src/fontdb/mkfont.c
@@ -40,6 +40,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
--- a/src/progs/defcolors.c
+++ b/src/progs/defcolors.c
@@ -41,6 +41,7 @@
 
 #include "udposix.h"
 #include "xgks.h"
+#include "gks_implem.h"
 #include <string.h>
 #include "demo.h"
 
--- a/src/progs/font.c
+++ b/src/progs/font.c
@@ -41,9 +41,11 @@
 #include "udposix.h"
 #include <stdlib.h>		/* for atof() */
 #include <stdio.h>
+#include <unistd.h>
 #include <string.h>
 #include <ctype.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "demo.h"
 
 Gint            ws_id = 1;
@@ -53,6 +55,8 @@
 Glimit          wsw;
 Glimit          wsv;
 
+void test_font(int nfonts);
+void SetColor(int hash);
 
     static int
 show_font(font)
@@ -111,7 +115,7 @@
     return 1;
 }
 
-
+int
 main(argc, argv)
     int             argc;
     char           *argv[];
@@ -212,7 +216,7 @@
     return 0;
 }
 
-
+void
 perr(i, s)
     int             i;
     char           *s;
@@ -230,6 +234,7 @@
 };
 
 
+void
 test_font(nfonts)
     int             nfonts;
 {
@@ -283,6 +288,7 @@
 }
 
 
+void
 SetColor(hash)
     Gint            hash;
 {
--- a/src/progs/hanoi.c
+++ b/src/progs/hanoi.c
@@ -47,8 +47,11 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
 #include <math.h>
 #include <xgks.h>
+#include "gks_implem.h"
 #include "demo.h"
 
 #define TOWERSPC 9.0
@@ -60,12 +63,28 @@
  */
 static int	n	= 5;
 
+/*
+ * tower data structures and manipulation
+ */
+
+Gfloat          tcount[3] = {0.2, 0.2, 0.2};
+
+int             towers[3][10] =
+    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
+
+int             towerx[3] = {0, 0, 0};
+
+Gpoint          pathpts[4] = {{0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}};
+
 
 /*
  * Set up the color table.
  */
-    static void
+void
 SetColor(id)
+     int id;
 {
     Gcobundl	rep;
 
@@ -122,122 +141,10 @@
     return;
 }
 
-
-main(argc, argv)
-    int             argc;
-    char           *argv[];
-{
-    Gint            ws_id	= 1;
-    Gint            mo_id	= 3;
-    Glimit          WsWindow;
-    char           *conn	= (char *) NULL;
-    char           *mo_path	= "hanoi.gksm";
-    int             c;
-    extern char    *optarg;
-    extern int      optind;
-
-    WsWindow.xmin = 0.0;
-    WsWindow.xmax = 1.0;
-    WsWindow.ymin = 0.0;
-    WsWindow.ymax = 0.8;
-
-    while ((c = getopt(argc, argv, "d:n:o:")) != -1) {
-	switch (c) {
-	case 'd':
-	    conn	= optarg;
-	    break;
-	case 'n':
-	    n		= atoi(optarg);
-	    break;
-	case 'o':
-	    mo_path	= optarg;
-	    break;
-	}
-    }
-
-    gopengks(stdout, 0);
-
-    gopenws(ws_id, conn, conn);
-    gopenws(mo_id, mo_path, "MO");
-
-    gactivatews(ws_id);
-    gactivatews(mo_id);
-
-    SetColor(ws_id);
-    SetColor(mo_id);
-
-    gsetwswindow(ws_id, &WsWindow);
-    gsetwswindow(mo_id, &WsWindow);
-
-    title();
-
-    /*
-     * solve the problem
-     */
-    inittower(n);
-    f(n, 0, 1, 2);
-
-    /*
-     * close workstation and GKS
-     */
-    WaitForBreak(ws_id);
-    gdeactivatews(mo_id);
-    gdeactivatews(ws_id);
-    gclosews(mo_id);
-    gclosews(ws_id);
-    gclosegks();
-
-    return 0;
-}
-
-
-/*
- * transfer n disks from tower a to tower b using c as a spare
- *
- *		transfer n-1 from a to c using b
- *		move 1 from a to b
- *		transfer n-1 from c to b using a
- */
-f(n, a, b, c)
-    int             n;
-    int             a;
-    int             b;
-    int             c;
-{
-    if (n == 0)
-	return;
-
-    f(n - 1, a, c, b);
-    movedisk(a, b);
-    f(n - 1, c, b, a);
-}
-
-
-box(l)
-    Glimit         *l;
-{
-    Gpoint          pts[5];
-
-#define e 0.01
-
-    pts[0].x = l->xmin + e;
-    pts[0].y = l->ymin + e;
-    pts[1].x = l->xmin + e;
-    pts[1].y = l->ymax - e;
-    pts[2].x = l->xmax - e;
-    pts[2].y = l->ymax - e;
-    pts[3].x = l->xmax - e;
-    pts[3].y = l->ymin + e;
-    pts[4].x = l->xmin + e;
-    pts[4].y = l->ymin + e;
-    gsetfillcolorind(WHITE);
-    gfillarea(5, pts);
-}
-
-
 /*
  * print title across top of page
  */
+void
 title()
 {
     Gpoint          p;
@@ -282,90 +189,7 @@
     gtext(&p, "Tower of Hanoi");
 }
 
-
-/*
- * initialize towers with all disks on tower 0.
- */
-inittower(n)
-    int             n;
-{
-    Glimit          Window;
-    Glimit          Viewport;
-    int             i;
-
-    Window.xmin = 0.0;
-    Window.xmax = WINDWD;
-    Window.ymin = 0.0;
-    Window.ymax = WINDHT;
-
-    Viewport.xmin = 0.1;
-    Viewport.xmax = 0.9;
-    Viewport.ymin = 0.06;
-    Viewport.ymax = 0.54;
-
-    gsetwindow(1, &Window);
-    gsetviewport(1, &Viewport);
-    border(0.0, WINDWD, 0.0, WINDHT);
-
-    for (i = n; i > 0; i--)
-	placedisk(0, i);
-}
-
-
-/*
- * tower data structures and manipulation
- */
-
-Gfloat          tcount[3] = {0.2, 0.2, 0.2};
-
-int             towers[3][10] =
-    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
-
-int             towerx[3] = {0, 0, 0};
-
-
-movedisk(a, b)
-{
-    int             diskno;
-
-    path(a, b);
-    diskno = DiskRemove(a);
-    unpath();
-    placedisk(b, diskno);
-}
-
-
-placedisk(tower, diskno)
-    int             tower, diskno;
-{
-    gsetfillcolorind(diskno);
-    gsetfillintstyle(GSOLID);
-
-    disk(diskno, TOWERSPC * (1 + tower) - (Gfloat) (diskno) / 
-		 2.0, tcount[tower]);
-    tcount[tower] += (Gfloat) diskno;
-    pushdisk(tower, diskno);
-}
-
-
-DiskRemove(tower)
-    int             tower;
-{
-    int             diskno;
-
-    diskno = popdisk(tower);
-    gsetfillcolorind(0);
-    gsetfillintstyle(GSOLID);
-
-    tcount[tower] -= (Gfloat) diskno;
-    disk(diskno,
-	 TOWERSPC * (1 + tower) - (Gfloat) (diskno) / 2.0, tcount[tower]);
-    return diskno;
-}
-
-
+void
 disk(diskno, x, y)
     int             diskno;
     Gfloat          x, y;
@@ -388,14 +212,36 @@
     gfillarea(4, pts);
 }
 
+int
+popdisk(tower)
+    int             tower;
+{
 
-Gpoint          pathpts[4] = {{0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}};
+    towerx[tower]--;
+    return towers[tower][towerx[tower]];
+}
 
+int
+DiskRemove(tower)
+    int             tower;
+{
+    int             diskno;
+
+    diskno = popdisk(tower);
+    gsetfillcolorind(0);
+    gsetfillintstyle(GSOLID);
+
+    tcount[tower] -= (Gfloat) diskno;
+    disk(diskno,
+	 TOWERSPC * (1 + tower) - (Gfloat) (diskno) / 2.0, tcount[tower]);
+    return diskno;
+}
 
 /*
  * draw a line from top disk of tower a to top of screen, then over
  * to tower b.
  */
+void
 path(a, b)
     int             a, b;
 {
@@ -414,14 +260,95 @@
     gpolyline(4, pathpts);
 }
 
-
+void
 unpath()
 {
     gsetlinecolorind(0);
     gpolyline(4, pathpts);
 }
 
+void
+pushdisk(tower, diskno)
+    int             tower, diskno;
+{
+    towers[tower][towerx[tower]] = diskno;
+    towerx[tower]++;
+}
+
+void
+placedisk(tower, diskno)
+    int             tower, diskno;
+{
+    gsetfillcolorind(diskno);
+    gsetfillintstyle(GSOLID);
+
+    disk(diskno, TOWERSPC * (1 + tower) - (Gfloat) (diskno) / 
+		 2.0, tcount[tower]);
+    tcount[tower] += (Gfloat) diskno;
+    pushdisk(tower, diskno);
+}
 
+void
+movedisk(a, b)
+     int a, b;
+{
+    int             diskno;
+
+    path(a, b);
+    diskno = DiskRemove(a);
+    unpath();
+    placedisk(b, diskno);
+}
+
+/*
+ * transfer n disks from tower a to tower b using c as a spare
+ *
+ *		transfer n-1 from a to c using b
+ *		move 1 from a to b
+ *		transfer n-1 from c to b using a
+ */
+void
+f(n, a, b, c)
+    int             n;
+    int             a;
+    int             b;
+    int             c;
+{
+    if (n == 0)
+	return;
+
+    f(n - 1, a, c, b);
+    movedisk(a, b);
+    f(n - 1, c, b, a);
+}
+
+
+
+
+void
+box(l)
+    Glimit         *l;
+{
+    Gpoint          pts[5];
+
+#define e 0.01
+
+    pts[0].x = l->xmin + e;
+    pts[0].y = l->ymin + e;
+    pts[1].x = l->xmin + e;
+    pts[1].y = l->ymax - e;
+    pts[2].x = l->xmax - e;
+    pts[2].y = l->ymax - e;
+    pts[3].x = l->xmax - e;
+    pts[3].y = l->ymin + e;
+    pts[4].x = l->xmin + e;
+    pts[4].y = l->ymin + e;
+    gsetfillcolorind(WHITE);
+    gfillarea(5, pts);
+}
+
+
+void
 border(x1, x2, y_1, y2)
     Gfloat          x1, x2, y_1, y2;
 {
@@ -445,18 +372,115 @@
 }
 
 
-pushdisk(tower, diskno)
-    int             tower, diskno;
+/*
+ * initialize towers with all disks on tower 0.
+ */
+void
+inittower(n)
+    int             n;
 {
-    towers[tower][towerx[tower]] = diskno;
-    towerx[tower]++;
+    Glimit          Window;
+    Glimit          Viewport;
+    int             i;
+
+    Window.xmin = 0.0;
+    Window.xmax = WINDWD;
+    Window.ymin = 0.0;
+    Window.ymax = WINDHT;
+
+    Viewport.xmin = 0.1;
+    Viewport.xmax = 0.9;
+    Viewport.ymin = 0.06;
+    Viewport.ymax = 0.54;
+
+    gsetwindow(1, &Window);
+    gsetviewport(1, &Viewport);
+    border(0.0, WINDWD, 0.0, WINDHT);
+
+    for (i = n; i > 0; i--)
+	placedisk(0, i);
 }
 
 
-popdisk(tower)
-    int             tower;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+int main(argc, argv)
+    int             argc;
+    char           *argv[];
 {
+    Gint            ws_id	= 1;
+    Gint            mo_id	= 3;
+    Glimit          WsWindow;
+    char           *conn	= (char *) NULL;
+    char           *mo_path	= "hanoi.gksm";
+    int             c;
+    extern char    *optarg;
+    extern int      optind;
 
-    towerx[tower]--;
-    return towers[tower][towerx[tower]];
+    WsWindow.xmin = 0.0;
+    WsWindow.xmax = 1.0;
+    WsWindow.ymin = 0.0;
+    WsWindow.ymax = 0.8;
+
+    while ((c = getopt(argc, argv, "d:n:o:")) != -1) {
+	switch (c) {
+	case 'd':
+	    conn	= optarg;
+	    break;
+	case 'n':
+	    n		= atoi(optarg);
+	    break;
+	case 'o':
+	    mo_path	= optarg;
+	    break;
+	}
+    }
+
+    gopengks(stdout, 0);
+
+    gopenws(ws_id, conn, conn);
+    gopenws(mo_id, mo_path, "MO");
+
+    gactivatews(ws_id);
+    gactivatews(mo_id);
+
+    SetColor(ws_id);
+    SetColor(mo_id);
+
+    gsetwswindow(ws_id, &WsWindow);
+    gsetwswindow(mo_id, &WsWindow);
+
+    title();
+
+    /*
+     * solve the problem
+     */
+    inittower(n);
+    f(n, 0, 1, 2);
+
+    /*
+     * close workstation and GKS
+     */
+    WaitForBreak(ws_id);
+    gdeactivatews(mo_id);
+    gdeactivatews(ws_id);
+    gclosews(mo_id);
+    gclosews(ws_id);
+    gclosegks();
+
+    return 0;
 }
+
--- a/src/progs/demo.h
+++ b/src/progs/demo.h
@@ -55,7 +55,7 @@
 #define MEDIUMGRAY BEIGE
 
     static
-WaitForBreak( ws_id )
+int WaitForBreak( ws_id )
     Gint       ws_id;
 {
     Gchoice    init;
--- a/src/progs/mi.c
+++ b/src/progs/mi.c
@@ -41,7 +41,9 @@
 #include "udposix.h"
 #include <stdlib.h>
 #include <stdio.h>
+#include <unistd.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include "demo.h"
 
 #define CLEAR_WORKSTATION	1
@@ -51,6 +53,7 @@
 #define MO_WSID			3	/* Output Metafile workstation ID */
 
 
+int
 main(argc, argv)
     int             argc;
     char           *argv[];
--- a/src/progs/pline.c
+++ b/src/progs/pline.c
@@ -42,9 +42,10 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include "xgks.h"
+#include "gks_implem.h"
 #include <stdlib.h>
 
-    static
+int
 WaitForBreak(wsid)
     Gint            wsid;
 {
@@ -67,42 +68,9 @@
 }
 
 
-main(argc, argv)
-    /*ARGSUSED*/
-    int             argc;
-    char           *argv[];
-{
-    Gint            ws_id = 1;
-    Gint            result;
-
-    if ((result = gopengks(stdout, 0)) != 0)
-	perr(result, "...open_gks");
-
-    if ((result = gopenws(ws_id, argv[1], argv[1])) != 0)
-	perr(result, "...open_ws");
-
-    if ((result = gactivatews(ws_id)) != 0)
-	perr(result, "...activate_ws");
-
-    test_pline(ws_id);
-
-    (void) fprintf(stderr, "Done, press break...\n");
-
-    WaitForBreak(1);
-
-    if ((result = gdeactivatews(ws_id)) != 0)
-	perr(result, "...deactivate_ws");
-
-    if ((result = gclosews(ws_id)) != 0)
-	perr(result, "...close_ws");
-
-    if ((result = gclosegks()) != 0)
-	perr(result, "...close_gks");
-
-    return 0;
-}
 
 
+void
 perr(i, s)
     int             i;
     char           *s;
@@ -147,7 +115,7 @@
 int             lntbl[] = {GLN_LDASH, GLN_DDOTDASH, GLN_SDASH, GLN_SOLID,
 			   GLN_DASH, GLN_DOT, GLN_DOTDASH};
 
-
+void
 test_pline(ws_id)
     Gint	    ws_id;
 {
@@ -207,3 +175,39 @@
 	gpolyline(2, lpts);
     }
 }
+
+int
+main(argc, argv)
+    /*ARGSUSED*/
+    int             argc;
+    char           *argv[];
+{
+    Gint            ws_id = 1;
+    Gint            result;
+
+    if ((result = gopengks(stdout, 0)) != 0)
+	perr(result, "...open_gks");
+
+    if ((result = gopenws(ws_id, argv[1], argv[1])) != 0)
+	perr(result, "...open_ws");
+
+    if ((result = gactivatews(ws_id)) != 0)
+	perr(result, "...activate_ws");
+
+    test_pline(ws_id);
+
+    (void) fprintf(stderr, "Done, press break...\n");
+
+    WaitForBreak(1);
+
+    if ((result = gdeactivatews(ws_id)) != 0)
+	perr(result, "...deactivate_ws");
+
+    if ((result = gclosews(ws_id)) != 0)
+	perr(result, "...close_ws");
+
+    if ((result = gclosegks()) != 0)
+	perr(result, "...close_gks");
+
+    return 0;
+}
--- a/src/progs/pmark.c
+++ b/src/progs/pmark.c
@@ -42,9 +42,9 @@
 #include <stdio.h>
 #include <string.h>
 #include "xgks.h"
+#include "gks_implem.h"
 
-
-    static
+	int
 WaitForBreak(ws_id)
     Gint            ws_id;
 {
@@ -71,47 +71,7 @@
 Gint            result;
 
 
-main(argc, argv)
-    int             argc;
-    char           *argv[];
-{
-    Gchar          *conn = (char *) NULL;
-    Gint            i;
-
-    for (i = 1; i < argc; i++) {
-	if (strchr(argv[i], ':'))
-	    conn = argv[i];
-    }
-
-    if ((result = gopengks(stdout, 0)) != 0)
-	perr(result, "...open_gks");
-
-    if ((result = gopenws(ws_id, conn, conn)) != 0)
-	perr(result, "...open_ws");
-
-    if ((result = gactivatews(ws_id)) != 0)
-	perr(result, "...activate_ws");
-
-    test_pmark();
-
-    (void) fprintf(stderr, "Done, press break...\n");
-
-    WaitForBreak(1);
-
-    if ((result = gdeactivatews(ws_id)) != 0)
-	perr(result, "...deactivate_ws");
-
-    if ((result = gclosews(ws_id)) != 0)
-	perr(result, "...close_ws");
-
-    if ((result = gclosegks()) != 0)
-	perr(result, "...close_gks");
-    (void) fprintf(stdout, "after close_gks\n");
-
-    return 0;
-}
-
-
+void
 perr(i, s)
     int             i;
     char           *s;
@@ -171,6 +131,7 @@
 };
 
 
+void
 test_pmark()
 {
     Gpoint          tpt, pt;
@@ -229,3 +190,44 @@
 	}
     }
 }
+
+int
+main(argc, argv)
+    int             argc;
+    char           *argv[];
+{
+    Gchar          *conn = (char *) NULL;
+    Gint            i;
+
+    for (i = 1; i < argc; i++) {
+	if (strchr(argv[i], ':'))
+	    conn = argv[i];
+    }
+
+    if ((result = gopengks(stdout, 0)) != 0)
+	perr(result, "...open_gks");
+
+    if ((result = gopenws(ws_id, conn, conn)) != 0)
+	perr(result, "...open_ws");
+
+    if ((result = gactivatews(ws_id)) != 0)
+	perr(result, "...activate_ws");
+
+    test_pmark();
+
+    (void) fprintf(stderr, "Done, press break...\n");
+
+    WaitForBreak(1);
+
+    if ((result = gdeactivatews(ws_id)) != 0)
+	perr(result, "...deactivate_ws");
+
+    if ((result = gclosews(ws_id)) != 0)
+	perr(result, "...close_ws");
+
+    if ((result = gclosegks()) != 0)
+	perr(result, "...close_gks");
+    (void) fprintf(stdout, "after close_gks\n");
+
+    return 0;
+}
