www.c
上传用户:zlh9724
上传日期:2007-01-04
资源大小:1991k
文件大小:61k
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include <signal.h>
- #include <sys/types.h>
- #include <sys/time.h>
- #if 0
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
- #include <X11/keysym.h>
- #include <X11/cursorfont.h>
- #ifdef __hpux
- #include <X11/HPkeysym.h>
- #endif
- #endif
- #ifndef NFDBITS
- #define NFDBITS 0
- #endif
- #include "www.h"
- #include "popup.h"
- #include "style.h"
- #include "neweditor.h"
- #ifndef XK_DeleteChar
- #define XK_DeleteChar XK_Delete
- #endif
- #define BITMAPDEPTH 1
- /* values for window_size in main, is window big enough to be useful */
- #define SMALL 1
- #define OK 0
- extern int statusHeight;
- extern int sbar_width;
- extern int ToolBarHeight;
- extern long PixelOffset;
- extern long buf_height;
- extern int PixelIndent;
- extern int buf_width;
- extern char *buffer;
- extern int hdrlen;
- extern int Authorize;
- extern int OpenURL;
- extern int IsIndex;
- extern int SaveFile;
- extern int FindStr;
- extern char *FindStrVal, *FindNextStr;
- extern int font;
- extern Field *focus;
- extern Frame background;
- extern Byte *paint;
- extern Bool TextFieldFocus;
- extern double lens_factor;
- extern GC disp_gc, gc_fill;
- int debug = 0; /* used to control reporting of errors */
- int initialised = 0; /* avoid X output until this is true! */
- int busy = 0; /* blocks hypertext links etc while receiving data */
- int UseHTTP2 = 1; /* use new HTRQ/HTTP protocol */
- int OpenSubnet = 0; /* if true host is on OpenSubnet */
- int UsePaper = 1;
- int fontsize = 0;
- int NoTerminal = 0; /* howcome 5/11/94: can we ask for passwd? */
- char *CacheRoot = "/tmp"; /* howcome 5/10/94: command line option to turn caching on */
- char *Printer = NULL; /* howcome 5/10/94: command line option enables printing */
- char *Editor = NULL; /* howcome 5/10/94: command line option turns the editor on */
- int Badflags = 5; /* howcome 5/10/94: how many badflags do we want in the output */
- char *Icon = NULL; /* howcome 5/10/94: command line option turns the use of icon */
- double Gamma = 2.2; /* howcome 7/11/94: made into command line option */
- int NoMailcap = 0; /* howcome 7/11/94 */
- BOOL NoStyle = FALSE; /* howcome 2/3/95 */
- BOOL Quiet = FALSE; /* howcome 10/8/95 */
- BOOL OwnColorMap = FALSE; /* howcome 10/8/95 */
- Atom ARENA_LOCATION;
- Atom ARENA_COMMAND;
- long main_stack[256];
- long *stack;
- int library_trace = 0; /* howcome 20/11/94 */
- Doc *CurrentDoc;
- Context *context;
- /* Display and screen are used as arguments to nearly every Xlib
- * routine, so it simplifies routine calls to declare them global.
- * If there were additional source files, these variables would be
- * declared `extern' in them.
- */
- Display *display;
- Visual *visual;
- Colormap colormap;
- int screen;
- int depth;
- Window win;
- int ExposeCount; /* used to monitor GraphicsExpose events during scrolling */
- char *prog; /* name of invoking program */
- int default_pixmap_width, default_pixmap_height;
- Pixmap background_pixmap, default_pixmap;
- Pixmap icon_pixmap;
- Cursor hourglass;
- int shape;
- unsigned long textColor, labelColor, windowColor, strikeColor, statusColor,
- transparent, windowTopShadow, windowBottomShadow, windowShadow;
- #ifdef SELECTION
- unsigned long statusSelectColor; /* howcome */
- static char *selectStr=NULL; /* howcome 2/8/94 */
- #endif
- int charWidth, charHeight, charAscent, lineHeight;
- unsigned int win_width, win_height, tileWidth, tileHeight;
- unsigned char *tileData;
- /*int document;*/
- int gadget;
- int gatewayport = 3000; /* GATEWAYPORT; */
- char *gateway; /* gateway if can't access server directly */
- char *help;
- /* char *printer; */ /* howcome 16/10/94 */
- char *startwith; /* default initial document */
- char *user;
- int RepeatButtonDown = 0;
- XFontStruct *fixed_font;
- XFontStruct *Fonts[FONTS]; /* array of fonts */
- char *FontsName[FONTS];
- int LineSpacing[FONTS];
- int BaseLine[FONTS];
- int StrikeLine[FONTS];
- int LineThickness[FONTS];
- int ListIndent1, ListIndent2;
- GC gc_fill;
- static GC gc_scrollbar, gc_status, gc_text;
- static char *display_name = NULL;
- static int window_size = 0; /* OK or SMALL to display contents */
- static int button_x, button_y;
- static XSizeHints size_hints;
- int ColorStyle;
- unsigned int display_width, display_height;
- double display_pt2px;
- struct itimerval itimer, old_itimer;
- void ShowBusy()
- {
- XDefineCursor(display, win, hourglass);
- XFlush(display);
- busy = 1;
- }
- void HideBusy()
- {
- XUndefineCursor(display, win);
- XFlush(display);
- busy = 0;
- }
- /* From Scott Nelson <snelson@canopus.llnl.gov> 24 bit color 1/12/94 */
- /* these are here for speed reasons */
- int RPixelShift=16, GPixelShift=8, BPixelShift=0;
- int RPixelMask=0xff, GPixelMask=0xff, BPixelMask=0xff;
- /* pause for delay milliseconds */
- /* howcome moved this from tcp.c 20/9/94 */
- void Pause(int delay)
- {
- struct timeval timer;
- timer.tv_sec = 0;
- timer.tv_usec = delay * 1000;
- select(NFDBITS, 0, 0, 0, &timer);
- }
- void CatchCore()
- {
- fprintf(stderr,"CATCH_CORE %d%cn",(int)getpid(),7);
- Exit(1);
- }
- void CatchQuit()
- {
- fprintf(stderr,"CATCH_QUITn");
- Exit(1);
- }
- void CatchX(Display * err_dpy_p, XErrorEvent *err_event)
- {
- fprintf(stderr,"catchX pid %dn", (int)getpid());
- }
- /* howcome 4/10/94: need to clean the library cache.. */
- int Exit(int i)
- {
- if (VERBOSE_TRACE)
- printf("bridge.c: Exitn");
- libExit(0);
- printf("nThanks for using %s %s. The authors -- Dave, Hakon, Henrik nand Yves -- can be reached at arena@w3.org. nPlease check %s nbefore reporting bugs.n", BANNER, VERSION, HELP_URL);
- exit(i);
- }
- /* find best visual for specified visual class */
- Visual *BestVisual(int class, int *depth)
- {
- long visual_info_mask;
- int number_visuals, i, best_depth;
- XVisualInfo *visual_array, visual_info_template;
- Visual *best_visual;
- visual_info_template.class = class;
- visual_info_template.screen = DefaultScreen(display);
- visual_info_mask = VisualClassMask | VisualScreenMask;
- visual_array = XGetVisualInfo(display, visual_info_mask,
- &visual_info_template,
- &number_visuals);
- *depth = 0;
- best_depth = 0; /* *depth */
- best_visual = 0;
-
- for (i = 0; i < number_visuals; ++i)
- {
- if (visual_array[i].depth > *depth)
- {
- best_visual = visual_array[i].visual;
- *depth = visual_array[i].depth;
- }
- if (*depth == best_depth)
- break;
- }
- XFree((void *)visual_array);
- return best_visual;
- }
- #ifdef SELECTION
- void SetSelection(char *s) /* howcome 2/8/94 */
- {
- Free(selectStr);
- selectStr = strdup(s);
- XSetSelectionOwner(display, XA_PRIMARY, win, CurrentTime);
- XStoreBytes(display, selectStr, strlen(selectStr));
- }
- #endif
- /* send myself an expose event to force redrawing of give rectangle */
- void Redraw(int x, int y, int w, int h)
- {
- XExposeEvent event;
- event.type = Expose;
- event.serial = 0;
- event.send_event = 1;
- event.display = display;
- event.window = win;
- event.x = x;
- event.y = y;
- event.width = w;
- event.height = h;
- event.count = 0;
- if (X_TRACE)
- fprintf(stderr,"Redrawn");
- XSendEvent(display, win, 0, ExposureMask, (XEvent *)&event);
- }
- void SetBanner(char *title)
- {
- XTextProperty textprop;
- /* Support multiple <TITLE>s in a document */
- if(CurrentDoc->title)
- free(CurrentDoc->title);
- CurrentDoc->title = strdup(title);
- XStoreName(display, win, title);
- if(CurrentDoc->url)
- {
- char *v;
- int v_size;
- v_size = strlen(title)+strlen(CurrentDoc->url)+13; /* 13: 'URL='(string) 'TITLE='(string)