Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtlogin / vg.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: vg.h /main/10 1998/09/14 18:30:15 mgreess $ */
24 /*                                                                      *
25  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
26  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
27  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
28  * (c) Copyright 1993, 1994 Novell, Inc.                                *
29  */
30 /************************************<+>*************************************
31  ****************************************************************************
32  **
33  **   File:        vg.h
34  **
35  **   Project:     HP Visual User Environment (DT)
36  **
37  **   Description: Main header file for Dtgreet application.
38  **
39  **                Defines, structure definitions, and external declarations
40  **                are specified here.
41  **
42  **
43  **   (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
44  **
45  **
46  **
47  ****************************************************************************
48  ************************************<+>*************************************/
49
50 #ifndef _VG_H
51 #define _VG_H
52
53 #include <X11/Xosdefs.h>
54 #include <errno.h>
55 #ifdef X_NOT_STDC_ENV
56 extern int errno;
57 #endif
58
59 #include        <sys/errno.h>
60 #include        <sys/param.h>
61 #include        <stdlib.h>
62 #include        <Xm/Xm.h>
63 #include        "vgproto.h"
64
65 #ifdef BLS
66 #    include <sys/security.h>
67 #endif
68
69
70 #ifdef SIGNALRETURNSINT
71 #define SIGVAL int
72 #else
73 #define SIGVAL void
74 #endif
75
76
77 /****************************************************************************
78  *
79  *  Defines
80  *
81  ****************************************************************************/
82
83
84 /*
85  * SAIC DT copyright is in a dt directory
86  */
87 #if defined( _SUN_OS )
88 #  define COPYRIGHT             "/usr/lib/X11/dt/etc/copyright"
89 #else
90 #  if defined( __hp_osf )
91 #     define COPYRIGHT          "/usr/X11/copyright"
92 #  else
93 #     define COPYRIGHT          "/etc/copyright"
94 #  endif
95 #endif
96
97 #define NO_LOGIN_FILE           "/etc/nologin"
98
99 #define DTLITESESSION           "/usr/dt/bin/dtlitesession"
100
101 #define LOGIN_STR_LEN 1024
102
103 /*
104  *  option menu items...
105  */
106
107 #define OB_RESTART_SERVER       1
108 #define OB_NO_WINDOWS           2
109 #define OB_COPYRIGHT            3
110 #define OB_FAILSAFE             4
111 #define OB_LANGUAGE             5
112 #define OB_DTLITE               6
113 #define OB_DT                   7
114 #define OB_ALT_DTS              8
115 #define OB_LAST_DT              10
116  
117 #ifndef LAST_SESSION_FILE
118 #define LAST_SESSION_FILE "/.dt/sessions/lastsession"
119 #endif
120
121 #ifndef DEF_SESSION
122 #define DEF_SESSION CDE_INSTALLATION_TOP "/bin/Xsession"
123 #endif
124
125 /*
126  *  default resources...  (Dimensions are in units of 100TH_MILLIMETER)
127  *
128  *  - width/height of main matte
129  *  - percentage offsets of login matte within main matte
130  *  - shadow thickness
131  *  - margin height for message box buttons
132  *  - fonts
133  *  - colors
134  */
135
136 #ifndef XmNPIXELS
137 #define XmNPIXELS               "PIXELS"
138 #endif
139
140 #ifndef XmN100TH_MILLIMETERS
141 #define XmN100TH_MILLIMETERS    "100TH_MILLIMETERS"
142 #endif
143
144 #define VnNmatteUnitType        "Dtlogin*matte.unitType"
145 #define VnNmatteWidth           "Dtlogin*matte.width"
146 #define VnNmatteHeight          "Dtlogin*matte.height"
147 #define VnCMatteUnitType        "Dtlogin*Form.UnitType"
148 #define VnCMatteWidth           "Dtlogin*Form.Width"
149 #define VnCMatteHeight          "Dtlogin*Form.Height"
150
151 #define MATTE_WIDTH                 18500
152 #define MATTE_HEIGHT            6746
153
154 #define HRES_MATTE_WIDTH        "835"           /* pixels                  */
155 #define HRES_MATTE_HEIGHT       "425"           /* pixels                  */
156 #define MRES_MATTE_WIDTH        "775"           /* pixels                  */
157 #define MRES_MATTE_HEIGHT       "400"           /* pixels                  */
158 #define LRES_MATTE_WIDTH        "585"           /* pixels                  */
159 #define LRES_MATTE_HEIGHT       "300"           /* pixels                  */
160
161 #define LOGIN_TOP_POSITION      "31"            /* percent                 */
162 #define LOGIN_BOTTOM_POSITION   "79"            /* percent                 */
163 #define LOGIN_LEFT_POSITION     "12"            /* percent                 */
164 #define LOGIN_RIGHT_POSITION    "88"            /* percent                 */
165
166 #define SHADOW_THICKNESS        FromMM(100)     /* general border size     */
167 #define ETCH_THICKNESS          FromMM(150)     /* login etch thickness    */
168 #define MBOX_MARGIN_WIDTH       FromMM(300)
169 #define MBOX_MARGIN_HEIGHT      FromMM(300)
170 #define DROP_SHADOW_THICKNESS   FromMM(400)     /* logo drop shadow size   */
171 /*#define       MIN_BUTTON_SIZE         FromMM(3600)     minimum button size       */
172 #define MIN_BUTTON_SIZE         FromMM(3100)    /* minimum button size     */
173 #define TEXT_MARGIN_WIDTH       FromMM(200)     /* text wgt margin width   */
174 #define TEXT_MARGIN_HEIGHT      FromMM(100)     /* text wgt margin height  */
175
176
177 #  define LABEL_FONT            "-*-swiss 742-bold-r-normal-*-140-*-p-100-*"
178 #  define LABEL_FONT_HRES       "-*-swiss 742-medium-r-normal-*-140-*-p-110-*"
179 #  define TEXT_FONT             "-*-prestige-medium-r-normal-*-128-72-*"
180 #  define TEXT_FONT_LRES        "-*-helvetica-bold-r-normal-*-100-*"
181 #  define GREET_FONT            "-*-*schoolbook-medium-i-normal--18-*"
182
183 #if 0
184 #  define GREET_FONT            "-*-*schoolbook-medium-i-normal--18-*-*-*-*-*-ISO8859-1"
185 #endif
186
187 #define TABLE_BACKGROUND        "black"
188 #define TEXT_FOREGROUND         "white"
189
190 #define BW_BACKGROUND           "white"
191 #define BW_FOREGROUND           "black"
192 #define BW_TEXT_BACKGROUND      "black"
193
194 #define BW_LOGO_BACKGROUND      "#a8a8a8"
195 #define BW_LOGO_TOPSHPIXMAP     "25_foreground"
196 #define BW_DROP_BACKGROUND      "black"
197 #define BW_DROP_FOREGROUND      "white"
198 #define BW_DROP_BACKPIXMAP      "25_foreground"
199
200 /*
201  *  define colors by rgb value rather than name. On other systems the name
202  *  may map to a different shade of the desired color.
203  *
204  *  on hp-ux...
205  *
206  *  #a8a8a8  =  lightgray
207  *  #7e7e7e  =  gray
208  *  #ef506f  =  burgundy
209  *
210  */
211 #define CO_BACKGROUND           "#a8a8a8"
212 #define CO_FOREGROUND           "black"
213 #define CO_TEXT_BACKGROUND      "#7e7e7e"
214 #define CO_HIGHLIGHT            "#ef506f"
215 #define CO_SELECTCOLOR          "#ef506f"
216
217 #define CO_LOGO_BACKGROUND      "#ef506f"
218 #define CO_LOGO_TOPSHPIXMAP     "25_foreground"
219 #define CO_DROP_BACKGROUND      "#7e7e7e"
220 #define CO_DROP_FOREGROUND      "#7e7e7e"
221 #define CO_DROP_BACKPIXMAP      "background"
222
223
224 /*
225  *  macros to use when differentiating on resolution...
226  */
227
228 #define HIRES   (dpyinfo.width >  1200)         /* SUN MED_RES = 1182  */
229 #define MEDRES  (dpyinfo.width >   800 && dpyinfo.width <= 1200)
230 #define LOWRES  (dpyinfo.width <=  800)
231
232
233 /*
234  *  macro to determine authentication mechanism name...
235  */
236  
237 #define vg_IsVerifyName(n) \
238     ((strcmp(getenv(VERIFYNAME),(n)) == 0 ) ? TRUE : FALSE)
239
240 /****************************************************************************
241  *
242  *  Structure definitions
243  *
244  ****************************************************************************/
245
246 typedef enum widgetType { CascadeBG, DrawingA, Frame, Form, MessageBox,
247                           Label, LabelG, PushB, PushBG, SeparatorG,
248                           ToggleB, ToggleBG, Text }
249              WidgetType;
250
251
252 typedef enum dialogType { error, help, copyright, hostname, expassword,
253                           help_chooser }
254              DialogType;
255
256
257 typedef struct {
258     Boolean     workspaceCursor;/* whether to define a root window cursor  */
259     XmFontList  labelFont;      /* font for labels and buttons             */
260     XmFontList  textFont;       /* font for dialog text                    */
261     XmFontList  chlistFont;     /* font for chooser list and heading       */
262     int         optionsDelay;   /* seconds to delay before building menu   */
263     int         altDts;         /* number of alternate desktops            */
264     char        *languageList;  /* list of languages to display in menu    */
265     int         unitType;       /* widgets' unit type                      */
266     char        *languageListCmd; /* command to produce language list      */
267 } AppInfo, *AppInfoPtr;
268
269
270
271 typedef struct displayInfo {
272     Display     *dpy;           /* initialized with XtDisplay()            */
273     char        *name;          /* ASCII name of the display being used    */
274     int         screen;         /* initialized with DefaultScreen()        */
275     Window      root;           /* initialized with RootWindow()           */
276     int         depth;          /* initialized with DefaultDepth()         */
277     int         width;          /* initialized with DisplayWidth()         */
278     int         height;         /* initialized with DisplayHeight()        */
279     Pixel       black_pixel;    /* initialized with BlackPixel()           */
280     Visual      *visual;        /* initialized with DefaultVisual()        */
281 } DisplayInfo;
282
283
284
285 typedef  struct {
286     char        *bitmapFile;    /* bitmap file (if any)                    */
287 } LogoInfo, *LogoInfoPtr;
288
289 typedef struct {
290   int bEcho;                    /* True=echoOn, False=echoOff              */
291   Widget text[2];               /* [0] is echoOff, [1] is echoOn           */ 
292   String onGreeting;            /* echoOn greeting                         */
293   char *offGreetingFormat;      /* printf format for echoOff greeting      */
294   char *offGreetingUname;       /* insert for echoOff greeting             */
295   char noechobuf[MAXPATHLEN+1]; /* alternate buffer for echoOff            */
296 } LoginText, *LoginTextPtr;
297
298
299 /****************************************************************************
300  *
301  *  External variable declarations
302  *
303  ****************************************************************************/
304
305 extern Arg      argt[];         /* used for resources                      */
306 extern DisplayInfo dpyinfo;     /* information about the display           */
307 extern char     *errorLogFile;  /* name of error log file (if any)         */
308 extern char     *langenv;       /* current value of LANG environment var.  */
309 extern XmString xmstr;          /* used for compound strings               */
310 extern int      showVerifyError;/* display a Verify() error dialog         */
311
312 extern AppInfo  appInfo;        /* application resources                   */
313
314 extern Widget toplevel;         /* top level shell widget                  */
315 extern Widget login_shell;      /* shell for the main login widgets.       */
316 extern Widget table;            /* black background for everything         */
317 extern Widget matte;            /* main level form widget                  */
318 extern Widget matteFrame;       /* main level form widget                  */
319 extern Widget matte1;           /* main level form widget                  */
320
321 extern Widget greeting;         /* Welcome message                         */
322 extern Widget dt_label;         /* Desktop label set in options menu       */
323
324 extern Widget logo1;            /* frame around the Corporate logo         */
325 extern Widget logo_pixmap;      /* Corporate logo                          */
326 extern Widget logo_shadow;      /* drop shadow under the Corporate logo    */
327
328 extern Widget login_matte;      /* bulletin board for login/password       */
329 extern Widget login_form;       /* form containing the login extern Widgets        */
330 extern Widget login_label;      /* label to left of login text widget      */
331 extern Widget login_text;       /* login text widget                       */
332 extern Widget passwd_form;      /* form containing the password widgets    */
333 extern Widget passwd_label;     /* label to left of password text widget   */
334 extern Widget passwd_text;      /* password text widget                    */
335
336 extern Widget ok_button;        /* accept name/password text button        */
337 extern Widget clear_button;     /* clear name/password text button         */
338 extern Widget options_button;   /* login options button                    */
339 extern Widget help_button;      /* help button                             */
340
341 extern Widget copyright_msg;    /* copyright notice widget                 */
342 extern Widget help_message;     /* the help message box                    */
343 extern Widget error_message;    /* the error message box                   */
344 extern Widget hostname_message; /* the invalid hostname message box        */
345 extern Widget passwd_message;   /* the password expired message box        */
346
347 extern Widget options_menu;     /* pop-up menu on options button           */
348 extern Widget options_item[];   /* items on options pop_up menu            */
349 extern Widget options_failsafe; /* failsafe pane on options pop_up menu    */
350 extern Widget options_dtlite;   /* dtlite  pane on options pop_up menu    */
351 extern Widget options_dt;       /* dt pane on options pop_up menu          */
352 extern Widget *alt_dts;         /* alt_dts  widgets on options pop_up menu */
353 extern Widget options_last_dt;  /* toggle button for user's last dt        */
354 extern Widget options_sp_dt;    /* toggle for user's special dt            */
355
356
357 extern Widget lang_menu;        /* cascading menu on "Language" option     */
358 extern LogoInfo logoInfo;       /* logo resources                          */
359
360 /****************************************************************************
361  *
362  *  Macro definitions
363  *
364  ****************************************************************************/
365 #define vg_TRACE_EXECUTION(str) \
366 LogError((unsigned char *)"VG_TRACE:  %s\n", str)
367
368
369 /****************************************************************************
370  *
371  *  External procedure declarations
372  *
373  ****************************************************************************/
374
375 extern void ChangeBell( char *string) ;
376 extern void CleanupAndExit( Widget w, int exit_code) ;
377 extern void ClearCB( Widget w, XtPointer client_data, XtPointer call_data) ;
378 extern void CloseCatalog();
379 extern void CopyrightCB( Widget w, XtPointer client_data, XtPointer call_data) ;
380 extern void EditPasswdCB( Widget w, XtPointer client, XtPointer call_data) ;
381 extern void FakeFocusIn( Widget focus_widget, XtPointer client_data,
382                                    XEvent *eventprm, 
383                                    Boolean *continue_to_dispatch) ;
384 extern int  FromMM( int mm ) ;
385 extern int  FromPixel( Widget w, int orientation, int pixel) ;
386 extern void GetBiggest( Widget widget, Dimension *width, Dimension *height) ;
387 extern LoginTextPtr GetLoginTextPtr( Widget w );
388 extern int  InitArg( WidgetType wtype) ;
389 extern void LangItemCB( Widget w, XtPointer client_data, XtPointer call_data) ;
390 extern void LayoutCB( Widget w, XtPointer client_data, XtPointer call_data) ;
391 extern void LogError( unsigned char *fmt, ... );
392 extern void MakeDialog( DialogType dtype) ;
393 extern void MakeLangMenu( void ) ;
394 extern void MakeLogo( void ) ;
395 extern void MakeOptionsMenu( void ) ;
396 extern void MenuItemCB( Widget w, XtPointer client_data, XtPointer call_data) ;
397 extern void OpenCatalog();
398 extern void OptionsUnmapCB( Widget wd, XtPointer client_data, XtPointer call_data) ;
399 extern void PingServerCB( XtPointer call_data, XtIntervalId *id) ;
400 extern void PostMenuCB( Widget w, XtPointer client_data, XtPointer call_data);
401 extern unsigned char * ReadCatalog( int set_num, int msg_num, char *def_str) ;
402 extern XmString ReadCatalogXms( int set_num, int msg_num, char *def_str) ;
403 extern void RefreshEH( Widget w, XtPointer client_data, XEvent *event,
404                                    Boolean *continue_to_dispatch) ;
405 extern void RequestCB( XtPointer client_data, int *source, XtInputId *id);
406 extern void RespondExitCB( Widget w, XtPointer client, XtPointer call);
407 extern void RespondLangCB( Widget w, XtPointer client, XtPointer call);
408 extern void RespondChallengeCB(Widget w, XtPointer client, XtPointer call);
409 extern void RespondClearCB(Widget w, XtPointer client, XtPointer call);
410 extern void RespondDialogCB(Widget w, XtPointer client, XtPointer call_data);
411 extern int  SecureDisplay( void ) ;
412 extern void SetResourceDatabase( void ) ;
413 extern void ShowDialogCB( Widget w, XtPointer dialog, XtPointer call_data) ;
414 extern void TextFocusCB( Widget w, XtPointer client_data, XtPointer call_data) ;
415 extern int  ToPixel( Widget w, int orientation, int pixel) ;
416 extern void UnsecureDisplay( void ) ;
417 extern void SetDtLabelAndIcon( void );  
418 extern void SetDefaultDt( Widget w );   
419 #ifndef _DM_H
420 extern int  Verify( char *name, char *passwd) ;
421 #endif
422
423
424
425 #endif /* _VG_H */