1 /*
2 Copyright (C) 1997-2005 Dimitrios P. Bouras
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 For author contact information, look in the README file.
19 */
20
21 #include <forms.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <errno.h>
25 #include <stdarg.h>
26 #include <time.h>
27 #include <string.h>
28 #include <pwd.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <sys/param.h>
32 #include <fcntl.h>
33 #include <sys/time.h>
34 #include <unistd.h>
35 #include <signal.h>
36 #include <sys/wait.h>
37 #include <dirent.h>
38 #include <math.h>
39 #include <locale.h>
40
41 #ifdef SUNOS41x
42 #include <memory.h>
43 extern int sys_nerr;
44 extern char *sys_errlist[];
45 extern int errno;
46 extern int gettimeofday(), fputs(), usleep(), mknod(), pclose(), select();
47 extern int on_exit(), strftime(), fprintf(), fclose(), sscanf(), fscanf();
48 extern int rename(), gethostname(), putenv(), seteuid(), vfprintf();
49 extern void bcopy(), bzero();
50 extern char *vsprintf();
51 extern time_t time();
52 extern pid_t getpid();
53 #endif
54
55 #ifdef SUNOS5x
56 #include <netdb.h>
57 extern int usleep(), gethostname();
58 #endif
59
60 #ifdef RUNASEUID
61 int xisp_euidaccess();
62 #endif
63
64 #if defined(SUNOS5x) || defined(SVR4)
65 #include <sys/mkdev.h>
66 #endif
67
68 #include "common.h"
69 #include "xisp.h"
70 #include "pcode.h"
71 #include "network.h"
72 #include "rcio.h"
73 #include "logs.h"
74 #include "xisp.xpm"
75 #include "excl.xpm"
76 #include "version.h"
77 #include "help.c"
78 #include "peHelp.c"
79
80 #ifdef XPMANIMATE
81 #include "online1.xpm"
82 #include "online2.xpm"
83 #include "online3.xpm"
84 #include "online4.xpm"
85 #include "online5.xpm"
86 #include "online6.xpm"
87 #include "online7.xpm"
88 #include "online8.xpm"
89 #include "online9.xpm"
90 #include "online10.xpm"
91 #include "online11.xpm"
92 #include "online12.xpm"
93 #endif
94
95 /*+-------------------------------------------------------------------------+
96 | |
97 | Global program storage |
98 | |
99 +-------------------------------------------------------------------------+*/
100
101 /* All application objects and any accompanying
102 communication structures are declared global */
103
104 FD_instanceCheck *fd_instanceCheck; /* Instance check alert message form */
105 FD_topFrame *fd_topFrame; /* The main application form */
106 FD_accountInfo *fd_accountInfo; /* Account information */
107 typedef struct { /* and its inter-form communication */
108 unsigned char cur; /* (or IFC) data structure */
109 unsigned char dflt;
110 int new, modified;
111 char descr[MAXLEN_DESCR+1];
112 unsigned long udata;
113 } accountInfo_t;
114 accountInfo_t IFC_accountInfo;
115 FD_dialInfo *fd_dialInfo; /* Dialing options */
116 FD_CBInfo *fd_CBInfo; /* Call-back script */
117 FD_aboutInfo *fd_aboutInfo; /* Application "About" */
118 FD_exitDialog *fd_exitDialog; /* Exit dialog */
119 FD_renameISP *fd_renameISP; /* Modify ISP name */
120 FD_helpInfo *fd_helpInfo; /* General GUI information */
121 FD_commInfo *fd_commInfo; /* Communication options */
122 typedef struct { /* and its IFC structure */
123 unsigned int speed;
124 unsigned char custom;
125 unsigned long operOpts;
126 } commInfo_t;
127 commInfo_t IFC_commInfo;
128 FD_tcpipInfo *fd_tcpipInfo; /* TCP/IP options */
129 FD_optsTab *fd_optsTab; /* Tab folder for all options */
130 FD_logInfo *fd_logInfo; /* Logging and PTT selection options */
131 FD_statInfo *fd_statInfo; /* Connection-time/cost statistics */
132 FD_pttEditor *fd_pttEditor; /* The PTT editor */
133 ptt_t IFC_pttEditor; /* and its IFC structure */
134 FD_renamePTT *fd_renamePTT; /* Modify PTT name */
135 FD_renameZone *fd_renameZone; /* Modify zone name */
136 FD_actionVerify *fd_actionVerify; /* Action verification dialog */
137 FD_envInfo *fd_envInfo; /* Edit program/system paths */
138 glob_t IFC_envInfo; /* and its IFC structure */
139 FD_alertMessage *fd_alertMessage; /* alert messages */
140
141 /* Global selection options go in here */
142
143 glob_t global = GLOB_DEFAULT;
144
145 /* ISP information from .xisprc goes in here; default values are held
146 in [0] and all further ISP records are saved from [1] and upwards */
147
148 xisprc_t *xispOptions; /* ISP information table */
149 unsigned currentRC = 0; /* sequence number of, and */
150 xisprc_t *p_xisprc; /* pointer to current ISP information block */
151 xisprc_t ISPCopyBuf; /* buffer for ISP copy-and-paste operations */
152
153 /* File names independent of user specified paths */
154
155 char *rcfname; /* file holding program parameters */
156 #ifndef ISPENV_USEVARS
157 char *envfname; /* temp file for passing the dialing environment */
158 #endif
159 char *papfname; /* temp file with PAP username and password for +ua */
160 char *logdirname; /* path for xisp logging files */
161 char *logfname; /* connection logging file complete name */
162 char *costfname; /* total units/time logging file complete name */
163 char *bkupfname; /* backup name work-space for logfname and costfname */
164 char *uupfname; /* user's "ip-up" file name */
165 char *udownfname; /* user's "ip-down" file name */
166 char *upidfname; /* file containing PID number of running xisp */
167
168 /* File names dependent on user specified paths and related variables */
169
170 char *Pppd = NULL; /* pppd daemon */
171 #ifdef RUNDIR
172 char *PIDFname = NULL; /* complete path to pppd PID files */
173 char *runfnp; /* pointer to first filename char in PIDFname */
174 #endif
175 char *lockFname = NULL; /* complete path to modem device lock files */
176 char *lockfnp; /* pointer to first filename char in lockFname */
177 char *Chat = NULL; /* chat utility */
178 char *Dialer = NULL; /* xispdial dedicated dialer utility */
179 char *Terminal = NULL; /* xispterm manual login popup */
180 char *Pipe = NULL; /* named pipe node for reading dialer output */
181 char *IPParam = NULL; /* ipparam string for pppd and .xisp-up/-down calls */
182
183 /* Other global variables */
184
185 int dialerFD; /* file descriptor used for reading dialer output */
186 int dialerON = 0; /* indicates whether if a dialer process is active */
187 int ipUDON = 0; /* if ip-up/-down active = browser read iter. left */
188 int xispUDON = 0; /* same function as ipUDON but for .xisp-up/-down */
189 char ipWhich[8] = {0}; /* the active script name; "ip-up" or "ip-down" */
190 int pppdPID = 0; /* saved process id of initiated pppd process */
191 char *devName = NULL; /* ptr to modem device name of spawned pppd process */
192 char *devPath = NULL; /* full path to device node (includes devName) */
193
194 #ifdef PPPDLCKDIR
195 char devLock /* pppd's lock file name */
196 [2*MAXLEN_DEVICE] =
197 {0};
198 #endif
199
200 int ipUDPID = 0; /* saved process id of the ip-up or ip-down process */
201 int xispUDPID = 0; /* saved process id of the .xisp-up/-down process */
202 int pppdPPID = 0; /* the parent PID of the above, after pppd forks */
203 int pppdStat = 0; /* set to 1 when pppd process status has been collected */
204 int pppdRet = 0; /* return status of pppd when it forks in the background */
205 int dialerPID = 0; /* process id returned by dialer via named pipe */
206 int connected = 0; /* flag indicating connection status */
207 int firstConn=1; /* for distinguishing 1st from 2nd (call-back) CONNECT */
208 int linkTOCounter; /* link poll timeout counter */
209 time_t connTime; /* ammount of time connected */
210 char speedStr[32]; /* saved speed string printed out by modem */
211 char connSpeed[8]; /* formatted string of connection speed */
212 int linkOK = 0; /* flag indicating link status */
213 char connIP[16]; /* string IP address of PPP interface when up */
214 int userDiscon = 0; /* indicates user initiated disconnection request */
215
216 #ifdef XPMANIMATE
217 int frame = 0; /* frame number of xpm animation */
218 unsigned netpkts=0; /* sum of net packets */
219 int transfer = 0; /* indicates data is coming over the modem line */
220 int minimized = 0; /* flag indicating master form mapstate */
221 Pixmap offline; /* animation pixmaps */
222 Pixmap online[12];
223 Pixmap amask; /* and transparency mask */
224 #endif
225
226 char pppIF[8]={0}; /* PPP interface name (when RUNDIR available) */
227 int progState = /* globally available program state variable */
228 DISCONNECTED;
229 Window topWin; /* saved window ID for program top level form window */
230 int wasTab = 0; /* used in script-line hacked multi-line input fields */
231 #ifndef SUNOS41x
232 int exitStatus = 0; /* saved argument to exit() calls for use by exitCleanup */
233 #endif
234
235 /* Variables related to cost calculation and logging */
236
237 ptt_t *ptt; /* table of PTT information records */
238 unsigned currentPTT = 0; /* sequence number of, and */
239 ptt_t *p_ptt; /* pointer to current PTT information record */
240 char *pttfname; /* PTT data base file name */
241
242 time_t upTime; /* local time connection was established */
243 time_t CBTime; /* time call-back connection was established */
244 time_t downTime; /* local time connection was torn down */
245 unsigned long onLineSecs; /* seconds online, for current connection */
246 float onLineCost; /* cost for current dialup session */
247 unsigned long onLineUnits; /* units for current dialup session */
248 float totalCost; /* total cost recorded for logging period */
249 unsigned long totalTime; /* total on-line time (secs) for logging period */
250 unsigned long totalUnits; /* total number of units for logging period */
251
252 /* Timers for periodic events */
253
254 FL_OBJECT *btimer; /* triggers browser updates with dialer output */
255 FL_OBJECT *ctimer; /* measures connection time */
256 FL_OBJECT *ltimer; /* used for polling link status */
257 #ifdef XPMANIMATE
258 FL_OBJECT *xpmtimer; /* times XPM icon animation */
259 #endif
260
261 /* Extra cursors */
262
263 static unsigned char timer_cursor[] = {
264 0x80, 0x03, 0x00, 0x00, 0x01, 0x00, 0xc0, 0x47, 0x00, 0x30, 0xd8, 0x00,
265 0xc8, 0x27, 0x00, 0x34, 0x58, 0x00, 0x1a, 0xb1, 0x00, 0x2a, 0xa9, 0x00,
266 0x05, 0x41, 0x01, 0x05, 0x41, 0x01, 0x1d, 0x71, 0x01, 0x85, 0x40, 0x01,
267 0x45, 0x40, 0x01, 0x2a, 0xa8, 0x00, 0x0a, 0xb1, 0x00, 0x34, 0x59, 0x00,
268 0xc8, 0x27, 0x00, 0x30, 0x18, 0x00, 0xc0, 0x07, 0x00
269 };
270 static unsigned char timer_mask[] = {
271 0x80, 0x03, 0x00, 0x00, 0x01, 0x00, 0xc0, 0x47, 0x00, 0xf0, 0xdf, 0x00,
272 0xf8, 0x3f, 0x00, 0xfc, 0x7f, 0x00, 0xfe, 0xff, 0x00, 0xfe, 0xff, 0x00,
273 0xff, 0xff, 0x01, 0xff, 0xff, 0x01, 0xff, 0xff, 0x01, 0xff, 0xff, 0x01,
274 0xff, 0xff, 0x01, 0xfe, 0xff, 0x00, 0xfe, 0xff, 0x00, 0xfc, 0x7f, 0x00,
275 0xf8, 0x3f, 0x00, 0xf0, 0x1f, 0x00, 0xc0, 0x07, 0x00
276 };
277 int tcid;
278
279 /* Pppd (version >= 2.3.9) status messages (return code = index value) */
280
281 char *pppdMsg[20] = {
282 "either pppd has detached, or otherwise\n" /* retuned 0 */
283 "the connection was successfully\n"
284 "established and terminated at the peer's\n"
285 "request.",
286
287 "an immediately fatal error of some kind\n" /* retuned 1 */
288 "occurred, such as an essential system\n"
289 "call failing, or running out of virtual memory.\n"
290 "\n"
291 "If you changed the modem device, make\n"
292 "sure that you create a corresponding options\n"
293 "file in pppd's peers directory (most probably\n"
294 "/etc/ppp/peers). Read the comments found in\n"
295 "file xisp.peers.device in the xisp distribution\n"
296 "for details. Alternatively check modem power\n"
297 "and/or the interconnecting cables.",
298
299 "an error was detected in processing the\n" /* retuned 2 */
300 "options given, such as two mutually\n"
301 "exclusive options being used.",
302
303 "the pppd executable is not setuid-root and\n" /* retuned 3 */
304 "the invoking user is not root.",
305
306 "the running kernel does not support PPP,\n" /* retuned 4 */
307 "for example, the PPP kernel driver is not\n"
308 "included or cannot be loaded.",
309
310 "pppd terminated because it received a\n" /* retuned 5 */
311 "SIGINT, SIGTERM or SIGHUP signal.",
312
313 "the serial port could not be locked.", /* retuned 6 */
314
315 "the serial port could not be opened.", /* retuned 7 */
316
317 "the connect script (or program) failed\n" /* retuned 8 */
318 "(i.e. it returned a non-zero exit status).",
319
320 "the command specified as the argument\n" /* retuned 9 */
321 "to the pty option could not be run.",
322
323 "the PPP negotiation failed, that is, it didn't\n" /* retuned 10 */
324 "reach the point where at least one network\n"
325 "protocol (e.g. IP) was running.",
326
327 "the peer system failed (or refused) to\n" /* retuned 11 */
328 "authenticate itself.",
329
330 "the link was established successfully and\n" /* retuned 12 */
331 "terminated because it was idle. ",
332
333 "the link was established successfully and\n" /* retuned 13 */
334 "terminated because the connect time limit\n"
335 "was reached.",
336
337 "callback was negotiated and an incoming\n" /* retuned 14 */
338 "call should arrive shortly.",
339
340 "the link was terminated because the peer\n" /* retuned 15 */
341 "is not responding to echo requests.",
342
343 "the link was terminated by the modem\n" /* retuned 16 */
344 "hanging up.",
345
346 "the PPP negotiation failed because serial\n" /* retuned 17 */
347 "loopback was detected.",
348
349 "the init script failed (returned a non-zero\n" /* retuned 18 */
350 "exit status).",
351
352 "pppd failed to authenticate itself to\n" /* retuned 19 */
353 "the peer."
354 };
355
356 /*+-------------------------------------------------------------------------+
357 | |
358 | Command line options & Resources - Data structures |
359 | |
360 +-------------------------------------------------------------------------+*/
361
362 #define NUMOPTS 9
363 FL_CMD_OPT options[NUMOPTS] =
364 {
365 {"-bgcol", ".bgcol", XrmoptionSepArg, BGCOL_STRING},
366 {"-iconic", ".iconic", XrmoptionNoArg, "True"},
367 {"-geometry", ".geometry", XrmoptionSepArg, ""},
368 {"-isp", ".isp", XrmoptionSepArg, ""},
369 {"-autodial", ".autodial", XrmoptionNoArg, "True"},
370 {"-debug", ".debug", XrmoptionNoArg, "True"},
371 {"-expert", ".expert", XrmoptionNoArg, "True"},
372 {"-nohints", ".nohints", XrmoptionNoArg, "True"},
373 {"-pidfp", ".pidfp", XrmoptionSepArg, PIDFP},
374 };
375
376 char bgcols[16+1] = {0}; /* the background color string */
377 color_t bgcol = BGCOL_DEFAULT, /* default background for all forms */
378 tabcol; /* color for tab folder backdrop */
379 int iconic = 0, /* window placement flag */
380 winPosX, /* hint to WM for position */
381 winPosY,
382 winWidth, /* request for different size */
383 winHeight,
384 clISP = 0, /* command-line specified ISP */
385 autodial = 0, /* request for auto dial on startup */
386 debug = 0, /* request pppd maximum debugging */
387 expert = 0, /* switch for confirmation dialogues */
388 nohints = 0; /* switch for tips and hints */
389 char geoms[32+1] = {0}; /* the geometry string */
390 int placementMethod = FL_PLACE_FREE; /* top form placement method */
391 char pidfp[16+1] = {0}; /* pppd's PID file prefix */
392
393 FL_resource resources[NUMOPTS] =
394 {
395 {"bgcol", "BGColor", FL_STRING, bgcols, BGCOL_STRING, 16},
396 {"iconic", "Iconic", FL_BOOL, &iconic, "False"},
397 {"geometry", "Geometry", FL_STRING, geoms, "", 32},
398 {"isp", "Isp", FL_INT, &clISP, "0"},
399 {"autodial", "Autodial", FL_BOOL, &autodial, "False"},
400 {"debug", "Debug", FL_BOOL, &debug, "False"},
401 {"expert", "Expert", FL_BOOL, &expert, "False"},
402 {"nohints", "Hints", FL_BOOL, &nohints, "False"},
403 {"pidfp", "PIDFP", FL_STRING, pidfp, PIDFP, 16},
404 };
405
406 /*+-------------------------------------------------------------------------+
407 | |
408 | Utility routines |
409 | |
410 +-------------------------------------------------------------------------+*/
411
412 /* Safe strerror (for arch's that don't have one). Note the implicit
413 total length of MSGLEN_ERR bytes for the resulting string. */
414
415 #define MSGLEN_ERR 128
416
Strerror(int Errno)417 char *Strerror(int Errno)
418 {
419 #ifdef HAVE_STRERROR
420 return strerror(Errno);
421 #else
422 static char emsg[MSGLEN_ERR+1];
423
424 memset(emsg, 0, MSGLEN_ERR+1);
425 if (Errno < sys_nerr)
426 strncpy(emsg, sys_errlist[Errno], MSGLEN_ERR);
427 else
428 sprintf(emsg, "error #%d", Errno);
429 return emsg;
430 #endif
431 }
432
433
434 /* Print message together with system error message and exit. */
435
doErr(char * msg)436 void doErr(char *msg)
437 {
438 fprintf(stderr, "xISP: %s: %s\n", msg, Strerror(errno));
439 exit(1);
440 }
441
442
443 /* Returns pointer to string with current time in 12-hour format */
444
strtime(void)445 char *strtime(void)
446 {
447 struct timeval tv;
448 time_t time;
449 static char tout[16];
450
451 gettimeofday(&tv, NULL);
452 time = tv.tv_sec;
453 strftime(tout, 16, "%I:%M:%S %p", localtime(&time));
454 return tout;
455 }
456
457
458 /* Prints out-of-memory diagnostic and aborts program */
459
outofMem(void)460 void outofMem(void)
461 {
462 fprintf(stderr, "xISP: out of memory!\n");
463 exit(1);
464 }
465
466
467 /* Waits for desired number of miliseconds using usleep(3). Thus, we avoid
468 using sleep(3), which causes problems when mixed with calls to alarm(3). */
469
mSleep(unsigned int msec)470 void mSleep(unsigned int msec)
471 {
472 unsigned long usec;
473
474 usec = msec * 1000;
475 usleep(usec);
476 }
477
478
479 /* SunOS-4.1.x-safe realloc(). If the pointer
480 is NULL, it uses malloc instead */
481
482 #ifdef SUNOS41x
myRealloc(void * ptr,unsigned size)483 void *myRealloc(void *ptr, unsigned size)
484 {
485 if (ptr) return (void *)realloc((char *)ptr, size);
486 else return (void *)malloc(size);
487 }
488
489 #define realloc myRealloc
490 #endif
491
492
493 /* Assembles the string variables holding file names dependent
494 on user-specified paths. May be called any number of times */
495
initUDFnames(glob_t * p)496 void initUDFnames(glob_t *p)
497 {
498 int size;
499 #ifdef RUNASEUID
500 struct passwd *user = getpwuid(geteuid());
501 #else
502 struct passwd *user = getpwuid(getuid());
503 #endif
504 int namelen = strlen(user->pw_name);
505
506 size = strlen(p->pppdPath)+strlen(PPPD)+1;
507 if ((Pppd = realloc(Pppd, size)) == NULL)
508 outofMem();
509 strcpy(Pppd, p->pppdPath); strcat(Pppd, PPPD);
510
511 #ifdef RUNDIR
512 size = strlen(p->runPath)+12+1;
513 if ((PIDFname = realloc(PIDFname, size)) == NULL)
514 outofMem();
515 strcpy(PIDFname, p->runPath); strcat(PIDFname, "/");
516 runfnp = &PIDFname[strlen(PIDFname)];
517 #endif
518
519 size = strlen(p->lockPath)+6+2*MAXLEN_DEVICE+1; /* more than enough */
520 if ((lockFname = realloc(lockFname, size)) == NULL)
521 outofMem();
522 strcpy(lockFname, p->lockPath);
523 #if defined(SUNOS5x) || defined(SVR4)
524 strcat(lockFname, "/LK.");
525 #else
526 strcat(lockFname, "/LCK..");
527 #endif
528 lockfnp = &lockFname[strlen(lockFname)];
529
530 size = strlen(p->chatPath)+strlen(CHAT)+1;
531 if ((Chat = realloc(Chat, size)) == NULL)
532 outofMem();
533 strcpy(Chat, p->chatPath); strcat(Chat, CHAT);
534
535 size = strlen(p->utilsPath)+strlen(PPPD_CONNECT)+1;
536 if ((Dialer = realloc(Dialer, size)) == NULL)
537 outofMem();
538 strcpy(Dialer, p->utilsPath); strcat(Dialer, PPPD_CONNECT);
539
540 size = strlen(p->utilsPath)+strlen(TERMINAL)+1;
541 if ((Terminal = realloc(Terminal, size)) == NULL)
542 outofMem();
543 strcpy(Terminal, p->utilsPath); strcat(Terminal, TERMINAL);
544
545 size = strlen(p->pipePath)+1+strlen(PIPEFNAME)+1+namelen+1;
546 if ((Pipe = realloc(Pipe, size)) == NULL)
547 outofMem();
548 strcpy(Pipe, p->pipePath); strcat(Pipe, "/"); strcat(Pipe, PIPEFNAME);
549 strcat(Pipe, "."); strcat(Pipe, user->pw_name);
550
551 size = strlen(Pipe)+1+MAXLEN_DESCR+1+2*MAXLEN_IP+2+MAXLEN_DNNAME+1;
552 if ((IPParam = realloc(IPParam, size)) == NULL)
553 outofMem();
554 }
555
556
557 /* Assembles the string variables holding file
558 names independent of user-specified paths. */
559
initUIFnames(void)560 void initUIFnames(void)
561 {
562 #ifdef RUNASEUID
563 struct passwd *user = getpwuid(geteuid());
564 #else
565 struct passwd *user = getpwuid(getuid());
566 #endif
567 unsigned int hdirlen = strlen(user->pw_dir), commonlen, per_host = 0;
568 char hostname[MAXHOSTNAMELEN+1];
569
570 if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
571 rcfname = (char *)malloc(hdirlen+1+strlen(RCFNAME)+1+MAXHOSTNAMELEN+1);
572 if (rcfname != NULL) {
573 strcpy(rcfname, user->pw_dir); strcat(rcfname, "/");
574 strcat(rcfname, RCFNAME); strcat(rcfname, ".");
575 strcat(rcfname, hostname);
576 }
577 else
578 outofMem();
579 #ifdef RUNASEUID
580 if (xisp_euidaccess(rcfname, R_OK) == 0)
581 #else
582 if (access(rcfname, R_OK) == 0)
583 #endif
584 per_host = 1;
585 else
586 free(rcfname);
587 }
588 if (! per_host) {
589 rcfname = (char *)malloc(hdirlen+1+strlen(RCFNAME)+1);
590 if (rcfname != NULL) {
591 strcpy(rcfname, user->pw_dir); strcat(rcfname, "/");
592 strcat(rcfname, RCFNAME);
593 }
594 else
595 outofMem();
596 }
597 upidfname = (char *)malloc(hdirlen+1+strlen(XISPPIDFNAME)+1);
598 #ifndef ISPENV_USEVARS
599 envfname = (char *)malloc(hdirlen+1+strlen(ENVFNAME)+1);
600 #endif
601 papfname = (char *)malloc(hdirlen+1+strlen(PAPFNAME)+1);
602 logdirname = (char *)malloc(hdirlen+1+strlen(LOGDIRNAME)+1);
603 logfname = (char *)malloc(hdirlen+1+strlen(LOGDIRNAME)+1+
604 strlen(LOGFNROOT)+5+1);
605 costfname = (char *)malloc(hdirlen+1+strlen(LOGDIRNAME)+1+
606 strlen(COSTFNROOT)+5+1);
607 commonlen = strlen(COSTFNROOT);
608 if (strlen(LOGFNROOT) > commonlen)
609 commonlen = strlen(LOGFNROOT);
610 bkupfname = (char *)malloc(hdirlen+1+strlen(LOGDIRNAME)+1+
611 commonlen+5+4+1);
612 uupfname = (char *)malloc(hdirlen+1+strlen(XISPUPNAME)+1);
613 udownfname = (char *)malloc(hdirlen+1+strlen(XISPDOWNNAME)+1);
614 pttfname = (char *)malloc(hdirlen+1+strlen(LOGDIRNAME)+1+
615 strlen(PTTFNAME)+1);
616 if (upidfname != NULL &&
617 #ifndef ISPENV_USEVARS
618 envfname != NULL &&
619 #endif
620 papfname != NULL &&
621 logdirname != NULL && logfname != NULL && costfname != NULL &&
622 bkupfname != NULL && uupfname != NULL && udownfname != NULL &&
623 pttfname != NULL)
624 {
625 strcpy(upidfname, user->pw_dir); strcat(upidfname, "/");
626 strcat(upidfname, XISPPIDFNAME);
627 #ifndef ISPENV_USEVARS
628 strcpy(envfname, user->pw_dir); strcat(envfname, "/");
629 strcat(envfname, ENVFNAME);
630 #endif
631 strcpy(papfname, user->pw_dir); strcat(papfname, "/");
632 strcat(papfname, PAPFNAME);
633 strcpy(logdirname, user->pw_dir); strcat(logdirname, "/");
634 strcat(logdirname, LOGDIRNAME);
635 strcpy(logfname, logdirname); strcat(logfname, "/");
636 strcat(logfname, LOGFNROOT);
637 strcpy(costfname, logdirname); strcat(costfname, "/");
638 strcat(costfname, COSTFNROOT);
639 strcpy(uupfname, user->pw_dir); strcat(uupfname, "/");
640 strcat(uupfname, XISPUPNAME);
641 strcpy(udownfname, user->pw_dir); strcat(udownfname, "/");
642 strcat(udownfname, XISPDOWNNAME);
643 strcpy(pttfname, logdirname); strcat(pttfname, "/");
644 strcat(pttfname, PTTFNAME);
645 }
646 else
647 outofMem();
648 }
649
650
651 /* Create and/or open a named pipe for reading only */
652
namedPipe(char * fname)653 int namedPipe(char *fname)
654 {
655 struct stat st;
656 int create, fd;
657 #ifdef RUNASEUID
658 struct passwd *user = getpwuid(geteuid());
659 #else
660 struct passwd *user = getpwuid(getuid());
661 #endif
662
663 #ifdef RUNASEUID
664 if (xisp_euidaccess(fname, F_OK) == -1) /* check to see if it exists */
665 #else
666 if (access(fname, F_OK) == -1)
667 #endif
668 create = 1; /* nope, creation required */
669 else {
670 stat(fname, &st); /* yes, get the node status */
671 if (!S_ISFIFO(st.st_mode)) { /* is it a FIFO? */
672 unlink(fname); /* nope, delete it */
673 create = 1; /* indicate creation required */
674 }
675 else
676 create = 0; /* it's a FIFO, all OK */
677 }
678 if (create) { /* was creation requested? */
679 #ifdef RUNASEUID
680 if (xisp_euidaccess(global.pipePath, /* yes, check user */
681 R_OK|W_OK) /* specified directory */
682 == -1) {
683 #else
684 if (access(global.pipePath, R_OK|W_OK)
685 == -1) {
686 #endif
687 fprintf(stderr,
688 "xISP: can't create named-pipe (FIFO) in directory: %s\n"
689 "xISP: set read/write permission in %s for user: %s.\n",
690 global.pipePath, global.pipePath, user->pw_name);
691 exit(1);
692 }
693 #if (defined(BSD) && BSD >= 199306)
694 if (mkfifo(Pipe, 0600)) /* directory is OK, so */
695 doErr("namedPipe: mkfifo"); /* create the FIFO node */
696 if (chown(fname, -1, getgid())) /* make pipe group id same */
697 doErr("namedPipe: chown"); /* as user real group id */
698 #else
699 if (mknod(Pipe, S_IFIFO+0600, 0))
700 doErr("namedPipe: mknod");
701 #endif
702 }
703 #ifdef SUNOS5x
704 fd = open(fname, O_RDONLY|O_NONBLOCK); /* and open it for reading */
705 #elif (defined(BSD) && BSD >= 199306)
706 fd = open(fname, O_RDONLY|O_NONBLOCK);
707 #else
708 fd = open(fname, O_RDONLY|O_NDELAY);
709 #endif
710 if (fd < 0) /* bail out on error */
711 doErr("namedPipe: open");
712 return fd; /* return the descriptor */
713 }
714
715
716 /* Search a string for multiple characters returning first occurrence */
717
718 static char *strfstr(char *haystack, char *needles)
719 {
720 char cn, *hp;
721
722 while ((cn=*needles)) { /* search for all needles */
723 hp = strchr(haystack, cn); /* found in haystack? */
724 if (hp != NULL) /* yes, return pointer to */
725 return(hp); /* location of matched char */
726 ++needles; /* nope, get next needle */
727 }
728 return(NULL); /* nothing found */
729 }
730
731
732 /* Write printf style in the browser object. Note the implicit
733 total length of MSGLEN_BROWSER bytes for the resulting string.
734 A routine to flush the buffer used by bprintf is also provided. */
735
736 #define MSGLEN_BROWSER (MAXBUF_CHILD*2)
737
738 char bmsg[MSGLEN_BROWSER+1] = {0}; /* the string buffer used by bprintf() */
739 char btmp[MAXBUF_CHILD+1] = {0}; /* temporary buffer for new strings */
740 char *where = bmsg; /* incomplete line continuation pointer */
741 int needNL = 0; /* and the continuation indicator */
742
743 void bDoBuf(void)
744 {
745 char *nl;
746
747 while ((nl= strfstr(bmsg,"\r\n"))!=NULL) { /* string contains CR or LF? */
748 *nl = 0; /* yes, mark it as last char */
749 if (needNL) { /* redisplay string if the */
750 fl_replace_browser_line( /* last line input lacked */
751 fd_topFrame->lstBrowser, /* an accepted new line char */
752 fl_get_browser_maxline( /* so replace instead */
753 fd_topFrame->lstBrowser), /* of adding the line */
754 bmsg);
755 needNL = 0; /* done with line with no NL */
756 }
757 else if (strcspn(bmsg, "\r\n")) /* unless NL right after NL */
758 fl_addto_browser(fd_topFrame-> /* display string normally */
759 lstBrowser, bmsg); /* on the browser object */
760 strcpy(bmsg, nl+1); /* move rest to beginning */
761 }
762 }
763
764 int bprintf(char *fmt, ...)
765 {
766 int bw, pending = 0;
767 va_list ap;
768 static int tot = 0;
769
770 va_start(ap, fmt); /* start variable arg list */
771 #ifdef BROKEN_SPRINTF
772 vsprintf(btmp, fmt, ap); /* pass the rest to vsprintf */
773 bw = strlen(btmp);
774 #else
775 bw = vsprintf(btmp, fmt, ap);
776 #endif
777 va_end(ap); /* end variable arg list */
778 if ((tot+bw) < (MSGLEN_BROWSER-1)) /* do we have space for new? */
779 strcat(where, btmp); /* yup, tack it on the end */
780 else { /* nope, so */
781 strcat(where, "\n"); /* end the string here */
782 pending = 1; /* and indicate new pending */
783 }
784 bDoBuf(); /* process the message buf */
785 if (pending) { /* pending new string? */
786 strcpy(bmsg, btmp); /* yup, copy it in the buffer */
787 bDoBuf(); /* process the buffer again */
788 }
789 tot = strlen(bmsg); /* total chars so far */
790 where = bmsg + tot; /* pick up from where we left */
791 if (tot) { /* any trailing characters? */
792 if (needNL)
793 fl_replace_browser_line( /* last line input lacked */
794 fd_topFrame->lstBrowser, /* an accepted new line char */
795 fl_get_browser_maxline( /* so replace instead */
796 fd_topFrame->lstBrowser), /* of adding the line */
797 bmsg);
798 else if (strcspn(bmsg, "\r\n")) /* unless it just happened */
799 fl_addto_browser(fd_topFrame-> /* in which case add the */
800 lstBrowser, bmsg); /* new line at the end */
801 needNL = 1; /* indicate we need NL */
802 }
803 return bw; /* return bytes written */
804 }
805
806 void bflush(void)
807 {
808 if ( *bmsg ) { /* if leftover chars exist */
809 fl_replace_browser_line( /* last line input lacked */
810 fd_topFrame->lstBrowser, /* an accepted new line char */
811 fl_get_browser_maxline( /* so replace it */
812 fd_topFrame->lstBrowser),
813 bmsg);
814 *bmsg = 0; /* indicate nothing here */
815 needNL = 0; /* no incomplete line */
816 }
817 where = bmsg; /* and start all over again */
818 }
819
820
821 /* Argument list building functions for pppd. freePppdArgs() is called
822 to free previously used arguments, while pppdArg() gradually builds
823 the pppd argument list up to MAXARGS_CHILD arguments; it requires a
824 null terminated variable argument list. */
825
826 #define MAXARGS_CHILD 64
827
828 char *pppd_arg[MAXARGS_CHILD+1]; /* the argument list strings */
829 int npppd_args = 0; /* current number of args */
830
831 void freePppdArgs(void)
832 {
833 int i;
834
835 for (i=0; i<npppd_args; i++) /* free all current args */
836 free(pppd_arg[i]);
837 npppd_args = 0; /* and restart counter */
838 }
839
840 void pppdArg(char *va, ...)
841 {
842 va_list ap;
843 char *arg;
844
845 va_start(ap, va); /* start variable arg list */
846 while ((arg=va_arg(ap,char*))!=(char*)0) { /* get next argument */
847 if (npppd_args > MAXARGS_CHILD-1) { /* next argument overflows ? */
848 fprintf(stderr, "xISP: %s %s\n", /* yup, bail out */
849 "pppdArg",
850 "argument overflow!");
851 exit(1);
852 }
853 if ((pppd_arg[npppd_args] = /* nope, try to allocate it */
854 malloc(strlen(arg)+1)) == NULL) /* if allocation failed */
855 doErr("pppdArg"); /* then bail out */
856 strcpy(pppd_arg[npppd_args], arg); /* all OK, copy it */
857 ++npppd_args; /* and increment the counter */
858 }
859 va_end(ap); /* end variable arg list */
860 }
861
862 /* Executes pppd process with the argument list given. The argument
863 list is terminated by a (char *)0 pointer. It also initializes
864 the browser-update timer. */
865
866 void pppd(char *args[])
867 {
868 pppdPPID = pppdPID = fork(); /* fork to create child */
869 if (pppdPID < 0) /* ret < 0 : fork failed */
870 doErr("pppd: fork");
871 if (pppdPID) { /* in parrent process */
872 freePppdArgs(); /* free used arguments */
873 dialerON = 1; /* indicate dial in progress */
874 pppdStat = 0; /* status not collected yet */
875 fl_set_timer(btimer, BU_INTERVAL); /* start callback timer */
876 }
877 else { /* in pppd process */
878 umask(022); /* ensure readable pid file */
879 args[npppd_args] = (char *)0; /* in /var/run, terminate */
880 execv(args[0], args); /* arg list and exec pppd */
881 doErr("pppd: execv"); /* return here means error */
882 }
883 }
884
885
886 /* Check script-line syntax to comply with xisp/xispdial syntax. Make
887 sure we have maximum one %U and one %P in the script line segment */
888
889 int lineCheck(char *sline)
890 {
891 char *pc = sline;
892 int len = strlen(sline), haveU = 0, haveP = 0;
893
894 for (; *pc; pc++) { /* check all '%' characters */
895 for(; *pc!='%'; pc++) /* by skipping the rest */
896 if (*pc == 0) return 1;
897 if (pc++ > sline+len-2) /* is '%' the last char? */
898 if (*pc != '%') /* yes, this is no good */
899 return 0; /* unless last char is '%' */
900 if (*pc == 'U') { /* next char is 'U' ? */
901 if ( haveU ) return -1; /* yes, make sure we have */
902 ++haveU; /* only one %U per line */
903 }
904 else if (*pc == 'P') { /* next char is 'P' ? */
905 if ( haveP ) return -1; /* yes, make sure we have */
906 ++haveP; /* only one %P per line */
907 }
908 else if (*pc != '%') return 0; /* else char must be '%' */
909 }
910 return 1; /* done, all OK */
911 }
912
913 /* Assemble entire line; make ready for xispdial consumption.
914 Replace %U and %P codes with username and password */
915
916 char *linePrep(xisprc_t *p, char *Esline, char *Ssline)
917 {
918 static char tline[2*MAXLEN_SLINE+5+5*MAXLEN_ACCOUNT+1] = {0};
919 char ppasswd[MAXLEN_PASSWD+1] = {0}, eppasswd[2*MAXLEN_PASSWD+1] = {0},
920 *pc, *tpc = tline, *epc;
921
922 pdecode(ppasswd, p->passwd); /* decrypt password */
923 for (pc=ppasswd, epc=eppasswd; /* escape any '%' characters */
924 *pc; pc++, epc++) { /* so they don't screw up */
925 *epc = *pc; /* the sprintf() statement */
926 if (*pc == '%') { /* in xispdial, by escaping */
927 ++epc; /* a la printf any %'s found */
928 *epc = '%';
929 }
930 }
931 *tpc++ = '\''; /* opening single quote */
932 for (pc = Esline; *pc; pc++) { /* check all '%' characters */
933 for(; *pc && *pc!='%'; pc++) /* by skipping the rest */
934 *tpc++ = *pc; /* while copying them in */
935 if (*pc == 0) break; /* reached end so skip rest */
936 else ++pc; /* else, point to next char */
937 if (*pc == 'U') { /* next char is 'U' */
938 sprintf(tpc, "%s", p->account); /* so stick username in */
939 tpc += strlen(p->account);
940 }
941 else if (*pc == 'P') { /* next char is 'P' */
942 sprintf(tpc, "%s", eppasswd); /* so stick password in */
943 tpc += strlen(eppasswd);
944 }
945 else *tpc++ = *pc; /* tack the second '%' on */
946 }
947 *tpc++='\''; *tpc++=' '; *tpc++='\''; /* insert quotes and space */
948 for (pc = Ssline; *pc; pc++) { /* check all '%' characters */
949 for(; *pc && *pc!='%'; pc++) /* by skipping the rest */
950 *tpc++ = *pc; /* while copying them in */
951 if (*pc == 0) break; /* reached end so skip rest */
952 else ++pc; /* else, point to next char */
953 if (*pc == 'U') { /* next char is 'U' */
954 sprintf(tpc, "%s", p->account); /* so stick username in */
955 tpc += strlen(p->account);
956 }
957 else if (*pc == 'P') { /* next char is 'P' */
958 sprintf(tpc, "%s", eppasswd); /* so stick password in */
959 tpc += strlen(eppasswd);
960 }
961 else *tpc++ = *pc; /* tack the second '%' on */
962 }
963 *tpc++ = '\''; /* closing single quote */
964 *tpc = 0; /* terminate assembled line */
965 return tline;
966 }
967
968 /* Create dialing environment, according to the various dial-in and/
969 or call-back access combinations; some utility functions follow */
970
971 #ifdef ISPENV_USEVARS
972
973 #if BROKEN_SPRINTF
974 #define min(a,b) (((a)<(b))?(a):(b))
975 #endif
976
977 /* Function for accumulating xispdial
978 environment in an environment variable */
979
980 static void
981 eprintf(char *fmt, ...)
982 {
983 va_list ap;
984 static char *buf = NULL;
985 static size_t buflen = 0;
986 static size_t bufsiz = 0;
987 #if BROKEN_SPRINTF
988 char etmp[MAXLEN_FNAME + 32];
989 #endif
990
991 va_start(ap, fmt);
992 if (fmt) {
993 unsigned int n;
994
995 while (buflen >= bufsiz ||
996 #if BROKEN_SPRINTF
997 (vsprintf(etmp, fmt, ap),
998 bcopy(etmp, buf+buflen, min(bufsiz-buflen, strlen(etmp))),
999 n = strlen(etmp))
1000 #else
1001 (n = vsnprintf(buf+buflen, bufsiz-buflen, fmt, ap))
1002 #endif
1003 >= bufsiz - buflen
1004 )
1005 {
1006 if ((buf = realloc(buf, bufsiz+1024)) == NULL)
1007 doErr("eprintf, realloc");
1008 memset(&buf[bufsiz], 0, 1024);
1009 bufsiz += 1024;
1010 }
1011 buflen += n;
1012 }
1013 else {
1014 #if defined(SUNOS41x) || defined(SUNOS5x)
1015 int len = strlen(ENVVAR) + 1;
1016
1017 if ((buf = realloc(buf, bufsiz+len+1)) == NULL)
1018 doErr("eprintf, realloc");
1019 memset(&buf[bufsiz], 0, len+1);
1020 #ifdef SUNOS41x
1021 bcopy(buf, &buf[len], bufsiz);
1022 #else
1023 memmove(&buf[len], buf, bufsiz);
1024 #endif /* SUNOS41x */
1025 bufsiz += (len + 1);
1026 strncpy(buf, ENVVAR, len-1);
1027 buf[len-1] = '=';
1028 putenv(buf);
1029 #else
1030 setenv(ENVVAR, buf, 1);
1031 #endif /* defined(SUNOS41x) || defined(SUNOS5x) */
1032 buf[0] = '\0';
1033 buflen = 0;
1034 }
1035 va_end(ap);
1036 }
1037
1038 #else /* ISPENV_USEVARS */
1039
1040 /* Function for accumulating xispdial environment in a file */
1041
1042 static void
1043 eprintf(char *fmt, ...)
1044 {
1045 va_list ap;
1046 static FILE *envfp = NULL;
1047
1048 va_start(ap, fmt);
1049 /* If the 'fmt' arg is NULL, close the environment file. */
1050 if (fmt) {
1051 /* Create the environment file if it is not already open. */
1052 if (envfp == NULL) {
1053 envfp = fopen(envfname, "w"); /* create the file */
1054 if (envfp == NULL) /* bail out on error */
1055 doErr("writeISPenv, fopen");
1056 }
1057 vfprintf(envfp, fmt, ap);
1058 }
1059 else if (envfp != NULL) {
1060 fclose(envfp);
1061 envfp = NULL;
1062 }
1063
1064 va_end(ap);
1065 }
1066
1067 #endif /* ISPENV_USEVARS */
1068
1069 /* Send terminal parameters for xispterm */
1070
1071 void envTermParms(xisprc_t *p)
1072 {
1073 int w, h, tmp;
1074 FL_Coord x, y;
1075
1076 eprintf("%s\n", /* tell xispdial the DISPLAY */
1077 XDisplayName(NULL));
1078 eprintf("#%02X%02X%02X\n", /* the background color */
1079 bgcol.r, bgcol.g, bgcol.b);
1080 fl_get_winorigin(topWin, &x, &y); /* a geometry position */
1081 x = (x-40 > 0)? x-40 : 0;
1082 y = (y-60 > 0)? y-60 : 0;
1083 w = fl_get_char_width( /* a width in chars */
1084 FL_FIXED_STYLE, FL_MEDIUM_SIZE);
1085 w = w * (p->termW) + 24;
1086 h = fl_get_char_height( /* and a height in chars */
1087 FL_FIXED_STYLE, FL_MEDIUM_SIZE,
1088 &tmp, &tmp);
1089 h = h * (p->termH) + 59;
1090 eprintf("%dx%d+%d+%d\n", w, h, x, y);
1091 }
1092
1093 /* Return mode according to selected options */
1094
1095 unsigned char envAdjustMode(xisprc_t *p)
1096 {
1097 unsigned int mode = SCRIPT_DIALIN;
1098 void adjustPAPCap();
1099
1100 adjustPAPCap(); /* check PAP capability */
1101 if (p->operOpts & (PAP_LOGIN | PAPS_LOGIN | /* authenticated login? */
1102 CHAPS_LOGIN)) {
1103 mode = AUTH_DIALIN; /* yes, set generic mode */
1104 if (p->operOpts & MANUAL_LOGIN) /* manual login during dial- */
1105 mode |= MANUAL_DIALIN; /* in desired -> add option */
1106 if (p->operOpts & CALL_BACK) { /* if call-back selected */
1107 if (p->operOpts & CB_NT_RAS) { /* NT RAS call-back server? */
1108 if (firstConn) /* first call -> AUTH_DIALIN */
1109 mode |= NT_RAS_DIALIN; /* tell xispdial it's NT-RAS */
1110 else {
1111 mode |= NT_RAS_CALLBACK; /* second call -> call-back */
1112 mode &= ~MANUAL_DIALIN; /* flag has no meaning in */
1113 } /* the RAS call-back phase */
1114 }
1115 else /* otherwise, generic */
1116 mode |= AUTH_CALLBACK; /* authenticated call-back */
1117 }
1118 }
1119 else { /* else, not authenticated */
1120 if (p->operOpts & MANUAL_LOGIN) /* is this a manual login? */
1121 mode = MANUAL_DIALIN; /* yes, set generic mode */
1122 else /* else not manual login */
1123 mode = SCRIPT_DIALIN; /* so it's simple, scripted */
1124 if (p->operOpts & CALL_BACK) { /* is call-back enabled? */
1125 if (p->operOpts & CBMAN_LOGIN) /* call-back phase manual? */
1126 mode |= MANUAL_CALLBACK; /* yes, combination mode */
1127 else /* else, scripted call-back */
1128 mode |= SCRIPT_CALLBACK; /* phase is assumed */
1129 }
1130 }
1131 return mode;
1132 }
1133
1134 int writeISPenv(xisprc_t *p)
1135 {
1136 int i, ret = 0;
1137 unsigned int mode = SCRIPT_DIALIN;
1138
1139 eprintf("%s\n", Chat); /* write all global */
1140 eprintf("%s\n", Pipe); /* dialing variables */
1141 eprintf("%s\n", Terminal);
1142 eprintf("%d\n", p->maxAttempts);
1143 eprintf("%d\n", p->sleepDelay);
1144 eprintf("%d\n", p->connectWait);
1145 eprintf("%d\n", p->numPhones);
1146 for (i=0; i<p->numPhones; i++)
1147 eprintf("%s\n", p->phone[i]);
1148 mode = envAdjustMode(p);
1149 eprintf("%X\n", mode); /* send connection mode */
1150 switch (mode) { /* send data according to */
1151 /* the selected mode */
1152 case SCRIPT_DIALIN:
1153 eprintf("%s\n", p->account); /* account and script lines */
1154 eprintf("%d\n",p->numSlines); /* only for scripted login */
1155 for (i=0; i<p->numSlines; i++) {
1156 ret = lineCheck(p->sline[i]); /* check expect-line syntax */
1157 if (ret > 0)
1158 ret = lineCheck(p->sline[ /* if OK, check send-line */
1159 MAXNUM_SLINES+i]);
1160 if (ret <= 0) { /* syntax problem? */
1161 eprintf(NULL); /* yes, close file */
1162 return ret; /* and bail out */
1163 }
1164 eprintf("%s\n", /* print expect-send pairs */
1165 linePrep(p, p->sline[i], /* as prepared by routine */
1166 p->sline[MAXNUM_SLINES+i])); /* linePrep() */
1167 }
1168 break;
1169
1170 case SCRIPT_DIALIN|SCRIPT_CALLBACK:
1171 eprintf("%s\n", p->account); /* account and script lines */
1172 eprintf("%d\n",p->numSlines); /* only for scripted login */
1173 for (i=0; i<p->numSlines; i++) {
1174 ret = lineCheck(p->sline[i]); /* check expect-line syntax */
1175 if (ret > 0)
1176 ret = lineCheck(p->sline[ /* if OK, check send-line */
1177 MAXNUM_SLINES+i]);
1178 if (ret <= 0) { /* syntax problem? */
1179 eprintf(NULL); /* yes, close file */
1180 return ret; /* and bail out */
1181 }
1182 eprintf("%s\n", /* print expect-send pairs */
1183 linePrep(p, p->sline[i], /* as prepared by routine */
1184 p->sline[MAXNUM_SLINES+i])); /* linePrep() */
1185 }
1186 eprintf("%d\n",p->CBDelay); /* print out call-back delay */
1187 eprintf("%d\n",p->numCBSlns); /* and the call-back */
1188 for (i=0; i<p->numCBSlns; i++) { /* script lines */
1189 ret = lineCheck(p->CBsln[i]); /* check expect-line syntax */
1190 if (ret > 0)
1191 ret = lineCheck(p->CBsln[
1192 MAXNUM_SLINES+i]); /* if OK, check send-line */
1193 if (ret <= 0) { /* syntax problem? */
1194 eprintf(NULL); /* yes, close file */
1195 return ret; /* and bail out */
1196 }
1197 eprintf("%s\n", /* print expect-send pairs */
1198 linePrep(p, p->CBsln[i], /* for call-back lines as */
1199 p->CBsln[MAXNUM_SLINES+i])); /* prepared by linePrep() */
1200 }
1201 break;
1202
1203 case SCRIPT_DIALIN|MANUAL_CALLBACK:
1204 eprintf("%s\n", p->account); /* account and script lines */
1205 eprintf("%d\n",p->numSlines); /* only for scripted login */
1206 for (i=0; i<p->numSlines; i++) {
1207 ret = lineCheck(p->sline[i]); /* check expect-line syntax */
1208 if (ret > 0)
1209 ret = lineCheck(p->sline[ /* if OK, check send-line */
1210 MAXNUM_SLINES+i]);
1211 if (ret <= 0) { /* syntax problem? */
1212 eprintf(NULL); /* yes, close file */
1213 return ret; /* and bail out */
1214 }
1215 eprintf("%s\n", /* print expect-send pairs */
1216 linePrep(p, p->sline[i], /* as prepared by routine */
1217 p->sline[MAXNUM_SLINES+i])); /* linePrep() */
1218 }
1219 envTermParms(p); /* send terminal parameters */
1220 eprintf("%d\n",p->CBDelay); /* and call-back delay */
1221 break;
1222
1223 case MANUAL_DIALIN:
1224 envTermParms(p); /* send terminal parameters */
1225 break;
1226
1227 case MANUAL_DIALIN|SCRIPT_CALLBACK:
1228 envTermParms(p); /* send terminal parameters */
1229 eprintf("%d\n",p->CBDelay); /* and call-back delay */
1230 eprintf("%d\n",p->numCBSlns); /* then send the call-back */
1231 for (i=0; i<p->numCBSlns; i++) { /* script lines */
1232 ret = lineCheck(p->CBsln[i]); /* check expect-line syntax */
1233 if (ret > 0)
1234 ret = lineCheck(p->CBsln[
1235 MAXNUM_SLINES+i]); /* if OK, check send-line */
1236 if (ret <= 0) { /* syntax problem? */
1237 eprintf(NULL); /* yes, close file */
1238 return ret; /* and bail out */
1239 }
1240 eprintf("%s\n", /* print expect-send pairs */
1241 linePrep(p, p->CBsln[i], /* for call-back lines as */
1242 p->CBsln[MAXNUM_SLINES+i])); /* prepared by linePrep() */
1243 }
1244 break;
1245
1246 case MANUAL_DIALIN|MANUAL_CALLBACK:
1247 envTermParms(p); /* send terminal parameters */
1248 eprintf("%d\n",p->CBDelay); /* and call-back delay */
1249 break;
1250
1251 case AUTH_DIALIN:
1252 case AUTH_DIALIN|NT_RAS_DIALIN:
1253 break;
1254
1255 case AUTH_DIALIN|AUTH_CALLBACK:
1256 case AUTH_DIALIN|NT_RAS_CALLBACK:
1257 eprintf("%d\n",p->CBDelay); /* send the call-back delay */
1258 break;
1259
1260 case AUTH_DIALIN|MANUAL_DIALIN:
1261 case AUTH_DIALIN|MANUAL_DIALIN|
1262 NT_RAS_DIALIN:
1263 envTermParms(p); /* send terminal parameters */
1264 break;
1265
1266 case AUTH_DIALIN|MANUAL_DIALIN|
1267 AUTH_CALLBACK:
1268 envTermParms(p); /* send terminal parameters */
1269 eprintf("%d\n",p->CBDelay); /* and call-back delay */
1270 break;
1271
1272 default: break;
1273 }
1274 eprintf("%s\n", p->modemReset); /* modem reset */
1275 eprintf("%s\n", p->modemInit); /* and init strings */
1276 if (p->operOpts & MODEM_TONEDIAL) /* dialing command char(s) */
1277 eprintf("%sDT\n",
1278 p->dialExtra);
1279 else if (p->operOpts & MODEM_ISDNDIAL)
1280 eprintf("%sDI\n", p->dialExtra);
1281 else
1282 eprintf("%sDP\n", p->dialExtra);
1283 eprintf("%s\n", p->modemConnect); /* modem connect string */
1284 eprintf(NULL); /* finally, close the file */
1285 return 1; /* all OK */
1286 }
1287
1288 /* Create PAP authentication file */
1289
1290 void writeISPPAP(xisprc_t *p)
1291 {
1292 FILE *papfp;
1293 char ppasswd[MAXLEN_PASSWD+1] = {0};
1294
1295 papfp = fopen(papfname, "w"); /* create the file */
1296 if (papfp == NULL) /* bail out on error */
1297 doErr("writeISPPAP, fopen");
1298 pdecode(ppasswd, p->passwd); /* decrypt password */
1299 fprintf(papfp, "%s\n", p->account); /* write username and */
1300 fprintf(papfp, "%s\n", ppasswd); /* password for PAP */
1301 fclose(papfp);
1302 }
1303
1304 /* Update all connection indicators */
1305
1306 void updateStat(int linkOK)
1307 {
1308 fl_set_object_label(fd_topFrame->statusText,
1309 (connected)? ((linkOK) ? "ON-LINE" : "CARRIER") :
1310 ((dialerON) ? "XISPDIAL" : "OFF-LINE"));
1311 fl_set_object_label(fd_topFrame->speedText,
1312 (connected) ? connSpeed : EMPTY_SPEED);
1313 fl_set_object_label(fd_topFrame->IPText,
1314 (linkOK) ? connIP : EMPTY_IP);
1315 }
1316
1317
1318 /* Figure out the name of the PPP interface created by the pppd process
1319 we started. Routine is functional only when RUNDIR is available, and
1320 is quite simplistic in its assumptions. More specifically, as there's
1321 no "robust" way of figuring out if the pppd we started indeed was the
1322 parent process of the detached pppd who's PID is saved in the file,
1323 it assumes that there may be only one active PPP interface at any
1324 given time. Needless to say that this will not work on hosts which
1325 have a static PPP link always active */
1326
1327 #ifdef RUNDIR
1328 #define MAXNUM_PPPIF 4
1329 int getIFname(char *IFname)
1330 {
1331 char buf[16], IFn[8] = {0};
1332 int IFc, fd, br;
1333
1334 for (IFc=0; IFc<MAXNUM_PPPIF; IFc++)
1335 {
1336 sprintf(IFn, "%s%d", pidfp, IFc); /* IF PID-filename prefix */
1337 strcpy(runfnp, IFn);
1338 strcat(runfnp, ".pid"); /* IF PID-filename suffix */
1339 fd = open(PIDFname, O_RDONLY); /* open it for reading */
1340 if (fd < 0) /* file not there */
1341 continue; /* try next available name */
1342 br = read(fd, buf, 16); /* read the PID string */
1343 close(fd); /* close the file */
1344 if (br < 0) /* if error in reading */
1345 continue; /* try next available name */
1346 else {
1347 strcpy(IFname, IFn); /* save interface name */
1348 return 1; /* indicate found */
1349 }
1350 }
1351 *IFname = 0; /* indicate nothing found */
1352 return 0;
1353 }
1354 #else
1355 int getIFname(char *IFname)
1356 {
1357 strcpy(IFname, "ppp0");
1358 return 1;
1359 }
1360 #endif
1361
1362
1363 /* Search for the PID of a process by its name and its parent PID. If
1364 allow_detached is set, then init's PID (i.e., 1) is also considered
1365 a valid parent PID. */
1366
1367 #if !defined(SUNOS41x) && !defined(SUNOS5x) && !(defined(BSD) && BSD >= 199306)
1368 int procPID(char *procname, int parentPID, int allow_detached)
1369 {
1370 DIR *procd;
1371 struct dirent *direntp;
1372 char name[32], statbuf[64], *p;
1373 int statd, br, pid = 0, ppid;
1374
1375 procd = opendir("/proc"); /* open the /proc tree */
1376 while ((direntp=readdir(procd)) != NULL && /* search all entries */
1377 !pid ) {
1378 if (! atoi(direntp->d_name)) /* skip non numeric entries */
1379 continue;
1380 p = direntp->d_name; /* file name is PID number */
1381 strcpy(name, "/proc/"); /* form status file name */
1382 strcat(name, p);
1383 strcat(name, "/status");
1384 if ((statd=open(name,O_RDONLY)) < 0) { /* and open it */
1385 closedir(procd); /* bail out on failure */
1386 return 0;
1387 }
1388 br = read(statd, statbuf, 63); /* read first few lines */
1389 close(statd); /* and close it */
1390 if (br < 0) { /* bail out if read fails */
1391 closedir(procd);
1392 return 0;
1393 }
1394 statbuf[br] = 0; /* zero terminate buffer */
1395 sscanf(statbuf, "Name: %s", name); /* get process name */
1396 if (strcmp(name, procname)) /* continue if it's not the */
1397 continue; /* one we're looking for */
1398 p = strstr(statbuf, "Pid:"); /* find PID string */
1399 sscanf(p, "Pid: %d PPid: %d", /* and read PID and PPID */
1400 &pid, &ppid);
1401 if (allow_detached) { /* detached OK -> check init */
1402 if (ppid != 1 && /* if parent is not init nor */
1403 ppid != parentPID) /* the specified parent PID */
1404 pid = 0; /* then ignore and continue */
1405 }
1406 else { /* else, detached not OK, so */
1407 if (ppid != parentPID) /* if parent does not match */
1408 pid = 0; /* then ignore and continue */
1409 }
1410 } /* so ignore it and continue */
1411 closedir(procd); /* search done */
1412 return pid; /* return whatever we found */
1413 }
1414 #else
1415 int procPID(char *procname, int parentPID, int allow_detached)
1416 {
1417 FILE *infofp;
1418 char psLine[128], name[32];
1419 int pid = 0, ppid;
1420
1421 #ifdef SUNOS41x
1422 infofp = popen("/bin/ps -aclxw", "r"); /* open proc info stream */
1423 #elif (defined(BSD) && BSD >= 199306)
1424 infofp = popen("/bin/ps -aclxw", "r");
1425 #else
1426 infofp = popen("/bin/ps -el", "r");
1427 #endif
1428 if (infofp == NULL) /* failed to open? */
1429 return 0; /* yes, bail out */
1430 while (fgets(psLine, 128, infofp)!=NULL && /* open OK, read entries */
1431 !pid) {
1432 #ifdef SUNOS41x
1433 if (sscanf(psLine, "%*s %*s %d %d %*s"
1434 " %*s %*s %*s %*s %*s %*s %*s"
1435 " %*s %s", &pid, &ppid, name))
1436 #elif (defined(BSD) && BSD >= 199306)
1437 if (sscanf(psLine, "%*s %d %d %*s"
1438 " %*s %*s %*s %*s %*s %*s %*s"
1439 " %*s %s", &pid, &ppid, name))
1440 #else
1441 if (sscanf(psLine, "%*s %*s %*s %d %d"
1442 " %*s %*s %*s %*s %*s %*s %*s"
1443 " %*s %s", &pid, &ppid, name))
1444 #endif
1445 {
1446 if (strcmp(name, procname)) { /* continue if no match */
1447 pid = 0;
1448 continue;
1449 }
1450 if (allow_detached) { /* detached OK -> check init */
1451 if (ppid != 1 && /* parent is not init nor */
1452 ppid != parentPID) /* the specified parent PID */
1453 pid = 0; /* so ignore and continue */
1454 }
1455 else {
1456 if (ppid != parentPID) /* parent does not match */
1457 pid = 0; /* so ignore and continue */
1458 }
1459 }
1460 else pid = 0;
1461 }
1462 pclose(infofp); /* search done */
1463 return pid; /* return whatever we found */
1464 }
1465 #endif
1466
1467
1468 /* Retrieve PID of spawned pppd process from RUNDIR/(s)ppp?.pid and/or from
1469 the PPPDLCKDIR/LCK..? or PPPDLCKDIR/LK.major(dev).major(rdev).minor(rdev)
1470 lock file for the modem device (the actual name is assembled in
1471 call-back function doConnect()). If RUNDIR is not defined, search /proc
1472 for the pppd entry in the process table. Note that if RUNDIR is not
1473 available, the pppIF global var defaults to "ppp0", so checks for cases
1474 of multiple PPP interfaces are not possible */
1475
1476 int getPppdPID(char *devlock)
1477 {
1478 #if defined(RUNDIR) && defined (PPPDLCKDIR)
1479 char buf[32];
1480 int fd = -1, br;
1481
1482 if (*pppIF || /* if we know, or if we can */
1483 (*pppIF == 0 && getIFname(pppIF))) /* find the PID file name */
1484 {
1485 strcpy(runfnp, pppIF); /* form the complete file */
1486 strcat(runfnp, ".pid"); /* name for this interface */
1487 fd = open(PIDFname, O_RDONLY); /* and open it for reading */
1488 }
1489 if (fd < 0 && devlock != NULL) { /* if PID file is not there */
1490 strcpy(lockfnp, devlock); /* try the lock file for the */
1491 fd = open(lockFname, O_RDONLY); /* modem port device; this */
1492 } /* also contains pppd's PID */
1493 if (fd < 0) /* if file(s) not there */
1494 return 0; /* indicate nothing found */
1495 br = read(fd, buf, 32); /* else read the PID string */
1496 close(fd); /* close the file */
1497 if (br < 0) /* if error in reading */
1498 return 0; /* ppp?.pid or LCK..? file */
1499 else { /* screwed -> ret not found */
1500 buf[br] = 0; /* else mark end of string */
1501 return atoi(buf); /* and return converted */
1502 }
1503 #elif defined(PPPDLCKDIR)
1504 char buf[32];
1505 int fd = -1, br;
1506
1507 if (devlock != NULL) { /* if a lock is specified */
1508 strcpy(lockfnp, devlock); /* try the lock file for it */
1509 fd = open(lockFname, O_RDONLY); /* this file contains pppd's */
1510 } /* PID */
1511 if (fd < 0) /* name or file not there */
1512 return 0; /* indicate nothing found */
1513 br = read(fd, buf, 32); /* else read the PID string */
1514 close(fd); /* close the file */
1515 if (br < 0) /* if error in reading */
1516 return 0; /* ppp?.pid or LCK..? file */
1517 else { /* screwed -> ret not found */
1518 buf[br] = 0; /* else mark end of string */
1519 return atoi(buf); /* and return converted */
1520 }
1521 #else
1522 return procPID("pppd", pppdPPID, 1); /* return PID search result */
1523 #endif
1524 }
1525
1526 /* Retrieve PID of ip-up/ip-down script spawned by the child pppd process */
1527
1528 int getipUDPID()
1529 {
1530 return procPID(ipWhich, pppdPID, 0); /* return PID search result */
1531 }
1532
1533
1534 /* Wait for pppd to die, after sending SIGINT. Procedure provided because
1535 pppd appears not to honor SIGINT while in the connection phase, when
1536 sending LCP packets to its peer. New pppd started during this phase
1537 will terminate with error. If after sending KILL signals (if it comes
1538 to that) and before returning, the procedure makes sure that there's no
1539 ppp?.pid file left over if there's no pppd process in the process table.
1540 This is for accommodating pppd binaries compiled without the option for
1541 automatic deletion of stale ppp?.pid files. All this, of course, only
1542 when RUNDIR is available. */
1543
1544 #define MAXWAIT_PPPD 8 /* number of iterations waiting for pppd to die */
1545
1546 /* Note that the above number is multiplied by 5 when we are waiting for
1547 pppd to exit gracefully; this is used before starting pppd a second time,
1548 when we are in the process of setting up an NT-RAS call-back connection */
1549
1550 void waitPppd(int beNice)
1551 {
1552 int i, pid, stat = 0, wait = MAXWAIT_PPPD;
1553
1554 #ifdef PPPDLCKDIR
1555 if (beNice && (pid=getPppdPID(devLock))) { /* if in "graceful" mode */
1556 #else /* and provided we can */
1557 if (beNice && (pid=getPppdPID(NULL))) { /* figure out pppd's PID */
1558 #endif
1559 wait *= 5; /* multiply iterations by 5 */
1560 bprintf("%s%d%s%s%s...\n", /* print message on browser */
1561 "Waiting for pppd[",pid,"] (",
1562 #if defined(SUNOS5x) || defined(SVR4)
1563 devPath,
1564 #else
1565 devName,
1566 #endif
1567 ") to terminate...");
1568 fl_check_forms(); /* update browser */
1569 }
1570 for (i=0; i<wait && !stat && /* as long as pppd is there */
1571 #ifdef PPPDLCKDIR /* and up to "wait" times */
1572 (pid=getPppdPID(devLock));
1573 #else
1574 (pid=getPppdPID(NULL));
1575 #endif
1576 i++)
1577 {
1578 if (! beNice) {
1579 stat = kill(pid, SIGINT); /* send SIGINT to pppd */
1580 bprintf("%s%d%s...%d\n", /* print message on browser */
1581 "Waiting for pppd[", pid,
1582 "] to die", i+1);
1583 }
1584 fl_check_forms(); /* update forms */
1585 mSleep(2000); /* wait a couple of seconds */
1586 }
1587 if (i >= wait || stat < 0) { /* timeout or signal failed */
1588 #ifdef PPPDLCKDIR
1589 if ((pid = getPppdPID(devLock))) { /* if pppd's PID exists */
1590 #else
1591 if ((pid = getPppdPID(NULL))) {
1592 #endif
1593 bprintf("%s%d%s\n", /* print message on browser */
1594 "Killing pppd[", pid, "].");
1595 fl_check_forms(); /* update browser */
1596 kill(pid, SIGKILL); /* send SIGKILL to pppd */
1597 mSleep(1000); /* and wait a second */
1598 }
1599 #ifdef RUNDIR
1600 #ifdef PPPDLCKDIR
1601 if ((pid = getPppdPID(devLock))) { /* if pppd's PID exists */
1602 #else
1603 if ((pid = getPppdPID(NULL))) {
1604 #endif
1605 if (! procPID("pppd",pppdPPID,1)) { /* without a pppd process */
1606 bprintf("\n@bStale %s file " /* print a hint for the user */
1607 "exists.\nIf pppd fails to " /* with regards to the stale */
1608 "start, please\nremove it " /* ppp?.pid file found */
1609 "manually and try again.\n",
1610 PIDFname);
1611 fl_check_forms(); /* update browser */
1612 }
1613 }
1614 #endif
1615 }
1616 else if (wait > 0) /* signal OK, but some delay */
1617 mSleep(1500); /* so wait another 1.5 sec */
1618 }
1619
1620
1621 /* String <-> IP address conversions */
1622
1623 void IPToStr(unsigned char *ip, char *str) /* convert IP to string */
1624 {
1625 sprintf(str, "%u.%u.%u.%u",
1626 ip[0],ip[1],ip[2],ip[3]);
1627 }
1628
1629 int StrToIP(char *str, unsigned char *ip) /* convert string to IP */
1630 {
1631 unsigned int iip[4];
1632 int n, i;
1633
1634 n = sscanf(str, "%3u.%3u.%3u.%3u", &iip[0],
1635 &iip[1], &iip[2], &iip[3]);
1636 if (n == 4)
1637 for (i=0; i<4; ip++, i++) *ip = iip[i];
1638 return n;
1639 }
1640
1641
1642 /* Check optional pppd options file */
1643
1644 int pppdOptsFileOK(void)
1645 {
1646 struct stat st;
1647
1648 if (!stat(PPPD_OPTIONS, &st)) /* does it exist ? */
1649 return (st.st_size > 0); /* yup, if size > 0 all OK */
1650 else
1651 return 0; /* no it doesn't */
1652 }
1653
1654
1655 /* Reduce colormap usage */
1656
1657 void colorSqueeze(void)
1658 {
1659 int i;
1660
1661 for (i=0; i<FL_FREE_COL1; i++) {
1662 switch (i) {
1663
1664 case FL_BLACK: /* except for these which */
1665 case FL_CYAN: /* are used in our code */
1666 case FL_DARKCYAN:
1667 case FL_WHITE:
1668 case FL_COL1:
1669 case FL_RIGHT_BCOL:
1670 case FL_BOTTOM_BCOL:
1671 case FL_TOP_BCOL:
1672 case FL_LEFT_BCOL:
1673 case FL_MCOL:
1674 case FL_INACTIVE:
1675 case FL_WHEAT:
1676
1677 case FL_INDIANRED: /* these are replaced */
1678 case FL_GREEN:
1679 break;
1680
1681 default:
1682 fl_set_icm_color(i, 0,0,0); /* reset all unused internal */
1683 } /* colormap colors to black */
1684 }
1685 }
1686
1687 /* Parse user-specified background color from string */
1688
1689 void bgColor(char *color)
1690 {
1691 color_t bgcol_default = BGCOL_DEFAULT;
1692 int i;
1693
1694 i = sscanf(color, "#%2X%2X%2X", /* scan the hex color */
1695 &bgcol.r, &bgcol.g, &bgcol.b);
1696 if (i != 3) /* if scan unsuccessful */
1697 bgcol = bgcol_default; /* use the default color */
1698 fl_mapcolor(FL_INDIANRED, /* replace the ones used */
1699 bgcol.r, bgcol.g, bgcol.b);
1700 tabcol.r = 2.9 * bgcol.r / 4.;
1701 tabcol.g = 2.5 * bgcol.g / 4.;
1702 tabcol.b = 2.5 * bgcol.b / 4.;
1703 fl_mapcolor(FL_GREEN,
1704 tabcol.r, tabcol.g, tabcol.b);
1705 }
1706
1707
1708 /* Make sure the fonts used are the same as those used for designing
1709 all program forms. Although generally this isn't such a good idea,
1710 it nevertheless prevents selection of "ugly" or "oversize" fonts
1711 by the XForms GUI library */
1712
1713 void fontSelect(void)
1714 {
1715 int status = 0;
1716
1717 status = fl_set_font_name(FL_NORMAL_STYLE,
1718 "-adobe-helvetica-medium-r-*-*-*-?-75-75-*-*-*-*");
1719 status += fl_set_font_name(FL_BOLD_STYLE,
1720 "-adobe-helvetica-bold-r-*-*-*-?-75-75-*-*-*-*");
1721 status += fl_set_font_name(FL_ITALIC_STYLE,
1722 "-adobe-helvetica-medium-o-*-*-*-?-75-75-*-*-*-*");
1723 status += fl_set_font_name(FL_BOLDITALIC_STYLE,
1724 "-adobe-helvetica-bold-o-*-*-*-?-75-75-*-*-*-*");
1725 status += fl_set_font_name(FL_FIXED_STYLE,
1726 "-adobe-courier-medium-r-*-*-*-?-75-75-*-*-*-*");
1727 status += fl_set_font_name(FL_FIXEDBOLD_STYLE,
1728 "-adobe-courier-bold-r-*-*-*-?-75-75-*-*-*-*");
1729 status += fl_set_font_name(FL_FIXEDITALIC_STYLE,
1730 "-adobe-courier-medium-o-*-*-*-?-75-75-*-*-*-*");
1731 status += fl_set_font_name(FL_FIXEDBOLDITALIC_STYLE,
1732 "-adobe-courier-bold-o-*-*-*-?-75-75-*-*-*-*");
1733 if (status != 0) {
1734 fprintf(stderr, "xISP: warning: desired font(s) not found.\n"
1735 "Replacements may appear ugly/unintelligible.\n");
1736 }
1737 }
1738
1739
1740 /* Returns pointer to string with cost value properly formatted */
1741
1742 char *costStr(ptt_t *p, float cost)
1743 {
1744 char format[MAXLEN_CURRENCY+5+1];
1745 static char cstr[32+MAXLEN_CURRENCY+5+1];
1746
1747 if (p->attribs & PTT_CUR_AFTER_COST) /* format according to type */
1748 sprintf(format, "%%.%df %s",
1749 p->decimals, p->currency);
1750 else
1751 sprintf(format, "%s %%.%df",
1752 p->currency, p->decimals);
1753 sprintf(cstr, format, cost); /* build the cost printout */
1754 return cstr;
1755 }
1756
1757 /* Returns pointer to string with time-part value properly formatted */
1758
1759 char *uc2ts(ruletime_t time, char part)
1760 {
1761 static char tstr[3];
1762
1763 switch (part) {
1764 case 'H': sprintf(tstr, "%02d", time.h); break;
1765 case 'M': sprintf(tstr, "%02d", time.m); break;
1766 case 'S': sprintf(tstr, "%02d", time.s); break;
1767 default: strcpy(tstr, "00"); break;
1768 }
1769 return tstr;
1770 }
1771
1772 /* Returns pointer to string with date-part value properly formatted */
1773
1774 char *uc2ds(ruledate_t date, char part)
1775 {
1776 static char dstr[3];
1777
1778 switch (part) {
1779 case 'M': if (date.day > 0) sprintf(dstr, "%02d", 1+date.mon);
1780 else strcpy(dstr, "00");
1781 break;
1782 case 'D': sprintf(dstr, "%02d", date.day);
1783 break;
1784 default: strcpy(dstr, "00"); break;
1785 }
1786 return dstr;
1787 }
1788
1789
1790 /* Updates xisp logging files if logging is enabled */
1791
1792 void updateLogs(int online)
1793 {
1794 time_t ct;
1795 char cts[32];
1796 unsigned long packetsTXed, packetsRXed;
1797
1798 if (! (global.logOpts & LOG_NONE)) { /* if logging desired */
1799 if (online) ct = upTime; /* pick appropriate time */
1800 else ct = downTime;
1801 strcpy(cts, ctime(&ct)); /* format it the usual way */
1802 cts[strlen(cts)-1] = 0; /* remove trailing '\n' */
1803 if (p_ptt->attribs & PTT_BY_UNIT) /* if the selected PTT */
1804 totalCost = totalUnits * /* charges by unit, then */
1805 p_ptt->cost_quantum; /* calculate total cost and */
1806 writeXispCost(totalTime, totalCost); /* save time/cost totals */
1807 pppPkts(pppIF, &packetsTXed, /* get packet totals */
1808 &packetsRXed);
1809 if (online) { /* if coming "up", then */
1810 if (initLogFnames(&global)) /* check file names; if */
1811 restartXispCost(&totalTime, /* changed, reset log file */
1812 &totalCost); /* this also resets totals */
1813 }
1814 writeXispLog(online, p_ptt, cts, /* update connection logs */
1815 p_xisprc->descr, connIP,
1816 speedStr, onLineSecs, onLineCost,
1817 packetsTXed, packetsRXed);
1818 if (! online) { /* if going "down", perform */
1819 if (initLogFnames(&global)) /* the file name changing */
1820 restartXispCost(&totalTime, /* and log resetting AFTER */
1821 &totalCost); /* the logs are updated */
1822 }
1823 }
1824 }
1825
1826
1827 /* Displays information for PTT selected on the Logging-information
1828 browser. Note the maximum internal length of the buffer used. */
1829
1830 #define MAXLEN_PTTINFB 128
1831
1832 int ibprt(char *fmt, ...)
1833 {
1834 int bw;
1835 char buf[MAXLEN_PTTINFB+1] = {0};
1836 va_list ap;
1837
1838 va_start(ap, fmt);
1839 #ifdef BROKEN_SPRINTF
1840 vsprintf(buf, fmt, ap);
1841 bw = strlen(buf);
1842 #else
1843 bw = vsprintf(buf, fmt, ap);
1844 #endif
1845 va_end(ap);
1846 fl_addto_browser(fd_logInfo->costBrowser, buf);
1847 return bw;
1848 }
1849
1850
1851 void showPttInfo(ptt_t *p)
1852 {
1853 char method[8], pnc[16] = {0}, pmc[16] = {0};
1854 int z, c;
1855 float minVal = 0.0, maxVal = 0.0;
1856
1857 fl_clear_browser(fd_logInfo->costBrowser);
1858 if (p->num_zones < 1) {
1859 ibprt("Unitialized PTT entry\n");
1860 return;
1861 }
1862 if (p->attribs & PTT_PER_MINUTE)
1863 strcpy(method, "minute");
1864 else {
1865 if (p->attribs & PTT_PER_SECS) {
1866 if (p->charge_period > 1)
1867 sprintf(method, "%d seconds", p->charge_period);
1868 else
1869 strcpy(method, "second");
1870 }
1871 else
1872 strcpy(method, "unit");
1873 }
1874 ibprt("PTT entry has %d zone%s", p->num_zones,
1875 (p->num_zones>1)? "s":"");
1876 if (p->attribs & (PTT_PER_MINUTE|PTT_PER_SECS))
1877 ibprt("Charging is per %s", method);
1878 else {
1879 if (p->attribs & PTT_CUR_AFTER_COST)
1880 ibprt("Charging is by %s, each costing %g %s",
1881 method, p->cost_quantum, p->currency);
1882 else
1883 ibprt("Charging is by %s, each costing %s %g",
1884 method, p->currency, p->cost_quantum);
1885 }
1886
1887 if (p->attribs & (PTT_PER_MINUTE|PTT_PER_SECS)) {
1888 if (p->min_cost > 0) {
1889 strncpy(pnc, costStr(p, p->min_cost), 15);
1890 ibprt("Minimum cost charged: %s", pnc);
1891 }
1892 else
1893 ibprt("No minimum cost charged");
1894 for (z=0; z<p->num_zones; z++) {
1895 minVal = maxVal = p->dflt_tariff[z];
1896 for (c=0; c<p->num_categories; c++) {
1897 if (p->rule[z][c].tariff < minVal)
1898 minVal = p->rule[z][c].tariff;
1899 if (p->rule[z][c].tariff > maxVal)
1900 maxVal = p->rule[z][c].tariff;
1901 }
1902 if (p->num_categories > 1 && minVal != maxVal) {
1903 strncpy(pnc, costStr(p, 60.0*minVal), 15);
1904 strncpy(pmc, costStr(p, 60.0*maxVal), 15);
1905 ibprt("%s: %s/h to %s/h",
1906 p->zone_name[z], pnc, pmc);
1907 }
1908 else {
1909 if (p->num_categories > 0) {
1910 strncpy(pnc, costStr(p, 60.0*p->rule[z][0].tariff), 15);
1911 ibprt("%s: %s/h", p->zone_name[z], pnc);
1912 }
1913 else {
1914 strncpy(pnc, costStr(p, 60.0*p->dflt_tariff[z]), 15);
1915 ibprt("%s: %s/h", p->zone_name[z], pnc);
1916 }
1917 }
1918 }
1919 }
1920 else {
1921 if (p->min_units > 0)
1922 ibprt("Minimum units charged: %d", p->min_units);
1923 else
1924 ibprt("No minimum units charged");
1925 for (z=0; z<p->num_zones; z++) {
1926 minVal = maxVal = p->dflt_tariff[z];
1927 for (c=0; c<p->num_categories; c++) {
1928 if (p->rule[z][c].tariff < minVal)
1929 minVal = p->rule[z][c].tariff;
1930 if (p->rule[z][c].tariff > maxVal)
1931 maxVal = p->rule[z][c].tariff;
1932 }
1933 if (p->num_categories > 1 && minVal != maxVal) {
1934 ibprt("%s: unit lasts %d':%d'' to %d':%d''",
1935 p->zone_name[z],
1936 (int)(minVal/60.0), (int)fmod(minVal, 60.0),
1937 (int)(maxVal/60.0), (int)fmod(maxVal, 60.0));
1938 }
1939 else
1940 ibprt("%s: unit lasts %d':%d''",
1941 p->zone_name[z],
1942 (int)(p->rule[z][0].tariff/60.0),
1943 (int)fmod(p->rule[z][0].tariff, 60.0));
1944 }
1945 }
1946 }
1947
1948
1949 /* Returns pointer to pppd version string */
1950
1951 struct pppdVerStruct {char major, minor, plevel;} pppdVersion(void)
1952 {
1953 static char *cmd, opts[] = " /dev/null --version 2>&1",
1954 ver[8] = {0}, oplevel[4] = {0};
1955 static struct pppdVerStruct nver;
1956 static int first = 1;
1957 char buf[512];
1958 FILE *pfp;
1959 void alertMessage();
1960
1961 if (*ver)
1962 return nver;
1963 if (first || *ver==0) {
1964 cmd = (char *)malloc(strlen(Pppd)+strlen(opts)+1);
1965 if (cmd == NULL)
1966 doErr("pppdVersion");
1967 strcpy(cmd, Pppd); strcat(cmd, opts);
1968 first = 0;
1969 }
1970 *buf = 0;
1971 pfp = popen(cmd, "r");
1972 if (pfp != NULL) {
1973 while (fgets(buf, 63, pfp) &&
1974 sscanf(buf, "%*s version %s %*s %*s %s", ver, oplevel) < 1);
1975 while (fgets(buf, 63, pfp));
1976 pclose(pfp);
1977 }
1978 else {
1979 sprintf(buf, "Unable to start pppd daemon (while checking version)!\n"
1980 "Please check path in File->Options->Program Paths.\n");
1981 alertMessage("xISP: pppdVersion()", 0, 0, buf);
1982 nver.major = nver.minor = nver.plevel = -1;
1983 }
1984 if (*ver) {
1985 char *pfc = ver, *plc;
1986
1987 if ((plc = strchr(pfc,'.')) != NULL) {
1988 *plc = 0;
1989 nver.major = atoi(pfc);
1990 pfc = plc + 1;
1991 }
1992 else {
1993 nver.major = nver.minor = nver.plevel = -1;
1994 return nver;
1995 }
1996 if ((plc = strchr(pfc,'.')) != NULL) {
1997 *plc = 0;
1998 nver.minor = atoi(pfc);
1999 pfc = plc + 1;
2000 nver.plevel = atoi(pfc);
2001 }
2002 else {
2003 nver.minor = atoi(pfc);
2004 if (*oplevel)
2005 nver.plevel = atoi(oplevel);
2006 else
2007 nver.plevel = -1;
2008 }
2009 }
2010 else
2011 nver.major = nver.minor = nver.plevel = -1;
2012 return nver;
2013 }
2014
2015
2016 /* Executes .xisp-up/-down. The up parameter is for distinguishing
2017 between .xisp-up and .xisp-down. The seq parameter is used only
2018 for .xisp-down, and it serves to distinguish between the first
2019 call before disconnection (seq = 0) and the second call after
2020 disconnection (seq = 1). Returns the script PID number */
2021
2022 #define XISPUD_ARGS 8
2023
2024 int xispUD(int up, int seq)
2025 {
2026 int pid, i;
2027 static char *arg[XISPUD_ARGS+1] = {NULL};
2028 char msg[512] = {0};
2029 void alertMessage();
2030 static char prev = 0;
2031
2032 if (!up && !prev && !seq) /* ignore first "down" call */
2033 return 0; /* without a previous "up" */
2034 prev = up; /* save state of last call */
2035
2036 if (up) {
2037 for (i=0; i<XISPUD_ARGS; i++) /* start freeing arg space */
2038 free(arg[i]);
2039 arg[0] = (char *) /* allocate storage for */
2040 malloc(strlen(uupfname)+1); /* argument list; all args */
2041 arg[1] = (char *) /* are retained for "down" */
2042 malloc(strlen(pppIF)+1); /* state also; only the */
2043 arg[2] = (char *) /* name and the seq flag */
2044 malloc(strlen( /* change between states */
2045 p_xisprc->modemDevice)+1);
2046 arg[3] = (char *)
2047 malloc(strlen(speedStr)+1);
2048 arg[4] = (char *)malloc(16);
2049 arg[5] = (char *)malloc(16);
2050 arg[6] = (char *)
2051 malloc(strlen(IPParam)+1);
2052 arg[7] = (char *)malloc(8);
2053
2054 for (i=0; i<XISPUD_ARGS; i++)
2055 if (arg[i] == NULL) /* if allocation failed */
2056 outofMem(); /* then exit with error */
2057
2058 strcpy(arg[0], uupfname); /* script path in arg[0] */
2059 strcpy(arg[1], pppIF); /* interface in arg[1] */
2060 strcpy(arg[2], p_xisprc->modemDevice); /* device in arg[2] */
2061 strcpy(arg[3], speedStr); /* speed in arg[3] */
2062 strcpy(arg[4], IFAddr(pppIF, 0)); /* copy local and remote */
2063 strcpy(arg[5], IFAddr(pppIF, 1)); /* IP addresses */
2064 strcpy(arg[6], IPParam); /* ipparam in arg[6] */
2065 }
2066 else { /* "down" phase: do it twice */
2067 free(arg[0]); /* due to unknown sequencing */
2068 arg[0] = (char *) /* i.e. seq: 0->1 or 1->0 */
2069 malloc(strlen(udownfname)+1); /* re-allocate script name */
2070 if (arg[0] == NULL) /* check allocation */
2071 outofMem(); /* and exit if it failed */
2072 strcpy(arg[0], udownfname); /* script path in arg[0] */
2073 }
2074
2075 if (up) /* arg[7] = 0 if called */
2076 strcpy(arg[7], "1"); /* before state changes or 1 */
2077 else /* if called afterwards but */
2078 sprintf(arg[7], "%d", seq); /* always "0" for "up" mode */
2079 arg[XISPUD_ARGS] = (char *)0; /* terminate argument list */
2080
2081 #ifdef RUNASEUID
2082 if (xisp_euidaccess(arg[0], X_OK) < 0) /* file OK and executable? */
2083 #else
2084 if (access(arg[0], X_OK) < 0)
2085 #endif
2086 return 0; /* nope -> do nothing */
2087
2088 pid = fork(); /* fork to create child */
2089 if (pid < 0) /* ret < 0 : fork failed */
2090 doErr("xispUD: fork");
2091 if (pid) /* in parrent process */
2092 return pid; /* return PID number */
2093 else { /* in script process */
2094 execv(arg[0], arg); /* execute the script */
2095 sprintf(msg, "Can't exec %s!", /* return here means error */
2096 arg[0]);
2097 alertMessage("xISP: xispUD()",0,0,msg);
2098 return 0;
2099 }
2100 }
2101
2102
2103 /* Records the xisp PID in .xisppid in the user's home directory, and
2104 also checks if another xisp process is running, via xisp's PID file.
2105 Prints its error message on a specially designed form */
2106
2107 void recordPID(void)
2108 {
2109 char msg[4*128+2*1024] = {0};
2110 FILE *fp;
2111 FL_OBJECT *ans;
2112
2113 #ifdef RUNASEUID
2114 if (xisp_euidaccess(upidfname, F_OK) == 0) {
2115 sprintf(msg, "If that is not the case, then file %s\n"
2116 "either refers to an instance of xISP which terminated "
2117 "abnormally,\nor another user in your LAN is already "
2118 "running this shared copy\nof xISP. In the former case, "
2119 "you may press Continue to remove\n%s and start xISP.",
2120 upidfname, upidfname);
2121 #else
2122 if (access(upidfname, F_OK) == 0) {
2123 sprintf(msg, "If this is not the case, then file %s\n"
2124 "either contains the PID of xISP running on another machine\n"
2125 "which mounts your home directory, or your last instance of\n"
2126 "xISP terminated abnormally. In the latter case, press Continue\n"
2127 "to remove %s and start xISP.", upidfname, upidfname);
2128 #endif
2129 fl_set_object_label(fd_instanceCheck->msgString, msg);
2130 fl_show_form(fd_instanceCheck->instanceCheck, FL_PLACE_MOUSE,
2131 FL_TRANSIENT, "Instance Check");
2132 while (ans = fl_do_forms(),
2133 ans != fd_instanceCheck->instanceCheckContinue &&
2134 ans != fd_instanceCheck->instanceCheckAbort);
2135 fl_hide_form(fd_instanceCheck->instanceCheck);
2136 if (ans != fd_instanceCheck->instanceCheckAbort)
2137 unlink(upidfname);
2138 else {
2139 fl_finish();
2140 _exit(1);
2141 }
2142 fl_free_form(fd_instanceCheck->instanceCheck);
2143 }
2144 if ((fp = fopen(upidfname, "w")) != NULL) {
2145 fprintf(fp, "%d\n", (int)getpid());
2146 fclose(fp);
2147 }
2148 }
2149
2150
2151 /* Updates the icon label and the window title with the given string */
2152
2153 void updateTitles(char *it, char *wt)
2154 {
2155 char buf[32];
2156 Display *disp = fl_get_display();
2157
2158 if (*wt)
2159 sprintf(buf, "X-ISP %s", wt);
2160 else
2161 strcpy(buf, "X-ISP");
2162 XStoreName(disp, topWin, buf);
2163 XSetIconName(disp, topWin, it);
2164 }
2165
2166 /* Clips the given string so that it fits in the horizontal size
2167 specified; appends '...' as GUI feedback. Returns pointer to
2168 statically allocated result string, or the input string if no
2169 clipping was necessary. Note the maximum internal string size! */
2170
2171 #define CLIPSTRSIZE 128
2172
2173 char *clipStr(char *msg, int size, int style, unsigned int hsize)
2174 {
2175 static char res[CLIPSTRSIZE+4];
2176 unsigned int len = strlen(msg), swidth, sheight;
2177
2178 fl_get_string_dimension(style, size, msg, len, &swidth, &sheight);
2179 if (swidth <= hsize)
2180 return msg;
2181 strncpy(res, msg, CLIPSTRSIZE);
2182 strcat(res, "...");
2183 len += 3;
2184 do {
2185 #ifdef SUNOS41x
2186 bcopy(&res[len-3], &res[len-5], 4);
2187 #else
2188 memmove(&res[len-5], &res[len-3], 4);
2189 #endif
2190 len = strlen(res);
2191 fl_get_string_dimension(style, size, msg, len, &swidth, &sheight);
2192 }
2193 while (swidth > hsize && len > 3);
2194 return res;
2195 }
2196
2197
2198 /* Pops-up a Yes/No dialog box, with the given input
2199 string message, and returns 1 for "Yes" or 0 for "No" */
2200
2201 #define max(a,b) (((a)>(b))?(a):(b))
2202
2203 int actionVerify(char *msg, int big)
2204 {
2205 FL_OBJECT *ans;
2206 int width, height, diff, style, size;
2207
2208 if (big) {
2209 style = FL_NORMAL_STYLE + FL_SHADOW_STYLE;
2210 size = FL_MEDIUM_SIZE;
2211 }
2212 else {
2213 style = FL_NORMAL_STYLE + FL_SHADOW_STYLE;
2214 size = FL_NORMAL_SIZE;
2215 }
2216 fl_set_object_lstyle(fd_actionVerify->actionVerifyStr, style);
2217 fl_set_object_lsize(fd_actionVerify->actionVerifyStr, size);
2218 fl_get_string_dimension(style, size, msg, strlen(msg), &width, &height);
2219 fl_set_form_size(fd_actionVerify->actionVerify,
2220 max(300, width+64), height+84);
2221 diff = (max(300, width+64) - (width+64)) / 3;
2222 fl_set_object_size(fd_actionVerify->actionVerifyStr,
2223 width+10, height+13);
2224 fl_set_object_position(fd_actionVerify->actionVerifyStr, diff+37,16);
2225 fl_set_object_label(fd_actionVerify->actionVerifyStr, msg);
2226 fl_show_form(fd_actionVerify->actionVerify, FL_PLACE_MOUSE,
2227 FL_TRANSIENT, "Action Verification");
2228 while (ans = fl_do_forms(),
2229 ans != fd_actionVerify->actionVerifyYes &&
2230 ans != fd_actionVerify->actionVerifyNo);
2231 fl_hide_form(fd_actionVerify->actionVerify);
2232 if (ans == fd_actionVerify->actionVerifyYes)
2233 return 1;
2234 else
2235 return 0;
2236 }
2237
2238
2239 /* Pops-up an alert message box, with the given input
2240 string, and returns when "Dismiss" is pressed */
2241
2242 void alertMessage(char *title, int hint, int big, char *msg)
2243 {
2244 FL_OBJECT *ans;
2245 int width, height, diff, style, size;
2246
2247 if (big) {
2248 style = FL_NORMAL_STYLE + FL_SHADOW_STYLE;
2249 size = FL_MEDIUM_SIZE;
2250 }
2251 else {
2252 style = FL_NORMAL_STYLE + FL_SHADOW_STYLE;
2253 size = FL_NORMAL_SIZE;
2254 }
2255 fl_set_object_lstyle(fd_alertMessage->alertMessageStr, style);
2256 fl_set_object_lsize(fd_alertMessage->alertMessageStr, size);
2257 fl_get_string_dimension(style, size, msg, strlen(msg), &width, &height);
2258 fl_set_form_size(fd_alertMessage->alertMessage,
2259 max(320,width+64), height+66);
2260 diff = (max(320, width+64) - (width+64)) / 3;
2261 fl_set_object_size(fd_alertMessage->alertMessageStr,
2262 width+10, height+13);
2263 fl_set_object_position(fd_alertMessage->alertMessageStr, diff+37,11);
2264 fl_set_object_label(fd_alertMessage->alertMessageStr, msg);
2265 if (hint)
2266 fl_show_object(fd_alertMessage->noMoreHints);
2267 else
2268 fl_hide_object(fd_alertMessage->noMoreHints);
2269 fl_show_form(fd_alertMessage->alertMessage, FL_PLACE_MOUSE,
2270 FL_TRANSIENT, title);
2271 while (ans = fl_do_forms(),
2272 ans != fd_alertMessage->alertMessageDismiss) {
2273 if (ans == fd_alertMessage->noMoreHints) {
2274 nohints = !nohints;
2275 if (nohints) {
2276 fl_set_menu(fd_topFrame->fileMenu,
2277 "Options . . .|Enable hints|Exit");
2278 global.logOpts &= ~LOG_HINTS;
2279 }
2280 else {
2281 fl_set_menu(fd_topFrame->fileMenu,
2282 "Options . . .|Disable hints|Exit");
2283 global.logOpts |= LOG_HINTS;
2284 }
2285 writeXisprc(rcfname, xispOptions, &global);
2286 }
2287 }
2288 fl_hide_form(fd_alertMessage->alertMessage);
2289 }
2290
2291
2292 /* Adjusts PAP option flag and activation status of the corresponding button
2293 in the Account information form, according to the available pppd version */
2294
2295 void adjustPAPCap(void)
2296 {
2297 char msg[512] = {0};
2298
2299 if (pppdVersion().major < 0) {
2300 sprintf(msg, "Unknown pppd version:\n"
2301 "unexpected behavior might occur!");
2302 alertMessage("xISP: adjustPAPCap()",0,0,msg);
2303 return;
2304 }
2305 if (pppdVersion().major < 2) { /* version number must */
2306 sprintf(msg, "Unknown pppd version " /* be greater than 1 */
2307 "(v%d.x):\nunexpected "
2308 "behavior might occur!",
2309 pppdVersion().major);
2310 alertMessage("xISP: adjustPAPCap()",0,0,msg);
2311 return;
2312 }
2313 if (pppdVersion().major > 2 || /* check pppd version */
2314 pppdVersion().minor > 2) {
2315 if (p_xisprc->operOpts & PAP_LOGIN) /* if > v2.2, disable */
2316 p_xisprc->operOpts &= ~PAP_LOGIN; /* PAP as it depends on */
2317 fl_deactivate_object( /* the +ua option */
2318 fd_accountInfo->authPAPButton);
2319 fl_set_object_lcol(
2320 fd_accountInfo->authPAPButton,
2321 FL_INACTIVE);
2322 }
2323 else {
2324 fl_activate_object(
2325 fd_accountInfo->authPAPButton);
2326 fl_set_object_lcol(
2327 fd_accountInfo->authPAPButton,
2328 FL_WHITE);
2329 }
2330 }
2331
2332
2333 /* Adjusts Auto DNS option flag and activation status of the corresponding
2334 button in the TCP/IP information form, according to the available pppd
2335 version */
2336
2337 void adjustAutoDNSCap(void)
2338 {
2339 char msg[512] = {0};
2340
2341 if (pppdVersion().major < 0) {
2342 sprintf(msg, "Unknown pppd version:\n"
2343 "unexpected behavior might occur!");
2344 alertMessage("xISP: adjustAutoDNSCap()",0,0,msg);
2345 return;
2346 }
2347 if (pppdVersion().major < 2) { /* version number must */
2348 sprintf(msg, "Unknown pppd version " /* be greater than 1 */
2349 "(v%d.x):\nunexpected "
2350 "behavior might occur!",
2351 pppdVersion().major);
2352 alertMessage("xISP: adjustAutoDNSCap()",0,0,msg);
2353 return;
2354 }
2355 if (pppdVersion().major < 2 ||
2356 (pppdVersion().major == 2 && pppdVersion().minor < 3) ||
2357 (pppdVersion().major == 2 && pppdVersion().minor == 3 &&
2358 pppdVersion().plevel < 9)
2359 )
2360 {
2361 if (p_xisprc->operOpts & AUTO_DNS) /* if < v2.3.9, disable */
2362 p_xisprc->operOpts &= ~AUTO_DNS; /* auto-DNS capability */
2363 fl_deactivate_object(
2364 fd_tcpipInfo->DNSAutoButton);
2365 fl_set_object_lcol(
2366 fd_tcpipInfo->DNSAutoButton,
2367 FL_INACTIVE);
2368 }
2369 else {
2370 fl_activate_object(
2371 fd_tcpipInfo->DNSAutoButton);
2372 fl_set_object_lcol(
2373 fd_tcpipInfo->DNSAutoButton,
2374 FL_WHITE);
2375 }
2376 }
2377
2378
2379 /* Adjusts compression option flag and activation status of the
2380 corresponding button in the Communication information form,
2381 according to the available pppd version */
2382
2383 void adjustCompCap(void)
2384 {
2385 char msg[512] = {0};
2386
2387 if (pppdVersion().major < 0) {
2388 sprintf(msg, "Unknown pppd version:\n"
2389 "unexpected behavior might occur!");
2390 alertMessage("xISP: adjustCompCap()",0,0,msg);
2391 return;
2392 }
2393 if (pppdVersion().major < 2) { /* version number must */
2394 sprintf(msg, "Unknown pppd version " /* be greater than 1 */
2395 "(v%d.x):\nunexpected "
2396 "behavior might occur!",
2397 pppdVersion().major);
2398 alertMessage("xISP: adjustCompCap()",0,0,msg);
2399 return;
2400 }
2401 if (pppdVersion().major < 2 ||
2402 (pppdVersion().major == 2 && pppdVersion().minor < 3)
2403 )
2404 {
2405 if (p_xisprc->operOpts & DEFL_COMPRESS) /* if < v2.3.x, disable */
2406 p_xisprc->operOpts &= ~DEFL_COMPRESS; /* "deflate" option */
2407 fl_deactivate_object(
2408 fd_commInfo->SWCDeflateButton);
2409 fl_set_object_lcol(
2410 fd_commInfo->SWCDeflateButton,
2411 FL_INACTIVE);
2412 }
2413 else {
2414 fl_activate_object(
2415 fd_commInfo->SWCDeflateButton);
2416 fl_set_object_lcol(
2417 fd_commInfo->SWCDeflateButton,
2418 FL_WHITE);
2419 }
2420 }
2421
2422
2423 /* Runs through all ISPs in the ISP database and makes sure that none uses
2424 a non-existent PTT. If any such are found, their PTT entries are changed
2425 to point to the last available PTT in the PTT database. The check includes
2426 the global section for the variable that holds the PTT used for calculating
2427 the cost totals, as well as the PTT zone selected for each ISP entry */
2428
2429 void checkUpdatePTTs()
2430 {
2431 int i;
2432
2433 global.costPTT = (global.costPTT < global.numPTTs) ?
2434 global.costPTT : global.numPTTs-1;
2435 for (i=0; i<global.numISPs; i++) {
2436 if (xispOptions[i+1].ispPTT >= global.numPTTs) {
2437 xispOptions[i+1].ispPTT = global.numPTTs-1;
2438 xispOptions[i+1].ispZone = 0;
2439 }
2440 }
2441 }
2442
2443
2444 /*+-------------------------------------------------------------------------+
2445 | |
2446 | XPM animation routines and callbacks |
2447 | |
2448 +-------------------------------------------------------------------------+*/
2449
2450 #ifdef XPMANIMATE
2451 void updateAnim(int run)
2452 {
2453 Pixmap id;
2454
2455 if (run) { /* if animation is running */
2456 id = online[frame]; /* use current frame */
2457 if (minimized) /* if minimized */
2458 fl_winicon(topWin, id, amask); /* set the window icon */
2459 else /* if maximized */
2460 fl_set_pixmap_pixmap( /* set the master form icon */
2461 fd_topFrame->topIcon, id,
2462 amask);
2463 }
2464 else {
2465 id = offline; /* otherwise, reset icons */
2466 fl_winicon(topWin, id, amask); /* for the main form */
2467 fl_set_pixmap_pixmap(fd_topFrame-> /* and the minimized window */
2468 topIcon, id, amask);
2469 frame = 0; /* reset current frame */
2470 }
2471 }
2472
2473 void prepAnimPixmaps(void)
2474 {
2475 unsigned int width = 50, height = 50,
2476 hotx = 1, hoty = 1;
2477
2478 offline = fl_create_from_pixmapdata(fl_default_window(), xisp_xpm,
2479 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2480 online[0] = fl_create_from_pixmapdata(fl_default_window(), online1_xpm,
2481 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2482 online[1] = fl_create_from_pixmapdata(fl_default_window(), online2_xpm,
2483 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2484 online[2] = fl_create_from_pixmapdata(fl_default_window(), online3_xpm,
2485 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2486 online[3] = fl_create_from_pixmapdata(fl_default_window(), online4_xpm,
2487 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2488 online[4] = fl_create_from_pixmapdata(fl_default_window(), online5_xpm,
2489 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2490 online[5] = fl_create_from_pixmapdata(fl_default_window(), online6_xpm,
2491 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2492 online[6] = fl_create_from_pixmapdata(fl_default_window(), online7_xpm,
2493 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2494 online[7] = fl_create_from_pixmapdata(fl_default_window(), online8_xpm,
2495 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2496 online[8] = fl_create_from_pixmapdata(fl_default_window(), online9_xpm,
2497 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2498 online[9] = fl_create_from_pixmapdata(fl_default_window(), online10_xpm,
2499 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2500 online[10] = fl_create_from_pixmapdata(fl_default_window(), online11_xpm,
2501 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2502 online[11] = fl_create_from_pixmapdata(fl_default_window(), online12_xpm,
2503 &width, &height, &amask, &hotx, &hoty, FL_INDIANRED);
2504 }
2505
2506 void doXPMUpdate(FL_OBJECT *obj, long param)
2507 {
2508 unsigned newnetpkts;
2509
2510 frame = (frame + 1) % 12; /* increment frame counter */
2511 if (frame) { /* if not on frame 0 */
2512 if (transfer) /* just spin the animation */
2513 updateAnim(1);
2514 }
2515 else { /* if on frame 0 */
2516 newnetpkts = pppPkts(pppIF, NULL,NULL); /* check for new packets */
2517 if (newnetpkts != netpkts) { /* if new packets exist */
2518 netpkts = newnetpkts; /* start next animation cycle */
2519 transfer = 1;
2520 updateAnim(1);
2521 }
2522 else transfer = 0;
2523 }
2524 fl_set_timer(xpmtimer, XPM_INTERVAL); /* restart animation timer */
2525 }
2526 #endif
2527
2528
2529 /*+-------------------------------------------------------------------------+
2530 | |
2531 | Routine adjusting possible actions according to state |
2532 | |
2533 +-------------------------------------------------------------------------+*/
2534
2535 void possibleActions(int state)
2536 {
2537 progState = state;
2538 switch (state) {
2539
2540 case DISCONNECTED: {
2541 fl_activate_object(fd_topFrame->conButton);
2542 fl_set_object_lcol(fd_topFrame->conButton,FL_LCOL);
2543 fl_deactivate_object(fd_topFrame->intButton);
2544 fl_set_object_lcol(fd_topFrame->intButton,FL_INACTIVE);
2545 fl_deactivate_object(fd_topFrame->disButton);
2546 fl_set_object_lcol(fd_topFrame->disButton,FL_INACTIVE);
2547 fl_activate_object(fd_topFrame->fileMenu);
2548 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
2549 fl_activate_object(fd_topFrame->logMenu);
2550 fl_set_object_lcol(fd_topFrame->logMenu,FL_LCOL);
2551 fl_activate_object(fd_topFrame->hlpMenu);
2552 fl_set_object_lcol(fd_topFrame->hlpMenu,FL_LCOL);
2553 break;
2554 }
2555
2556 case DIALING: {
2557 fl_deactivate_object(fd_topFrame->conButton);
2558 fl_set_object_lcol(fd_topFrame->conButton,FL_INACTIVE);
2559 fl_activate_object(fd_topFrame->intButton);
2560 fl_set_object_lcol(fd_topFrame->intButton,FL_LCOL);
2561 fl_deactivate_object(fd_topFrame->disButton);
2562 fl_set_object_lcol(fd_topFrame->disButton,FL_INACTIVE);
2563 fl_deactivate_object(fd_topFrame->fileMenu);
2564 fl_set_object_lcol(fd_topFrame->fileMenu,FL_INACTIVE);
2565 fl_deactivate_object(fd_topFrame->logMenu);
2566 fl_set_object_lcol(fd_topFrame->logMenu,FL_INACTIVE);
2567 fl_deactivate_object(fd_topFrame->hlpMenu);
2568 fl_set_object_lcol(fd_topFrame->hlpMenu,FL_INACTIVE);
2569 break;
2570 }
2571
2572 case CONNECTED: {
2573 fl_deactivate_object(fd_topFrame->conButton);
2574 fl_set_object_lcol(fd_topFrame->conButton,FL_INACTIVE);
2575 fl_deactivate_object(fd_topFrame->intButton);
2576 fl_set_object_lcol(fd_topFrame->intButton,FL_INACTIVE);
2577 fl_activate_object(fd_topFrame->disButton);
2578 fl_set_object_lcol(fd_topFrame->disButton,FL_LCOL);
2579 fl_activate_object(fd_topFrame->fileMenu);
2580 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
2581 fl_deactivate_object(fd_topFrame->logMenu);
2582 fl_set_object_lcol(fd_topFrame->logMenu,FL_INACTIVE);
2583 fl_activate_object(fd_topFrame->hlpMenu);
2584 fl_set_object_lcol(fd_topFrame->hlpMenu,FL_LCOL);
2585 break;
2586 }
2587
2588 default: break;
2589 }
2590 }
2591
2592
2593 /*+-------------------------------------------------------------------------+
2594 | |
2595 | Dialer output parsing routines |
2596 | |
2597 +-------------------------------------------------------------------------+*/
2598
2599 /* IMPORTANT!: Note the maximum field length defined by
2600 MAXLEN_FIELD, used by the generic parser doutWait() */
2601
2602 #define MAXLEN_FIELD 64
2603
2604 char *doutWait(char *buf, char *field, char *ecs)
2605 {
2606 char *p1, *p2;
2607 static int next = 0, nc;
2608 static char rstr[MAXLEN_FIELD];
2609 char msg[512] = {0};
2610
2611 if (next) { /* processing field string? */
2612 p2 = strfstr(buf, ecs); /* yup, find ending char */
2613 if (p2 != NULL) { /* if found */
2614 next = 0; /* indicate processing done */
2615 strncpy(&rstr[nc], buf, /* save it locally */
2616 (int)(p2-buf));
2617 rstr[nc+(int)(p2-buf)] = 0; /* terminate it */
2618 return rstr; /* and return its address */
2619 }
2620 else {
2621 sprintf(msg, "Invalid output" /* ec not found: dialer */
2622 "from dialer process!"); /* output is screwed, or */
2623 alertMessage("xISP: doutWait()", /* something is very wrong */
2624 0, 0, msg);
2625 return NULL;
2626 }
2627 }
2628
2629 p1 = strstr(buf, field); /* wanted field in there? */
2630 if (p1 != NULL) { /* yup, parse to ending ec */
2631 p2 = strfstr(p1, ecs);
2632 if (p2 != NULL) { /* if found */
2633 nc = (int)(p2-p1)-strlen(field); /* string has so many chars */
2634 strncpy(rstr, p1+strlen(field), /* save it locally */
2635 nc);
2636 rstr[nc] = 0; /* terminate it */
2637 return rstr; /* and return its address */
2638 }
2639 else { /* oops, string ends */
2640 strcpy(rstr, p1+strlen(field)); /* copy what's there */
2641 next = 1; /* take note for next call */
2642 nc = strlen(rstr);
2643 return NULL;
2644 }
2645 }
2646 return NULL;
2647 }
2648
2649 /* Parse dialer output for its PID number */
2650
2651 int doutPID(char *buf)
2652 {
2653 char pids[16], *p;
2654
2655 p = doutWait(buf, "PID=", "."); /* look for PID=?????. */
2656 if (p != NULL) { /* found it? */
2657 strcpy(pids, p); /* yup, copy the string */
2658 dialerPID = atoi(pids); /* convert and save it */
2659 possibleActions(DIALING); /* mark possible actions */
2660 return 1; /* indicate found */
2661 }
2662 else /* nope */
2663 return 0; /* indicate not found */
2664 }
2665
2666 /* Parse dialer output for modem connect string. Note that even
2667 if the modems are found to be connected, when call-back is
2668 enabled, xisp ignores the first modem connect string. However,
2669 it does keep track of the time the call-back connection was
2670 initiated and estimates an elapsed time for later call-cost
2671 calculation/logging */
2672
2673 int doutCONN(char *buf)
2674 {
2675 char *p, *sp, chead[5] = {0}, *ctail;
2676 unsigned speed;
2677
2678 strncpy(chead, p_xisprc->modemConnect, 4); /* retrieve "connect" string */
2679 ctail = &(p_xisprc->modemConnect[4]);
2680 p = doutWait(buf, chead, "/\r\n"); /* look for first 4 chars */
2681 if (p != NULL) { /* found them? */
2682 if (strstr(p, ctail) == NULL) /* rest of the string OK? */
2683 return 0; /* nope, indicate not found */
2684 if (p_xisprc->operOpts & CALL_BACK) { /* if call-back is enabled */
2685 if (firstConn) { /* and it's 1st connection */
2686 upTime = time(NULL); /* record connection time */
2687 updateLogs(1); /* and update log files */
2688 firstConn = 0; /* indicate it's gone by and */
2689 return 0; /* wait for 2nd connection */
2690 }
2691 else /* if it's the CB connection */
2692 CBTime = time(NULL); /* record CB connection time */
2693 }
2694 else { /* else call-back not enabled */
2695 upTime = time(NULL); /* record connection time */
2696 costCalcReset(p_ptt, upTime); /* reset calculations module */
2697 }
2698 onLineSecs = 0; /* and counters */
2699 onLineUnits = 0;
2700 sp = strchr(p, ' '); /* continue: look for space */
2701 if (sp != NULL) { /* found it? */
2702 strcpy(speedStr, sp); /* yes, copy the string */
2703 speed = atoi(speedStr); /* convert and save speed */
2704 if (speed < 1000) /* and format its string */
2705 sprintf(connSpeed,"%d",speed);
2706 else
2707 sprintf(connSpeed,"%d,%03d",
2708 speed/1000,speed%1000);
2709 sprintf(speedStr, "%u", speed); /* erase leading whitespace */
2710 }
2711 else { /* oops, no speed! */
2712 strcpy(connSpeed, "- NA -"); /* copy this instead */
2713 strcpy(speedStr, connSpeed);
2714 }
2715 connected = 1; /* update variables */
2716 connTime = 0;
2717 if (global.logOpts & COST_READOUT) /* cost readout desired? */
2718 fl_set_object_label( /* yes, so display */
2719 fd_topFrame->logText, /* appropriately formatted */
2720 costStr(p_ptt, 0.0)); /* zero cost */
2721 else
2722 fl_set_object_label( /* nope, display the */
2723 fd_topFrame->logText,EMPTY_TIME); /* reset-timer string */
2724 strcpy(connIP, EMPTY_IP);
2725 updateStat(linkOK); /* update indicators */
2726 fl_set_timer(ctimer, CT_INTERVAL); /* start connection timer */
2727 if (p_xisprc->operOpts & CONNECT_BELL) /* ring bell if desired */
2728 XBell(fl_get_display(), 50);
2729 #ifdef XPMANIMATE
2730 netpkts = 0; /* initialize net packets */
2731 fl_set_pixmap_pixmap( /* animation pixmap */
2732 fd_topFrame->topIcon,
2733 online[11], amask);
2734 fl_winicon(topWin, online[11], amask); /* window icon, and */
2735 fl_set_timer(xpmtimer, XPM_INTERVAL); /* start xpm-animation timer */
2736 #endif
2737 possibleActions(CONNECTED); /* mark possible actions */
2738 return 1; /* indicate found */
2739 }
2740 else /* nope */
2741 return 0; /* indicate not found */
2742 }
2743
2744 /* Parse dialer output for TIMEOUT string from xispdial */
2745
2746 int doutTIMEOUT(char *buf)
2747 {
2748 char *p;
2749
2750 p = doutWait(buf, "TIME", "\n");
2751 if (p != NULL) {
2752 if (connected && firstConn) /* if it was 1st connection */
2753 updateLogs(connected); /* update logs for upTime */
2754 connected = 0; /* invalidate connection */
2755 fl_set_timer(ctimer, 0.0); /* stop connection timer */
2756 updateTitles("X-ISP", ""); /* reset icon&window titles */
2757 #ifdef XPMANIMATE
2758 updateAnim(0); /* and animation pixmap */
2759 fl_set_timer(xpmtimer, 0.0); /* disable animation timer */
2760 #endif
2761 strcpy(connSpeed, EMPTY_SPEED); /* reset speed indicator */
2762 updateStat(linkOK); /* update display */
2763 if (firstConn) { /* if it was 1st connection */
2764 downTime = time(NULL); /* record time */
2765 totalTime += onLineSecs; /* calculate total seconds */
2766 if (p_ptt->attribs & /* depending on the PTT */
2767 (PTT_PER_MINUTE|PTT_PER_SECS)) /* charging scheme */
2768 totalCost += onLineCost; /* update the total cost */
2769 else
2770 totalUnits += onLineUnits; /* or the total unit value */
2771 updateLogs(connected); /* update log files */
2772 }
2773 firstConn = 1; /* reset this for next time */
2774 possibleActions(DIALING); /* mark possible actions */
2775 return 1; /* indicate found */
2776 }
2777 else
2778 return 0;
2779 }
2780
2781 /* Parse dialer output for ABORT string from xispterm */
2782
2783 int doutABORT(char *buf)
2784 {
2785 char *p;
2786
2787 p = doutWait(buf, "ABOR", "\n");
2788 if (p != NULL) {
2789 userDiscon = 1; /* it's a user disconnect */
2790 if (connected && firstConn) /* if it was 1st connection */
2791 updateLogs(connected); /* update logs for upTime */
2792 connected = 0; /* invalidate connection */
2793 fl_set_timer(ctimer, 0.0); /* stop connection timer */
2794 updateTitles("X-ISP", ""); /* reset icon&window titles */
2795 #ifdef XPMANIMATE
2796 updateAnim(0); /* and animation pixmap */
2797 fl_set_timer(xpmtimer, 0.0); /* disable animation timer */
2798 #endif
2799 strcpy(connSpeed, EMPTY_SPEED); /* reset speed indicator */
2800 updateStat(linkOK); /* update display */
2801 if (firstConn) { /* if it was 1st connection */
2802 downTime = time(NULL); /* record time */
2803 totalTime += onLineSecs; /* calculate total seconds */
2804 if (p_ptt->attribs & /* if the selected PTT */
2805 (PTT_PER_MINUTE|PTT_PER_SECS)) /* charges by time */
2806 totalCost += onLineCost; /* update the total cost */
2807 else /* else update the */
2808 totalUnits += onLineUnits; /* total unit value instead */
2809 updateLogs(connected); /* update log files */
2810 }
2811 firstConn = 1; /* reset this for next time */
2812 possibleActions(DIALING); /* mark possible actions */
2813 return 1; /* indicate found */
2814 }
2815 else
2816 return 0;
2817 }
2818
2819 /* Parse dialer output for NT-RAS string from xispterm. Note that nothing
2820 changes in xisp's state: it starts pppd a second time and then waits
2821 for the call-back connection */
2822
2823 int doutNTRAS(char *buf)
2824 {
2825 char *p;
2826
2827 p = doutWait(buf, "NT-RAS", "\n");
2828 if (p != NULL) {
2829 fl_call_object_callback( /* "push Connect" again */
2830 fd_topFrame->conButton);
2831 return 1; /* indicate found */
2832 }
2833 else
2834 return 0;
2835 }
2836
2837 /* Parse dialer output for strings changing our state */
2838
2839 void doutParse(char *buf)
2840 {
2841 static char line[MAXBUF_CHILD+1] = {0}, *pline = line;
2842 char *p;
2843
2844 if (MAXBUF_CHILD-(unsigned int)(pline-line) /* take care of possible */
2845 < strlen(buf)) pline = line; /* line buffer overflow */
2846 for (p=buf; *p; ) { /* while chars are available */
2847 for (; *p && *p!='\n' && *p!='\r'; /* make local copy of buf */
2848 p++, pline++) *pline = *p; /* in line-buffered fashion */
2849 if (*p) { /* end of line found? */
2850 *pline++ = *p; /* yes, add special char */
2851 *pline = 0; /* and terminate the line */
2852 if (! dialerPID) doutPID(line); /* parse for dialer PID */
2853 if (! connected) { /* skip "NO CARRIER" message */
2854 if (doutWait(line, "NO CARR", /* in case our modem connect */
2855 "\n") == NULL) /* string is "CARRIER xxxxx" */
2856 doutCONN(line); /* parse for CONNECTED info */
2857 if (p_xisprc->operOpts & /* if NT RAS call-back on */
2858 (CALL_BACK|CB_NT_RAS)) { /* parse also for second */
2859 doutNTRAS(line); /* pppd invocation trigger */
2860 doutTIMEOUT(line); /* and for dialer TIMEOUT */
2861 }
2862 }
2863 else { /* if we are connected */
2864 doutTIMEOUT(line); /* parse for dialer TIMEOUT */
2865 if (p_xisprc->operOpts & /* if manual login for dial- */
2866 (MANUAL_LOGIN|CBMAN_LOGIN)) /* in/call-back is selected, */
2867 doutABORT(line); /* parse also for ABORT */
2868 }
2869 pline = line; /* start new line */
2870 ++p; /* from next input char */
2871 }
2872 }
2873 }
2874
2875 /* Check logging options and if logging is enabled, backup current log
2876 files, and reset logs; also check log file names and adjust if needed */
2877
2878 void resetLogs(void)
2879 {
2880 char msg[512] = {0};
2881 void alertMessage();
2882
2883 initLogFnames(&global); /* adjust log file names */
2884 if (! (global.logOpts & LOG_NONE)) { /* only if logging active */
2885 strcpy(bkupfname, costfname); /* backup current logs */
2886 strcat(bkupfname, ".bak");
2887 rename(costfname, bkupfname);
2888 strcpy(bkupfname, logfname);
2889 strcat(bkupfname, ".bak");
2890 rename(logfname, bkupfname);
2891 restartXispCost(&totalTime,&totalCost); /* create new log file */
2892 #ifdef RUNASEUID
2893 if (! nohints &&
2894 (!xisp_euidaccess(costfname, F_OK) ||
2895 !xisp_euidaccess(logfname, F_OK)))
2896 #else
2897 if (! nohints &&
2898 (!access(costfname, F_OK) || !access(logfname, F_OK)))
2899 #endif
2900 {
2901 sprintf(msg, "Your cost and connection time logging files\n"
2902 "%s and/or\n%s\n"
2903 "have been saved as *.bak and new log files for\n"
2904 "the current logging period have been created.",
2905 costfname, logfname);
2906 alertMessage("Logging hint", 1, 0, msg);
2907 }
2908 }
2909 }
2910
2911 /*+-------------------------------------------------------------------------+
2912 | |
2913 | Connection timer/PTT-charges callback |
2914 | |
2915 +-------------------------------------------------------------------------+*/
2916
2917 void doCTupdate(FL_OBJECT *obj, long param)
2918 {
2919 char tout[16], *p;
2920 struct tm *ptm;
2921
2922 if (p_xisprc->operOpts & CALL_BACK) /* if call-back is enabled */
2923 onLineSecs = time(NULL) - CBTime; /* use CB connection up time */
2924 else /* else use 1st connection */
2925 onLineSecs = time(NULL) - upTime; /* uptime for timer update */
2926 connTime += (int)CT_INTERVAL; /* increment "rough" timer */
2927 if (!(global.logOpts & LOG_NONE) || /* logging desired */
2928 (global.logOpts & COST_READOUT)) { /* or cost readout selected? */
2929 if (firstConn) /* yes, if 1st connection */
2930 onLineCost = callCost(p_ptt, /* calculate current cost */
2931 onLineSecs, &onLineUnits);
2932 else /* if 2nd connection in CB */
2933 onLineCost = 0.0; /* mode, it's for free :) */
2934 }
2935 if (global.logOpts & COST_READOUT) { /* cost readout selected? */
2936 p = costStr(p_ptt, onLineCost); /* format it in a string */
2937 fl_set_object_label( /* print it on main form */
2938 fd_topFrame->logText, p);
2939 }
2940 else { /* no, we want time readout */
2941 ptm = gmtime(&connTime); /* break down current time */
2942 p = tout;
2943 if (ptm->tm_yday > 0) { /* take days into account */
2944 #ifdef BROKEN_SPRINTF
2945 sprintf(p, "%dd:", /* if > 0, prepend number of */
2946 ptm->tm_yday); /* days to the time string */
2947 p += strlen(p);
2948 #else
2949 p += sprintf(p, "%dd:",
2950 ptm->tm_yday);
2951 #endif
2952 }
2953 strftime(p, 16, "%H:%M:%S", ptm); /* format time as HH:MM:SS */
2954 fl_set_object_label( /* print time only (not */
2955 fd_topFrame->logText, p); /* days) on main form */
2956 p = tout;
2957 if (ptm->tm_yday < 1 && /* skip first hour digit for */
2958 ptm->tm_hour < 10) /* icon label, if possible */
2959 ++p;
2960 }
2961 if (linkOK)
2962 updateTitles(p, p); /* update icon&window titles */
2963 if (connected)
2964 fl_set_timer(ctimer, CT_INTERVAL); /* and restart timer */
2965 }
2966
2967
2968 /*+-------------------------------------------------------------------------+
2969 | |
2970 | Link status callback |
2971 | |
2972 +-------------------------------------------------------------------------+*/
2973
2974 void doLPupdate(FL_OBJECT *obj, long param)
2975 {
2976 char *p;
2977 int linkWasUp = linkOK; /* previous link status */
2978
2979 if (*pppIF == 0) /* get PPP IF-name if we */
2980 getIFname(pppIF); /* don't know it already */
2981 if (pppdPID && *pppIF && /* pppd running and link OK? */
2982 (p=pppAddr(pppIF))!=NULL)
2983 {
2984 if (!linkOK) { /* yes, just now? */
2985 strcpy(connIP, p); /* yup, copy new IP address */
2986 if (firstConn) /* if it was 1st connection */
2987 updateLogs(connected); /* update log files */
2988 linkOK = 1; /* and mark link as OK */
2989 updateStat(linkOK); /* update indicators */
2990 linkTOCounter = 0; /* init for next time */
2991 pppdPID = getPppdPID(devName); /* get PID of detached pppd */
2992 if ((xispUDPID = xispUD(1,0))) { /* start .xisp-up script */
2993 xispUDON = UD_WAIT/BU_INTERVAL; /* mark max iterations, and */
2994 fl_set_timer(btimer, /* enable output processing */
2995 BU_INTERVAL);
2996 }
2997 }
2998 fl_set_timer(ltimer, SP_INTERVAL); /* restart timer */
2999 }
3000 else { /* pppd or link problem */
3001 if (pppdPID && (linkTOCounter--)) { /* keep going until timeout */
3002 fl_set_timer(ltimer, SP_INTERVAL); /* restart status poll timer */
3003 if (p_xisprc->operOpts & IP_UPDOWN) /* if ip-up/-down support on */
3004 ipUDON = UD_WAIT/BU_INTERVAL; /* restart ip-up/-down timer */
3005 xispUDON = UD_WAIT/BU_INTERVAL; /* timer for .xisp-up/-down */
3006 fl_set_timer(btimer, BU_INTERVAL); /* enable output processing */
3007 return;
3008 }
3009 downTime = time(NULL); /* record time instant */
3010 if (!linkOK && firstConn) /* connection 1, IF never up */
3011 updateLogs(connected); /* so update logs for upTime */
3012 bprintf("PPP link is down.\n"); /* nope, print message */
3013 fl_set_timer(ctimer, 0.0); /* disable timers */
3014 fl_set_timer(ltimer, 0.0);
3015 updateTitles("X-ISP", ""); /* reset icon&window titles */
3016 #ifdef XPMANIMATE
3017 updateAnim(0); /* and animation pixmap */
3018 fl_set_timer(xpmtimer, 0.0); /* disable animation timer */
3019 #endif
3020 if (pppdPID) /* if not dead already */
3021 kill(pppdPID, SIGINT); /* terminate pppd process */
3022 pppdPID = 0; /* indicate that it's gone */
3023 if (firstConn) { /* if it was 1st connection */
3024 totalTime += onLineSecs; /* calculate total seconds */
3025 if (p_ptt->attribs & /* if the selected PTT */
3026 (PTT_PER_MINUTE|PTT_PER_SECS)) /* charges by time */
3027 totalCost += onLineCost; /* update the total cost */
3028 else /* else update the */
3029 totalUnits += onLineUnits; /* total unit value instead */
3030 updateLogs(0); /* update log files */
3031 }
3032 connected = 0; /* update variables */
3033 firstConn = 1;
3034 connTime = 0;
3035 linkOK = 0;
3036 *pppIF = 0; /* mark IF name unknown */
3037 strcpy(connSpeed, EMPTY_SPEED);
3038 strcpy(connIP, EMPTY_IP);
3039 updateStat(linkOK); /* update indicators */
3040 possibleActions(DISCONNECTED); /* mark possible actions */
3041 if (p_xisprc->operOpts & IP_UPDOWN) /* ip-up/-down support? */
3042 ipUDON = UD_WAIT/BU_INTERVAL; /* yup, mark ip-up active */
3043 strcpy(ipWhich, "ip-down"); /* set user script name */
3044 if (linkWasUp&&(xispUDPID=xispUD(0,1))) /* start .xisp-down */
3045 xispUDON = UD_WAIT/BU_INTERVAL; /* and mark iterations */
3046 if (ipUDON || xispUDON) /* if either is active */
3047 fl_set_timer(btimer, BU_INTERVAL); /* start browser timer */
3048 if (!userDiscon && /* if not user disconnect */
3049 (p_xisprc->operOpts & /* and auto-redial set, then */
3050 AUTO_REDIAL)) {
3051 fl_call_object_callback( /* "push Connect" again */
3052 fd_topFrame->conButton);
3053 }
3054 userDiscon = 0; /* reset indicator */
3055 }
3056 }
3057
3058
3059 /*+-------------------------------------------------------------------------+
3060 | |
3061 | Callback and support routines for browser updates from dialer output |
3062 | |
3063 +-------------------------------------------------------------------------+*/
3064
3065 #define MAXLEN_IOTBUF 11 /* I/O trigger buffer size */
3066 char IOTBuf[MAXLEN_IOTBUF+1] = {0},
3067 *pIOTB = IOTBuf;
3068
3069 void browserIOTrigger(int fd, void *data) /* pipe I/O-triggered input */
3070 {
3071 int space, br, dump = 0;
3072 char *pc;
3073 void doBUpdate();
3074
3075 space = MAXLEN_IOTBUF-(int)(pIOTB-IOTBuf); /* calculate space left, and */
3076 br = read(fd, pIOTB, space); /* read max that many bytes */
3077 pIOTB += br; /* increment pointer */
3078 for (pc=IOTBuf; !dump && pc<pIOTB; pc++) /* scan for CR or LF */
3079 if (*pc=='\n' || *pc=='\r') dump = 1; /* dump buffer if found */
3080 dump |= (pIOTB == MAXLEN_IOTBUF + IOTBuf); /* or dump when buffer full */
3081 if (dump) { /* dump condition met? */
3082 fl_set_timer(btimer, BU_INTERVAL); /* yes, restart timer */
3083 fl_call_object_callback(btimer); /* call update routine */
3084 pIOTB = IOTBuf; /* and start all over again */
3085 }
3086 }
3087
3088 int IOIdleCallback(XEvent *xev, void *data) /* pipe input checking proc */
3089 {
3090 fd_set rfds;
3091 struct timeval tv;
3092 int stat;
3093
3094 FD_ZERO(&rfds); /* initialize the fs set */
3095 FD_SET(dialerFD, &rfds); /* stick the dialerFD in */
3096 tv.tv_sec = tv.tv_usec = 0; /* return with no delay */
3097 stat = select(dialerFD+1, &rfds, /* check the descriptor */
3098 NULL, NULL, &tv); /* for any input */
3099 if (stat < 0) {
3100 if (errno != EINTR) /* non-blocking signal? */
3101 doErr("IOIdleCallback: select"); /* no, abort with diagnostic */
3102 return 0; /* yes, do nothing */
3103 }
3104 if (stat) /* data exists for reading? */
3105 browserIOTrigger(dialerFD, NULL); /* yes, call the I/O proc */
3106 return 0;
3107 }
3108
3109 int readT(int fd, void *buf, size_t cnt) /* I/O-trigger aware read */
3110 { /* note that cnt is ignored */
3111 int br, bp = pIOTB - IOTBuf; /* when IOTbuf has data, as */
3112 /* cnt always >MAXLEN_IOTBUF */
3113 if (bp > 0) { /* are bytes from I/O */
3114 br = bp; /* trigger still pending? */
3115 memcpy(buf, IOTBuf, br); /* yes, put them in buffer */
3116 pIOTB = IOTBuf; /* mark trigger buffer empty */
3117 }
3118 else
3119 br = read(dialerFD, buf, cnt); /* else read from descriptor */
3120 return br; /* return bytes read */
3121 }
3122
3123 int pppdCleanup() /* collect pppd status etc. */
3124 {
3125 int i, stat;
3126 char msg[512] = {0};
3127
3128 i = waitpid(pppdPID, &stat, WNOHANG); /* get pppd return status */
3129 if (i < 0) /* ret < 0 : wait failed */
3130 doErr("pppdCleanup: waitpid"); /* abort with diagnostic */
3131 if (i == 0) /* if pppd hasn't forked yet */
3132 return -1; /* try again next time */
3133 pppdStat = 1; /* indicate status collected */
3134 if (stat) { /* if pppd didn't fare well */
3135 if (WIFSIGNALED(stat)) { /* print messages */
3136 sprintf(msg, "pppd received" /* for untrapped signal */
3137 " signal %d!\n",
3138 WTERMSIG(stat));
3139 alertMessage("Pppd signal",0,0,msg);
3140 }
3141 if (WIFEXITED(stat)) {
3142 sprintf(msg, "Pppd exited with" /* and for abnormal exit */
3143 " status %d. This means"
3144 " that\n%s", WIFEXITED(stat),
3145 pppdMsg[WIFEXITED(stat)]);
3146 alertMessage("Pppd status",0,0,msg);
3147 bprintf("\nAction terminated.\n");
3148 }
3149 if (dialerPID) /* dialer still there? */
3150 kill(dialerPID, SIGTERM); /* yup, terminate it */
3151 pppdPID = getPppdPID(devName); /* PID of spawned pppd */
3152 if (pppdPID) /* pppd still there? */
3153 kill(pppdPID, SIGINT); /* yup, terminate it */
3154 pppdPID = 0; /* indicate that it's gone */
3155 dialerON = 0; /* indicate dial aborted */
3156 dialerPID = 0; /* and no dialer process */
3157 fl_activate_object( /* finally reactivate the */
3158 fd_topFrame->conButton); /* connection button */
3159 fl_set_object_lcol(
3160 fd_topFrame->conButton, FL_LCOL);
3161 }
3162 else
3163 updateStat(linkOK); /* all OK, update display */
3164 if (p_xisprc->operOpts & PAP_LOGIN) /* PAP authentication used? */
3165 unlink(papfname); /* yes, delete PAP data file */
3166 return WEXITSTATUS(stat); /* return exit status */
3167 }
3168
3169 void doBUpdate(FL_OBJECT *obj, long param)
3170 {
3171 int br, stat;
3172 char buf[MAXBUF_CHILD+MAXLEN_IOTBUF+2], *p;
3173 static int dialWait = DIAL_WAIT/BU_INTERVAL;
3174 static int gotIP = 0;
3175
3176 if (dialerON) { /* if dial in progress */
3177 br = readT(dialerFD, buf,MAXBUF_CHILD); /* read a buffer full */
3178 if (br > 0) { /* if read OK */
3179 buf[br] = 0; /* indicate string end */
3180 bprintf("%s", buf); /* and print it */
3181 doutParse(buf); /* parse dialer output */
3182 fl_set_timer(btimer, BU_INTERVAL); /* restart timer */
3183 if (dialWait) dialWait = 0; /* no more waiting */
3184 }
3185 else if (br < 0) { /* read failed */
3186 #ifdef SUNOS41x
3187 if (errno != EWOULDBLOCK) /* pipe output unavailable? */
3188 #else
3189 if (errno != EAGAIN)
3190 #endif
3191 doErr("doBUpdate: read"); /* no, abort with diagnostic */
3192 fl_set_timer(btimer, BU_INTERVAL); /* yes, restart timer */
3193 }
3194 else { /* EOF on pipe output */
3195 if (dialWait) { /* wait for xispdial */
3196 if (! pppdStat) /* only once */
3197 pppdRet = pppdCleanup(); /* collect pppd's status */
3198 --dialWait; /* to open the pipe */
3199 fl_set_timer(btimer, /* if it hasn't managed yet */
3200 BU_INTERVAL); /* due to machine load */
3201 return;
3202 }
3203 else if (! (dialerPID | pppdRet)) { /* dialer has failed but */
3204 alertMessage("xispdial failed", /* pppd exit status is 0 */
3205 0, 0,
3206 "Failed to start xispdial"
3207 " for unknown reasons\n"
3208 "(pppd detached with status"
3209 " 0). Please look\n"
3210 "in the system logs (i.e."
3211 " most probably files\n"
3212 "/var/log/messages or "
3213 "/var/adm/messages) for\n"
3214 "an explanation.");
3215 bprintf("\nAction terminated.\n");
3216 }
3217 fl_set_idle_callback(0, NULL); /* remove idle callback */
3218 dialWait = DIAL_WAIT/BU_INTERVAL; /* reset for next time */
3219 dialerON = 0; /* indicate dial done */
3220 dialerPID = 0; /* and no dialer process */
3221 bflush(); /* flush browser output */
3222 if (connected) { /* check connection status */
3223 if (p_xisprc->operOpts & /* ip-up/-down support on? */
3224 IP_UPDOWN)
3225 ipUDON = /* yup, mark ip-up active */
3226 UD_WAIT/BU_INTERVAL; /* with such max iterations */
3227 strcpy(ipWhich, "ip-up"); /* set user script name */
3228 fl_set_timer(btimer, /* restart timer anyway for */
3229 BU_INTERVAL); /* ip-U/D and/or .xisp-U/D */
3230 linkTOCounter = /* init link polling timeout */
3231 ceil(p_xisprc->LCPWait/ /* counter (rounded up) */
3232 (double)SP_INTERVAL);
3233 fl_set_timer(ltimer, /* and activate link polling */
3234 SP_INTERVAL); /* timer call-back */
3235 }
3236 else { /* if we disconnected */
3237 possibleActions(DISCONNECTED); /* mark possible actions */
3238 updateStat(linkOK); /* update indicators */
3239 #ifdef XPMANIMATE
3240 updateAnim(0); /* and animation pixmap */
3241 fl_set_timer(xpmtimer, 0.0); /* disable animation timer */
3242 #endif
3243 }
3244 }
3245 if (! pppdStat) /* only once */
3246 pppdRet = pppdCleanup(); /* collect pppd's status */
3247 return;
3248 }
3249
3250 if (ipUDON) { /* if ip-up/-down active */
3251 br = readT(dialerFD, buf,MAXBUF_CHILD); /* read a buffer full */
3252 if (br > 0) { /* if read OK */
3253 buf[br] = 0; /* indicate string end */
3254 bprintf("%s", buf); /* print it */
3255 fl_set_timer(btimer, BU_INTERVAL); /* and restart timer */
3256 }
3257 else if (br < 0) { /* read failed */
3258 #ifdef SUNOS41x
3259 if (errno != EWOULDBLOCK) /* pipe output unavailable? */
3260 #else
3261 if (errno != EAGAIN)
3262 #endif
3263 doErr("doBUpdate: read"); /* no, abort with diagnostic */
3264 fl_set_timer(btimer, BU_INTERVAL); /* yes, restart timer */
3265 }
3266 else { /* EOF on pipe output */
3267 if (! ipUDPID) /* unless we know it already */
3268 ipUDPID = getipUDPID(); /* get PID of ip-up/-down */
3269 if (ipUDPID && /* ip-up/-down running? */
3270 waitpid(- ipUDPID, &stat, /* yes, get children status */
3271 WNOHANG) > 0)
3272 fl_set_timer(btimer, /* got status: restart timer */
3273 BU_INTERVAL);
3274 else { /* no ip-up/-down or wait<=0 */
3275 --ipUDON; /* count down as we drain */
3276 if (*pppIF == 0) /* get PPP IF-name if we */
3277 getIFname(pppIF); /* don't know it already */
3278 if (!gotIP && *pppIF && /* if we don't have it yet */
3279 (p=pppAddr(pppIF))!=NULL) /* get ppp IF address */
3280 {
3281 strcpy(connIP, p); /* got it, save IP address */
3282 gotIP = 1; /* and don't try it again */
3283 updateStat(gotIP); /* update indicators */
3284 }
3285 if (! ipUDON) { /* if no more iterations */
3286 gotIP = 0; /* reset vars for next time */
3287 ipUDPID = 0;
3288 }
3289 fl_set_timer(btimer, /* done or not,restart timer */
3290 BU_INTERVAL); /* for enabling next stage */
3291 }
3292 }
3293 return;
3294 }
3295
3296 if (xispUDON) { /* if .xisp-up/-down active */
3297 br = readT(dialerFD, buf,MAXBUF_CHILD); /* read a buffer full */
3298 if (br > 0) { /* if read OK */
3299 buf[br] = 0; /* indicate string end */
3300 bprintf("%s", buf); /* print it */
3301 fl_set_timer(btimer, BU_INTERVAL); /* and restart timer */
3302 }
3303 else if (br < 0) { /* read failed */
3304 #ifdef SUNOS41x
3305 if (errno != EWOULDBLOCK) /* pipe output unavailable? */
3306 #else
3307 if (errno != EAGAIN)
3308 #endif
3309 doErr("doBUpdate: read"); /* no, abort with diagnostic */
3310 fl_set_timer(btimer, BU_INTERVAL); /* yes, restart timer */
3311 }
3312 else { /* EOF on pipe output */
3313 if (waitpid(xispUDPID, &stat, /* if script already done */
3314 WNOHANG) < 0) {
3315 if (--xispUDON) /* count down as we drain */
3316 fl_set_timer(btimer, /* and if iterations still */
3317 BU_INTERVAL); /* to go, restart the timer */
3318 }
3319 else /* script either not done */
3320 fl_set_timer(btimer, /* yet, or just terminated */
3321 BU_INTERVAL); /* so restart timer */
3322 }
3323 return;
3324 }
3325 }
3326
3327
3328 /*+-------------------------------------------------------------------------+
3329 | |
3330 | Callback routines for topFrame |
3331 | |
3332 +-------------------------------------------------------------------------+*/
3333
3334 void doStartupTip(FL_OBJECT *obj, long param)
3335 {
3336 alertMessage("Startup hint", 1, 0,
3337 "xISP was invoked with pop-up hints enabled (this is\n"
3338 "the default since version 2.6). If you don't need on-\n"
3339 "line hints, please either use the \"-nohints\" command\n"
3340 "line option, or disable them from the \"File\" menu.");
3341 }
3342
3343 void doConnect(FL_OBJECT *obj, long param)
3344 {
3345 int ret;
3346 char speed[MAXDIG_BAUDRATE+1] = {0}, lcps[MAXDIG_LCPWAIT+1] = {0},
3347 blevel[2*(MAXDIG_BSDCOMP+1)], dlevel[2*(MAXDIG_BSDCOMP+1)],
3348 lips[MAXLEN_IP+1] = {0}, rips[MAXLEN_IP+1] = {0},
3349 nms[MAXLEN_IP+1] = {0}, lrs[2*MAXLEN_IP+2] = {0},
3350 mtus[MAXDIG_MTRU+1] = {0}, mrus[MAXDIG_MTRU+1] = {0},
3351 dnsips[MAXLEN_IP+1] = {0}, peerfn[MAXLEN_DEVICE+7+1] = {0},
3352 tout[16], *p, msg[512] = {0};
3353 struct tm *ptm;
3354 #if defined(SUNOS5x) || defined(SVR4)
3355 struct stat sbuf;
3356 #endif
3357
3358 if (global.numISPs < 1) {
3359 XBell(fl_get_display(), 50);
3360 alertMessage("xISP: doConnect()", 0, 0,
3361 "You haven't defined an ISP!");
3362 return;
3363 }
3364 if (p_xisprc->numPhones < 1) {
3365 XBell(fl_get_display(), 50);
3366 alertMessage("xISP: doConnect()", 0, 0,
3367 "No phone number(s) to dial!");
3368 return;
3369 }
3370 #ifdef RUNASEUID
3371 if (xisp_euidaccess(Pppd, F_OK) == -1) {
3372 #else
3373 if (access(Pppd, F_OK) == -1) {
3374 #endif
3375 XBell(fl_get_display(), 50);
3376 sprintf(msg, "%s: not found!", Pppd);
3377 alertMessage("xISP: doConnect()", 0, 0, msg);
3378 return;
3379 }
3380 #ifdef RUNASEUID
3381 if (xisp_euidaccess(Pppd, X_OK) == -1) {
3382 #else
3383 if (access(Pppd, X_OK) == -1) {
3384 #endif
3385 XBell(fl_get_display(), 50);
3386 alertMessage("xISP: doConnect()", 0, 0,
3387 "No permission to start pppd!");
3388 return;
3389 }
3390 #if 0
3391 if ((p_xisprc->operOpts & SCRIPT_DIALIN) &&
3392 *(p_xisprc->account) == 0)
3393 {
3394 XBell(fl_get_display(), 50);
3395 alertMessage("xISP: doConnect()", 0, 0,
3396 "You are using a connection "
3397 "script but\nyou haven't "
3398 "defined an account name!");
3399 return;
3400 }
3401 #endif
3402 fl_deactivate_object(fd_topFrame->conButton); /* disable button */
3403 fl_set_object_lcol(fd_topFrame->conButton,
3404 FL_INACTIVE);
3405 strcpy(connSpeed, EMPTY_SPEED); /* reset speed and */
3406 strcpy(connIP, EMPTY_IP); /* IP address strings */
3407 ret = writeISPenv(p_xisprc); /* create the env file */
3408 if (ret <= 0) { /* script lines OK? */
3409 if (ret < 0) /* nope, print message */
3410 sprintf(msg, "Script line syntax " /* and be more verbose */
3411 "error:\nMore than 1 %%U " /* if possible */
3412 "and/or %%P per expect "
3413 "and/or send section!");
3414 else
3415 sprintf(msg, "Script line syntax "
3416 "error!");
3417 alertMessage("xISP: doConnect()",0,0,msg);
3418 fl_activate_object(fd_topFrame->conButton); /* enable button */
3419 fl_set_object_lcol(fd_topFrame->conButton,
3420 FL_LCOL);
3421 #ifndef ISPENV_USEVARS
3422 unlink(envfname); /* del environment file */
3423 #endif
3424 return; /* and do nothing */
3425 }
3426 sprintf(speed, "%u", p_xisprc->modemSpeed); /* create the speed str */
3427 if (p_xisprc->operOpts & BSD_COMPRESS) /* the BSD compression */
3428 sprintf(blevel, "%d,%d", /* level string */
3429 p_xisprc->compLevel,
3430 p_xisprc->compLevel);
3431 else
3432 sprintf(blevel, "%d,%d", 0,0);
3433 if (p_xisprc->operOpts & DEFL_COMPRESS) /* deflate compression */
3434 sprintf(dlevel, "%d,%d", /* level string */
3435 p_xisprc->compLevel,
3436 p_xisprc->compLevel);
3437 else
3438 sprintf(dlevel, "%d,%d", 0,0);
3439 if (p_xisprc->operOpts & ACCEPT_LOCALIP) /* the local IP string */
3440 strcpy(lips, LOCAL_IPSTR);
3441 else
3442 IPToStr(p_xisprc->localIP, lips);
3443 if (p_xisprc->operOpts & ACCEPT_REMOTEIP) /* the remote IP string */
3444 strcpy(rips, REMOTE_IPSTR);
3445 else
3446 IPToStr(p_xisprc->remoteIP, rips);
3447 strcpy(lrs, lips); /* the local:remote */
3448 strcat(lrs, ":"); /* pppd parameter */
3449 strcat(lrs, rips);
3450 IPToStr(p_xisprc->netmask, nms); /* the netmask */
3451 sprintf(mtus, "%d", p_xisprc->mtu); /* MTU and MRU */
3452 sprintf(mrus, "%d", p_xisprc->mru);
3453 sprintf(lcps, "%d", /* LCP restart interval */
3454 (int)ceil(p_xisprc->LCPWait /
3455 LCP_RESTART));
3456 adjustPAPCap(); /* check PAP capability */
3457 if (p_xisprc->operOpts & PAP_LOGIN) /* using PAP via +ua ? */
3458 writeISPPAP(p_xisprc); /* yes, create data file */
3459 if (p_xisprc->operOpts & IP_UPDOWN) { /* if DNS support is on */
3460 strcpy(IPParam, Pipe); /* create ipparam string */
3461 strcat(IPParam, ":"); /* with named pipe file- */
3462 strcat(IPParam, p_xisprc->descr); /* name, ISP name */
3463 strcat(IPParam, ":");
3464 IPToStr(p_xisprc->dns1, dnsips); /* DNS server IP's */
3465 if (strcmp(dnsips, DNS_IPSTR) && /* insert empty string */
3466 !(p_xisprc->operOpts & AUTO_DNS) /* if DNS1 IP != 0.0.0.0 */
3467 ) /* and auto-DNS is off */
3468 strcat(IPParam, dnsips); /* then insert DNS1 IP */
3469 strcat(IPParam, ":");
3470 IPToStr(p_xisprc->dns2, dnsips);
3471 if (strcmp(dnsips, DNS_IPSTR) && /* if DNS2 IP != 0.0.0.0 */
3472 !(p_xisprc->operOpts & AUTO_DNS) /* and auto-DNS is off */
3473 ) /* then insert DNS2 IP */
3474 strcat(IPParam, dnsips);
3475 strcat(IPParam, ":");
3476 if (p_xisprc->operOpts & DEFAULT_DOMAIN) /* if default domain */
3477 strcat(IPParam, p_xisprc->domainname); /* def'ed, insert it too */
3478 }
3479 if ((p_xisprc->operOpts &
3480 (CALL_BACK|CB_NT_RAS)) && !firstConn)
3481 bprintf("NT-RAS call-back mode initiated\n");
3482 else
3483 bprintf("Connection initiated: %s\n",
3484 strtime());
3485 devPath = p_xisprc->modemDevice; /* full path to dev node */
3486 if ((devName = /* skip the leading */
3487 strrchr(p_xisprc->modemDevice, '/')) /* path component */
3488 == NULL) /* in the full path */
3489 devName = p_xisprc->modemDevice; /* in order to get the */
3490 else /* device name only */
3491 ++devName;
3492 #ifdef PPPDLCKDIR
3493 #if defined(SUNOS5x) || defined(SVR4)
3494 if (stat(devPath, &sbuf) == 0) /* assemble the lock */
3495 sprintf(devLock, "%03lu.%03lu.%03lu", /* file name */
3496 major((unsigned long int)sbuf.st_dev),
3497 major((unsigned long int)sbuf.st_rdev),
3498 minor((unsigned long int)sbuf.st_rdev));
3499 #else
3500 strcpy(devLock, devName);
3501 #endif
3502 #endif
3503 if (pppdVersion().major > 2 || /* build version */
3504 pppdVersion().minor > 2) { /* dependent arg list */
3505 strcpy(peerfn, "xisp_"); /* this for v2.3+ */
3506 strcat(peerfn, devName);
3507 pppdArg("", Pppd, speed, "call", peerfn,
3508 DEFLCOMP, dlevel,
3509 (char *)0);
3510 }
3511 else {
3512 pppdArg("", Pppd, p_xisprc->modemDevice, /* and this for v2.2- */
3513 speed, (char *)0);
3514 }
3515 pppdArg("", BSDCOMP, blevel, /* the rest is common */
3516 "noipdefault",
3517 "modem", "lock",
3518 "mru", mrus, "mtu", mtus,
3519 "asyncmap", p_xisprc->asyncmap,
3520 "lcp-restart", LCP_RESTART_STR,
3521 "lcp-max-configure", lcps,
3522 (char *)0);
3523 if (p_xisprc->operOpts & ESCAPE_ON)
3524 pppdArg("", "escape", p_xisprc->escape,
3525 (char *)0);
3526 if (p_xisprc->operOpts & HW_FLOWCTRL)
3527 pppdArg("", "crtscts", (char *)0);
3528 if (pppdOptsFileOK())
3529 pppdArg("", "file", PPPD_OPTIONS, (char *)0);
3530 if (p_xisprc->operOpts & ACCEPT_LOCALIP)
3531 pppdArg("", "ipcp-accept-local", (char *)0);
3532 if (p_xisprc->operOpts & ACCEPT_REMOTEIP)
3533 pppdArg("", "ipcp-accept-remote", (char *)0);
3534 pppdArg("", lrs, "netmask", nms, (char *)0);
3535 if (p_xisprc->operOpts & DEFAULT_ROUTE)
3536 pppdArg("", "defaultroute", (char *)0);
3537 if (p_xisprc->operOpts & PAP_LOGIN)
3538 pppdArg("", "+ua", papfname, (char *)0);
3539 if (p_xisprc->operOpts & PAPS_LOGIN) {
3540 pppdArg("", "user", p_xisprc->name,
3541 "remotename", p_xisprc->rname,
3542 (char *)0);
3543 }
3544 if (p_xisprc->operOpts & CHAPS_LOGIN) {
3545 if (pppdVersion().major > 2 || /* build version */
3546 pppdVersion().minor > 2) { /* dependent arg list */
3547 pppdArg("", "user", p_xisprc->name, /* this for v2.3+ */
3548 "remotename", p_xisprc->rname,
3549 (char *)0);
3550 }
3551 else {
3552 pppdArg("", "name", p_xisprc->name, /* and this for v2.2- */
3553 "remotename", p_xisprc->rname,
3554 (char *)0);
3555 }
3556 }
3557 if (p_xisprc->operOpts & IP_UPDOWN) {
3558 adjustAutoDNSCap(); /* check auto-DNS cap. */
3559 if (p_xisprc->operOpts & AUTO_DNS)
3560 pppdArg("", "usepeerdns", (char *)0);
3561 pppdArg("", "ipparam", IPParam, (char *)0);
3562 }
3563 if (debug)
3564 pppdArg("", "debug",
3565 "kdebug", "7", (char *)0);
3566 if (p_xisprc->operOpts &
3567 (CALL_BACK|CB_NT_RAS)) { /* if dial-in phase of */
3568 if (firstConn) { /* an NT-RAS connection */
3569 if (pppdVersion().major > 2 || /* build version */
3570 pppdVersion().minor > 2) /* dependent arg list */
3571 pppdArg("", "callback", /* use "callback" param */
3572 p_xisprc->CBphone, /* for v2.3+ */
3573 (char *)0);
3574 else
3575 pppdArg("", "cb", /* use "cb" param */
3576 p_xisprc->CBphone, /* for v2.2.x */
3577 (char *)0);
3578 } /* and start pppd now */
3579 else /* else call-back phase */
3580 mSleep(2000); /* so wait 2 seconds */
3581 if (pppdVersion().major > 2 && /* before starting pppd */
3582 pppdVersion().minor > 3 &&
3583 pppdVersion().plevel > 6) /* for v2.3.7+ allow all */
3584 pppdArg("", "receive-all", /* ctl chars (needed for */
3585 (char *)0); /* buggy NT PPP peers) */
3586 }
3587 if (pppdVersion().major < 3 &&
3588 pppdVersion().minor < 3)
3589 pppdArg("", "connect", Dialer, (char *)0);
3590 if (p_xisprc->operOpts &
3591 (CALL_BACK|CB_NT_RAS)) { /* if dial-in phase of */
3592 if (firstConn) /* an NT-RAS connection */
3593 waitPppd(0); /* std pppd timed-wait */
3594 else { /* else call-back phase */
3595 waitPppd(1); /* so wait gracefully */
3596 downTime = time(NULL); /* record pppd exit time */
3597 onLineSecs = downTime - upTime; /* calc dial-in time */
3598 onLineCost = callCost(p_ptt, /* and cost */
3599 onLineSecs, &onLineUnits);
3600 if (p_ptt->attribs & /* if the selected PTT */
3601 (PTT_PER_MINUTE|PTT_PER_SECS)) /* charges by time */
3602 totalCost += onLineCost; /* update the total cost */
3603 else /* else update the total */
3604 totalUnits += onLineUnits; /* unit value instead */
3605 updateLogs(0); /* then update logs */
3606 if (global.logOpts & COST_READOUT) { /* cost readout selected? */
3607 p = costStr(p_ptt, onLineCost); /* format it in a string */
3608 fl_set_object_label( /* print it on main form */
3609 fd_topFrame->logText, p);
3610 }
3611 else { /* no, time readout */
3612 ptm = gmtime(&connTime); /* break down time */
3613 strftime(tout,16, "%H:%M:%S", ptm); /* format it as HH:MM:SS */
3614 fl_set_object_label( /* print it on main form */
3615 fd_topFrame->logText, tout);
3616 if (ptm->tm_hour <10) p = &tout[1]; /* skip first hour digit */
3617 else p = tout; /* for the icon label */
3618 }
3619 updateTitles(p, p); /* upd icon & win titles */
3620 }
3621 }
3622 else /* for all other types */
3623 waitPppd(0); /* old pppd timed wait */
3624 pppd(pppd_arg); /* exec new pppd */
3625 fl_set_idle_callback(IOIdleCallback, NULL); /* and set idle callback */
3626 return;
3627 }
3628
3629 void doInterrupt(FL_OBJECT *obj, long param)
3630 {
3631 fl_deactivate_object(fd_topFrame->intButton); /* disable button */
3632 fl_set_object_lcol(fd_topFrame->intButton,
3633 FL_INACTIVE);
3634 fl_call_object_callback(btimer); /* flush/check status */
3635 if (dialerPID) { /* dialer still there? */
3636 bprintf("\nDialing interrupted: %s\n",
3637 strtime());
3638 if (kill(dialerPID, SIGTERM)) /* yup, terminate it */
3639 doErr("doInterrupt: kill");
3640 }
3641 connected = 0; /* invalidate connection */
3642 firstConn = 1;
3643 return;
3644 }
3645
3646
3647 /* .xisp-down is executed before the link is disconnected; note
3648 that the maximum wait for the child script to finish (while
3649 printing its output on xisp's browser) is set to 20 secons */
3650
3651 #define MAXSEC_XISPDNWAIT 20
3652 #define MSEC_ITERATION 200
3653 #define MAX_WAIT (MAXSEC_XISPDNWAIT*1000/MSEC_ITERATION)
3654
3655 void doDisconnect(FL_OBJECT *obj, long param)
3656 {
3657 char buf[MAXBUF_CHILD+1];
3658 int br, wait = MAX_WAIT, stat;
3659
3660 userDiscon = 1; /* set indicator */
3661 fl_deactivate_object(fd_topFrame->disButton); /* disable button */
3662 fl_set_object_lcol(fd_topFrame->disButton,
3663 FL_INACTIVE);
3664 bprintf("Disconnection: %s\n", strtime());
3665
3666 if ((xispUDPID = xispUD(0,0))) { /* if .xisp-down exists */
3667 do { /* and starts OK */
3668 br = read(dialerFD, buf, MAXBUF_CHILD); /* read a buffer full */
3669 if (br > 0) { /* if read OK */
3670 buf[br] = 0; /* indicate string end */
3671 bprintf("%s", buf); /* print it */
3672 fl_check_forms(); /* update browser */
3673 }
3674 else if (br < 0) { /* read failed */
3675 #ifdef SUNOS41x
3676 if (errno != EWOULDBLOCK) /* output unavailable? */
3677 #else
3678 if (errno != EAGAIN)
3679 #endif
3680 wait = 1; /* yes, exit loop */
3681 }
3682 else if (waitpid(xispUDPID, &stat, /* EOF on pipe output */
3683 WNOHANG) < 0) /* so, if script done */
3684 wait = 1; /* exit the loop */
3685 if (--wait) /* decrement sec counter */
3686 mSleep(MSEC_ITERATION); /* if != 0, sleep a bit */
3687 fl_check_forms(); /* update windows */
3688 }
3689 while (wait > 0);
3690 }
3691
3692 if (dialerPID) /* dialer still there? */
3693 kill(dialerPID, SIGTERM); /* yup, terminate it */
3694 pppdPID = getPppdPID(devName); /* PID of spawned pppd */
3695 if (pppdPID) /* interrupt pppd proc */
3696 kill(pppdPID, SIGINT);
3697 pppdPID = 0; /* indicate no pppd proc */
3698 fl_call_object_callback(ltimer); /* update link status */
3699 return;
3700 }
3701
3702 void doFile(FL_OBJECT *obj, long param)
3703 {
3704 void prepFolderForm(int);
3705 int deleteHandler(FL_FORM *, void *);
3706
3707 switch (fl_get_menu(obj)) {
3708
3709 case FILE_OPTIONS:{
3710 fl_deactivate_object(fd_topFrame->fileMenu);
3711 fl_set_object_lcol(fd_topFrame->fileMenu,FL_INACTIVE);
3712 prepFolderForm(OPTIONS_ACCOUNT);
3713 fl_set_folder_bynumber(fd_optsTab->optsFolder, OPTIONS_ACCOUNT);
3714 fl_set_form_hotspot(fd_optsTab->optsTab, 100,80);
3715 fl_show_form(fd_optsTab->optsTab, FL_PLACE_HOTSPOT,
3716 FL_TRANSIENT, "Options Setup");
3717 break;
3718 }
3719
3720 case FILE_HINTS:{
3721 nohints = !nohints;
3722 if (nohints) {
3723 fl_set_menu(fd_topFrame->fileMenu,
3724 "Options . . .|Enable hints|Exit");
3725 global.logOpts &= ~LOG_HINTS;
3726 }
3727 else {
3728 fl_set_menu(fd_topFrame->fileMenu,
3729 "Options . . .|Disable hints|Exit");
3730 global.logOpts |= LOG_HINTS;
3731 }
3732 writeXisprc(rcfname, xispOptions, &global);
3733 }
3734 break;
3735
3736 case FILE_EXIT:{
3737 deleteHandler(fd_topFrame->topFrame, NULL);
3738 break;
3739 }
3740
3741 default: break;
3742 }
3743
3744 return;
3745 }
3746
3747 void doLogging(FL_OBJECT *obj, long param)
3748 {
3749 int selection, i, tnf[3] = {52, 12, 6},
3750 type, cur, color;
3751 unsigned long tblTime[64], tTime = 0;
3752 float tblCosts[64];
3753 char buf[64], fid[32],
3754 mon[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
3755 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
3756 double cost, tcost = 0, max = 0;
3757
3758 fl_deactivate_object(fd_topFrame->logMenu);
3759 fl_set_object_lcol(fd_topFrame->logMenu,FL_INACTIVE);
3760 selection = fl_get_menu(obj);
3761 switch (selection) {
3762 case LOGGING_OPTIONS: {
3763 fl_set_button(fd_logInfo->OLTimeButton, 0);
3764 fl_set_button(fd_logInfo->OLChargeButton, 0);
3765 if (global.logOpts & COST_READOUT)
3766 fl_set_button(fd_logInfo->OLChargeButton, 1);
3767 else
3768 fl_set_button(fd_logInfo->OLTimeButton, 1);
3769 fl_set_button(fd_logInfo->logNoButton, 0);
3770 fl_set_button(fd_logInfo->logWeekButton, 0);
3771 fl_set_button(fd_logInfo->logMonthButton, 0);
3772 fl_set_button(fd_logInfo->logBiMonthButton, 0);
3773 if (global.logOpts & LOG_NONE)
3774 fl_set_button(fd_logInfo->logNoButton, 1);
3775 if (global.logOpts & LOG_WEEKLY)
3776 fl_set_button(fd_logInfo->logWeekButton, 1);
3777 if (global.logOpts & LOG_MONTHLY)
3778 fl_set_button(fd_logInfo->logMonthButton, 1);
3779 if (global.logOpts & LOG_BIMONTHLY)
3780 fl_set_button(fd_logInfo->logBiMonthButton, 1);
3781 fd_logInfo->ldata = global.logOpts |
3782 (currentPTT << 16) |
3783 (p_ptt->current_zone << 24);
3784 fl_clear_choice(fd_logInfo->pttDropChoice);
3785 for (i=0; i<global.numPTTs; i++)
3786 fl_addto_choice(fd_logInfo->pttDropChoice,
3787 clipStr(ptt[i].name, FL_NORMAL_SIZE,
3788 FL_NORMAL_STYLE, 240));
3789 fl_set_choice(fd_logInfo->pttDropChoice, currentPTT+1);
3790 fl_clear_choice(fd_logInfo->zoneDropChoice);
3791 for (i=0; i<p_ptt->num_zones; i++)
3792 fl_addto_choice(fd_logInfo->zoneDropChoice,
3793 clipStr(p_ptt->zone_name[i], FL_NORMAL_SIZE,
3794 FL_NORMAL_STYLE, 240));
3795 fl_set_choice(fd_logInfo->zoneDropChoice,p_ptt->current_zone+1);
3796 showPttInfo(p_ptt);
3797 fd_logInfo->vdata = NULL; /* reset PTT database change flag */
3798 strcpy(fd_logInfo->cdata, p_ptt->currency); /* save currency */
3799 fl_set_form_hotspot(fd_logInfo->logInfo, 310,120);
3800 fl_show_form(fd_logInfo->logInfo, FL_PLACE_HOTSPOT,
3801 FL_TRANSIENT, "Logging Options");
3802 break;
3803 }
3804
3805 case LOGGING_STATS: {
3806 type = buildStats(&global, &cur, tblTime, tblCosts);
3807 fl_clear_browser(fd_statInfo->statsBrowser);
3808 fl_clear_chart(fd_statInfo->statsChart);
3809 fl_clear_chart(fd_statInfo->pieChart);
3810 fl_set_chart_autosize(fd_statInfo->statsChart, 0);
3811 fl_set_chart_maxnumb(fd_statInfo->statsChart, tnf[type]);
3812 for (i=0; i<tnf[type]; i++) {
3813 switch (type) {
3814 case 0: sprintf(fid, "Week %d", i+1); break;
3815 case 1: sprintf(fid, "%s", mon[i]); break;
3816 case 2: sprintf(fid, "M%d,%d", 2*i+1, 2*i+2); break;
3817 }
3818 cost = tblCosts[i];
3819 if (cost > max)
3820 max = cost;
3821 tTime += tblTime[i];
3822 tcost += cost;
3823 sprintf(buf, "%s%s: %lu s, %s", (i==(cur-1))? "@b":"",
3824 fid, tblTime[i], costStr(p_ptt, cost));
3825 fl_addto_browser(fd_statInfo->statsBrowser, buf);
3826 if (i >= cur)
3827 color = FL_WHEAT;
3828 else
3829 color = FL_DARKCYAN;
3830 if (i == (cur-1)) {
3831 sprintf(buf, "@bTotal: %lu s, %s",
3832 tTime, costStr(p_ptt, tcost));
3833 fl_addto_browser(fd_statInfo->statsBrowser, buf);
3834 color = FL_WHITE;
3835 tTime = tcost = 0;
3836 }
3837 switch (type) {
3838 case 0: if (i>0 && (i%10)) *fid = 0;
3839 else sprintf(fid, "W%d", i+1);
3840 break;
3841 case 2: sprintf(fid, "%s,%s", mon[2*i], mon[2*i+1]);
3842 break;
3843 }
3844 fl_add_chart_value(fd_statInfo->statsChart, cost, fid, color);
3845 if (cost > 0.1) {
3846 if (i % 2)
3847 color = FL_DARKCYAN;
3848 else
3849 color = FL_WHEAT;
3850 }
3851 if (i == (cur-1))
3852 color = FL_WHITE;
3853 fl_add_chart_value(fd_statInfo->pieChart, cost, fid, color);
3854 }
3855 fl_set_chart_bounds(fd_statInfo->statsChart, 0.0, max);
3856 if (i != tnf[type]) {
3857 sprintf(buf, "@bTotal: %lu s, %s",
3858 tTime, costStr(p_ptt, tcost));
3859 fl_addto_browser(fd_statInfo->statsBrowser, buf);
3860 }
3861 fl_show_form(fd_statInfo->statInfo, FL_PLACE_MOUSE,
3862 FL_TRANSIENT, "Logging Statistics");
3863 }
3864
3865 default: break;
3866 }
3867 return;
3868 }
3869
3870 void doHelp(FL_OBJECT *obj, long param)
3871 {
3872 int selection, i;
3873
3874 selection = fl_get_menu(obj);
3875 switch (selection) {
3876 case HELP_ABOUT: {
3877 fl_show_form(fd_aboutInfo->aboutInfo, FL_PLACE_MOUSE,
3878 FL_TRANSIENT, "About xISP");
3879 break;
3880 }
3881
3882 case HELP_GENERAL: {
3883 fl_clear_browser(fd_helpInfo->helpBrowser);
3884 for (i=0; i<MAXNUM_HELPLINES; i++)
3885 fl_add_browser_line(fd_helpInfo->helpBrowser,
3886 helpText[i]);
3887 fl_show_form(fd_helpInfo->helpInfo, FL_PLACE_MOUSE,
3888 FL_TRANSIENT, "General Information");
3889 break;
3890 }
3891
3892 default: break;
3893 }
3894 return;
3895 }
3896
3897 void doISPDropChoice(FL_OBJECT *obj, long param)
3898 {
3899 int c, sPTT, newCurrency;
3900
3901 if ((c = fl_get_choice(obj))) {
3902 if ((unsigned int)c == currentRC)
3903 return;
3904 sPTT = xispOptions[c].ispPTT;
3905 newCurrency = strcmp(ptt[currentPTT].currency,ptt[sPTT].currency);
3906 if (!(global.logOpts & LOG_NONE) && newCurrency &&
3907 ! actionVerify("The PTT for the selected ISP bills you in "
3908 "currency\nwhich is different from the one "
3909 "currently in use. This\nimplies resetting of "
3910 "log files, continue?", 0))
3911 {
3912 fl_set_choice(obj, currentRC);
3913 return;
3914 }
3915 if (!(global.logOpts & LOG_NONE) && newCurrency)
3916 resetLogs();
3917 currentRC = c;
3918 p_xisprc = &xispOptions[currentRC];
3919 currentPTT = p_xisprc->ispPTT;
3920 global.costPTT = currentPTT;
3921 p_ptt = &ptt[currentPTT];
3922 p_ptt->current_zone = p_xisprc->ispZone;
3923 writeXisprc(rcfname, xispOptions, &global);
3924 }
3925 return;
3926 }
3927
3928
3929 /*+-------------------------------------------------------------------------+
3930 | |
3931 | Selection routines for topFrame |
3932 | |
3933 +-------------------------------------------------------------------------+*/
3934
3935 int select_IPText(FL_OBJECT *obj, int event,
3936 FL_Coord mx, FL_Coord my,
3937 int key, void *raw_event)
3938 {
3939 Display *disp = fl_get_display();
3940 static unsigned char selected = 0;
3941
3942 if (linkOK && event == FL_RELEASE) {
3943 selected ^= 1;
3944 if (selected) {
3945 XSetSelectionOwner(disp, XA_CUT_BUFFER0, topWin, CurrentTime);
3946 if (XGetSelectionOwner(disp, XA_CUT_BUFFER0) == topWin) {
3947 XStoreBytes(disp, connIP, strlen(connIP));
3948 fl_set_object_color(obj, FL_CYAN, FL_MCOL);
3949 fl_set_object_lcolor(obj, FL_BLACK);
3950 fl_set_object_lstyle(obj, FL_NORMAL_STYLE);
3951 }
3952 else
3953 selected ^= 1;
3954 }
3955 else {
3956 fl_set_object_color(obj, FL_BLACK, FL_MCOL);
3957 fl_set_object_lcolor(obj, FL_WHITE);
3958 fl_set_object_lstyle(obj, FL_NORMAL_STYLE+FL_SHADOW_STYLE);
3959 }
3960 }
3961 return 0;
3962 }
3963
3964
3965 /*+-------------------------------------------------------------------------+
3966 | |
3967 | Utility and callback routines for accountInfo |
3968 | |
3969 +-------------------------------------------------------------------------+*/
3970
3971 void updateAccInfo(accountInfo_t *a)
3972 {
3973 char phone[MAXNUM_TELS*(MAXLEN_PHONE+1)+1] = {0},
3974 ppasswd[MAXLEN_PASSWD+1] = {0};
3975 xisprc_t *p = &xispOptions[a->cur];
3976 int i;
3977
3978 strcpy(a->descr, p->descr);
3979 if (global.numISPs && a->dflt == a->cur)
3980 fl_set_button(fd_accountInfo->ISPDefault, 1);
3981 else
3982 fl_set_button(fd_accountInfo->ISPDefault, 0);
3983 fd_accountInfo->ldata = p->operOpts;
3984 if (global.numISPs && p->operOpts & STARTUP_DIAL)
3985 fl_set_button(fd_accountInfo->ISPAutoDial, 1);
3986 else
3987 fl_set_button(fd_accountInfo->ISPAutoDial, 0);
3988 if (global.numISPs && p->operOpts & AUTO_REDIAL)
3989 fl_set_button(fd_accountInfo->autoRedial, 1);
3990 else
3991 fl_set_button(fd_accountInfo->autoRedial, 0);
3992 for (i=0; i<p->numPhones; i++) {
3993 if (i) strcat(phone, ";");
3994 strcat(phone, p->phone[i]);
3995 }
3996 fl_set_input(fd_accountInfo->telInput, phone);
3997 fl_set_input(fd_accountInfo->accInput, p->account);
3998 if (*(p->account))
3999 pdecode(ppasswd, p->passwd);
4000 fl_set_input(fd_accountInfo->pswInput, ppasswd);
4001 fl_set_input(fd_accountInfo->UNInput, p->name);
4002 fl_set_input(fd_accountInfo->remoteInput, p->rname);
4003 fl_set_button(fd_accountInfo->authPAPButton, 0);
4004 fl_set_button(fd_accountInfo->authPAPSButton, 0);
4005 fl_set_button(fd_accountInfo->authCHAPSButton, 0);
4006 fl_set_button(fd_accountInfo->authNoneButton, 0);
4007 if (global.numISPs) {
4008 if (p->operOpts & PAP_LOGIN) {
4009 fl_set_button(fd_accountInfo->authPAPButton, 1);
4010 fl_activate_object(fd_accountInfo->accInput);
4011 fl_set_object_lcol(fd_accountInfo->accInput, FL_WHITE);
4012 fl_activate_object(fd_accountInfo->pswInput);
4013 fl_set_object_lcol(fd_accountInfo->pswInput, FL_WHITE);
4014 fl_deactivate_object(fd_accountInfo->UNInput);
4015 fl_set_object_lcol(fd_accountInfo->UNInput, FL_INACTIVE);
4016 fl_deactivate_object(fd_accountInfo->remoteInput);
4017 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_INACTIVE);
4018 }
4019 else if (p->operOpts & PAPS_LOGIN) {
4020 fl_set_button(fd_accountInfo->authPAPSButton, 1);
4021 fl_deactivate_object(fd_accountInfo->accInput);
4022 fl_set_object_lcol(fd_accountInfo->accInput, FL_INACTIVE);
4023 fl_deactivate_object(fd_accountInfo->pswInput);
4024 fl_set_object_lcol(fd_accountInfo->pswInput, FL_INACTIVE);
4025 fl_activate_object(fd_accountInfo->UNInput);
4026 fl_set_object_lcol(fd_accountInfo->UNInput, FL_WHITE);
4027 fl_activate_object(fd_accountInfo->remoteInput);
4028 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_WHITE);
4029 }
4030 else if (p->operOpts & CHAPS_LOGIN) {
4031 fl_set_button(fd_accountInfo->authCHAPSButton, 1);
4032 fl_deactivate_object(fd_accountInfo->accInput);
4033 fl_set_object_lcol(fd_accountInfo->accInput, FL_INACTIVE);
4034 fl_deactivate_object(fd_accountInfo->pswInput);
4035 fl_set_object_lcol(fd_accountInfo->pswInput, FL_INACTIVE);
4036 fl_activate_object(fd_accountInfo->UNInput);
4037 fl_set_object_lcol(fd_accountInfo->UNInput, FL_WHITE);
4038 fl_activate_object(fd_accountInfo->remoteInput);
4039 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_WHITE);
4040 }
4041 else {
4042 fl_set_button(fd_accountInfo->authNoneButton, 1);
4043 fl_activate_object(fd_accountInfo->accInput);
4044 fl_set_object_lcol(fd_accountInfo->accInput, FL_WHITE);
4045 fl_activate_object(fd_accountInfo->pswInput);
4046 fl_set_object_lcol(fd_accountInfo->pswInput, FL_WHITE);
4047 fl_deactivate_object(fd_accountInfo->UNInput);
4048 fl_set_object_lcol(fd_accountInfo->UNInput, FL_INACTIVE);
4049 fl_deactivate_object(fd_accountInfo->remoteInput);
4050 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_INACTIVE);
4051 }
4052 p_ptt = &ptt[p->ispPTT];
4053 p_ptt->current_zone = p->ispZone;
4054 IFC_accountInfo.udata = p->ispPTT |
4055 (p_ptt->current_zone << 8);
4056 if (!(global.logOpts & LOG_NONE) || (global.logOpts & COST_READOUT)) {
4057 fl_set_choice(fd_accountInfo->ispPttDropChoice, p->ispPTT+1);
4058 fl_clear_choice(fd_accountInfo->ispZoneDropChoice);
4059 for (i=0; i<p_ptt->num_zones; i++)
4060 fl_addto_choice(fd_accountInfo->ispZoneDropChoice,
4061 clipStr(p_ptt->zone_name[i], FL_MEDIUM_SIZE,
4062 FL_BOLD_STYLE, 235));
4063 fl_set_choice(fd_accountInfo->ispZoneDropChoice,
4064 p_ptt->current_zone+1);
4065 }
4066 }
4067 }
4068
4069 void saveAccInfo(accountInfo_t *a)
4070 {
4071 char *p1, *p2;
4072 int i, nc;
4073 unsigned char sPTT = (unsigned)a->udata & 0x000000FF,
4074 sZone = ((unsigned)a->udata & 0x00000FF00) >> 8;
4075
4076 currentRC = a->cur;
4077 p_xisprc = &xispOptions[currentRC];
4078 fl_call_object_callback(fd_renameISP->ISPNameInput);
4079 strcpy(p_xisprc->descr, fd_renameISP->cdata);
4080 global.dfltISP = a->dflt;
4081 p_xisprc->operOpts = fd_accountInfo->ldata;
4082 fl_clear_choice(fd_topFrame->ISPDropChoice);
4083 for (i=0; i<global.numISPs; i++)
4084 if (*(xispOptions[i+1].descr))
4085 fl_addto_choice(fd_topFrame->ISPDropChoice,
4086 clipStr(xispOptions[i+1].descr, FL_NORMAL_SIZE,
4087 FL_NORMAL_STYLE, 150));
4088 fl_set_choice(fd_topFrame->ISPDropChoice, currentRC);
4089 fl_call_object_callback(fd_accountInfo->telInput);
4090 p1 = fd_accountInfo->cdata;
4091 for (i=0; i<MAXNUM_TELS && *p1; i++) {
4092 p2 = strchr(p1, ';');
4093 if (p2 != NULL)
4094 nc = p2 - p1;
4095 else {
4096 nc = strlen(p1);
4097 p2 = p1 + nc - 1;
4098 }
4099 strncpy(p_xisprc->phone[i], p1, nc);
4100 p_xisprc->phone[i][nc] = 0;
4101 p1 = p2 + 1;
4102 }
4103 p_xisprc->numPhones = i;
4104 fl_call_object_callback(fd_accountInfo->accInput);
4105 strcpy(p_xisprc->account, fd_accountInfo->cdata);
4106 fl_call_object_callback(fd_accountInfo->pswInput);
4107 memcpy(p_xisprc->passwd, fd_accountInfo->cdata, MAXLEN_PASSWD);
4108 fl_call_object_callback(fd_accountInfo->UNInput);
4109 strcpy(p_xisprc->name, fd_accountInfo->cdata);
4110 fl_call_object_callback(fd_accountInfo->remoteInput);
4111 strcpy(p_xisprc->rname, fd_accountInfo->cdata);
4112 p_ptt = &ptt[sPTT];
4113 p_xisprc->ispPTT = sPTT;
4114 p_xisprc->ispZone = sZone;
4115 p_ptt->current_zone = p_xisprc->ispZone;
4116 writeXisprc(rcfname, xispOptions, &global);
4117 }
4118
4119 void askSaveAccInfo(accountInfo_t *a)
4120 {
4121 if (! a->modified)
4122 return;
4123 if (actionVerify("Changes recorded for current ISP.\n"
4124 "Save them in the ISP data-base ?", 0))
4125 saveAccInfo(a);
4126 else {
4127 fl_replace_browser_line(fd_accountInfo->ISPBrowser, a->cur, a->descr);
4128 strcpy(xispOptions[a->cur].descr, a->descr);
4129 }
4130 }
4131
4132 void doAccountInfoTip(FL_OBJECT *obj, long param)
4133 {
4134 alertMessage("Authentication hints", 1, 0,
4135 "The \"authentication protocol\" is the method used to establish\n"
4136 "your identity when connecting to an ISP.\n"
4137 "\n"
4138 "- If you choose \"None\", then most probably you will need to\n"
4139 " create a login script and enter it in the \"Dialing and Login\"\n"
4140 " form. Read Help->General for more details.\n"
4141 "\n"
4142 "- If you Choose PAP (and your pppd version is newer than\n"
4143 " 2.2.0) or CHAP, then your system administrator (or yourself\n"
4144 " acting as root) must add entries for your ISP account in file\n"
4145 " /etc/ppp/pap-secrets or /etc/ppp/chap-secrets respectively.\n");
4146 }
4147
4148 void doTelNoInput(FL_OBJECT *obj, long param)
4149 {
4150 accountInfo_t *a = &IFC_accountInfo;
4151 static char phone[MAXNUM_TELS*(MAXLEN_PHONE+1)+1] = {0};
4152
4153 strncpy(phone, (char *)fl_get_input(obj), MAXNUM_TELS*(MAXLEN_PHONE+1));
4154 fd_accountInfo->cdata = phone;
4155 a->modified = 1;
4156 return;
4157 }
4158
4159 void doAccountInput(FL_OBJECT *obj, long param)
4160 {
4161 accountInfo_t *a = &IFC_accountInfo;
4162 static char account[MAXLEN_ACCOUNT+1] = {0};
4163
4164 strncpy(account, (char *)fl_get_input(obj), MAXLEN_ACCOUNT);
4165 fd_accountInfo->cdata = account;
4166 a->modified = 1;
4167 return;
4168 }
4169
4170 void doPasswdInput(FL_OBJECT *obj, long param)
4171 {
4172 accountInfo_t *a = &IFC_accountInfo;
4173 static char epasswd[MAXLEN_PASSWD+1] = {0};
4174 char ppasswd[MAXLEN_PASSWD+1];
4175
4176 memset(ppasswd, 0, MAXLEN_PASSWD+1);
4177 strncpy(ppasswd, (char *)fl_get_input(obj), MAXLEN_PASSWD);
4178 pencode(epasswd, ppasswd);
4179 fd_accountInfo->cdata = epasswd;
4180 a->modified = 1;
4181 return;
4182 }
4183
4184 void doAuthPAPButton(FL_OBJECT *obj, long param)
4185 {
4186 accountInfo_t *a = &IFC_accountInfo;
4187
4188 if (fl_get_button(fd_accountInfo->authPAPButton)) {
4189 fd_accountInfo->ldata |= PAP_LOGIN;
4190 fd_accountInfo->ldata &= ~(PAPS_LOGIN | CHAPS_LOGIN);
4191 fl_activate_object(fd_accountInfo->accInput);
4192 fl_set_object_lcol(fd_accountInfo->accInput, FL_WHITE);
4193 fl_activate_object(fd_accountInfo->pswInput);
4194 fl_set_object_lcol(fd_accountInfo->pswInput, FL_WHITE);
4195 fl_deactivate_object(fd_accountInfo->UNInput);
4196 fl_set_object_lcol(fd_accountInfo->UNInput, FL_INACTIVE);
4197 fl_deactivate_object(fd_accountInfo->remoteInput);
4198 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_INACTIVE);
4199 a->modified = 1;
4200 }
4201 return;
4202 }
4203
4204 void doAuthPAPSButton(FL_OBJECT *obj, long param)
4205 {
4206 accountInfo_t *a = &IFC_accountInfo;
4207
4208 if (fl_get_button(fd_accountInfo->authPAPSButton)) {
4209 fd_accountInfo->ldata |= PAPS_LOGIN;
4210 fd_accountInfo->ldata &= ~(PAP_LOGIN | CHAPS_LOGIN);
4211 fl_deactivate_object(fd_accountInfo->accInput);
4212 fl_set_object_lcol(fd_accountInfo->accInput, FL_INACTIVE);
4213 fl_deactivate_object(fd_accountInfo->pswInput);
4214 fl_set_object_lcol(fd_accountInfo->pswInput, FL_INACTIVE);
4215 fl_activate_object(fd_accountInfo->UNInput);
4216 fl_set_object_lcol(fd_accountInfo->UNInput, FL_WHITE);
4217 fl_activate_object(fd_accountInfo->remoteInput);
4218 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_WHITE);
4219 a->modified = 1;
4220
4221 if (! nohints) alertMessage("PAP hint", 1, 0,
4222 "Standard PAP operation requires an entry in your system\n"
4223 "file /etc/ppp/pap-secrets, for this ISP account. You need\n"
4224 "to enter your account name (at your ISP, e.g. \"dbouras\") in\n"
4225 "the \"User/Name:\" input field, and a short-hand name for your\n"
4226 "ISP in the \"Remotename:\" input field (e.g. \"hol\").\n"
4227 "\n"
4228 "Then, your system administrator (or yourself acting as root)\n"
4229 "needs to enter a line in /etc/ppp/pap-secrets, with three items\n"
4230 "separated by spaces: your account name, the short-hand\n"
4231 "name you chose for this ISP, and your password. If the pass-\n"
4232 "word for the example account name above was \"saruobd\",\n"
4233 "the line in /etc/ppp/pap-secrets should read:\n"
4234 "\n"
4235 " dbouras hol saruobd");
4236 }
4237 return;
4238 }
4239
4240 void doAuthCHAPSButton(FL_OBJECT *obj, long param)
4241 {
4242 accountInfo_t *a = &IFC_accountInfo;
4243
4244 if (fl_get_button(fd_accountInfo->authCHAPSButton)) {
4245 fd_accountInfo->ldata |= CHAPS_LOGIN;
4246 fd_accountInfo->ldata &= ~(PAP_LOGIN | PAPS_LOGIN);
4247 fl_deactivate_object(fd_accountInfo->accInput);
4248 fl_set_object_lcol(fd_accountInfo->accInput, FL_INACTIVE);
4249 fl_deactivate_object(fd_accountInfo->pswInput);
4250 fl_set_object_lcol(fd_accountInfo->pswInput, FL_INACTIVE);
4251 fl_activate_object(fd_accountInfo->UNInput);
4252 fl_set_object_lcol(fd_accountInfo->UNInput, FL_WHITE);
4253 fl_activate_object(fd_accountInfo->remoteInput);
4254 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_WHITE);
4255 a->modified = 1;
4256
4257 if (! nohints) alertMessage("CHAP hint", 1, 0,
4258 "CHAP operation requires two entries in your system file\n"
4259 "/etc/ppp/chap-secrets, for this ISP account. You need to\n"
4260 "enter your account name (at your ISP, e.g. \"dbouras\") in the\n"
4261 "\"User/Name:\" input field, and a remote name as provided by\n"
4262 "your ISP in the \"Remotename:\" input field (e.g. \"hol\").\n"
4263 "\n"
4264 "Then, your system administrator (or yourself acting as root)\n"
4265 "needs to enter two lines in /etc/ppp/chap-secrets, each one\n"
4266 "having three items separated by spaces: your account name,\n"
4267 "the remote name, and your password. If the password for\n"
4268 "the example account name above was \"saruobd\", the lines\n"
4269 "in /etc/ppp/pap-secrets should read:\n"
4270 "\n"
4271 " dbouras hol saruobd\n"
4272 " hol dbouras saruobd\n"
4273 "\n"
4274 "If you are selecting CHAP because you are setting up an\n"
4275 "NT-RAS call-back account, please read carefully the details\n"
4276 "in section \"NT-RAS call-back support\" under \"Help->General\".");
4277 }
4278 return;
4279 }
4280
4281 void doAuthNoneButton(FL_OBJECT *obj, long param)
4282 {
4283 accountInfo_t *a = &IFC_accountInfo;
4284
4285 if (fl_get_button(fd_accountInfo->authNoneButton)) {
4286 fd_accountInfo->ldata &= ~(PAP_LOGIN | PAPS_LOGIN | CHAPS_LOGIN);
4287 fl_activate_object(fd_accountInfo->accInput);
4288 fl_set_object_lcol(fd_accountInfo->accInput, FL_WHITE);
4289 fl_activate_object(fd_accountInfo->pswInput);
4290 fl_set_object_lcol(fd_accountInfo->pswInput, FL_WHITE);
4291 fl_deactivate_object(fd_accountInfo->UNInput);
4292 fl_set_object_lcol(fd_accountInfo->UNInput, FL_INACTIVE);
4293 fl_deactivate_object(fd_accountInfo->remoteInput);
4294 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_INACTIVE);
4295 a->modified = 1;
4296 }
4297 return;
4298 }
4299
4300 void doUNInput(FL_OBJECT *obj, long param)
4301 {
4302 accountInfo_t *a = &IFC_accountInfo;
4303 static char name[MAXLEN_UNR+1] = {0};
4304
4305 strncpy(name, (char *)fl_get_input(obj), MAXLEN_UNR);
4306 fd_accountInfo->cdata = name;
4307 a->modified = 1;
4308 return;
4309 }
4310
4311 void doRemoteInput(FL_OBJECT *obj, long param)
4312 {
4313 accountInfo_t *a = &IFC_accountInfo;
4314 static char rname[MAXLEN_UNR+1] = {0};
4315
4316 strncpy(rname, (char *)fl_get_input(obj), MAXLEN_UNR);
4317 fd_accountInfo->cdata = rname;
4318 a->modified = 1;
4319 return;
4320 }
4321
4322 void doIspPttDropChoice(FL_OBJECT *obj, long param)
4323 {
4324 accountInfo_t *a = &IFC_accountInfo;
4325 unsigned char sPTT = (unsigned)a->udata & 0x000000FF;
4326 int c, i;
4327 ptt_t *p;
4328
4329 if ((c = fl_get_choice(obj)) && --c != sPTT) {
4330 a->udata &= 0x0FFFFFF00;
4331 a->udata |= (unsigned)c;
4332 p = &ptt[c];
4333 fl_clear_choice(fd_accountInfo->ispZoneDropChoice);
4334 for (i=0; i<p->num_zones; i++)
4335 fl_addto_choice(fd_accountInfo->ispZoneDropChoice,
4336 clipStr(p->zone_name[i], FL_MEDIUM_SIZE,
4337 FL_BOLD_STYLE, 235));
4338 a->udata &= 0xFFFF00FF;
4339 fl_set_choice(fd_accountInfo->ispZoneDropChoice, 1);
4340 a->modified = 1;
4341 }
4342 return;
4343 }
4344
4345 void doIspZoneDropChoice(FL_OBJECT *obj, long param)
4346 {
4347 accountInfo_t *a = &IFC_accountInfo;
4348 unsigned char cZone = ((unsigned)a->udata & 0x0000FF00) >> 8;
4349 int c;
4350
4351 if ((c = fl_get_choice(obj)) && --c != cZone) {
4352 a->udata &= 0xFFFF00FF;
4353 a->udata |= ((unsigned)c << 8);
4354 a->modified = 1;
4355 }
4356 return;
4357 }
4358
4359 void doISPPick(FL_OBJECT *obj, long param)
4360 {
4361 accountInfo_t *a = &IFC_accountInfo;
4362 unsigned char cur = fl_get_browser(obj);
4363
4364 if (cur && a->cur != cur) {
4365 askSaveAccInfo(a);
4366 a->cur = cur;
4367 fl_set_input(fd_renameISP->ISPNameInput, xispOptions[cur].descr);
4368 updateAccInfo(a);
4369 a->modified = 0;
4370 }
4371 return;
4372 }
4373
4374 void doISPPickNEdit(FL_OBJECT *obj, long param)
4375 {
4376 accountInfo_t *a = &IFC_accountInfo;
4377 xisprc_t *p = &xispOptions[a->cur];
4378
4379 fl_call_object_callback(fd_accountInfo->ISPBrowser);
4380 fl_set_input(fd_renameISP->ISPNameInput, p->descr);
4381 a->new = 0;
4382 fl_deactivate_form(fd_accountInfo->accountInfo);
4383 fl_show_form(fd_renameISP->renameISP, FL_PLACE_MOUSE,
4384 FL_TRANSIENT, "Rename ISP record");
4385 return;
4386 }
4387
4388 void doAccountInfoAdd(FL_OBJECT *obj, long param)
4389 {
4390 accountInfo_t *a = &IFC_accountInfo;
4391
4392 fl_set_input(fd_renameISP->ISPNameInput, "");
4393 a->new = 1;
4394 fl_deactivate_form(fd_accountInfo->accountInfo);
4395 fl_show_form(fd_renameISP->renameISP, FL_PLACE_MOUSE,
4396 FL_TRANSIENT, "ISP name");
4397 return;
4398 }
4399
4400 void doAccountInfoDelete(FL_OBJECT *obj, long param)
4401 {
4402 accountInfo_t *a = &IFC_accountInfo;
4403 xisprc_t *p_src, *p_dest, *p = &xispOptions[a->cur];
4404
4405 if (! expert) {
4406 char msg[128+MAXLEN_PTTNAME] = {0};
4407
4408 sprintf(msg, "Are you sure you want to delete ISP\n\"%s\"?", p->descr);
4409 if (! actionVerify(msg, 0))
4410 return;
4411 }
4412 fl_delete_browser_line(fd_accountInfo->ISPBrowser, a->cur);
4413 if (a->cur == a->dflt)
4414 a->dflt = 1;
4415 if (a->cur < global.numISPs) {
4416 p_dest = &xispOptions[a->cur];
4417 p_src = &xispOptions[(a->cur)+1];
4418 #ifdef SUNOS41x
4419 bcopy(p_src, p_dest, (global.numISPs-(a->cur))*sizeof(xisprc_t));
4420 #else
4421 memmove(p_dest, p_src, (global.numISPs-(a->cur))*sizeof(xisprc_t));
4422 #endif
4423 }
4424 else
4425 a->cur -= 1;
4426 p = realloc(xispOptions, global.numISPs*sizeof(xisprc_t));
4427 if (p == NULL)
4428 outofMem();
4429 else {
4430 xispOptions = p;
4431 global.numISPs -= 1;
4432 fd_accountInfo->vdata = (void *)1; /* ISP database resize */
4433 }
4434 if (global.numISPs < 1) {
4435 fl_deactivate_object(fd_accountInfo->accountInfoCopy);
4436 fl_set_object_lcol(fd_accountInfo->accountInfoCopy, FL_INACTIVE);
4437 fl_deactivate_object(fd_accountInfo->accountInfoDelete);
4438 fl_set_object_lcol(fd_accountInfo->accountInfoDelete, FL_INACTIVE);
4439 fl_deactivate_object(fd_accountInfo->ISPDefault);
4440 fl_set_object_lcol(fd_accountInfo->ISPDefault, FL_INACTIVE);
4441 fl_deactivate_object(fd_accountInfo->ISPAutoDial);
4442 fl_set_object_lcol(fd_accountInfo->ISPAutoDial, FL_INACTIVE);
4443 fl_deactivate_object(fd_accountInfo->autoRedial);
4444 fl_set_object_lcol(fd_accountInfo->autoRedial, FL_INACTIVE);
4445 fl_deactivate_object(fd_accountInfo->telInput);
4446 fl_set_object_lcol(fd_accountInfo->telInput, FL_INACTIVE);
4447 fl_deactivate_object(fd_accountInfo->accInput);
4448 fl_set_object_lcol(fd_accountInfo->accInput, FL_INACTIVE);
4449 fl_deactivate_object(fd_accountInfo->pswInput);
4450 fl_set_object_lcol(fd_accountInfo->pswInput, FL_INACTIVE);
4451 fl_deactivate_object(fd_accountInfo->UNInput);
4452 fl_set_object_lcol(fd_accountInfo->UNInput, FL_INACTIVE);
4453 fl_deactivate_object(fd_accountInfo->remoteInput);
4454 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_INACTIVE);
4455 fl_deactivate_object(fd_accountInfo->authType);
4456 fl_set_object_lcol(fd_accountInfo->authType, FL_INACTIVE);
4457 a->cur = a->dflt = 0;
4458 }
4459 else {
4460 p = &xispOptions[a->cur];
4461 fl_set_input(fd_renameISP->ISPNameInput, p->descr);
4462 fl_select_browser_line(fd_accountInfo->ISPBrowser, a->cur);
4463 }
4464 updateAccInfo(a);
4465 a->modified = 0;
4466 return;
4467 }
4468
4469 void doAccountInfoCopy(FL_OBJECT *obj, long param)
4470 {
4471 accountInfo_t *a = &IFC_accountInfo;
4472
4473 memcpy(&ISPCopyBuf, &xispOptions[a->cur], sizeof(xisprc_t));
4474 fl_activate_object(fd_accountInfo->accountInfoPaste);
4475 fl_set_object_lcol(fd_accountInfo->accountInfoPaste, FL_LCOL);
4476 return;
4477 }
4478
4479 void doAccountInfoPaste(FL_OBJECT *obj, long param)
4480 {
4481 accountInfo_t *a = &IFC_accountInfo;
4482 xisprc_t *p = &xispOptions[a->cur];
4483
4484 p = realloc(xispOptions, (1+global.numISPs+1)*sizeof(xisprc_t));
4485 if (p == NULL)
4486 outofMem();
4487 else {
4488 xispOptions = p;
4489 global.numISPs += 1;
4490 fd_accountInfo->vdata = (void *)1; /* ISP database resize */
4491 }
4492 a->cur = global.numISPs;
4493 p = &xispOptions[a->cur];
4494 *p = ISPCopyBuf;
4495 fl_addto_browser(fd_accountInfo->ISPBrowser, p->descr);
4496 if (a->dflt == 0) {
4497 a->dflt = 1;
4498 fl_activate_object(fd_accountInfo->accountInfoCopy);
4499 fl_set_object_lcol(fd_accountInfo->accountInfoCopy, FL_LCOL);
4500 fl_activate_object(fd_accountInfo->accountInfoDelete);
4501 fl_set_object_lcol(fd_accountInfo->accountInfoDelete, FL_LCOL);
4502 fl_activate_object(fd_accountInfo->ISPDefault);
4503 fl_set_object_lcol(fd_accountInfo->ISPDefault, FL_WHITE);
4504 fl_activate_object(fd_accountInfo->ISPAutoDial);
4505 fl_set_object_lcol(fd_accountInfo->ISPAutoDial, FL_WHITE);
4506 fl_activate_object(fd_accountInfo->autoRedial);
4507 fl_set_object_lcol(fd_accountInfo->autoRedial, FL_WHITE);
4508 fl_activate_object(fd_accountInfo->telInput);
4509 fl_set_object_lcol(fd_accountInfo->telInput, FL_WHITE);
4510 fl_activate_object(fd_accountInfo->authType);
4511 fl_set_object_lcol(fd_accountInfo->authType, FL_WHITE);
4512 adjustPAPCap();
4513 }
4514 fl_select_browser_line(fd_accountInfo->ISPBrowser, a->cur);
4515 updateAccInfo(a);
4516 a->modified = 0;
4517 return;
4518 }
4519
4520 void doISPDefault(FL_OBJECT *obj, long param)
4521 {
4522 accountInfo_t *a = &IFC_accountInfo;
4523
4524 if (fl_get_button(fd_accountInfo->ISPDefault))
4525 a->dflt = a->cur;
4526 else {
4527 a->dflt = 1;
4528 if (a->cur == 1) {
4529 XBell(fl_get_display(), 50);
4530 fl_set_button(fd_accountInfo->ISPDefault, 1);
4531 }
4532 }
4533 a->modified = 1;
4534 return;
4535 }
4536
4537 void doISPAutoDial(FL_OBJECT *obj, long param)
4538 {
4539 accountInfo_t *a = &IFC_accountInfo;
4540
4541 if (fl_get_button(fd_accountInfo->ISPAutoDial))
4542 fd_accountInfo->ldata |= STARTUP_DIAL;
4543 else
4544 fd_accountInfo->ldata &= ~STARTUP_DIAL;
4545 a->modified = 1;
4546 return;
4547 }
4548
4549 void doAutoRedial(FL_OBJECT *obj, long param)
4550 {
4551 accountInfo_t *a = &IFC_accountInfo;
4552
4553 if (fl_get_button(fd_accountInfo->autoRedial))
4554 fd_accountInfo->ldata |= AUTO_REDIAL;
4555 else
4556 fd_accountInfo->ldata &= ~AUTO_REDIAL;
4557 a->modified = 1;
4558 return;
4559 }
4560
4561 void doISPNameInput(FL_OBJECT *obj, long param)
4562 {
4563 static char name[MAXLEN_DESCR+1] = {0};
4564
4565 strncpy(name, (char *)fl_get_input(obj), MAXLEN_DESCR);
4566 fd_renameISP->cdata = name;
4567 return;
4568 }
4569
4570 void doISPNameEditOK(FL_OBJECT *obj, long param)
4571 {
4572 accountInfo_t *a = &IFC_accountInfo;
4573 xisprc_t *p = &xispOptions[a->cur];
4574 int i;
4575
4576 fl_call_object_callback(fd_renameISP->ISPNameInput);
4577 if (*(fd_renameISP->cdata) == 0) {
4578 XBell(fl_get_display(), 50);
4579 fl_set_input(fd_renameISP->ISPNameInput, "My new ISP");
4580 fl_redraw_object(fd_renameISP->ISPNameInput);
4581 return;
4582 }
4583 if (! (a->new)) {
4584 strncpy(p->descr, fd_renameISP->cdata, MAXLEN_DESCR);
4585 fl_replace_browser_line(fd_accountInfo->ISPBrowser, a->cur, p->descr);
4586 a->modified = 1;
4587 }
4588 else {
4589 p = realloc(xispOptions, (1+global.numISPs+1)*sizeof(xisprc_t));
4590 if (p == NULL)
4591 outofMem();
4592 else {
4593 xispOptions = p;
4594 global.numISPs += 1;
4595 fd_accountInfo->vdata = (void *)1; /* ISP database resize */
4596 }
4597 a->cur = global.numISPs;
4598 p = &xispOptions[a->cur];
4599 initXisprc(p);
4600 if (p->ispPTT >= global.numPTTs)
4601 p->ispPTT = global.numPTTs-1;
4602 if (a->dflt == 0) {
4603 a->dflt = 1;
4604 fl_activate_object(fd_accountInfo->accountInfoCopy);
4605 fl_set_object_lcol(fd_accountInfo->accountInfoCopy, FL_LCOL);
4606 fl_activate_object(fd_accountInfo->accountInfoDelete);
4607 fl_set_object_lcol(fd_accountInfo->accountInfoDelete, FL_LCOL);
4608 fl_activate_object(fd_accountInfo->ISPDefault);
4609 fl_set_object_lcol(fd_accountInfo->ISPDefault, FL_WHITE);
4610 fl_activate_object(fd_accountInfo->ISPAutoDial);
4611 fl_set_object_lcol(fd_accountInfo->ISPAutoDial, FL_WHITE);
4612 fl_activate_object(fd_accountInfo->autoRedial);
4613 fl_set_object_lcol(fd_accountInfo->autoRedial, FL_WHITE);
4614 fl_activate_object(fd_accountInfo->telInput);
4615 fl_set_object_lcol(fd_accountInfo->telInput, FL_WHITE);
4616 fl_activate_object(fd_accountInfo->accInput);
4617 fl_set_object_lcol(fd_accountInfo->accInput, FL_WHITE);
4618 fl_activate_object(fd_accountInfo->pswInput);
4619 fl_set_object_lcol(fd_accountInfo->pswInput, FL_WHITE);
4620 fl_activate_object(fd_accountInfo->UNInput);
4621 fl_set_object_lcol(fd_accountInfo->UNInput, FL_WHITE);
4622 fl_activate_object(fd_accountInfo->remoteInput);
4623 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_WHITE);
4624 fl_activate_object(fd_accountInfo->authType);
4625 fl_set_object_lcol(fd_accountInfo->authType, FL_WHITE);
4626 adjustPAPCap();
4627
4628 if (!(global.logOpts & LOG_NONE) || (global.logOpts & COST_READOUT)
4629 )
4630 {
4631 fl_activate_object(fd_accountInfo->ispPttDropChoice);
4632 fl_set_object_lcol(fd_accountInfo->ispPttDropChoice,
4633 FL_WHITE);
4634 fl_activate_object(fd_accountInfo->ispZoneDropChoice);
4635 fl_set_object_lcol(fd_accountInfo->ispZoneDropChoice,
4636 FL_WHITE);
4637 for (i=0; i<global.numPTTs; i++)
4638 fl_addto_choice(fd_accountInfo->ispPttDropChoice,
4639 clipStr(ptt[i].name, FL_MEDIUM_SIZE,
4640 FL_BOLD_STYLE, 235));
4641 fl_set_choice(fd_accountInfo->ispPttDropChoice,
4642 currentPTT+1);
4643 for (i=0; i<p_ptt->num_zones; i++)
4644 fl_addto_choice(fd_accountInfo->ispZoneDropChoice,
4645 clipStr(p_ptt->zone_name[i], FL_MEDIUM_SIZE,
4646 FL_BOLD_STYLE, 235));
4647 fl_set_choice(fd_accountInfo->ispZoneDropChoice,
4648 p_ptt->current_zone+1);
4649 }
4650 else {
4651 fl_deactivate_object(fd_accountInfo->ispPttDropChoice);
4652 fl_set_object_lcol(fd_accountInfo->ispPttDropChoice,
4653 FL_INACTIVE);
4654 fl_deactivate_object(fd_accountInfo->ispZoneDropChoice);
4655 fl_set_object_lcol(fd_accountInfo->ispZoneDropChoice,
4656 FL_INACTIVE);
4657 }
4658 }
4659 strncpy(p->descr, fd_renameISP->cdata, MAXLEN_DESCR);
4660 fl_addto_browser(fd_accountInfo->ISPBrowser, p->descr);
4661 fl_select_browser_line(fd_accountInfo->ISPBrowser, a->cur);
4662 updateAccInfo(a);
4663 a->modified = 0;
4664 }
4665 fl_hide_form(fd_renameISP->renameISP);
4666 fl_activate_form(fd_accountInfo->accountInfo);
4667 return;
4668 }
4669
4670 void doISPNameEditCancel(FL_OBJECT *obj, long param)
4671 {
4672 fl_hide_form(fd_renameISP->renameISP);
4673 fl_activate_form(fd_accountInfo->accountInfo);
4674 return;
4675 }
4676
4677 void doAccountOK(FL_OBJECT *obj, long done)
4678 {
4679 accountInfo_t *a = &IFC_accountInfo;
4680
4681 if (done) {
4682 currentPTT = (unsigned)a->udata & 0x000000FF;
4683 global.costPTT = currentPTT;
4684 saveAccInfo(a);
4685 fl_hide_form(fd_optsTab->optsTab);
4686 fl_activate_object(fd_topFrame->fileMenu);
4687 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
4688 }
4689 else
4690 saveAccInfo(a);
4691 return;
4692 }
4693
4694 void doAccountCancel(FL_OBJECT *obj, long param)
4695 {
4696 if (fd_accountInfo->vdata || IFC_accountInfo.modified) {
4697 free(xispOptions);
4698 readXisprc(rcfname, &xispOptions, &global);
4699 p_xisprc = &xispOptions[currentRC];
4700 currentPTT = p_xisprc->ispPTT;
4701 global.costPTT = currentPTT;
4702 p_ptt = &ptt[currentPTT];
4703 p_ptt->current_zone = p_xisprc->ispZone;
4704 }
4705 fl_hide_form(fd_optsTab->optsTab);
4706 fl_activate_object(fd_topFrame->fileMenu);
4707 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
4708 return;
4709 }
4710
4711
4712 /*+-------------------------------------------------------------------------+
4713 | |
4714 | Utility routines for dialInfo and CBInfo |
4715 | |
4716 +-------------------------------------------------------------------------+*/
4717
4718 void lineParse(char *buf, char (*sline)[MAXLEN_SLINE+1])
4719 {
4720 int lc = 0;
4721 char *p = sline[0];
4722
4723 memset(sline, 0, MAXNUM_SLINES*(MAXLEN_SLINE+1));
4724 while (*buf != 0) {
4725 if (*buf != '\n')
4726 *p++ = *buf++;
4727 else {
4728 *p = 0; ++buf;
4729 p = sline[++lc];
4730 }
4731 }
4732 }
4733
4734 int slinePreH(FL_OBJECT *obj, int event, FL_COORD mx,
4735 FL_COORD my, int key, void *raw_event)
4736 {
4737 switch (event) {
4738 case FL_KEYBOARD:
4739 if (key == '\t') wasTab = 1;
4740 else wasTab = 0;
4741 break;
4742
4743 default: break;
4744 }
4745 return !FL_PREEMPT;
4746 }
4747
4748 int byteFilter(FL_OBJECT *obj, const char *old, const char *cur, int c)
4749 {
4750 if (c == '-')
4751 return FL_RINGBELL|FL_INVALID;
4752 return FL_VALID;
4753 }
4754
4755 /*+-------------------------------------------------------------------------+
4756 | |
4757 | Callback routines for dialInfo and CBInfo |
4758 | |
4759 +-------------------------------------------------------------------------+*/
4760
4761 void doDialInfoTip(FL_OBJECT *obj, long param)
4762 {
4763 alertMessage("Script lines hint", 1, 0,
4764 "For an example on the syntax for the \"Expect:\" and \"Send:\"\n"
4765 "parts of each script line in the \"Automatic Login:\" section,\n"
4766 "please read section \"Dialing and Login\" under \"Help->General\".\n"
4767 "For a more detailed presentation of script syntax, read the\n"
4768 "manual page for the \"chat\" command.");
4769 }
4770
4771 void doRetryInput(FL_OBJECT *obj, long param)
4772 {
4773 char ns[MAXDIG_RETRY+1] = {0};
4774 static unsigned char num;
4775
4776 strncpy(ns, (char *)fl_get_input(obj), MAXDIG_RETRY);
4777 num = atoi(ns);
4778 if (! num) {
4779 XBell(fl_get_display(), 50);
4780 num = MAXNUM_RETRY;
4781 sprintf(ns, "%d", num);
4782 fl_set_input(obj, ns);
4783 fl_redraw_object(obj);
4784 }
4785 fd_dialInfo->vdata = #
4786 return;
4787 }
4788
4789 void doDelayInput(FL_OBJECT *obj, long param)
4790 {
4791 char ns[MAXDIG_DELAY+1] = {0};
4792 static unsigned char num;
4793
4794 strncpy(ns, (char *)fl_get_input(obj), MAXDIG_DELAY);
4795 num = atoi(ns);
4796 if (! num) {
4797 XBell(fl_get_display(), 50);
4798 num = MAXSEC_DELAY;
4799 sprintf(ns, "%d", num);
4800 fl_set_input(obj, ns);
4801 fl_redraw_object(obj);
4802 }
4803 fd_dialInfo->vdata = #
4804 return;
4805 }
4806
4807 void doCNWaitInput(FL_OBJECT *obj, long param)
4808 {
4809 char ns[MAXDIG_CNWAIT+1] = {0};
4810 static unsigned char num;
4811
4812 strncpy(ns, (char *)fl_get_input(obj), MAXDIG_CNWAIT);
4813 num = atoi(ns);
4814 if (! num) {
4815 XBell(fl_get_display(), 50);
4816 num = MAXSEC_CNWAIT;
4817 sprintf(ns, "%d", num);
4818 fl_set_input(obj, ns);
4819 fl_redraw_object(obj);
4820 }
4821 if (num < MINSEC_MODEM_TO) {
4822 XBell(fl_get_display(), 50);
4823 num = MINSEC_MODEM_TO;
4824 sprintf(ns, "%d", num);
4825 fl_set_input(obj, ns);
4826 fl_redraw_object(obj);
4827 }
4828 fd_dialInfo->vdata = #
4829 return;
4830 }
4831
4832 void doLCPWaitInput(FL_OBJECT *obj, long param)
4833 {
4834 char ns[MAXDIG_LCPWAIT+1] = {0};
4835 static unsigned char num;
4836
4837 strncpy(ns, (char *)fl_get_input(obj), MAXDIG_LCPWAIT);
4838 num = atoi(ns);
4839 if (! num) {
4840 XBell(fl_get_display(), 50);
4841 num = MAXSEC_CNWAIT;
4842 sprintf(ns, "%d", num);
4843 fl_set_input(obj, ns);
4844 fl_redraw_object(obj);
4845 }
4846 if (num < MINSEC_LINK_TO) {
4847 XBell(fl_get_display(), 50);
4848 num = MINSEC_LINK_TO;
4849 sprintf(ns, "%d", num);
4850 fl_set_input(obj, ns);
4851 fl_redraw_object(obj);
4852 }
4853 fd_dialInfo->vdata = #
4854 return;
4855 }
4856
4857 void doColumnsInput(FL_OBJECT *obj, long param)
4858 {
4859 char ns[4] = {0};
4860 static unsigned char num;
4861
4862 strncpy(ns, (char *)fl_get_input(obj), 3);
4863 num = atoi(ns);
4864 if (! num || num < MINCHAR_TERMW) {
4865 XBell(fl_get_display(), 50);
4866 num = MINCHAR_TERMW;
4867 sprintf(ns, "%d", num);
4868 fl_set_input(obj, ns);
4869 fl_redraw_object(obj);
4870 }
4871 fd_dialInfo->vdata = #
4872 return;
4873 }
4874
4875 void doRowsInput(FL_OBJECT *obj, long param)
4876 {
4877 char ns[4] = {0};
4878 static unsigned char num;
4879
4880 strncpy(ns, (char *)fl_get_input(obj), 3);
4881 num = atoi(ns);
4882 if (! num || num < MINCHAR_TERMH) {
4883 XBell(fl_get_display(), 50);
4884 num = MINCHAR_TERMH;
4885 sprintf(ns, "%d", num);
4886 fl_set_input(obj, ns);
4887 fl_redraw_object(obj);
4888 }
4889 fd_dialInfo->vdata = #
4890 return;
4891 }
4892
4893 void doExpectInput(FL_OBJECT *obj, long param)
4894 {
4895 static char line[MAXNUM_SLINES][MAXLEN_SLINE+1] = {{0}};
4896
4897 lineParse((char *)fl_get_input(obj), line);
4898 fd_dialInfo->vdata = line;
4899 return;
4900 }
4901
4902 int expectFilter(FL_OBJECT *obj, const char *old, const char *cur, int c)
4903 {
4904 int x, y;
4905
4906 fl_get_input_cursorpos(obj, &x, &y);
4907 if (c) {
4908 if (x <= MAXLEN_SLINE && y <= MAXNUM_SLINES) {
4909 if (c == '\n' && fl_get_input_numberoflines(obj) > MAXNUM_SLINES)
4910 return FL_RINGBELL|FL_INVALID;
4911 else
4912 return FL_VALID;
4913 }
4914 else return FL_RINGBELL|FL_INVALID;
4915 }
4916 else if (wasTab)
4917 fl_set_focus_object(fd_dialInfo->dialInfo,
4918 fd_dialInfo->sendInput->child);
4919 return FL_VALID;
4920 }
4921
4922 void doSendInput(FL_OBJECT *obj, long param)
4923 {
4924 static char line[MAXNUM_SLINES][MAXLEN_SLINE+1] = {{0}};
4925
4926 lineParse((char *)fl_get_input(obj), line);
4927 fd_dialInfo->vdata = line;
4928 return;
4929 }
4930
4931 int sendFilter(FL_OBJECT *obj, const char *old, const char *cur, int c)
4932 {
4933 int x, y;
4934
4935 fl_get_input_cursorpos(obj, &x, &y);
4936 if (c) {
4937 if (x <= MAXLEN_SLINE && y <= MAXNUM_SLINES) {
4938 if (c == '\n' && fl_get_input_numberoflines(obj) > MAXNUM_SLINES)
4939 return FL_RINGBELL|FL_INVALID;
4940 else
4941 return FL_VALID;
4942 }
4943 else return FL_RINGBELL|FL_INVALID;
4944 }
4945 else if (wasTab)
4946 fl_set_focus_object(fd_dialInfo->dialInfo, fd_dialInfo->rtrInput);
4947 return FL_VALID;
4948 }
4949
4950 void doRBYesButton(FL_OBJECT *obj, long param)
4951 {
4952 if (fl_get_button(fd_dialInfo->RBYesButton))
4953 fd_dialInfo->ldata |= CONNECT_BELL;
4954 return;
4955 }
4956
4957 void doRBNoButton(FL_OBJECT *obj, long param)
4958 {
4959 if (fl_get_button(fd_dialInfo->RBNoButton))
4960 fd_dialInfo->ldata &= ~CONNECT_BELL;
4961 return;
4962 }
4963
4964 void doTTYesButton(FL_OBJECT *obj, long param)
4965 {
4966 if (fl_get_button(fd_dialInfo->TTYesButton)) {
4967 fd_dialInfo->ldata |= MANUAL_LOGIN;
4968 fl_activate_object(fd_dialInfo->TSGroup);
4969 fl_set_object_lcol(fd_dialInfo->TSGroup,FL_WHITE);
4970 fl_deactivate_object(fd_dialInfo->ALGroup);
4971 fl_set_object_lcol(fd_dialInfo->ALGroup,FL_INACTIVE);
4972 }
4973 return;
4974 }
4975
4976 void doTTNoButton(FL_OBJECT *obj, long param)
4977 {
4978 if (fl_get_button(fd_dialInfo->TTNoButton)) {
4979 fd_dialInfo->ldata &= ~MANUAL_LOGIN;
4980 fl_deactivate_object(fd_dialInfo->TSGroup);
4981 fl_set_object_lcol(fd_dialInfo->TSGroup,FL_INACTIVE);
4982 fl_activate_object(fd_dialInfo->ALGroup);
4983 fl_set_object_lcol(fd_dialInfo->ALGroup,FL_WHITE);
4984 }
4985 return;
4986 }
4987
4988 void doCBYesButton(FL_OBJECT *obj, long param)
4989 {
4990 if (fl_get_button(fd_dialInfo->CBYesButton)) {
4991 fd_dialInfo->ldata |= CALL_BACK;
4992 fl_activate_object(fd_dialInfo->CBOptions);
4993 fl_set_object_lcol(fd_dialInfo->CBOptions,FL_LCOL);
4994 }
4995 return;
4996 }
4997
4998 void doCBNoButton(FL_OBJECT *obj, long param)
4999 {
5000 if (fl_get_button(fd_dialInfo->CBNoButton)) {
5001 fd_dialInfo->ldata &= ~CALL_BACK;
5002 fl_deactivate_object(fd_dialInfo->CBOptions);
5003 fl_set_object_lcol(fd_dialInfo->CBOptions,FL_INACTIVE);
5004 }
5005 return;
5006 }
5007
5008 void doCBOptions(FL_OBJECT *obj, long param)
5009 {
5010 int i, ml = p_xisprc->numCBSlns;
5011 char dflt[5], input[MAXNUM_SLINES*(MAXLEN_SLINE+1)+1] = {0};
5012
5013 sprintf(dflt, "%d", p_xisprc->CBDelay);
5014 fl_set_input(fd_CBInfo->CBdlyInput, dflt);
5015 for (i=0; i<ml; i++) {
5016 strcat(input, p_xisprc->CBsln[i]);
5017 if (i < (ml-1)) strcat(input, "\n");
5018 }
5019 fl_set_input(fd_CBInfo->CBExpectInput, input);
5020 input[0] = 0;
5021 for (i=0; i<ml; i++) {
5022 strcat(input, p_xisprc->CBsln[MAXNUM_SLINES+i]);
5023 if (i < (ml-1)) strcat(input, "\n");
5024 }
5025 fl_set_input(fd_CBInfo->CBSendInput, input);
5026 wasTab = 0;
5027 if (fd_dialInfo->ldata & CHAPS_LOGIN) {
5028 fl_activate_object(fd_CBInfo->LTRASButton);
5029 fl_set_object_lcol(fd_CBInfo->LTRASButton, FL_WHITE);
5030 }
5031 else {
5032 fd_dialInfo->ldata &= ~CB_NT_RAS;
5033 fl_deactivate_object(fd_CBInfo->LTRASButton);
5034 fl_set_object_lcol(fd_CBInfo->LTRASButton, FL_INACTIVE);
5035 if (! nohints) fl_set_timer(fd_CBInfo->tipTimer, HINT_TRIGGER);
5036 }
5037 if (fd_dialInfo->ldata & CBMAN_LOGIN) {
5038 fl_set_button(fd_CBInfo->LTScriptedButton, 0);
5039 fl_set_button(fd_CBInfo->LTTerminalButton, 1);
5040 fl_set_button(fd_CBInfo->LTRASButton, 0);
5041 fl_deactivate_object(fd_CBInfo->ALGroup);
5042 fl_set_object_lcol(fd_CBInfo->ALGroup,FL_INACTIVE);
5043 fl_activate_object(fd_CBInfo->TSGroup);
5044 fl_set_object_lcol(fd_CBInfo->TSGroup,FL_WHITE);
5045 fl_deactivate_object(fd_CBInfo->CBTelInput);
5046 fl_set_object_lcol(fd_CBInfo->CBTelInput,FL_INACTIVE);
5047 }
5048 else if (fd_dialInfo->ldata & CB_NT_RAS) {
5049 fl_set_button(fd_CBInfo->LTScriptedButton, 0);
5050 fl_set_button(fd_CBInfo->LTTerminalButton, 0);
5051 fl_set_button(fd_CBInfo->LTRASButton, 1);
5052 fl_deactivate_object(fd_CBInfo->ALGroup);
5053 fl_set_object_lcol(fd_CBInfo->ALGroup,FL_INACTIVE);
5054 fl_deactivate_object(fd_CBInfo->TSGroup);
5055 fl_set_object_lcol(fd_CBInfo->TSGroup,FL_INACTIVE);
5056 fl_activate_object(fd_CBInfo->CBTelInput);
5057 fl_set_object_lcol(fd_CBInfo->CBTelInput,FL_WHITE);
5058 }
5059 else {
5060 fl_set_button(fd_CBInfo->LTScriptedButton, 1);
5061 fl_set_button(fd_CBInfo->LTTerminalButton, 0);
5062 fl_set_button(fd_CBInfo->LTRASButton, 0);
5063 fl_activate_object(fd_CBInfo->ALGroup);
5064 fl_set_object_lcol(fd_CBInfo->ALGroup,FL_WHITE);
5065 fl_deactivate_object(fd_CBInfo->TSGroup);
5066 fl_set_object_lcol(fd_CBInfo->TSGroup,FL_INACTIVE);
5067 fl_deactivate_object(fd_CBInfo->CBTelInput);
5068 fl_set_object_lcol(fd_CBInfo->CBTelInput,FL_INACTIVE);
5069 }
5070 sprintf(dflt, "%d", p_xisprc->CBtermW);
5071 fl_set_input(fd_CBInfo->columnsInput, dflt);
5072 sprintf(dflt, "%d", p_xisprc->CBtermH);
5073 fl_set_input(fd_CBInfo->rowsInput, dflt);
5074 fd_CBInfo->ldata = fd_dialInfo->ldata;
5075 fl_set_input(fd_CBInfo->CBTelInput, p_xisprc->CBphone);
5076 fl_deactivate_form(fd_dialInfo->dialInfo);
5077 fl_show_form(fd_CBInfo->CBInfo, FL_PLACE_MOUSE,
5078 FL_TRANSIENT, "Call-back Options");
5079 return;
5080 }
5081
5082 void doDialOK(FL_OBJECT *obj, long done)
5083 {
5084 char *Ep, *Sp;
5085 int i;
5086
5087 fl_call_object_callback(fd_dialInfo->rtrInput);
5088 p_xisprc->maxAttempts = *(unsigned char *)(fd_dialInfo->vdata);
5089 fl_call_object_callback(fd_dialInfo->dlyInput);
5090 p_xisprc->sleepDelay = *(unsigned char *)(fd_dialInfo->vdata);
5091 fl_call_object_callback(fd_dialInfo->CNWaitInput);
5092 p_xisprc->connectWait = *(unsigned char *)(fd_dialInfo->vdata);
5093 fl_call_object_callback(fd_dialInfo->LCPWaitInput);
5094 p_xisprc->LCPWait = *(unsigned char *)(fd_dialInfo->vdata);
5095 p_xisprc->operOpts = (unsigned)fd_dialInfo->ldata;
5096 fl_call_object_callback(fd_dialInfo->columnsInput);
5097 p_xisprc->termW = *(unsigned char *)(fd_dialInfo->vdata);
5098 fl_call_object_callback(fd_dialInfo->rowsInput);
5099 p_xisprc->termH = *(unsigned char *)(fd_dialInfo->vdata);
5100 fl_call_object_callback(fd_dialInfo->expectInput);
5101 memcpy(p_xisprc->sline, fd_dialInfo->vdata,
5102 MAXNUM_SLINES*(MAXLEN_SLINE+1));
5103 fl_call_object_callback(fd_dialInfo->sendInput);
5104 memcpy(&((p_xisprc->sline)[MAXNUM_SLINES]), fd_dialInfo->vdata,
5105 MAXNUM_SLINES*(MAXLEN_SLINE+1));
5106 for (i=0; i<MAXNUM_SLINES; i++) {
5107 Ep = p_xisprc->sline[i];
5108 Sp = p_xisprc->sline[MAXNUM_SLINES+i];
5109 if (*Ep | *Sp) p_xisprc->numSlines = i+1;
5110 }
5111 if (! (p_xisprc->operOpts & CALL_BACK))
5112 p_xisprc->numCBSlns = 0;
5113 writeXisprc(rcfname, xispOptions, &global);
5114 if (done) {
5115 fl_hide_form(fd_optsTab->optsTab);
5116 fl_activate_object(fd_topFrame->fileMenu);
5117 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
5118 }
5119 return;
5120 }
5121
5122 void doDialCancel(FL_OBJECT *obj, long param)
5123 {
5124 fl_hide_form(fd_optsTab->optsTab);
5125 fl_activate_object(fd_topFrame->fileMenu);
5126 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
5127 return;
5128 }
5129
5130 void doCBInfoTip(FL_OBJECT *obj, long param)
5131 {
5132 alertMessage("NT-RAS hint", 1, 0,
5133 "If \"NT-RAS call-back\" is grayed-out, that is because you have\n"
5134 "not chosen \"CHAP\" as your password authentication protocol.\n"
5135 "If you are setting up an account using an NT-RAS based call-\n"
5136 "back server, go back to the \"Account Information\" form and select\n"
5137 "CHAP; then come back to this form and select \"NT-RAS call-back\".");
5138 }
5139
5140 void doCBExpectInput(FL_OBJECT *obj, long param)
5141 {
5142 static char line[MAXNUM_SLINES][MAXLEN_SLINE+1] = {{0}};
5143
5144 lineParse((char *)fl_get_input(obj), line);
5145 fd_CBInfo->vdata = line;
5146 return;
5147 }
5148
5149 int CBExpectFilter(FL_OBJECT *obj, const char *old, const char *cur, int c)
5150 {
5151 int x, y;
5152
5153 fl_get_input_cursorpos(obj, &x, &y);
5154 if (c) {
5155 if (x <= MAXLEN_SLINE && y <= MAXNUM_SLINES) {
5156 if (c == '\n' && fl_get_input_numberoflines(obj) > MAXNUM_SLINES)
5157 return FL_RINGBELL|FL_INVALID;
5158 else
5159 return FL_VALID;
5160 }
5161 else return FL_RINGBELL|FL_INVALID;
5162 }
5163 else if (wasTab)
5164 fl_set_focus_object(fd_CBInfo->CBInfo,
5165 fd_CBInfo->CBSendInput->child);
5166 return FL_VALID;
5167 }
5168
5169 void doCBSendInput(FL_OBJECT *obj, long param)
5170 {
5171 static char line[MAXNUM_SLINES][MAXLEN_SLINE+1] = {{0}};
5172
5173 lineParse((char *)fl_get_input(obj), line);
5174 fd_CBInfo->vdata = line;
5175 return;
5176 }
5177
5178 int CBSendFilter(FL_OBJECT *obj, const char *old, const char *cur, int c)
5179 {
5180 int x, y;
5181
5182 fl_get_input_cursorpos(obj, &x, &y);
5183 if (c) {
5184 if (x <= MAXLEN_SLINE && y <= MAXNUM_SLINES) {
5185 if (c == '\n' && fl_get_input_numberoflines(obj) > MAXNUM_SLINES)
5186 return FL_RINGBELL|FL_INVALID;
5187 else
5188 return FL_VALID;
5189 }
5190 else return FL_RINGBELL|FL_INVALID;
5191 }
5192 else if (wasTab)
5193 fl_set_focus_object(fd_CBInfo->CBInfo, fd_CBInfo->CBdlyInput);
5194 return FL_VALID;
5195 }
5196
5197 void doCBDelayInput(FL_OBJECT *obj, long param)
5198 {
5199 char ns[MAXDIG_CBDELAY] = {0};
5200 static unsigned char num;
5201
5202 strncpy(ns, (char *)fl_get_input(obj), MAXDIG_CBDELAY);
5203 num = atoi(ns);
5204 if (! num) {
5205 XBell(fl_get_display(), 50);
5206 num = MAXSEC_CBDELAY;
5207 sprintf(ns, "%d", num);
5208 fl_set_input(obj, ns);
5209 fl_redraw_object(obj);
5210 }
5211 fd_CBInfo->vdata = #
5212 return;
5213 }
5214
5215 void doLTScriptedButton(FL_OBJECT *obj, long param)
5216 {
5217 if (fl_get_button(fd_CBInfo->LTScriptedButton)) {
5218 fd_CBInfo->ldata &= ~CBMAN_LOGIN;
5219 fd_CBInfo->ldata &= ~CB_NT_RAS;
5220 fl_deactivate_object(fd_CBInfo->TSGroup);
5221 fl_set_object_lcol(fd_CBInfo->TSGroup,FL_INACTIVE);
5222 fl_deactivate_object(fd_CBInfo->CBTelInput);
5223 fl_set_object_lcol(fd_CBInfo->CBTelInput,FL_INACTIVE);
5224 fl_activate_object(fd_CBInfo->ALGroup);
5225 fl_set_object_lcol(fd_CBInfo->ALGroup,FL_WHITE);
5226 }
5227 }
5228
5229 void doLTTerminalButton(FL_OBJECT *obj, long param)
5230 {
5231 if (fl_get_button(fd_CBInfo->LTTerminalButton)) {
5232 fd_CBInfo->ldata |= CBMAN_LOGIN;
5233 fd_CBInfo->ldata &= ~CB_NT_RAS;
5234 fl_activate_object(fd_CBInfo->TSGroup);
5235 fl_set_object_lcol(fd_CBInfo->TSGroup,FL_WHITE);
5236 fl_deactivate_object(fd_CBInfo->CBTelInput);
5237 fl_set_object_lcol(fd_CBInfo->CBTelInput,FL_INACTIVE);
5238 fl_deactivate_object(fd_CBInfo->ALGroup);
5239 fl_set_object_lcol(fd_CBInfo->ALGroup,FL_INACTIVE);
5240 }
5241 }
5242
5243 void doLTRASButton(FL_OBJECT *obj, long param)
5244 {
5245 if (fl_get_button(fd_CBInfo->LTRASButton)) {
5246 fd_CBInfo->ldata &= ~CBMAN_LOGIN;
5247 fd_CBInfo->ldata |= CB_NT_RAS;
5248 fl_deactivate_object(fd_CBInfo->TSGroup);
5249 fl_set_object_lcol(fd_CBInfo->TSGroup,FL_INACTIVE);
5250 fl_activate_object(fd_CBInfo->CBTelInput);
5251 fl_set_object_lcol(fd_CBInfo->CBTelInput,FL_WHITE);
5252 fl_deactivate_object(fd_CBInfo->ALGroup);
5253 fl_set_object_lcol(fd_CBInfo->ALGroup,FL_INACTIVE);
5254
5255 if (! nohints) alertMessage("NT-RAS setup hint", 1, 0,
5256 "In order for NT-RAS call-back to work you need:\n"
5257 "\n"
5258 "1. To have a patched version of pppd which includes\n"
5259 " support for NT-RAS call-back. Patches exist for\n"
5260 " relatively old (e.g. 2.2.0f), as well as for recent (e.g.\n"
5261 " 2.3.8) versions of pppd. The xisp source distribution\n"
5262 " includes a patch for pppd-2.2.0f; the patch for version\n"
5263 " 2.3.x is included in the official pppd source distribution.\n"
5264 "\n"
5265 "2. To configure the NT server to perform call-back auto-\n"
5266 " matically as opposed to \"asking\" whether or not the caller\n"
5267 " desires call-back.");
5268 }
5269 }
5270
5271 void doCBTelInput(FL_OBJECT *obj, long param)
5272 {
5273 static char phone[MAXLEN_PHONE+1] = {0};
5274
5275 strncpy(phone, (char *)fl_get_input(obj), MAXLEN_PHONE);
5276 fd_CBInfo->cdata = phone;
5277 return;
5278 }
5279
5280 void doCBColumnsInput(FL_OBJECT *obj, long param)
5281 {
5282 char ns[4] = {0};
5283 static unsigned char num;
5284
5285 strncpy(ns, (char *)fl_get_input(obj), 3);
5286 num = atoi(ns);
5287 if (! num || num < MINCHAR_TERMW) {
5288 XBell(fl_get_display(), 50);
5289 num = MINCHAR_TERMW;
5290 sprintf(ns, "%d", num);
5291 fl_set_input(obj, ns);
5292 fl_redraw_object(obj);
5293 }
5294 fd_CBInfo->vdata = #
5295 return;
5296 }
5297
5298 void doCBRowsInput(FL_OBJECT *obj, long param)
5299 {
5300 char ns[4] = {0};
5301 static unsigned char num;
5302
5303 strncpy(ns, (char *)fl_get_input(obj), 3);
5304 num = atoi(ns);
5305 if (! num || num < MINCHAR_TERMH) {
5306 XBell(fl_get_display(), 50);
5307 num = MINCHAR_TERMH;
5308 sprintf(ns, "%d", num);
5309 fl_set_input(obj, ns);
5310 fl_redraw_object(obj);
5311 }
5312 fd_CBInfo->vdata = #
5313 return;
5314 }
5315
5316 void doCBInfoOK(FL_OBJECT *obj, long param)
5317 {
5318 char *Ep, *Sp;
5319 int i;
5320
5321 fl_call_object_callback(fd_CBInfo->CBdlyInput);
5322 p_xisprc->CBDelay = *(unsigned char *)(fd_CBInfo->vdata);
5323 fl_call_object_callback(fd_CBInfo->CBExpectInput);
5324 memcpy(p_xisprc->CBsln, fd_CBInfo->vdata, MAXNUM_SLINES*(MAXLEN_SLINE+1));
5325 fl_call_object_callback(fd_CBInfo->CBSendInput);
5326 memcpy(&((p_xisprc->CBsln)[MAXNUM_SLINES]), fd_CBInfo->vdata,
5327 MAXNUM_SLINES*(MAXLEN_SLINE+1));
5328 for (i=0; i<MAXNUM_SLINES; i++) {
5329 Ep = p_xisprc->CBsln[i];
5330 Sp = p_xisprc->CBsln[MAXNUM_SLINES+i];
5331 if (*Ep | *Sp) p_xisprc->numCBSlns = i+1;
5332 }
5333 fd_dialInfo->ldata = fd_CBInfo->ldata;
5334 fl_call_object_callback(fd_CBInfo->columnsInput);
5335 p_xisprc->CBtermW = *(unsigned char *)(fd_CBInfo->vdata);
5336 fl_call_object_callback(fd_CBInfo->rowsInput);
5337 p_xisprc->CBtermH = *(unsigned char *)(fd_CBInfo->vdata);
5338 fl_call_object_callback(fd_CBInfo->CBTelInput);
5339 strncpy(p_xisprc->CBphone, fd_CBInfo->cdata, MAXLEN_PHONE);
5340 writeXisprc(rcfname, xispOptions, &global);
5341 fl_hide_form(fd_CBInfo->CBInfo);
5342 fl_activate_form(fd_dialInfo->dialInfo);
5343 return;
5344 }
5345
5346 void doCBInfoCancel(FL_OBJECT *obj, long param)
5347 {
5348 fl_hide_form(fd_CBInfo->CBInfo);
5349 fl_activate_form(fd_dialInfo->dialInfo);
5350 return;
5351 }
5352
5353
5354 /*+-------------------------------------------------------------------------+
5355 | |
5356 | Callback routines for aboutInfo and helpInfo |
5357 | |
5358 +-------------------------------------------------------------------------+*/
5359
5360 void doAboutOK(FL_OBJECT *obj, long param)
5361 {
5362 fl_hide_form(fd_aboutInfo->aboutInfo);
5363 return;
5364 }
5365
5366 void doHelpInfoOK(FL_OBJECT *obj, long param)
5367 {
5368 fl_hide_form(fd_helpInfo->helpInfo);
5369 return;
5370 }
5371
5372
5373 /*+-------------------------------------------------------------------------+
5374 | |
5375 | Callback routines for commInfo |
5376 | |
5377 +-------------------------------------------------------------------------+*/
5378
5379 void doCommInfoTip(FL_OBJECT *obj, long param)
5380 {
5381 alertMessage("Modem hints", 1, 0,
5382 "It is very important to properly specify your modem device. E.g.\n"
5383 "on i86 PC's, if your modem is on COM1, under Linux, your device\n"
5384 "would be /dev/ttyS0; if it's on COM2, use /dev/ttyS1 and so on.\n"
5385 "On other supported operating systems, please consult with your\n"
5386 "system's manual pages.\n"
5387 "\n"
5388 "Note that in order for xisp to work properly, the modem must be\n"
5389 "configured for verbose result strings (as opposed to numeric result\n"
5390 "codes). For most modems this is the default; if that is not the case\n"
5391 "for the one you are using, consult with the user's manual for the\n"
5392 "appropriate command. For example, most USR modems return\n"
5393 "verbose result strings when you include \"V1\" in the \"Init\" string.\n"
5394 "In such case, the complete \"Init\" string would be \"AT V1\".\n"
5395 "\n"
5396 "It is possible to enter command strings beginning with '\\' in the\n"
5397 "\"Reset:\" and/or the \"Init:\" input fields. Note, however, that in order\n"
5398 "to escape them from chat, you need to prepend an extra '\\'. For\n"
5399 "example, the initialization string \"AT \\N2\" needs to be entered as\n"
5400 "\"AT \\\\N2\".\n"
5401 "\n"
5402 "Choosing \"ISDN\" as \"Dialing method\" sets the dialing command\n"
5403 "to \"DI\", i.e. the complete dialing prefix will be \"ATDI\". \"Tone\"\n"
5404 "corresponds to prefix \"ATDT\" and \"Pulse\" to \"ATDP\". If you need\n"
5405 "to enter extra option characters between \"AT\" and e.g. \"DT\", use\n"
5406 "the \"Dialing extras\" input field.");
5407 }
5408
5409 void doModemInitInput(FL_OBJECT *obj, long param)
5410 {
5411 static char init[MAXLEN_MDMCMD+1] = {0};
5412
5413 strncpy(init, (char *)fl_get_input(obj), MAXLEN_MDMCMD);
5414 if (! strlen(init)) {
5415 XBell(fl_get_display(), 50);
5416 strcpy(init, MODEM_INIT);
5417 fl_set_input(obj, init);
5418 fl_redraw_object(obj);
5419 }
5420 fd_commInfo->cdata = init;
5421 return;
5422 }
5423
5424 void doModemResetInput(FL_OBJECT *obj, long param)
5425 {
5426 static char reset[MAXLEN_MDMCMD+1] = {0};
5427
5428 strncpy(reset, (char *)fl_get_input(obj), MAXLEN_MDMCMD);
5429 if (! strlen(reset)) {
5430 XBell(fl_get_display(), 50);
5431 strcpy(reset, MODEM_RESET);
5432 fl_set_input(obj, reset);
5433 fl_redraw_object(obj);
5434 }
5435 fd_commInfo->cdata = reset;
5436 return;
5437 }
5438
5439 void doModemConnectInput(FL_OBJECT *obj, long param)
5440 {
5441 static char connect[MAXLEN_MDMSTR+1] = {0};
5442
5443 strncpy(connect, (char *)fl_get_input(obj), MAXLEN_MDMSTR);
5444 if (! strlen(connect)) {
5445 XBell(fl_get_display(), 50);
5446 strcpy(connect, MODEM_CONNECT);
5447 fl_set_input(obj, connect);
5448 fl_redraw_object(obj);
5449 }
5450 fd_commInfo->cdata = connect;
5451 return;
5452 }
5453
5454 void doToneButton(FL_OBJECT *obj, long param)
5455 {
5456 commInfo_t *c = &IFC_commInfo;
5457
5458 if (fl_get_button(fd_commInfo->toneButton)) {
5459 c->operOpts |= MODEM_TONEDIAL;
5460 c->operOpts &= ~MODEM_ISDNDIAL;
5461 }
5462 return;
5463 }
5464
5465 void doPulseButton(FL_OBJECT *obj, long param)
5466 {
5467 commInfo_t *c = &IFC_commInfo;
5468
5469 if (fl_get_button(fd_commInfo->pulseButton)) {
5470 c->operOpts &= ~MODEM_TONEDIAL;
5471 c->operOpts &= ~MODEM_ISDNDIAL;
5472 }
5473 return;
5474 }
5475
5476 void doISDNButton(FL_OBJECT *obj, long param)
5477 {
5478 commInfo_t *c = &IFC_commInfo;
5479
5480 if (fl_get_button(fd_commInfo->ISDNButton)) {
5481 c->operOpts &= ~MODEM_TONEDIAL;
5482 c->operOpts |= MODEM_ISDNDIAL;
5483 }
5484 return;
5485 }
5486
5487 void doModemDialInput(FL_OBJECT *obj, long param)
5488 {
5489 static char extra[MAXLEN_DIALEXTRA+1] = {0};
5490
5491 strncpy(extra, (char *)fl_get_input(obj), MAXLEN_DIALEXTRA);
5492 if (! strlen(extra)) {
5493 strcpy(extra, DIAL_EXTRA);
5494 fl_set_input(obj, extra);
5495 fl_redraw_object(obj);
5496 }
5497 fd_commInfo->cdata = extra;
5498 return;
5499 }
5500
5501 void doSWCBSDButton(FL_OBJECT *obj, long param)
5502 {
5503 commInfo_t *c = &IFC_commInfo;
5504
5505 if (fl_get_button(fd_commInfo->SWCBSDButton)) {
5506 c->operOpts |= BSD_COMPRESS;
5507 c->operOpts &= ~DEFL_COMPRESS;
5508 fl_activate_object(fd_commInfo->SWCInput);
5509 fl_set_object_lcol(fd_commInfo->SWCInput,FL_WHITE);
5510 }
5511 return;
5512 }
5513
5514 void doSWCDeflateButton(FL_OBJECT *obj, long param)
5515 {
5516 commInfo_t *c = &IFC_commInfo;
5517
5518 if (fl_get_button(fd_commInfo->SWCDeflateButton)) {
5519 c->operOpts |= DEFL_COMPRESS;
5520 c->operOpts &= ~BSD_COMPRESS;
5521 fl_activate_object(fd_commInfo->SWCInput);
5522 fl_set_object_lcol(fd_commInfo->SWCInput,FL_WHITE);
5523 }
5524 return;
5525 }
5526
5527 void doSWCOffButton(FL_OBJECT *obj, long param)
5528 {
5529 commInfo_t *c = &IFC_commInfo;
5530
5531 if (fl_get_button(fd_commInfo->SWCOffButton)) {
5532 c->operOpts &= ~BSD_COMPRESS;
5533 c->operOpts &= ~DEFL_COMPRESS;
5534 fl_deactivate_object(fd_commInfo->SWCInput);
5535 fl_set_object_lcol(fd_commInfo->SWCInput,FL_INACTIVE);
5536 }
5537 return;
5538 }
5539
5540 void doSWCInput(FL_OBJECT *obj, long param)
5541 {
5542 char level[MAXDIG_BSDCOMP+1] = {0};
5543 static unsigned char num = COMP_LEVEL;
5544 commInfo_t *c = &IFC_commInfo;
5545
5546 strncpy(level, (char *)fl_get_input(obj), MAXDIG_BSDCOMP);
5547 num = atoi(level);
5548 if ((c->operOpts & (BSD_COMPRESS|DEFL_COMPRESS)) &&
5549 (num < MIN_COMPLEVEL || num > MAX_COMPLEVEL)) {
5550 XBell(fl_get_display(), 50);
5551 num = COMP_LEVEL;
5552 sprintf(level, "%d", num);
5553 fl_set_input(obj, level);
5554 fl_redraw_object(obj);
5555 }
5556 fd_commInfo->vdata = #
5557 return;
5558 }
5559
5560 int SWCInputFilter(FL_OBJECT *obj, const char *old, const char *cur, int c)
5561 {
5562 int test;
5563
5564 test = atoi(cur);
5565 if (c == '-' || test > 15)
5566 return FL_INVALID|FL_RINGBELL;
5567 else
5568 return FL_VALID;
5569 }
5570
5571 void doDeviceInput(FL_OBJECT *obj, long param)
5572 {
5573 static char device[MAXLEN_DEVICE+1] = {0};
5574
5575 strncpy(device, (char *)fl_get_input(obj), MAXLEN_DEVICE);
5576 if (! strlen(device)) {
5577 XBell(fl_get_display(), 50);
5578 strcpy(device, MODEM_DEVICE);
5579 fl_set_input(obj, device);
5580 fl_redraw_object(obj);
5581 }
5582 fd_commInfo->cdata = device;
5583 return;
5584 }
5585
5586 void updateKnownSpeed(commInfo_t *c, unsigned int speed)
5587 {
5588 char speed_string[MAXDIG_BAUDRATE+1] = {0};
5589
5590 c->speed = speed;
5591 if (c->custom) {
5592 c->custom = 0;
5593 fl_deactivate_object(fd_commInfo->customSpeedInput);
5594 }
5595 sprintf(speed_string, "%u", c->speed);
5596 fl_set_input(fd_commInfo->customSpeedInput, speed_string);
5597 }
5598
5599 void doSpeedButton(FL_OBJECT *obj, long param)
5600 {
5601 commInfo_t *c = &IFC_commInfo;
5602
5603 switch (param) {
5604 case 0: updateKnownSpeed(c, 1200); break;
5605 case 1: updateKnownSpeed(c, 2400); break;
5606 case 2: updateKnownSpeed(c, 4800); break;
5607 case 3: updateKnownSpeed(c, 9600); break;
5608 case 4: updateKnownSpeed(c, 19200); break;
5609 case 5: updateKnownSpeed(c, 38400); break;
5610 case 6: updateKnownSpeed(c, 57600); break;
5611 case 7: updateKnownSpeed(c, 115200); break;
5612
5613 case 8:
5614 c->custom = 1;
5615 fl_activate_object(fd_commInfo->customSpeedInput);
5616 break;
5617
5618 default: break;
5619 }
5620 return;
5621 }
5622
5623 void doCustomSpeedInput(FL_OBJECT *obj, long param)
5624 {
5625 char speed_string[MAXDIG_BAUDRATE+1] = {0};
5626 commInfo_t *c = &IFC_commInfo;
5627
5628 strncpy(speed_string, (char *)fl_get_input(obj), MAXDIG_BAUDRATE);
5629 c->speed = atoi(speed_string);
5630 if (c->custom && (c->speed<MIN_BAUDRATE || c->speed>MAX_BAUDRATE)) {
5631 XBell(fl_get_display(), 50);
5632 c->speed = MODEM_SPEED;
5633 sprintf(speed_string, "%u", c->speed);
5634 fl_set_input(obj, speed_string);
5635 fl_redraw_object(obj);
5636 }
5637 return;
5638 }
5639
5640 void doAsyncmapInput(FL_OBJECT *obj, long param)
5641 {
5642 static char asyncmap[MAXDIG_ASYNCMAP+1] = {0};
5643
5644 strncpy(asyncmap, (char *)fl_get_input(obj), MAXDIG_ASYNCMAP);
5645 if (! strlen(asyncmap)) {
5646 if (p_xisprc->operOpts & HW_FLOWCTRL)
5647 strcpy(asyncmap, PPPD_HASYNCMAP);
5648 else
5649 strcpy(asyncmap, PPPD_SASYNCMAP);
5650 fl_set_input(obj, asyncmap);
5651 fl_redraw_object(obj);
5652 }
5653 fd_commInfo->cdata = asyncmap;
5654 return;
5655 }
5656
5657 int AMInputFilter(FL_OBJECT *obj, const char *old, const char *cur, int c)
5658 {
5659 if (strcmp(old, cur)) {
5660 if (!((c>='0' && c<='9') || (c>='A' && c<='F')))
5661 return FL_INVALID|FL_RINGBELL;
5662 }
5663 return FL_VALID;
5664 }
5665
5666 void doEscapeYesButton(FL_OBJECT *obj, long param)
5667 {
5668 commInfo_t *c = &IFC_commInfo;
5669
5670 if (fl_get_button(fd_commInfo->escapeYesButton)) {
5671 c->operOpts |= ESCAPE_ON;
5672 fl_activate_object(fd_commInfo->escapeInput);
5673 fl_set_object_lcol(fd_commInfo->escapeInput,FL_WHITE);
5674 }
5675 return;
5676 }
5677
5678 void doEscapeNoButton(FL_OBJECT *obj, long param)
5679 {
5680 commInfo_t *c = &IFC_commInfo;
5681
5682 if (fl_get_button(fd_commInfo->escapeNoButton)) {
5683 c->operOpts &= ~ESCAPE_ON;
5684 fl_deactivate_object(fd_commInfo->escapeInput);
5685 fl_set_object_lcol(fd_commInfo->escapeInput,FL_INACTIVE);
5686 }
5687 return;
5688 }
5689
5690 void doEscapeInput(FL_OBJECT *obj, long param)
5691 {
5692 static char escape[MAXLEN_ESCAPE+1] = {0};
5693
5694 strncpy(escape, (char *)fl_get_input(obj), MAXLEN_ESCAPE);
5695 if (! strlen(escape)) {
5696 XBell(fl_get_display(), 50);
5697 strcpy(escape, PPPD_ESCAPE);
5698 fl_set_input(obj, escape);
5699 fl_redraw_object(obj);
5700 }
5701 fd_commInfo->cdata = escape;
5702 return;
5703 }
5704
5705 int EInputFilter(FL_OBJECT *obj, const char *old, const char *cur, int c)
5706 {
5707 if (strcmp(old, cur)) {
5708 if (!((c>='0' && c<='9') || (c>='A' && c<='F') || c==','))
5709 return FL_INVALID|FL_RINGBELL;
5710 }
5711 return FL_VALID;
5712 }
5713
5714 void doHWButton(FL_OBJECT *obj, long param)
5715 {
5716 static char asyncmap[MAXDIG_ASYNCMAP+1] = {0};
5717 commInfo_t *c = &IFC_commInfo;
5718
5719 if (fl_get_button(fd_commInfo->HWButton)) {
5720 c->operOpts |= HW_FLOWCTRL;
5721 strcpy(asyncmap, PPPD_HASYNCMAP);
5722 fl_set_input(fd_commInfo->asyncmapInput, asyncmap);
5723 fl_redraw_object(obj);
5724 }
5725 return;
5726 }
5727
5728 void doSWButton(FL_OBJECT *obj, long param)
5729 {
5730 static char asyncmap[MAXDIG_ASYNCMAP+1] = {0};
5731 commInfo_t *c = &IFC_commInfo;
5732
5733 if (fl_get_button(fd_commInfo->SWButton)) {
5734 c->operOpts &= ~HW_FLOWCTRL;
5735 strcpy(asyncmap, PPPD_SASYNCMAP);
5736 fl_set_input(fd_commInfo->asyncmapInput, asyncmap);
5737 fl_redraw_object(obj);
5738 }
5739 return;
5740 }
5741
5742 void doCommInfoOK(FL_OBJECT *obj, long done)
5743 {
5744 char msg[512] = {0}, *p;
5745 commInfo_t *c = &IFC_commInfo;
5746
5747 fl_call_object_callback(fd_commInfo->deviceInput);
5748 if ((p = strrchr(fd_commInfo->cdata, '/')) == NULL)
5749 p = fd_commInfo->cdata;
5750 else
5751 ++p;
5752 if (!nohints && (pppdVersion().major > 2 || pppdVersion().minor > 2)) {
5753 sprintf(msg, "Please make sure that a peer information\n"
5754 "file named xisp_%s exists in pppd's peers\n"
5755 "directory (most probably /etc/ppp/peers --\n"
5756 "read the pppd(8) manual page for details),\n"
5757 "and that it contains the following lines:\n\n"
5758 " /dev/%s\n"
5759 " noauth\n"
5760 " call xisp_dialer", p, p);
5761 alertMessage("Setup hint", 1, 0, msg);
5762 }
5763 strcpy(p_xisprc->modemDevice, fd_commInfo->cdata);
5764 fl_call_object_callback(fd_commInfo->customSpeedInput);
5765 p_xisprc->modemSpeed = c->speed;
5766 fl_call_object_callback(fd_commInfo->modemInitInput);
5767 strcpy(p_xisprc->modemInit, fd_commInfo->cdata);
5768 fl_call_object_callback(fd_commInfo->modemResetInput);
5769 strcpy(p_xisprc->modemReset, fd_commInfo->cdata);
5770 fl_call_object_callback(fd_commInfo->modemConnectInput);
5771 strcpy(p_xisprc->modemConnect, fd_commInfo->cdata);
5772 p_xisprc->operOpts = c->operOpts;
5773 fl_call_object_callback(fd_commInfo->modemDialInput);
5774 strcpy(p_xisprc->dialExtra, fd_commInfo->cdata);
5775 fl_call_object_callback(fd_commInfo->SWCInput);
5776 p_xisprc->compLevel = *(unsigned char *)(fd_commInfo->vdata);
5777 fl_call_object_callback(fd_commInfo->asyncmapInput);
5778 strcpy(p_xisprc->asyncmap, fd_commInfo->cdata);
5779 fl_call_object_callback(fd_commInfo->escapeInput);
5780 strcpy(p_xisprc->escape, fd_commInfo->cdata);
5781 writeXisprc(rcfname, xispOptions, &global);
5782 if (done) {
5783 fl_hide_form(fd_optsTab->optsTab);
5784 fl_activate_object(fd_topFrame->fileMenu);
5785 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
5786 }
5787 return;
5788 }
5789
5790 void doCommInfoCancel(FL_OBJECT *obj, long param)
5791 {
5792 fl_hide_form(fd_optsTab->optsTab);
5793 fl_activate_object(fd_topFrame->fileMenu);
5794 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
5795 return;
5796 }
5797
5798
5799 /*+-------------------------------------------------------------------------+
5800 | |
5801 | Callback routines for tcpipInfo |
5802 | |
5803 +-------------------------------------------------------------------------+*/
5804
5805 void doTcpipInfoTip(FL_OBJECT *obj, long param)
5806 {
5807 alertMessage("TCP/IP setup hints", 1, 0,
5808 "The default settings under \"Addressing/Routing\" should be\n"
5809 "adequate for the majority of cases. The same comment holds\n"
5810 "for \"Netmask\" and the \"MTU/MRU\" values; however in rare cases\n"
5811 "your ISP might require \"MTU/MRU\" values other than the default.\n"
5812 "\n"
5813 "For the DNS support to work, the ip-up and ip-down scripts\n"
5814 "distributed with xisp must have been installed properly on your\n"
5815 "system. If that is indeed the case, the DNS server(s) you enter\n"
5816 "here will be automatically available whenever you connect to\n"
5817 "the net using the ISP account they are defined for. If the auto-\n"
5818 "matic (ISP assigned) DNS server(s) capability is greyed out,\n"
5819 "this means that your pppd version is older than 2.3.9; to make\n"
5820 "use of this feature you must upgrade pppd.");
5821 }
5822
5823 void doLocalIPInput(FL_OBJECT *obj, long param)
5824 {
5825 static unsigned char ip[4] = LOCAL_IP, ips[MAXLEN_IP+1];
5826
5827 strncpy(ips, (char *)fl_get_input(obj), MAXLEN_IP);
5828 if (StrToIP(ips, ip) != 4) {
5829 XBell(fl_get_display(), 50);
5830 memcpy(ip, LOCAL_IP, 4);
5831 fl_set_input(obj, LOCAL_IPSTR);
5832 fl_redraw_object(obj);
5833 }
5834 fd_tcpipInfo->vdata = ip;
5835 return;
5836 }
5837
5838 void doALYesButton(FL_OBJECT *obj, long param)
5839 {
5840 if (fl_get_button(fd_tcpipInfo->ALYesButton)) {
5841 fd_tcpipInfo->ldata |= ACCEPT_LOCALIP;
5842 fl_deactivate_object(fd_tcpipInfo->localIPInput);
5843 fl_set_object_lcol(fd_tcpipInfo->localIPInput,FL_INACTIVE);
5844 }
5845 return;
5846 }
5847
5848 void doALNoButton(FL_OBJECT *obj, long param)
5849 {
5850 if (fl_get_button(fd_tcpipInfo->ALNoButton)) {
5851 fd_tcpipInfo->ldata &= ~ACCEPT_LOCALIP;
5852 fl_activate_object(fd_tcpipInfo->localIPInput);
5853 fl_set_object_lcol(fd_tcpipInfo->localIPInput,FL_WHITE);
5854 }
5855 return;
5856 }
5857
5858 void doRemoteIPInput(FL_OBJECT *obj, long param)
5859 {
5860 static unsigned char ip[4] = REMOTE_IP, ips[MAXLEN_IP+1];
5861
5862 strncpy(ips, (char *)fl_get_input(obj), MAXLEN_IP);
5863 if (StrToIP(ips, ip) != 4) {
5864 XBell(fl_get_display(), 50);
5865 memcpy(ip, REMOTE_IP, 4);
5866 fl_set_input(obj, REMOTE_IPSTR);
5867 fl_redraw_object(obj);
5868 }
5869 fd_tcpipInfo->vdata = ip;
5870 return;
5871 }
5872
5873 void doARYesButton(FL_OBJECT *obj, long param)
5874 {
5875 if (fl_get_button(fd_tcpipInfo->ARYesButton)) {
5876 fd_tcpipInfo->ldata |= ACCEPT_REMOTEIP;
5877 fl_deactivate_object(fd_tcpipInfo->remoteIPInput);
5878 fl_set_object_lcol(fd_tcpipInfo->remoteIPInput,FL_INACTIVE);
5879 }
5880 return;
5881 }
5882
5883 void doARNoButton(FL_OBJECT *obj, long param)
5884 {
5885 if (fl_get_button(fd_tcpipInfo->ARNoButton)) {
5886 fd_tcpipInfo->ldata &= ~ACCEPT_REMOTEIP;
5887 fl_activate_object(fd_tcpipInfo->remoteIPInput);
5888 fl_set_object_lcol(fd_tcpipInfo->remoteIPInput,FL_WHITE);
5889 }
5890 return;
5891 }
5892
5893 void doNMInput(FL_OBJECT *obj, long param)
5894 {
5895 static unsigned char ip[4] = NETMASK, ips[MAXLEN_IP+1];
5896
5897 strncpy(ips, (char *)fl_get_input(obj), MAXLEN_IP);
5898 if (StrToIP(ips, ip) != 4) {
5899 XBell(fl_get_display(), 50);
5900 memcpy(ip, NETMASK, 4);
5901 fl_set_input(obj, NETMASKSTR);
5902 fl_redraw_object(obj);
5903 }
5904 fd_tcpipInfo->vdata = ip;
5905 return;
5906 }
5907
5908 void doPDNSInput(FL_OBJECT *obj, long param)
5909 {
5910 static unsigned char ip[4] = DNS, ips[MAXLEN_IP+1];
5911
5912 strncpy(ips, (char *)fl_get_input(obj), MAXLEN_IP);
5913 if (StrToIP(ips, ip) != 4) {
5914 XBell(fl_get_display(), 50);
5915 memcpy(ip, DNS, 4);
5916 fl_set_input(obj, DNS_IPSTR);
5917 fl_redraw_object(obj);
5918 }
5919 fd_tcpipInfo->vdata = ip;
5920 return;
5921 }
5922
5923 void doSDNSInput(FL_OBJECT *obj, long param)
5924 {
5925 static unsigned char ip[4] = DNS, ips[MAXLEN_IP+1];
5926
5927 strncpy(ips, (char *)fl_get_input(obj), MAXLEN_IP);
5928 if (StrToIP(ips, ip) != 4) {
5929 XBell(fl_get_display(), 50);
5930 memcpy(ip, DNS, 4);
5931 fl_set_input(obj, DNS_IPSTR);
5932 fl_redraw_object(obj);
5933 }
5934 fd_tcpipInfo->vdata = ip;
5935 return;
5936 }
5937
5938 void doDRYesButton(FL_OBJECT *obj, long param)
5939 {
5940 if (fl_get_button(fd_tcpipInfo->DRYesButton))
5941 fd_tcpipInfo->ldata |= DEFAULT_ROUTE;
5942 return;
5943 }
5944
5945 void doDRNoButton(FL_OBJECT *obj, long param)
5946 {
5947 if (fl_get_button(fd_tcpipInfo->DRNoButton))
5948 fd_tcpipInfo->ldata &= ~DEFAULT_ROUTE;
5949 return;
5950 }
5951
5952 void doDNSNoButton(FL_OBJECT *obj, long param)
5953 {
5954 if (fl_get_button(fd_tcpipInfo->DNSNoButton)) {
5955 fd_tcpipInfo->ldata &= ~(IP_UPDOWN | AUTO_DNS);
5956 fl_deactivate_object(fd_tcpipInfo->pDNSInput);
5957 fl_set_object_lcol(fd_tcpipInfo->pDNSInput,FL_INACTIVE);
5958 fl_deactivate_object(fd_tcpipInfo->sDNSInput);
5959 fl_set_object_lcol(fd_tcpipInfo->sDNSInput,FL_INACTIVE);
5960 fl_deactivate_object(fd_tcpipInfo->DNTypeGroup);
5961 fl_set_object_lcol(fd_tcpipInfo->DNTypeGroup,FL_INACTIVE);
5962 }
5963 return;
5964 }
5965
5966 void doDNSAutoButton(FL_OBJECT *obj, long param)
5967 {
5968 if (fl_get_button(fd_tcpipInfo->DNSAutoButton)) {
5969 fd_tcpipInfo->ldata |= (IP_UPDOWN | AUTO_DNS);
5970 fl_deactivate_object(fd_tcpipInfo->pDNSInput);
5971 fl_set_object_lcol(fd_tcpipInfo->pDNSInput,FL_INACTIVE);
5972 fl_deactivate_object(fd_tcpipInfo->sDNSInput);
5973 fl_set_object_lcol(fd_tcpipInfo->sDNSInput,FL_INACTIVE);
5974 fl_activate_object(fd_tcpipInfo->DNTypeGroup);
5975 fl_set_object_lcol(fd_tcpipInfo->DNTypeGroup,FL_WHITE);
5976 }
5977 return;
5978 }
5979
5980 void doDNSManualButton(FL_OBJECT *obj, long param)
5981 {
5982 if (fl_get_button(fd_tcpipInfo->DNSManualButton)) {
5983 fd_tcpipInfo->ldata |= IP_UPDOWN;
5984 fd_tcpipInfo->ldata &= ~AUTO_DNS;
5985 fl_activate_object(fd_tcpipInfo->pDNSInput);
5986 fl_set_object_lcol(fd_tcpipInfo->pDNSInput,FL_WHITE);
5987 fl_activate_object(fd_tcpipInfo->sDNSInput);
5988 fl_set_object_lcol(fd_tcpipInfo->sDNSInput,FL_WHITE);
5989 fl_activate_object(fd_tcpipInfo->DNTypeGroup);
5990 fl_set_object_lcol(fd_tcpipInfo->DNTypeGroup,FL_WHITE);
5991 }
5992 return;
5993 }
5994
5995 void doDNYesButton(FL_OBJECT *obj, long param)
5996 {
5997 if (fl_get_button(fd_tcpipInfo->DNYesButton)) {
5998 fd_tcpipInfo->ldata |= DEFAULT_DOMAIN;
5999 fl_activate_object(fd_tcpipInfo->domainInput);
6000 fl_set_object_lcol(fd_tcpipInfo->domainInput,FL_WHITE);
6001 }
6002 return;
6003 }
6004
6005 void doDNNoButton(FL_OBJECT *obj, long param)
6006 {
6007 if (fl_get_button(fd_tcpipInfo->DNNoButton)) {
6008 fd_tcpipInfo->ldata &= ~DEFAULT_DOMAIN;
6009 fl_deactivate_object(fd_tcpipInfo->domainInput);
6010 fl_set_object_lcol(fd_tcpipInfo->domainInput,FL_INACTIVE);
6011 }
6012 return;
6013 }
6014
6015 void doDomainInput(FL_OBJECT *obj, long param)
6016 {
6017 static char domainname[MAXLEN_DNNAME+1] = {0};
6018
6019 strncpy(domainname, (char *)fl_get_input(obj), MAXLEN_DNNAME);
6020 if ((fd_tcpipInfo->ldata & DEFAULT_DOMAIN) &&
6021 strlen(domainname) == 0)
6022 {
6023 XBell(fl_get_display(), 50);
6024 memset(domainname, 0, MAXLEN_DNNAME);
6025 fl_set_button(fd_tcpipInfo->DNNoButton, 1);
6026 fl_call_object_callback(fd_tcpipInfo->DNNoButton);
6027 fl_redraw_object(obj);
6028 }
6029 fd_tcpipInfo->cdata = domainname;
6030 return;
6031 }
6032
6033 int IPInputFilter(FL_OBJECT *obj, const char *old, const char *cur, int c)
6034 {
6035 int nd;
6036
6037 if (strcmp(old, cur)) {
6038 if (!((c>='0' && c<='9') || c=='.'))
6039 return FL_INVALID|FL_RINGBELL;
6040 for (nd=0; *cur; ++cur) if (*cur == '.') ++nd;
6041 if (nd > 3)
6042 return FL_INVALID|FL_RINGBELL;
6043 }
6044 return FL_VALID;
6045 }
6046
6047 void doMTUInput(FL_OBJECT *obj, long param)
6048 {
6049 char mtu[MAXDIG_MTRU+1] = {0};
6050 static unsigned int num = MTU;
6051
6052 strncpy(mtu, (char *)fl_get_input(obj), MAXDIG_MTRU);
6053 num = atoi(mtu);
6054 if (num<128 || num>2048) {
6055 XBell(fl_get_display(), 50);
6056 if (num < 128) num = 128;
6057 if (num > 2048) num = 2048;
6058 sprintf(mtu, "%d", num);
6059 fl_set_input(obj, mtu);
6060 fl_redraw_object(obj);
6061 }
6062 fd_tcpipInfo->vdata = #
6063 return;
6064 }
6065
6066 void doMRUInput(FL_OBJECT *obj, long param)
6067 {
6068 char mru[MAXDIG_MTRU+1] = {0};
6069 static unsigned int num = MRU;
6070
6071 strncpy(mru, (char *)fl_get_input(obj), MAXDIG_MTRU);
6072 num = atoi(mru);
6073 if (num<128 || num>2048) {
6074 XBell(fl_get_display(), 50);
6075 if (num < 128) num = 128;
6076 if (num > 2048) num = 2048;
6077 sprintf(mru, "%d", num);
6078 fl_set_input(obj, mru);
6079 fl_redraw_object(obj);
6080 }
6081 fd_tcpipInfo->vdata = #
6082 return;
6083 }
6084
6085 void doTcpipInfoOK(FL_OBJECT *obj, long done)
6086 {
6087 fl_call_object_callback(fd_tcpipInfo->localIPInput);
6088 memcpy(p_xisprc->localIP, (char *)fd_tcpipInfo->vdata, 4);
6089 fl_call_object_callback(fd_tcpipInfo->remoteIPInput);
6090 memcpy(p_xisprc->remoteIP, (char *)fd_tcpipInfo->vdata, 4);
6091 fl_call_object_callback(fd_tcpipInfo->NMInput);
6092 memcpy(p_xisprc->netmask, (char *)fd_tcpipInfo->vdata, 4);
6093 fl_call_object_callback(fd_tcpipInfo->pDNSInput);
6094 memcpy(p_xisprc->dns1, (char *)fd_tcpipInfo->vdata, 4);
6095 fl_call_object_callback(fd_tcpipInfo->sDNSInput);
6096 memcpy(p_xisprc->dns2, (char *)fd_tcpipInfo->vdata, 4);
6097 p_xisprc->operOpts = (unsigned)fd_tcpipInfo->ldata;
6098 fl_call_object_callback(fd_tcpipInfo->MTUInput);
6099 p_xisprc->mtu = *(unsigned int *)(fd_tcpipInfo->vdata);
6100 fl_call_object_callback(fd_tcpipInfo->MRUInput);
6101 p_xisprc->mru = *(unsigned int *)(fd_tcpipInfo->vdata);
6102 fl_call_object_callback(fd_tcpipInfo->domainInput);
6103 strcpy(p_xisprc->domainname, fd_tcpipInfo->cdata);
6104 writeXisprc(rcfname, xispOptions, &global);
6105 if (done) {
6106 fl_hide_form(fd_optsTab->optsTab);
6107 fl_activate_object(fd_topFrame->fileMenu);
6108 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
6109 }
6110 return;
6111 }
6112
6113 void doTcpipInfoCancel(FL_OBJECT *obj, long param)
6114 {
6115 fl_hide_form(fd_optsTab->optsTab);
6116 fl_activate_object(fd_topFrame->fileMenu);
6117 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
6118 return;
6119 }
6120
6121
6122 /*+-------------------------------------------------------------------------+
6123 | |
6124 | Utility storage and routines for logInfo and pttEditor |
6125 | |
6126 +-------------------------------------------------------------------------+*/
6127
6128 static discount_t reset_discount = {0.0,{0,0,0},{24,0,0}};
6129 static rule_t rst_Urule = {RULE_WEEKALL,{0,1},{11,31},0,{0,0,0},{24,0,0},60.0},
6130 rst_Trule = {RULE_WEEKALL,{0,1},{11,31},0,{0,0,0},{24,0,0},1.0};
6131
6132 void markByUnit(ptt_t *p)
6133 {
6134 ptt_t *a; /* to keep the compiler happy :) */
6135
6136 a = p;
6137 fl_set_object_label(fd_pttEditor->defaultTariffUnits, CUNIT_STR);
6138 fl_set_object_label(fd_pttEditor->ruleTariffUnits, CUNIT_STR);
6139 fl_deactivate_object(fd_pttEditor->TimeChargeType);
6140 fl_set_object_lcol(fd_pttEditor->TimeChargeType, FL_INACTIVE);
6141 fl_activate_object(fd_pttEditor->minUnitsInput);
6142 fl_set_object_lcol(fd_pttEditor->minUnitsInput, FL_WHITE);
6143 fl_deactivate_object(fd_pttEditor->minCostInput);
6144 fl_set_object_lcol(fd_pttEditor->minCostInput, FL_INACTIVE);
6145 fl_deactivate_object(fd_pttEditor->CSecondsInput);
6146 fl_set_object_lcol(fd_pttEditor->CSecondsInput, FL_INACTIVE);
6147 fl_deactivate_object(fd_pttEditor->REDType);
6148 fl_set_object_lcol(fd_pttEditor->REDType, FL_INACTIVE);
6149 fl_deactivate_object(fd_pttEditor->ZMLType);
6150 fl_set_object_lcol(fd_pttEditor->ZMLType, FL_INACTIVE);
6151 fl_deactivate_object(fd_pttEditor->ZEDType);
6152 fl_set_object_lcol(fd_pttEditor->ZEDType, FL_INACTIVE);
6153 fl_deactivate_object(fd_pttEditor->MCType);
6154 fl_set_object_lcol(fd_pttEditor->MCType, FL_INACTIVE);
6155 fl_set_button(fd_pttEditor->CUnitButton, 1);
6156 fl_activate_object(fd_pttEditor->unitPriceInput);
6157 fl_set_object_lcol(fd_pttEditor->unitPriceInput, FL_WHITE);
6158 }
6159
6160 void markByTime(ptt_t *p)
6161 {
6162 char msg[64+MAXLEN_CURRENCY] = {0};
6163
6164 sprintf(msg, CTIME_STR, p->currency);
6165 fl_set_object_label(fd_pttEditor->defaultTariffUnits, msg);
6166 fl_set_object_label(fd_pttEditor->ruleTariffUnits, msg);
6167 fl_activate_object(fd_pttEditor->TimeChargeType);
6168 fl_set_object_lcol(fd_pttEditor->TimeChargeType, FL_WHITE);
6169 fl_activate_object(fd_pttEditor->minCostInput);
6170 fl_set_object_lcol(fd_pttEditor->minCostInput, FL_WHITE);
6171 fl_deactivate_object(fd_pttEditor->minUnitsInput);
6172 fl_set_object_lcol(fd_pttEditor->minUnitsInput, FL_INACTIVE);
6173 if (p->attribs & PTT_PER_SECS) {
6174 fl_activate_object(fd_pttEditor->CSecondsInput);
6175 fl_set_object_lcol(fd_pttEditor->CSecondsInput, FL_WHITE);
6176 }
6177 else {
6178 fl_deactivate_object(fd_pttEditor->CSecondsInput);
6179 fl_set_object_lcol(fd_pttEditor->CSecondsInput, FL_INACTIVE);
6180 }
6181 fl_activate_object(fd_pttEditor->REDType);
6182 fl_set_object_lcol(fd_pttEditor->REDType, FL_WHITE);
6183 fl_activate_object(fd_pttEditor->ZMLType);
6184 fl_set_object_lcol(fd_pttEditor->ZMLType, FL_WHITE);
6185 fl_activate_object(fd_pttEditor->ZEDType);
6186 fl_set_object_lcol(fd_pttEditor->ZEDType, FL_WHITE);
6187 fl_activate_object(fd_pttEditor->MCType);
6188 fl_set_object_lcol(fd_pttEditor->MCType, FL_WHITE);
6189 if (p->attribs & PTT_PER_MINUTE)
6190 fl_set_button(fd_pttEditor->CMinuteButton, 1);
6191 else
6192 fl_set_button(fd_pttEditor->CSecondsButton, 1);
6193 fl_deactivate_object(fd_pttEditor->unitPriceInput);
6194 fl_set_object_lcol(fd_pttEditor->unitPriceInput, FL_INACTIVE);
6195 }
6196
6197 void updateCharges(ptt_t *p)
6198 {
6199 char ns[16] = {0};
6200
6201 fl_set_button(fd_pttEditor->CUnitButton, 0);
6202 fl_set_button(fd_pttEditor->CMinuteButton, 0);
6203 fl_set_button(fd_pttEditor->CSecondsButton, 0);
6204 if (p->attribs & PTT_BY_UNIT)
6205 markByUnit(p);
6206 else
6207 markByTime(p);
6208 fl_set_button(fd_pttEditor->CPLButton, 0);
6209 fl_set_button(fd_pttEditor->CPRButton, 0);
6210 if (p->attribs & PTT_CUR_AFTER_COST)
6211 fl_set_button(fd_pttEditor->CPRButton, 1);
6212 else
6213 fl_set_button(fd_pttEditor->CPLButton, 1);
6214 sprintf(ns, "%d", p->min_units);
6215 fl_set_input(fd_pttEditor->minUnitsInput, ns);
6216 sprintf(ns, "%g", p->min_cost);
6217 fl_set_input(fd_pttEditor->minCostInput, ns);
6218 sprintf(ns, "%d", p->charge_period);
6219 fl_set_input(fd_pttEditor->CSecondsInput, ns);
6220 sprintf(ns, "%g", p->cost_quantum);
6221 fl_set_input(fd_pttEditor->unitPriceInput, ns);
6222 fl_set_input(fd_pttEditor->currencyInput, p->currency);
6223 sprintf(ns, "%d", p->decimals);
6224 fl_set_input(fd_pttEditor->decimalsInput, ns);
6225 }
6226
6227 void updateZone(ptt_t *p)
6228 {
6229 char ns[16] = {0};
6230
6231 fl_set_button(fd_pttEditor->MLLButton, 0);
6232 fl_set_button(fd_pttEditor->MLNButton, 0);
6233 if (p->attribs & PTT_NONLINEAR_MIN) {
6234 fl_set_button(fd_pttEditor->MLNButton, 1);
6235 sprintf(ns, "%g", p->min_cost_len[p->current_zone]);
6236 fl_set_input(fd_pttEditor->MLSecondsInput, ns);
6237 fl_activate_object(fd_pttEditor->MLSecondsInput);
6238 fl_set_object_lcol(fd_pttEditor->MLSecondsInput, FL_WHITE);
6239 }
6240 else {
6241 fl_set_button(fd_pttEditor->MLLButton, 1);
6242 fl_set_input(fd_pttEditor->MLSecondsInput, "0");
6243 fl_deactivate_object(fd_pttEditor->MLSecondsInput);
6244 fl_set_object_lcol(fd_pttEditor->MLSecondsInput, FL_INACTIVE);
6245 }
6246 fl_set_button(fd_pttEditor->ZEDYesButton, 0);
6247 fl_set_button(fd_pttEditor->ZEDNoButton, 0);
6248 if (p->discount[p->current_zone].percent > 0) {
6249 fl_set_button(fd_pttEditor->ZEDYesButton, 1);
6250 sprintf(ns, "%g", p->discount[p->current_zone].percent);
6251 fl_set_input(fd_pttEditor->discountInput, ns);
6252 fl_activate_object(fd_pttEditor->DiscountType);
6253 fl_set_object_lcol(fd_pttEditor->DiscountType, FL_WHITE);
6254 }
6255 else {
6256 fl_set_button(fd_pttEditor->ZEDNoButton, 1);
6257 fl_set_input(fd_pttEditor->discountInput, "0");
6258 fl_deactivate_object(fd_pttEditor->DiscountType);
6259 fl_set_object_lcol(fd_pttEditor->DiscountType, FL_INACTIVE);
6260 }
6261 sprintf(ns, "%g", p->dflt_tariff[p->current_zone]);
6262 fl_set_input(fd_pttEditor->baseChargeInput, ns);
6263 sprintf(ns, "%g", p->min_cost_len[p->current_zone]);
6264 fl_set_input(fd_pttEditor->MLSecondsInput, ns);
6265 sprintf(ns, "%g", p->discount[p->current_zone].percent);
6266 fl_set_input(fd_pttEditor->discountInput, ns);
6267 fl_set_input(fd_pttEditor->ZSHInput,
6268 uc2ts(p->discount[p->current_zone].start, 'H'));
6269 fl_set_input(fd_pttEditor->ZSMInput,
6270 uc2ts(p->discount[p->current_zone].start, 'M'));
6271 fl_set_input(fd_pttEditor->ZSSInput,
6272 uc2ts(p->discount[p->current_zone].start, 'S'));
6273 fl_set_input(fd_pttEditor->ZEHInput,
6274 uc2ts(p->discount[p->current_zone].end, 'H'));
6275 fl_set_input(fd_pttEditor->ZEMInput,
6276 uc2ts(p->discount[p->current_zone].end, 'M'));
6277 fl_set_input(fd_pttEditor->ZESInput,
6278 uc2ts(p->discount[p->current_zone].end, 'S'));
6279 }
6280
6281 void updateRule(ptt_t *p, int reset)
6282 {
6283 int rn;
6284 char ns[16] = {0};
6285
6286 if (reset) {
6287 fl_set_counter_bounds(fd_pttEditor->ruleCounter,
6288 1, (p->num_categories)? p->num_categories:1);
6289 fl_set_counter_value(fd_pttEditor->ruleCounter, 1);
6290 rn = 0;
6291 }
6292 else
6293 rn = fl_get_counter_value(fd_pttEditor->ruleCounter) - 1;
6294 fd_pttEditor->ldata = rn; /* save this for pttEditor call-back functions */
6295 fl_set_button(fd_pttEditor->RDYesButton, 0);
6296 fl_set_button(fd_pttEditor->RDNoButton, 0);
6297 if (p->rule[p->current_zone][rn].type & DISCOUNT_PERMITTED)
6298 fl_set_button(fd_pttEditor->RDYesButton, 1);
6299 else
6300 fl_set_button(fd_pttEditor->RDNoButton, 1);
6301 if (p->discount[p->current_zone].percent > 0) {
6302 fl_activate_object(fd_pttEditor->REDType);
6303 fl_set_object_lcol(fd_pttEditor->REDType, FL_WHITE);
6304 fl_set_object_lcol(fd_pttEditor->RDStr, FL_WHITE);
6305 }
6306 else {
6307 fl_deactivate_object(fd_pttEditor->REDType);
6308 fl_set_object_lcol(fd_pttEditor->REDType, FL_INACTIVE);
6309 fl_set_object_lcol(fd_pttEditor->RDStr, FL_INACTIVE);
6310 }
6311 fl_set_button(fd_pttEditor->TWDButton, 0);
6312 fl_set_button(fd_pttEditor->TWEButton, 0);
6313 fl_set_button(fd_pttEditor->TSDButton, 0);
6314 fl_set_button(fd_pttEditor->TUDButton, 0);
6315 fl_set_button(fd_pttEditor->THRButton, 0);
6316 fl_set_button(fd_pttEditor->THAButton, 0);
6317 fl_set_button(fd_pttEditor->TWDSButton, 0);
6318 fl_set_button(fd_pttEditor->TWESButton, 0);
6319 fl_set_button(fd_pttEditor->TAWButton, 0);
6320 fl_set_object_lcol(fd_pttEditor->ruleDateStr, FL_INACTIVE);
6321 fl_deactivate_object(fd_pttEditor->CalDateType);
6322 fl_set_object_lcol(fd_pttEditor->CalDateType, FL_INACTIVE);
6323 fl_deactivate_object(fd_pttEditor->EndDateType);
6324 fl_set_object_lcol(fd_pttEditor->EndDateType, FL_INACTIVE);
6325 fl_deactivate_object(fd_pttEditor->relDateInput);
6326 fl_set_object_lcol(fd_pttEditor->relDateInput, FL_INACTIVE);
6327 switch ((p->rule[p->current_zone][rn].type) & 0x3F) {
6328 case RULE_WEEKALL:
6329 fl_set_button(fd_pttEditor->TAWButton, 1);
6330 break;
6331 case RULE_WEEKDAY:
6332 fl_set_button(fd_pttEditor->TWDButton, 1);
6333 break;
6334 case RULE_SPECIAL_WEEKDAY:
6335 fl_set_button(fd_pttEditor->TWDSButton, 1);
6336 fl_set_object_lcol(fd_pttEditor->ruleDateStr, FL_WHITE);
6337 fl_activate_object(fd_pttEditor->CalDateType);
6338 fl_set_object_lcol(fd_pttEditor->CalDateType, FL_WHITE);
6339 fl_activate_object(fd_pttEditor->EndDateType);
6340 fl_set_object_lcol(fd_pttEditor->EndDateType, FL_WHITE);
6341 break;
6342 case RULE_WEEKEND:
6343 fl_set_button(fd_pttEditor->TWEButton, 1);
6344 break;
6345 case RULE_SPECIAL_WEEKEND:
6346 fl_set_button(fd_pttEditor->TWDSButton, 1);
6347 fl_set_object_lcol(fd_pttEditor->ruleDateStr, FL_WHITE);
6348 fl_activate_object(fd_pttEditor->CalDateType);
6349 fl_set_object_lcol(fd_pttEditor->CalDateType, FL_WHITE);
6350 fl_activate_object(fd_pttEditor->EndDateType);
6351 fl_set_object_lcol(fd_pttEditor->EndDateType, FL_WHITE);
6352 fl_set_button(fd_pttEditor->TWESButton, 1);
6353 break;
6354 case RULE_SATURDAY:
6355 fl_set_button(fd_pttEditor->TSDButton, 1);
6356 break;
6357 case RULE_SUNDAY:
6358 fl_set_button(fd_pttEditor->TUDButton, 1);
6359 break;
6360 case RULE_RHOLIDAY:
6361 fl_set_button(fd_pttEditor->THRButton, 1);
6362 fl_set_object_lcol(fd_pttEditor->ruleDateStr, FL_WHITE);
6363 fl_activate_object(fd_pttEditor->relDateInput);
6364 fl_set_object_lcol(fd_pttEditor->relDateInput, FL_WHITE);
6365 break;
6366 case RULE_AHOLIDAY:
6367 fl_set_button(fd_pttEditor->THAButton, 1);
6368 fl_set_object_lcol(fd_pttEditor->ruleDateStr, FL_WHITE);
6369 fl_activate_object(fd_pttEditor->CalDateType);
6370 fl_set_object_lcol(fd_pttEditor->CalDateType, FL_WHITE);
6371 break;
6372 default: break;
6373 }
6374 fl_set_button(fd_pttEditor->ZMLYesButton, 0);
6375 fl_set_button(fd_pttEditor->ZMLNoButton, 0);
6376 if (p->rule[p->current_zone][rn].type & DEFEAT_MIN_TIME_LEN)
6377 fl_set_button(fd_pttEditor->ZMLYesButton, 1);
6378 else
6379 fl_set_button(fd_pttEditor->ZMLNoButton, 1);
6380 if (p->attribs & PTT_NONLINEAR_MIN) {
6381 fl_activate_object(fd_pttEditor->ZMLType);
6382 fl_set_object_lcol(fd_pttEditor->ZMLType, FL_WHITE);
6383 fl_set_object_lcol(fd_pttEditor->ZMLStr, FL_WHITE);
6384 }
6385 else {
6386 fl_deactivate_object(fd_pttEditor->ZMLType);
6387 fl_set_object_lcol(fd_pttEditor->ZMLType, FL_INACTIVE);
6388 fl_set_object_lcol(fd_pttEditor->ZMLStr, FL_INACTIVE);
6389 }
6390 sprintf(ns, "%g", p->rule[p->current_zone][rn].tariff);
6391 fl_set_input(fd_pttEditor->ruleChargeInput, ns);
6392 fl_set_input(fd_pttEditor->RDMInput,
6393 uc2ds(p->rule[p->current_zone][rn].adate, 'M'));
6394 fl_set_input(fd_pttEditor->RDDInput,
6395 uc2ds(p->rule[p->current_zone][rn].adate, 'D'));
6396 fl_set_input(fd_pttEditor->RDEMInput,
6397 uc2ds(p->rule[p->current_zone][rn].edate, 'M'));
6398 fl_set_input(fd_pttEditor->RDEDInput,
6399 uc2ds(p->rule[p->current_zone][rn].edate, 'D'));
6400 sprintf(ns, "%d", p->rule[p->current_zone][rn].rdate);
6401 fl_set_input(fd_pttEditor->relDateInput, ns);
6402 fl_set_input(fd_pttEditor->RSHInput,
6403 uc2ts(p->rule[p->current_zone][rn].start, 'H'));
6404 fl_set_input(fd_pttEditor->RSMInput,
6405 uc2ts(p->rule[p->current_zone][rn].start, 'M'));
6406 fl_set_input(fd_pttEditor->RSSInput,
6407 uc2ts(p->rule[p->current_zone][rn].start, 'S'));
6408 fl_set_input(fd_pttEditor->REHInput,
6409 uc2ts(p->rule[p->current_zone][rn].end, 'H'));
6410 fl_set_input(fd_pttEditor->REMInput,
6411 uc2ts(p->rule[p->current_zone][rn].end, 'M'));
6412 fl_set_input(fd_pttEditor->RESInput,
6413 uc2ts(p->rule[p->current_zone][rn].end, 'S'));
6414 }
6415
6416 int intInput(FL_OBJECT *obj, int min, int max, char *fmt)
6417 {
6418 static char str[32];
6419 int num;
6420
6421 strncpy(str, (char *)fl_get_input(obj), 31);
6422 num = atoi(str);
6423 if (*str==0 || num<min || num>max) {
6424 XBell(fl_get_display(), 50);
6425 if (num < min) num = min;
6426 if (num > max) num = max;
6427 }
6428 sprintf(str, fmt, num);
6429 fl_set_input(obj, str);
6430 fl_redraw_object(obj);
6431 return num;
6432 }
6433
6434 float floatInput(FL_OBJECT *obj, float min, float max, char *fmt)
6435 {
6436 char str[32] = {0}, *endp;
6437 float num;
6438
6439 strncpy(str, (char *)fl_get_input(obj), 31);
6440 num = strtod(str, &endp);
6441 if (*str==0 || num<min || ((max-min)>1.e-6 && num>max) || endp==str) {
6442 XBell(fl_get_display(), 50);
6443 if (num < min) num = min;
6444 if (num > max) num = max;
6445 }
6446 sprintf(str, fmt, num);
6447 fl_set_input(obj, str);
6448 fl_redraw_object(obj);
6449 return num;
6450 }
6451
6452 /*+-------------------------------------------------------------------------+
6453 | |
6454 | Callback routines for logInfo and renamePTT |
6455 | |
6456 +-------------------------------------------------------------------------+*/
6457
6458 void doOLTimeButton(FL_OBJECT *obj, long param)
6459 {
6460 if (fl_get_button(fd_logInfo->OLTimeButton))
6461 fd_logInfo->ldata &= ~COST_READOUT;
6462 return;
6463 }
6464
6465 void doOLChargeButton(FL_OBJECT *obj, long param)
6466 {
6467 if (fl_get_button(fd_logInfo->OLChargeButton))
6468 fd_logInfo->ldata |= COST_READOUT;
6469 return;
6470 }
6471
6472 void doLogNoButton(FL_OBJECT *obj, long param)
6473 {
6474 if (fl_get_button(fd_logInfo->logNoButton)) {
6475 fd_logInfo->ldata |= LOG_NONE;
6476 fd_logInfo->ldata &= ~LOG_WEEKLY;
6477 fd_logInfo->ldata &= ~LOG_MONTHLY;
6478 fd_logInfo->ldata &= ~LOG_BIMONTHLY;
6479 }
6480 return;
6481 }
6482
6483 void doLogWeekButton(FL_OBJECT *obj, long param)
6484 {
6485 if (fl_get_button(fd_logInfo->logWeekButton)) {
6486 fd_logInfo->ldata &= ~LOG_NONE;
6487 fd_logInfo->ldata |= LOG_WEEKLY;
6488 fd_logInfo->ldata &= ~LOG_MONTHLY;
6489 fd_logInfo->ldata &= ~LOG_BIMONTHLY;
6490 }
6491 return;
6492 }
6493
6494 void doLogMonthButton(FL_OBJECT *obj, long param)
6495 {
6496 if (fl_get_button(fd_logInfo->logMonthButton)) {
6497 fd_logInfo->ldata &= ~LOG_NONE;
6498 fd_logInfo->ldata &= ~LOG_WEEKLY;
6499 fd_logInfo->ldata |= LOG_MONTHLY;
6500 fd_logInfo->ldata &= ~LOG_BIMONTHLY;
6501 }
6502 return;
6503 }
6504
6505 void doLogBiMonthButton(FL_OBJECT *obj, long param)
6506 {
6507 if (fl_get_button(fd_logInfo->logBiMonthButton)) {
6508 fd_logInfo->ldata &= ~LOG_NONE;
6509 fd_logInfo->ldata &= ~LOG_WEEKLY;
6510 fd_logInfo->ldata &= ~LOG_MONTHLY;
6511 fd_logInfo->ldata |= LOG_BIMONTHLY;
6512 }
6513 return;
6514 }
6515
6516 void doPttDropChoice(FL_OBJECT *obj, long param)
6517 {
6518 unsigned char sPTT = ((unsigned)fd_logInfo->ldata & 0x00FF0000) >> 16;
6519 int c, i;
6520 ptt_t *p;
6521
6522 if ((c = fl_get_choice(obj)) && --c != sPTT) {
6523 fd_logInfo->ldata &= 0x0FF00FFFF;
6524 fd_logInfo->ldata |= ((unsigned)c << 16);
6525 p = &ptt[c];
6526 fl_clear_choice(fd_logInfo->zoneDropChoice);
6527 for (i=0; i<p->num_zones; i++)
6528 fl_addto_choice(fd_logInfo->zoneDropChoice,
6529 clipStr(p->zone_name[i], FL_NORMAL_SIZE,
6530 FL_NORMAL_STYLE, 240));
6531 fd_logInfo->ldata &= 0x00FFFFFF;
6532 fl_set_choice(fd_logInfo->zoneDropChoice, 1);
6533 showPttInfo(p);
6534 }
6535 return;
6536 }
6537
6538 void doZoneDropChoice(FL_OBJECT *obj, long param)
6539 {
6540 unsigned char cZone = ((unsigned)fd_logInfo->ldata & 0x0FF000000) >> 24;
6541 int c;
6542
6543 if ((c = fl_get_choice(obj)) && --c != cZone) {
6544 fd_logInfo->ldata &= 0x00FFFFFF;
6545 fd_logInfo->ldata |= ((unsigned)c << 24);
6546 }
6547 return;
6548 }
6549
6550 void doLogInfoPTTEdit(FL_OBJECT *obj, long param)
6551 {
6552 unsigned char sPTT = ((unsigned)fd_logInfo->ldata & 0x00FF0000) >> 16;
6553 unsigned char cZone = ((unsigned)fd_logInfo->ldata & 0x0FF000000) >> 24;
6554 ptt_t *p;
6555 int z;
6556 char ns[16] = {0};
6557
6558 fl_deactivate_form(fd_logInfo->logInfo);
6559 p = &ptt[sPTT];
6560 p->current_zone = cZone;
6561 IFC_pttEditor = *p;
6562 fl_freeze_form(fd_pttEditor->pttEditor);
6563 updateCharges(p);
6564 updateZone(p);
6565 updateRule(p, 1);
6566 fl_unfreeze_form(fd_pttEditor->pttEditor);
6567 fl_set_input(fd_pttEditor->pttNameInput, p->name);
6568 sprintf(ns, "%d", p->num_zones);
6569 fl_set_input(fd_pttEditor->zonesInput, ns);
6570 sprintf(ns, "%d", p->num_categories);
6571 fl_set_input(fd_pttEditor->categoriesInput, ns);
6572 fl_show_form(fd_pttEditor->pttEditor, FL_PLACE_MOUSE,
6573 FL_TRANSIENT, "PTT Editor");
6574 fl_clear_browser(fd_pttEditor->zonePick);
6575 for (z=0; z<p->num_zones; z++)
6576 fl_add_browser_line(fd_pttEditor->zonePick, p->zone_name[z]);
6577 fl_select_browser_line(fd_pttEditor->zonePick, 1+cZone);
6578 fl_set_browser_topline(fd_pttEditor->zonePick, 1+cZone);
6579 return;
6580 }
6581
6582 void doLogInfoPTTAdd(FL_OBJECT *obj, long param)
6583 {
6584 fl_deactivate_form(fd_logInfo->logInfo);
6585 fl_show_form(fd_renamePTT->renamePTT, FL_PLACE_MOUSE,
6586 FL_TRANSIENT, "Add new PTT");
6587 return;
6588 }
6589
6590 void doLogInfoPTTRemove(FL_OBJECT *obj, long param)
6591 {
6592 ptt_t *p_dest, *p_src, *p;
6593 unsigned char sPTT = ((unsigned)fd_logInfo->ldata & 0x00FF0000) >> 16;
6594 void gr_epak_initPtt(); /* OTE A.E. (E�AK), Hellas (default PTT) */
6595 char msg[512] = {0};
6596 int i;
6597
6598 if (! expert) {
6599 sprintf(msg, "Are you sure you want to delete PTT\n\"%s\"?",
6600 ptt[sPTT].name);
6601 if (! actionVerify(msg, 0))
6602 return;
6603 }
6604 if (sPTT < (global.numPTTs-1)) {
6605 p_dest = &ptt[sPTT];
6606 p_src = &ptt[sPTT+1];
6607 #ifdef SUNOS41x
6608 bcopy(p_src, p_dest, (global.numPTTs-sPTT-1)*sizeof(ptt_t));
6609 #else
6610 memmove(p_dest, p_src, (global.numPTTs-sPTT-1)*sizeof(ptt_t));
6611 #endif
6612 }
6613 else if (sPTT)
6614 --sPTT;
6615
6616 fd_logInfo->ldata &= 0x0FF00FFFF;
6617 fd_logInfo->ldata |= (sPTT << 16);
6618
6619 if (global.numPTTs > 1) {
6620 global.numPTTs -= 1;
6621 p = realloc(ptt, global.numPTTs*sizeof(ptt_t));
6622 if (p == NULL)
6623 outofMem();
6624 ptt = p;
6625 }
6626 else {
6627 p = ptt;
6628 initXispPTT(p);
6629 gr_epak_initPtt(p);
6630 sprintf(msg, "You have deleted the last entry in the PTT database!\n"
6631 "Reverting to default PTT: %s\n", p->name);
6632 alertMessage("xISP: doLogInfoPTTRemove()", 0, 0, msg);
6633 }
6634 fd_logInfo->vdata = (void *)1; /* indicate change in PTT database */
6635 fl_clear_choice(fd_logInfo->pttDropChoice);
6636 for (i=0; i<global.numPTTs; i++)
6637 fl_addto_choice(fd_logInfo->pttDropChoice,
6638 clipStr(ptt[i].name, FL_NORMAL_SIZE,
6639 FL_NORMAL_STYLE, 240));
6640 fl_set_choice(fd_logInfo->pttDropChoice, sPTT+1);
6641 fl_clear_choice(fd_logInfo->zoneDropChoice);
6642 for (i=0, p=&ptt[sPTT]; i<p->num_zones; i++)
6643 fl_addto_choice(fd_logInfo->zoneDropChoice,
6644 clipStr(p->zone_name[i], FL_NORMAL_SIZE,
6645 FL_NORMAL_STYLE, 240));
6646 fl_set_choice(fd_logInfo->zoneDropChoice,p->current_zone+1);
6647 showPttInfo(p);
6648 return;
6649 }
6650
6651 void doLogInfoOK(FL_OBJECT *obj, long param)
6652 {
6653 unsigned short opts = (unsigned)fd_logInfo->ldata & 0x00FFFF;
6654 unsigned char sPTT = ((unsigned)fd_logInfo->ldata & 0x00FF0000) >> 16;
6655 int newCurrency = strcmp(fd_logInfo->cdata, ptt[sPTT].currency);
6656
6657 if (! (opts & 0x0F & LOG_NONE)) {
6658 if (newCurrency &&
6659 ! actionVerify("The PTT selected bills you in currency which "
6660 "is\ndifferent from the one currently in use. "
6661 "This implies\nresetting of log files, continue?",0)
6662 )
6663 return;
6664 if (newCurrency || ((opts & 0x0F) != (global.logOpts & 0x0F)))
6665 resetLogs();
6666 }
6667 checkUpdatePTTs(); /* make sure no deleted PTTs exist in ISP database */
6668 global.logOpts = opts;
6669 currentPTT = sPTT;
6670 global.costPTT = currentPTT;
6671 p_ptt = &ptt[currentPTT];
6672 p_ptt->current_zone = ((unsigned)fd_logInfo->ldata & 0x0FF000000) >> 24;
6673 p_xisprc->ispPTT = currentPTT;
6674 p_xisprc->ispZone = p_ptt->current_zone;
6675 writeXisprc(rcfname, xispOptions, &global);
6676 if (global.logOpts & COST_READOUT) {
6677 fl_set_object_label(fd_topFrame->logDescr, RCOST_STR);
6678 fl_set_object_label(fd_topFrame->logText, costStr(p_ptt, 0.0));
6679 }
6680 else {
6681 fl_set_object_label(fd_topFrame->logDescr, RTIME_STR);
6682 fl_set_object_label(fd_topFrame->logText, EMPTY_TIME);
6683 }
6684 if (global.logOpts & LOG_NONE)
6685 fl_set_menu_item_mode(fd_topFrame->logMenu, 2, FL_PUP_GREY);
6686 else
6687 fl_set_menu_item_mode(fd_topFrame->logMenu, 2, FL_PUP_NONE);
6688 if (fd_logInfo->vdata) {
6689 fl_set_cursor(fl_get_real_object_window(fd_logInfo->logGroup), tcid);
6690 fl_check_forms();
6691 writeXispPTTs(ptt, &global);
6692 fl_reset_cursor(fl_get_real_object_window(fd_logInfo->logGroup));
6693 fl_check_forms();
6694 }
6695 fl_hide_form(fd_logInfo->logInfo);
6696 fl_activate_object(fd_topFrame->logMenu);
6697 fl_set_object_lcol(fd_topFrame->logMenu,FL_LCOL);
6698 return;
6699 }
6700
6701 void doLogInfoCancel(FL_OBJECT *obj, long param)
6702 {
6703 if (fd_logInfo->vdata) {
6704 fl_set_cursor(fl_get_real_object_window(fd_logInfo->logGroup), tcid);
6705 fl_check_forms();
6706 free(ptt);
6707 readXispPTTs(&ptt, &global);
6708 p_ptt = &ptt[currentPTT];
6709 fl_reset_cursor(fl_get_real_object_window(fd_logInfo->logGroup));
6710 fl_check_forms();
6711 }
6712 fl_hide_form(fd_logInfo->logInfo);
6713 fl_activate_object(fd_topFrame->logMenu);
6714 fl_set_object_lcol(fd_topFrame->logMenu,FL_LCOL);
6715 return;
6716 }
6717
6718 void doPTTNameInput(FL_OBJECT *obj, long param)
6719 {
6720 static char name[MAXLEN_PTTNAME+1];
6721
6722 strncpy(name, fl_get_input(obj), MAXLEN_PTTNAME);
6723 fd_renamePTT->cdata = name;
6724 return;
6725 }
6726
6727 void doPTTNameEditOK(FL_OBJECT *obj, long param)
6728 {
6729 unsigned char sPTT = global.numPTTs;
6730 ptt_t *p;
6731 int i;
6732
6733 fd_logInfo->ldata &= 0x0FF00FFFF;
6734 fd_logInfo->ldata |= (sPTT << 16);
6735 p = realloc(ptt, (global.numPTTs+1)*sizeof(ptt_t));
6736 if (p == NULL)
6737 outofMem();
6738 else {
6739 ptt = p;
6740 global.numPTTs += 1;
6741 fd_logInfo->vdata = (void *)1; /* indicate change in PTT database */
6742 }
6743 p = &ptt[sPTT];
6744 initXispPTT(p);
6745 fl_call_object_callback(fd_renamePTT->PTTNameInput);
6746 if (*(fd_renamePTT->cdata))
6747 strncpy(p->name, fd_renamePTT->cdata, MAXLEN_PTTNAME);
6748 else
6749 strcpy(p->name, "My new PTT");
6750 fl_clear_choice(fd_logInfo->pttDropChoice);
6751 for (i=0; i<global.numPTTs; i++)
6752 fl_addto_choice(fd_logInfo->pttDropChoice,
6753 clipStr(ptt[i].name, FL_NORMAL_SIZE,
6754 FL_NORMAL_STYLE, 240));
6755 fl_set_choice(fd_logInfo->pttDropChoice, sPTT+1);
6756 fl_clear_choice(fd_logInfo->zoneDropChoice);
6757 showPttInfo(p);
6758 fl_hide_form(fd_renamePTT->renamePTT);
6759 fl_activate_form(fd_logInfo->logInfo);
6760 return;
6761 }
6762
6763 void doPTTNameEditCancel(FL_OBJECT *obj, long param)
6764 {
6765 fl_hide_form(fd_renamePTT->renamePTT);
6766 fl_activate_form(fd_logInfo->logInfo);
6767 return;
6768 }
6769
6770
6771 /*+-------------------------------------------------------------------------+
6772 | |
6773 | Callback routines for statInfo |
6774 | |
6775 +-------------------------------------------------------------------------+*/
6776
6777 void doStatsInfoOK(FL_OBJECT *obj, long param)
6778 {
6779 fl_hide_form(fd_statInfo->statInfo);
6780 fl_activate_object(fd_topFrame->logMenu);
6781 fl_set_object_lcol(fd_topFrame->logMenu,FL_LCOL);
6782 return;
6783 }
6784
6785
6786 /*+-------------------------------------------------------------------------+
6787 | |
6788 | Callback routines for pttEditor and renameZone |
6789 | |
6790 +-------------------------------------------------------------------------+*/
6791
6792 void doCUnitButton(FL_OBJECT *obj, long param)
6793 {
6794 ptt_t *p = &IFC_pttEditor;
6795 int z, c;
6796
6797 if (fl_get_button(fd_pttEditor->CUnitButton)) {
6798 if (p->attribs & PTT_BY_UNIT)
6799 return;
6800 p->attribs &= ~(PTT_PER_MINUTE|PTT_PER_SECS);
6801 p->attribs |= PTT_BY_UNIT;
6802 p->min_units = 0;
6803 p->min_cost = 0.0;
6804 p->charge_period = 0;
6805 if (p->cost_quantum < 1.e-2)
6806 p->cost_quantum = 1.0;
6807 if (p->decimals < 1)
6808 p->decimals = 1;
6809 fl_freeze_form(fd_pttEditor->pttEditor);
6810 updateCharges(p);
6811 for (z=0; z<p->num_zones; z++) {
6812 if (p->dflt_tariff[z] < 1)
6813 p->dflt_tariff[z] = 60;
6814 p->min_cost_len[z] = 0.0;
6815 p->discount[z] = reset_discount;
6816 for (c=0; c<p->num_categories; c++)
6817 if (p->rule[z][c].tariff < 1)
6818 p->rule[z][c] = rst_Urule;
6819 }
6820 updateZone(p);
6821 updateRule(p, 0);
6822 fl_unfreeze_form(fd_pttEditor->pttEditor);
6823 }
6824 return;
6825 }
6826
6827 void doCMinuteButton(FL_OBJECT *obj, long param)
6828 {
6829 ptt_t *p = &IFC_pttEditor;
6830 int z, c;
6831
6832 if (fl_get_button(fd_pttEditor->CMinuteButton)) {
6833 if (p->attribs & PTT_PER_MINUTE)
6834 return;
6835 p->attribs &= ~(PTT_BY_UNIT|PTT_PER_SECS);
6836 p->attribs |= PTT_PER_MINUTE;
6837 p->min_units = 0;
6838 p->min_cost = 0.0;
6839 p->charge_period = 60;
6840 p->cost_quantum = 0.0;
6841 if (p->decimals < 1)
6842 p->decimals = 2;
6843 fl_freeze_form(fd_pttEditor->pttEditor);
6844 updateCharges(p);
6845 for (z=0; z<p->num_zones; z++) {
6846 if (p->dflt_tariff[z] < 1.e-3)
6847 p->dflt_tariff[z] = 1;
6848 p->min_cost_len[z] = 0.0;
6849 p->discount[z] = reset_discount;
6850 for (c=0; c<p->num_categories; c++)
6851 if (p->rule[z][c].tariff < 1.e-3)
6852 p->rule[z][c] = rst_Trule;
6853 }
6854 updateZone(p);
6855 updateRule(p, 0);
6856 fl_unfreeze_form(fd_pttEditor->pttEditor);
6857 }
6858 return;
6859 }
6860
6861 void doCSecondsButton(FL_OBJECT *obj, long param)
6862 {
6863 ptt_t *p = &IFC_pttEditor;
6864 int z, c;
6865
6866 if (fl_get_button(fd_pttEditor->CSecondsButton)) {
6867 if (p->attribs & PTT_PER_SECS)
6868 return;
6869 p->attribs &= ~(PTT_BY_UNIT|PTT_PER_MINUTE);
6870 p->attribs |= PTT_PER_SECS;
6871 p->min_units = 0;
6872 p->min_cost = 0.0;
6873 if (p->charge_period < 1)
6874 p->charge_period = 1;
6875 p->cost_quantum = 0.0;
6876 if (p->decimals < 1)
6877 p->decimals = 2;
6878 fl_freeze_form(fd_pttEditor->pttEditor);
6879 updateCharges(p);
6880 for (z=0; z<p->num_zones; z++) {
6881 if (p->dflt_tariff[z] < 1.e-3)
6882 p->dflt_tariff[z] = 1;
6883 p->min_cost_len[z] = 0.0;
6884 p->discount[z] = reset_discount;
6885 for (c=0; c<p->num_categories; c++)
6886 if (p->rule[z][c].tariff < 1.e-3)
6887 p->rule[z][c] = rst_Trule;
6888 }
6889 updateZone(p);
6890 updateRule(p, 0);
6891 fl_unfreeze_form(fd_pttEditor->pttEditor);
6892 }
6893 return;
6894 }
6895
6896 void doCPLButton(FL_OBJECT *obj, long param)
6897 {
6898 ptt_t *p = &IFC_pttEditor;
6899
6900 if (fl_get_button(fd_pttEditor->CPLButton))
6901 p->attribs &= ~PTT_CUR_AFTER_COST;
6902 return;
6903 }
6904
6905 void doCPRButton(FL_OBJECT *obj, long param)
6906 {
6907 ptt_t *p = &IFC_pttEditor;
6908
6909 if (fl_get_button(fd_pttEditor->CPRButton))
6910 p->attribs |= PTT_CUR_AFTER_COST;
6911 return;
6912 }
6913
6914 void doMLLButton(FL_OBJECT *obj, long param)
6915 {
6916 ptt_t *p = &IFC_pttEditor;
6917 int z, c;
6918
6919 if (fl_get_button(fd_pttEditor->MLLButton)) {
6920 p->attribs &= ~PTT_NONLINEAR_MIN;
6921 for (z=0; z<p->num_zones; z++) {
6922 p->min_cost_len[z] = 0.0;
6923 for (c=0; c<p->num_categories; c++)
6924 p->rule[z][c].type &= ~DEFEAT_MIN_TIME_LEN;
6925 }
6926 fl_freeze_form(fd_pttEditor->pttEditor);
6927 updateZone(p);
6928 updateRule(p, 0);
6929 fl_unfreeze_form(fd_pttEditor->pttEditor);
6930 }
6931 return;
6932 }
6933
6934 void doMLNButton(FL_OBJECT *obj, long param)
6935 {
6936 ptt_t *p = &IFC_pttEditor;
6937 int z;
6938
6939 if (fl_get_button(fd_pttEditor->MLNButton)) {
6940 p->attribs |= PTT_NONLINEAR_MIN;
6941 for (z=0; z<p->num_zones; z++)
6942 p->min_cost_len[z] = 0.0;
6943 fl_freeze_form(fd_pttEditor->pttEditor);
6944 updateZone(p);
6945 updateRule(p, 0);
6946 fl_unfreeze_form(fd_pttEditor->pttEditor);
6947 }
6948 return;
6949 }
6950
6951 void doRuleCounter(FL_OBJECT *obj, long param)
6952 {
6953 fl_call_object_callback(fd_pttEditor->ruleChargeInput);
6954 fl_call_object_callback(fd_pttEditor->RDMInput);
6955 fl_call_object_callback(fd_pttEditor->RDDInput);
6956 fl_call_object_callback(fd_pttEditor->RDEMInput);
6957 fl_call_object_callback(fd_pttEditor->RDEDInput);
6958 fl_call_object_callback(fd_pttEditor->relDateInput);
6959 fl_call_object_callback(fd_pttEditor->RSHInput);
6960 fl_call_object_callback(fd_pttEditor->RSMInput);
6961 fl_call_object_callback(fd_pttEditor->RSSInput);
6962 fl_call_object_callback(fd_pttEditor->REHInput);
6963 fl_call_object_callback(fd_pttEditor->REMInput);
6964 fl_call_object_callback(fd_pttEditor->RESInput);
6965 fl_freeze_form(fd_pttEditor->pttEditor);
6966 updateRule(&IFC_pttEditor, 0);
6967 fl_unfreeze_form(fd_pttEditor->pttEditor);
6968 return;
6969 }
6970
6971 void doPttNameInput(FL_OBJECT *obj, long param)
6972 {
6973 ptt_t *p = &IFC_pttEditor;
6974
6975 strncpy(p->name, fl_get_input(obj), MAXLEN_PTTNAME);
6976 return;
6977 }
6978
6979 void doZonesInput(FL_OBJECT *obj, long param)
6980 {
6981 ptt_t *p = &IFC_pttEditor;
6982 int num, z, c;
6983 char dflt[16];
6984
6985 num = intInput(obj, 1, MAXNUM_ZONES, "%d");
6986 if (num == p->num_zones)
6987 return;
6988 else if (num > p->num_zones) {
6989 for (z=p->num_zones; z<num; z++) {
6990 if (*(p->zone_name[z]) == 0) {
6991 sprintf(dflt, "Zone %d", z+1);
6992 strcpy(p->zone_name[z], dflt);
6993 }
6994 fl_add_browser_line(fd_pttEditor->zonePick, p->zone_name[z]);
6995 }
6996 }
6997 else if (num < p->num_zones) {
6998 for (z=num; z<p->num_zones; z++) {
6999 fl_delete_browser_line(fd_pttEditor->zonePick, num+1);
7000 p->dflt_tariff[z] = 0.0;
7001 p->min_cost_len[z] = 0.0;
7002 p->zone_name[z][0] = 0;
7003 p->discount[z] = reset_discount;
7004 for (c=0; c<MAXNUM_CATEGORY; c++) {
7005 if (p->attribs & PTT_BY_UNIT)
7006 p->rule[z][c] = rst_Urule;
7007 else
7008 p->rule[z][c] = rst_Trule;
7009 }
7010 }
7011 if (p->current_zone > num-1) {
7012 p->current_zone = num - 1;
7013 fl_select_browser_line(fd_pttEditor->zonePick, num);
7014 fl_freeze_form(fd_pttEditor->pttEditor);
7015 updateZone(p);
7016 updateRule(p, 1);
7017 fl_unfreeze_form(fd_pttEditor->pttEditor);
7018 }
7019 }
7020 p->num_zones = num;
7021 return;
7022 }
7023
7024 void doCategoriesInput(FL_OBJECT *obj, long param)
7025 {
7026 ptt_t *p = &IFC_pttEditor;
7027 int num;
7028
7029 num = intInput(obj, 1, MAXNUM_CATEGORY, "%d");
7030 if (num == p->num_categories)
7031 return;
7032 else if (num > p->num_categories)
7033 fl_set_counter_bounds(fd_pttEditor->ruleCounter, 1, num);
7034 else if (num < p->num_categories) {
7035 if (fl_get_counter_value(fd_pttEditor->ruleCounter) > num) {
7036 fl_set_counter_value(fd_pttEditor->ruleCounter, num);
7037 fl_freeze_form(fd_pttEditor->pttEditor);
7038 updateRule(p, 0);
7039 fl_unfreeze_form(fd_pttEditor->pttEditor);
7040 }
7041 }
7042 p->num_categories = num;
7043 return;
7044 }
7045
7046 void doMinUnitsInput(FL_OBJECT *obj, long param)
7047 {
7048 ptt_t *p = &IFC_pttEditor;
7049
7050 p->min_units = intInput(obj, 0, MAXVAL_MINUNITS, "%d");
7051 return;
7052 }
7053
7054 void doMinCostInput(FL_OBJECT *obj, long param)
7055 {
7056 ptt_t *p = &IFC_pttEditor;
7057
7058 p->min_cost = floatInput(obj, 0, 0, "%g");
7059 return;
7060 }
7061
7062 void doCSecondsInput(FL_OBJECT *obj, long param)
7063 {
7064 ptt_t *p = &IFC_pttEditor;
7065
7066 if (p->attribs & (PTT_PER_MINUTE|PTT_PER_SECS))
7067 p->charge_period = intInput(obj, 1, 60, "%d");
7068 else
7069 p->charge_period = intInput(obj, 0, 0, "%d");
7070 return;
7071 }
7072
7073 void doUnitPriceInput(FL_OBJECT *obj, long param)
7074 {
7075 ptt_t *p = &IFC_pttEditor;
7076
7077 p->cost_quantum = floatInput(obj, 0, 0, "%g");
7078 return;
7079 }
7080
7081 void doCurrencyInput(FL_OBJECT *obj, long param)
7082 {
7083 ptt_t *p = &IFC_pttEditor;
7084 char str[64+MAXLEN_CURRENCY] = {0};
7085
7086 strncpy(p->currency, (char *)fl_get_input(obj), MAXLEN_CURRENCY);
7087 if (p->attribs & (PTT_PER_MINUTE|PTT_PER_SECS)) {
7088 sprintf(str, CTIME_STR, p->currency);
7089 fl_set_object_label(fd_pttEditor->defaultTariffUnits, str);
7090 fl_set_object_label(fd_pttEditor->ruleTariffUnits, str);
7091 }
7092 return;
7093 }
7094
7095 void doDecimalsInput(FL_OBJECT *obj, long param)
7096 {
7097 ptt_t *p = &IFC_pttEditor;
7098
7099 p->decimals = intInput(obj, 0, MAXNUM_DECIMALS, "%d");
7100 return;
7101 }
7102
7103 void doBaseChargeInput(FL_OBJECT *obj, long param)
7104 {
7105 ptt_t *p = &IFC_pttEditor;
7106 float num;
7107
7108 num = floatInput(obj, 0, 0, "%g");
7109 p->dflt_tariff[p->current_zone] = num;
7110 return;
7111 }
7112
7113 void doRuleChargeInput(FL_OBJECT *obj, long param)
7114 {
7115 ptt_t *p = &IFC_pttEditor;
7116 float num;
7117
7118 num = floatInput(obj, 0, 0, "%g");
7119 p->rule[p->current_zone][fd_pttEditor->ldata].tariff = num;
7120 return;
7121 }
7122
7123 void doRelDateInput(FL_OBJECT *obj, long param)
7124 {
7125 ptt_t *p = &IFC_pttEditor;
7126
7127 p->rule[p->current_zone][fd_pttEditor->ldata].rdate =
7128 intInput(obj, MINVAL_RELDATE, MAXVAL_RELDATE, "%d");
7129 return;
7130 }
7131
7132 void doMLSecondsInput(FL_OBJECT *obj, long param)
7133 {
7134 ptt_t *p = &IFC_pttEditor;
7135
7136 p->min_cost_len[p->current_zone] =
7137 floatInput(obj, 0, MAXSEC_MINCOSTLEN, "%g");
7138 return;
7139 }
7140
7141 void doDiscountInput(FL_OBJECT *obj, long param)
7142 {
7143 ptt_t *p = &IFC_pttEditor;
7144
7145 p->discount[p->current_zone].percent = floatInput(obj, 0.0, 99.0, "%g");
7146 fl_freeze_form(fd_pttEditor->pttEditor);
7147 updateZone(p);
7148 updateRule(p, 0);
7149 fl_unfreeze_form(fd_pttEditor->pttEditor);
7150 return;
7151 }
7152
7153 void doZEDYesButton(FL_OBJECT *obj, long param)
7154 {
7155 ptt_t *p = &IFC_pttEditor;
7156
7157 p->discount[p->current_zone].percent = 50.0; /* 1/2 price, for fun :) */
7158 fl_freeze_form(fd_pttEditor->pttEditor);
7159 updateZone(p);
7160 updateRule(p, 0);
7161 fl_unfreeze_form(fd_pttEditor->pttEditor);
7162 return;
7163 }
7164
7165 void doZEDNoButton(FL_OBJECT *obj, long param)
7166 {
7167 ptt_t *p = &IFC_pttEditor;
7168
7169 p->discount[p->current_zone].percent = 0.0;
7170 fl_freeze_form(fd_pttEditor->pttEditor);
7171 updateZone(p);
7172 updateRule(p, 0);
7173 fl_unfreeze_form(fd_pttEditor->pttEditor);
7174 return;
7175 }
7176
7177 void doRDYesButton(FL_OBJECT *obj, long param)
7178 {
7179 ptt_t *p = &IFC_pttEditor;
7180
7181 p->rule[p->current_zone][fd_pttEditor->ldata].type |= DISCOUNT_PERMITTED;
7182 return;
7183 }
7184
7185 void doRDNoButton(FL_OBJECT *obj, long param)
7186 {
7187 ptt_t *p = &IFC_pttEditor;
7188
7189 p->rule[p->current_zone][fd_pttEditor->ldata].type &= ~DISCOUNT_PERMITTED;
7190 return;
7191 }
7192
7193 void doZMLYesButton(FL_OBJECT *obj, long param)
7194 {
7195 ptt_t *p = &IFC_pttEditor;
7196
7197 p->rule[p->current_zone][fd_pttEditor->ldata].type |= DEFEAT_MIN_TIME_LEN;
7198 return;
7199 }
7200
7201 void doZMLNoButton(FL_OBJECT *obj, long param)
7202 {
7203 ptt_t *p = &IFC_pttEditor;
7204
7205 p->rule[p->current_zone][fd_pttEditor->ldata].type &= ~DEFEAT_MIN_TIME_LEN;
7206 return;
7207 }
7208
7209 void doTButton(FL_OBJECT *obj, long param)
7210 {
7211 ptt_t *p = &IFC_pttEditor;
7212 rule_t *r = &(p->rule[p->current_zone][fd_pttEditor->ldata]);
7213
7214 r->type &= 0x0C0;
7215 r->type |= (0x03F & param);
7216 fl_freeze_form(fd_pttEditor->pttEditor);
7217 updateRule(p, 0);
7218 fl_unfreeze_form(fd_pttEditor->pttEditor);
7219 return;
7220 }
7221
7222 void doRSInput(FL_OBJECT *obj, long param)
7223 {
7224 ptt_t *p = &IFC_pttEditor;
7225 rule_t *r = &(p->rule[p->current_zone][fd_pttEditor->ldata]);
7226 int max;
7227
7228 switch (param) {
7229 case 0:
7230 r->start.h = intInput(obj, 0, r->end.h, "%02d");
7231 if (r->start.h == 24) {
7232 fl_set_input(fd_pttEditor->RSMInput, "00");
7233 fl_redraw_object(fd_pttEditor->RSMInput);
7234 r->start.m = 0;
7235 fl_set_input(fd_pttEditor->RSSInput, "00");
7236 fl_redraw_object(fd_pttEditor->RSSInput);
7237 r->start.s = 0;
7238 }
7239 break;
7240
7241 case 1:
7242 if (r->start.h < 24) max = (r->start.h < r->end.h)? 59 : r->end.m;
7243 else max = 0;
7244 r->start.m = intInput(obj, 0, max, "%02d");
7245 break;
7246
7247 case 2:
7248 if (r->start.h < 24) {
7249 if (r->start.h < r->end.h) max = 59;
7250 else max = (r->start.m < r->end.m)? 59 : r->end.s;
7251 }
7252 else max = 0;
7253 r->start.s = intInput(obj, 0, max, "%02d");
7254 break;
7255
7256 default: break;
7257 }
7258 return;
7259 }
7260
7261 void doREInput(FL_OBJECT *obj, long param)
7262 {
7263 ptt_t *p = &IFC_pttEditor;
7264 rule_t *r = &(p->rule[p->current_zone][fd_pttEditor->ldata]);
7265 int min;
7266
7267 switch (param) {
7268 case 0:
7269 r->end.h = intInput(obj, r->start.h, 24, "%02d");
7270 if (r->end.h == 24) {
7271 fl_set_input(fd_pttEditor->REMInput, "00");
7272 fl_redraw_object(fd_pttEditor->REMInput);
7273 r->end.m = 0;
7274 fl_set_input(fd_pttEditor->RESInput, "00");
7275 fl_redraw_object(fd_pttEditor->RESInput);
7276 r->end.s = 0;
7277 }
7278 break;
7279
7280 case 1:
7281 min = (r->start.h < r->end.h)? 0 : r->start.m;
7282 r->end.m = intInput(obj, min, (r->end.h<24)? 59:0, "%02d");
7283 break;
7284
7285 case 2:
7286 if (r->start.h < r->end.h) min = 0;
7287 else min = (r->start.m < r->end.m)? 0 : r->start.s;
7288 r->end.s = intInput(obj, min, (r->end.h<24)? 59:0, "%02d");
7289 break;
7290
7291 default: break;
7292 }
7293 return;
7294 }
7295
7296 void doZSInput(FL_OBJECT *obj, long param)
7297 {
7298 ptt_t *p = &IFC_pttEditor;
7299 discount_t *d = &(p->discount[p->current_zone]);
7300 int max;
7301
7302 switch (param) {
7303 case 0:
7304 d->start.h = intInput(obj, 0, d->end.h, "%02d");
7305 if (d->start.h == 24) {
7306 fl_set_input(fd_pttEditor->ZSMInput, "00");
7307 fl_redraw_object(fd_pttEditor->ZSMInput);
7308 d->start.m = 0;
7309 fl_set_input(fd_pttEditor->ZSSInput, "00");
7310 fl_redraw_object(fd_pttEditor->ZSSInput);
7311 d->start.s = 0;
7312 }
7313 break;
7314
7315 case 1:
7316 if (d->start.h < 24) max = (d->start.h < d->end.h)? 59 : d->end.m;
7317 else max = 0;
7318 d->start.m = intInput(obj, 0, max, "%02d");
7319 break;
7320
7321 case 2:
7322 if (d->start.h < 24) {
7323 if (d->start.h < d->end.h) max = 59;
7324 else max = (d->start.m < d->end.m)? 59 : d->end.s;
7325 }
7326 else max = 0;
7327 d->start.s = intInput(obj, 0, max, "%02d");
7328 break;
7329
7330 default: break;
7331 }
7332 return;
7333 }
7334
7335 void doZEInput(FL_OBJECT *obj, long param)
7336 {
7337 ptt_t *p = &IFC_pttEditor;
7338 discount_t *d = &(p->discount[p->current_zone]);
7339 int min;
7340
7341 switch (param) {
7342 case 0:
7343 d->end.h = intInput(obj, d->start.h, 24, "%02d");
7344 if (d->end.h == 24) {
7345 fl_set_input(fd_pttEditor->ZEMInput, "00");
7346 fl_redraw_object(fd_pttEditor->ZEMInput);
7347 d->end.m = 0;
7348 fl_set_input(fd_pttEditor->ZESInput, "00");
7349 fl_redraw_object(fd_pttEditor->ZESInput);
7350 d->end.s = 0;
7351 }
7352 break;
7353
7354 case 1:
7355 min = (d->start.h < d->end.h)? 0 : d->start.m;
7356 d->end.m = intInput(obj, min, (d->end.h<24)? 59:0, "%02d");
7357 break;
7358
7359 case 2:
7360 if (d->start.h < d->end.h) min = 0;
7361 else min = (d->start.m < d->end.m)? 0 : d->start.s;
7362 d->end.s = intInput(obj, min, (d->end.h<24)? 59:0, "%02d");
7363 break;
7364
7365 default: break;
7366 }
7367 return;
7368 }
7369
7370 void doRDInput(FL_OBJECT *obj, long param)
7371 {
7372 ptt_t *p = &IFC_pttEditor;
7373 rule_t *r = &(p->rule[p->current_zone][fd_pttEditor->ldata]);
7374 int rt = (r->type & 0x03F), max = 1,
7375 dlim[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
7376
7377 switch (param) {
7378 case 0:
7379 max = (rt != RULE_SPECIAL_WEEKDAY && rt != RULE_SPECIAL_WEEKEND)?
7380 12 : 1+r->edate.mon;
7381 r->adate.mon = intInput(obj, 1, max, "%02d") - 1;
7382 break;
7383
7384 case 1:
7385 if (rt != RULE_SPECIAL_WEEKDAY && rt != RULE_SPECIAL_WEEKEND)
7386 max = dlim[r->adate.mon];
7387 else
7388 max = (r->adate.mon != r->edate.mon)?
7389 dlim[r->adate.mon] : r->edate.day;
7390 r->adate.day = intInput(obj, 1, max, "%02d");
7391 break;
7392
7393 default: break;
7394 }
7395 return;
7396 }
7397
7398 void doRDEInput(FL_OBJECT *obj, long param)
7399 {
7400 ptt_t *p = &IFC_pttEditor;
7401 rule_t *r = &(p->rule[p->current_zone][fd_pttEditor->ldata]);
7402 int dlim[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
7403
7404 switch (param) {
7405 case 0:
7406 r->edate.mon = intInput(obj, 1+r->adate.mon, 12, "%02d") - 1;
7407 break;
7408
7409 case 1:
7410 r->edate.day = intInput(obj, (r->adate.mon != r->edate.mon)?
7411 1:r->adate.day, dlim[r->edate.mon], "%02d");
7412 break;
7413
7414 default: break;
7415 }
7416 return;
7417 }
7418
7419 void doZonePick(FL_OBJECT *obj, long param)
7420 {
7421 ptt_t *p = &IFC_pttEditor;
7422 int zn;
7423
7424 if ((zn = fl_get_browser(obj))) {
7425 fl_call_object_callback(fd_pttEditor->baseChargeInput);
7426 fl_call_object_callback(fd_pttEditor->MLSecondsInput);
7427 fl_call_object_callback(fd_pttEditor->discountInput);
7428 fl_call_object_callback(fd_pttEditor->ZSHInput);
7429 fl_call_object_callback(fd_pttEditor->ZSMInput);
7430 fl_call_object_callback(fd_pttEditor->ZSSInput);
7431 fl_call_object_callback(fd_pttEditor->ZEHInput);
7432 fl_call_object_callback(fd_pttEditor->ZEMInput);
7433 fl_call_object_callback(fd_pttEditor->ZESInput);
7434 fl_call_object_callback(fd_pttEditor->ruleChargeInput);
7435 fl_call_object_callback(fd_pttEditor->RDMInput);
7436 fl_call_object_callback(fd_pttEditor->RDDInput);
7437 fl_call_object_callback(fd_pttEditor->RDEMInput);
7438 fl_call_object_callback(fd_pttEditor->RDEDInput);
7439 fl_call_object_callback(fd_pttEditor->relDateInput);
7440 fl_call_object_callback(fd_pttEditor->RSHInput);
7441 fl_call_object_callback(fd_pttEditor->RSMInput);
7442 fl_call_object_callback(fd_pttEditor->RSSInput);
7443 fl_call_object_callback(fd_pttEditor->REHInput);
7444 fl_call_object_callback(fd_pttEditor->REMInput);
7445 fl_call_object_callback(fd_pttEditor->RESInput);
7446 p->current_zone = zn - 1;
7447 fl_freeze_form(fd_pttEditor->pttEditor);
7448 updateZone(p);
7449 updateRule(p, 1);
7450 fl_unfreeze_form(fd_pttEditor->pttEditor);
7451 }
7452 return;
7453 }
7454
7455 void doZonePickNEdit(FL_OBJECT *obj, long param)
7456 {
7457 ptt_t *p = &IFC_pttEditor;
7458
7459 fl_call_object_callback(fd_pttEditor->zonePick);
7460 fl_deactivate_form(fd_pttEditor->pttEditor);
7461 fl_set_input(fd_renameZone->zoneNameInput, p->zone_name[p->current_zone]);
7462 fl_show_form(fd_renameZone->renameZone, FL_PLACE_MOUSE,
7463 FL_TRANSIENT, "Edit zone name");
7464 return;
7465 }
7466
7467 void doZoneNameInput(FL_OBJECT *obj, long param)
7468 {
7469 static char name[MAXLEN_ZNAME+1];
7470
7471 strncpy(name, fl_get_input(obj), MAXLEN_ZNAME);
7472 fd_renameZone->cdata = name;
7473 return;
7474 }
7475
7476 void doZoneNameEditOK(FL_OBJECT *obj, long param)
7477 {
7478 ptt_t *p = &IFC_pttEditor;
7479 char dflt[16] = {0};
7480
7481 fl_call_object_callback(fd_renameZone->zoneNameInput);
7482 if (*(fd_renameZone->cdata)) {
7483 strncpy(p->zone_name[p->current_zone],
7484 fd_renameZone->cdata, MAXLEN_ZNAME);
7485 fl_replace_browser_line(fd_pttEditor->zonePick, 1+p->current_zone,
7486 p->zone_name[p->current_zone]);
7487 fl_hide_form(fd_renameZone->renameZone);
7488 fl_activate_form(fd_pttEditor->pttEditor);
7489 }
7490 else {
7491 XBell(fl_get_display(), 50);
7492 sprintf(dflt, "Zone %d", 1+p->current_zone);
7493 fl_set_input(obj, dflt);
7494 fl_redraw_object(obj);
7495 }
7496 return;
7497 }
7498
7499 void doZoneNameEditCancel(FL_OBJECT *obj, long param)
7500 {
7501 fl_hide_form(fd_renameZone->renameZone);
7502 fl_activate_form(fd_pttEditor->pttEditor);
7503 return;
7504 }
7505
7506 void doPttEditOK(FL_OBJECT *obj, long param)
7507 {
7508 unsigned char sPTT = ((unsigned)fd_logInfo->ldata & 0x00FF0000) >> 16;
7509 unsigned char cZone = ((unsigned)fd_logInfo->ldata & 0x0FF000000) >> 24;
7510 ptt_t *p = &IFC_pttEditor;
7511 int i;
7512
7513 fl_call_object_callback(fd_pttEditor->pttNameInput);
7514 fl_call_object_callback(fd_pttEditor->zonesInput);
7515 fl_call_object_callback(fd_pttEditor->categoriesInput);
7516 fl_call_object_callback(fd_pttEditor->minUnitsInput);
7517 fl_call_object_callback(fd_pttEditor->minCostInput);
7518 fl_call_object_callback(fd_pttEditor->CSecondsInput);
7519 fl_call_object_callback(fd_pttEditor->unitPriceInput);
7520 fl_call_object_callback(fd_pttEditor->currencyInput);
7521 fl_call_object_callback(fd_pttEditor->decimalsInput);
7522 fl_call_object_callback(fd_pttEditor->baseChargeInput);
7523 fl_call_object_callback(fd_pttEditor->MLSecondsInput);
7524 fl_call_object_callback(fd_pttEditor->discountInput);
7525 fl_call_object_callback(fd_pttEditor->ZSHInput);
7526 fl_call_object_callback(fd_pttEditor->ZSMInput);
7527 fl_call_object_callback(fd_pttEditor->ZSSInput);
7528 fl_call_object_callback(fd_pttEditor->ZEHInput);
7529 fl_call_object_callback(fd_pttEditor->ZEMInput);
7530 fl_call_object_callback(fd_pttEditor->ZESInput);
7531 fl_call_object_callback(fd_pttEditor->ruleChargeInput);
7532 fl_call_object_callback(fd_pttEditor->RDMInput);
7533 fl_call_object_callback(fd_pttEditor->RDDInput);
7534 fl_call_object_callback(fd_pttEditor->RDEMInput);
7535 fl_call_object_callback(fd_pttEditor->RDEDInput);
7536 fl_call_object_callback(fd_pttEditor->relDateInput);
7537 fl_call_object_callback(fd_pttEditor->RSHInput);
7538 fl_call_object_callback(fd_pttEditor->RSMInput);
7539 fl_call_object_callback(fd_pttEditor->RSSInput);
7540 fl_call_object_callback(fd_pttEditor->REHInput);
7541 fl_call_object_callback(fd_pttEditor->REMInput);
7542 fl_call_object_callback(fd_pttEditor->RESInput);
7543 if (cZone > p->num_zones-1) {
7544 XBell(fl_get_display(), 50);
7545 cZone = p->num_zones - 1;
7546 }
7547 p->current_zone = cZone;
7548 ptt[sPTT] = *p;
7549 fd_logInfo->vdata = (void *)1; /* indicate change in PTT database */
7550 fl_clear_choice(fd_logInfo->pttDropChoice);
7551 for (i=0; i<global.numPTTs; i++)
7552 fl_addto_choice(fd_logInfo->pttDropChoice,
7553 clipStr(ptt[i].name, FL_NORMAL_SIZE,
7554 FL_NORMAL_STYLE, 240));
7555 fl_set_choice(fd_logInfo->pttDropChoice, sPTT+1);
7556 fl_clear_choice(fd_logInfo->zoneDropChoice);
7557 for (i=0; i<p->num_zones; i++)
7558 fl_addto_choice(fd_logInfo->zoneDropChoice,
7559 clipStr(p->zone_name[i], FL_NORMAL_SIZE,
7560 FL_NORMAL_STYLE, 240));
7561 fl_set_choice(fd_logInfo->zoneDropChoice,p->current_zone+1);
7562 showPttInfo(p);
7563 fl_hide_form(fd_pttEditor->pttEditor);
7564 fl_activate_form(fd_logInfo->logInfo);
7565 return;
7566 }
7567
7568 void doPttEditCancel(FL_OBJECT *obj, long param)
7569 {
7570 fl_hide_form(fd_pttEditor->pttEditor);
7571 fl_activate_form(fd_logInfo->logInfo);
7572 return;
7573 }
7574
7575 void doPttEditHelp(FL_OBJECT *obj, long param)
7576 {
7577 int i;
7578
7579 fl_clear_browser(fd_helpInfo->helpBrowser);
7580 for (i=0; i<MAXNUM_PE_HELPLINES; i++)
7581 fl_add_browser_line(fd_helpInfo->helpBrowser,
7582 PEHelpText[i]);
7583 fl_show_form(fd_helpInfo->helpInfo, FL_PLACE_MOUSE,
7584 FL_TRANSIENT, "PTT Editor Help");
7585 return;
7586 }
7587
7588
7589 /*+-------------------------------------------------------------------------+
7590 | |
7591 | Callback and utility routines for envInfo |
7592 | |
7593 +-------------------------------------------------------------------------+*/
7594
7595 char *statStr(char *path, char *tail)
7596 {
7597 char test[MAXLEN_FNAME];
7598 static char stat[8];
7599
7600 strcpy(test, path); strcat(test, tail);
7601 #ifdef RUNASEUID
7602 if (xisp_euidaccess(test, X_OK) < 0)
7603 #else
7604 if (access(test, X_OK) < 0)
7605 #endif
7606 strcpy(stat, "Error");
7607 else
7608 strcpy(stat, "OK");
7609 return stat;
7610 }
7611
7612 void doEnvInfoTip(FL_OBJECT *obj, long param)
7613 {
7614 alertMessage("Environment setup hints", 1, 0,
7615 "It is very important to enter the correct path to the location where\n"
7616 "xisp will find the \"pppd process ID files\". The \"Status\" check for\n"
7617 "this particular field only verifies the existence of the directory, as\n"
7618 "no check for process ID files is possible without an active PPP\n"
7619 "connection. Due to this fact it might be that, even though the\n"
7620 "directory exists, your pppd binary is compiled to save its ppp?.pid\n"
7621 "files elsewhere. Please consult with your pppd documentation and\n"
7622 "make sure this entry is correct, otherwise abnormal xisp behavior\n"
7623 "will most certainly occur. The default paths, hard-coded at compile\n"
7624 "time for each supported operating system, are usually correct but\n"
7625 "not 100% guaranteed to work; if you experience weird behavior,\n"
7626 "look here first.");
7627 }
7628
7629 void doPppdPathInput(FL_OBJECT *obj, long param)
7630 {
7631 glob_t *g = &IFC_envInfo;
7632
7633 strncpy(g->pppdPath, fl_get_input(obj), MAXLEN_PATH);
7634 fl_set_object_label(fd_envInfo->pppdStatus, statStr(g->pppdPath, PPPD));
7635 return;
7636 }
7637
7638 void doPppdDefault(FL_OBJECT *obj, long param)
7639 {
7640 fl_set_input(fd_envInfo->pppdPathInput, PPPD_PATH);
7641 fl_call_object_callback(fd_envInfo->pppdPathInput);
7642 return;
7643 }
7644
7645 void doRunPathInput(FL_OBJECT *obj, long param)
7646 {
7647 glob_t *g = &IFC_envInfo;
7648
7649 strncpy(g->runPath, fl_get_input(obj), MAXLEN_PATH);
7650 fl_set_object_label(fd_envInfo->runStatus, statStr(g->runPath, ""));
7651 return;
7652 }
7653
7654 void doRunDefault(FL_OBJECT *obj, long param)
7655 {
7656 fl_set_input(fd_envInfo->runPathInput, RUN_PATH);
7657 fl_call_object_callback(fd_envInfo->runPathInput);
7658 return;
7659 }
7660
7661 void doLockPathInput(FL_OBJECT *obj, long param)
7662 {
7663 glob_t *g = &IFC_envInfo;
7664
7665 strncpy(g->lockPath, fl_get_input(obj), MAXLEN_PATH);
7666 fl_set_object_label(fd_envInfo->lockStatus, statStr(g->lockPath, ""));
7667 return;
7668 }
7669
7670 void doLockDefault(FL_OBJECT *obj, long param)
7671 {
7672 fl_set_input(fd_envInfo->lockPathInput, LOCK_PATH);
7673 fl_call_object_callback(fd_envInfo->lockPathInput);
7674 return;
7675 }
7676
7677 void doChatPathInput(FL_OBJECT *obj, long param)
7678 {
7679 glob_t *g = &IFC_envInfo;
7680
7681 strncpy(g->chatPath, fl_get_input(obj), MAXLEN_PATH);
7682 fl_set_object_label(fd_envInfo->chatStatus, statStr(g->chatPath, CHAT));
7683 return;
7684 }
7685
7686 void doChatDefault(FL_OBJECT *obj, long param)
7687 {
7688 fl_set_input(fd_envInfo->chatPathInput, CHAT_PATH);
7689 fl_call_object_callback(fd_envInfo->chatPathInput);
7690 return;
7691 }
7692
7693 void doXispUtilsPathInput(FL_OBJECT *obj, long param)
7694 {
7695 glob_t *g = &IFC_envInfo;
7696 char *pc;
7697
7698 strncpy(g->utilsPath, fl_get_input(obj), MAXLEN_PATH);
7699 fl_set_object_label(fd_envInfo->utilsStatus,
7700 pc = statStr(g->utilsPath, PPPD_CONNECT));
7701 if (strcmp(pc, "Error")) {
7702 fl_set_object_label(fd_envInfo->utilsStatus,
7703 pc = statStr(g->utilsPath, TERMINAL));
7704 }
7705 return;
7706 }
7707
7708 void doXispUtilsDefault(FL_OBJECT *obj, long param)
7709 {
7710 fl_set_input(fd_envInfo->xispUtilsPathInput, UTILS_PATH);
7711 fl_call_object_callback(fd_envInfo->xispUtilsPathInput);
7712 return;
7713 }
7714
7715 void doPipePathInput(FL_OBJECT *obj, long param)
7716 {
7717 glob_t *g = &IFC_envInfo;
7718
7719 strncpy(g->pipePath, fl_get_input(obj), MAXLEN_PATH);
7720 return;
7721 }
7722
7723 void doPipeDefault(FL_OBJECT *obj, long param)
7724 {
7725 fl_set_input(fd_envInfo->pipePathInput, PIPE_PATH);
7726 fl_call_object_callback(fd_envInfo->pipePathInput);
7727 return;
7728 }
7729
7730 void doEnvInfoOK(FL_OBJECT *obj, long done)
7731 {
7732 glob_t *g = &IFC_envInfo;
7733 char msg[512];
7734
7735 fl_call_object_callback(fd_envInfo->pppdPathInput);
7736 fl_call_object_callback(fd_envInfo->runPathInput);
7737 fl_call_object_callback(fd_envInfo->lockPathInput);
7738 fl_call_object_callback(fd_envInfo->chatPathInput);
7739 fl_call_object_callback(fd_envInfo->xispUtilsPathInput);
7740 fl_call_object_callback(fd_envInfo->pipePathInput);
7741 global = *g;
7742 initUDFnames(g);
7743 if (!nohints && (pppdVersion().major > 2 || pppdVersion().minor > 2)) {
7744 sprintf(msg, "Please make sure that the peer information\n"
7745 "file xisp_dialer exists in pppd's peers directory\n"
7746 "(most probably /etc/ppp/peers -- read the pppd(8)\n"
7747 "manual page for details) -- and that it contains\n"
7748 "the line \"connect %s\"", Dialer);
7749 alertMessage("Setup hint", 1, 0, msg);
7750 }
7751 writeXisprc(rcfname, xispOptions, g);
7752 if (done) {
7753 fl_hide_form(fd_optsTab->optsTab);
7754 fl_activate_object(fd_topFrame->fileMenu);
7755 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
7756 }
7757 return;
7758 }
7759
7760 void doEnvInfoCancel(FL_OBJECT *obj, long param)
7761 {
7762 fl_hide_form(fd_optsTab->optsTab);
7763 fl_activate_object(fd_topFrame->fileMenu);
7764 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
7765 return;
7766 }
7767
7768
7769 /*+-------------------------------------------------------------------------+
7770 | |
7771 | Utility and callback routines for options tab folder |
7772 | |
7773 +-------------------------------------------------------------------------+*/
7774
7775 void prepFolderForm(int index)
7776 {
7777 int i, ml = p_xisprc->numSlines;
7778 char dflt[5], phone[MAXNUM_TELS*(MAXLEN_PHONE+1)+1] = {0},
7779 ppasswd[MAXLEN_PASSWD+1] = {0},
7780 slines[MAXNUM_SLINES*(MAXLEN_SLINE+1)] = {0},
7781 ipdns[MAXLEN_DNNAME+1] = {0}, speed[MAXDIG_BAUDRATE+1] = {0};
7782 unsigned int knownSpeed[MAXNUM_SPEEDS] = {MS_0, MS_1, MS_2, MS_3,
7783 MS_4, MS_5, MS_6, MS_7};
7784
7785 switch (index) {
7786
7787 case OPTIONS_ACCOUNT: {
7788 fl_deactivate_object(fd_accountInfo->accountInfoPaste);
7789 fl_set_object_lcol(fd_accountInfo->accountInfoPaste, FL_INACTIVE);
7790 fl_clear_browser(fd_accountInfo->ISPBrowser);
7791 if (global.numISPs < 1) {
7792 fl_deactivate_object(fd_accountInfo->accountInfoCopy);
7793 fl_set_object_lcol(fd_accountInfo->accountInfoCopy,
7794 FL_INACTIVE);
7795 fl_deactivate_object(fd_accountInfo->accountInfoDelete);
7796 fl_set_object_lcol(fd_accountInfo->accountInfoDelete,
7797 FL_INACTIVE);
7798 fl_deactivate_object(fd_accountInfo->ISPDefault);
7799 fl_set_object_lcol(fd_accountInfo->ISPDefault, FL_INACTIVE);
7800 fl_set_button(fd_accountInfo->ISPDefault, 0);
7801 fl_deactivate_object(fd_accountInfo->ISPAutoDial);
7802 fl_set_object_lcol(fd_accountInfo->ISPAutoDial, FL_INACTIVE);
7803 fl_set_button(fd_accountInfo->ISPAutoDial, 0);
7804 fl_deactivate_object(fd_accountInfo->autoRedial);
7805 fl_set_object_lcol(fd_accountInfo->autoRedial, FL_INACTIVE);
7806 fl_set_button(fd_accountInfo->autoRedial, 0);
7807 fl_deactivate_object(fd_accountInfo->authType);
7808 fl_set_object_lcol(fd_accountInfo->authType, FL_INACTIVE);
7809 fl_set_button(fd_accountInfo->authPAPButton, 0);
7810 fl_set_button(fd_accountInfo->authPAPSButton, 0);
7811 fl_set_button(fd_accountInfo->authCHAPSButton, 0);
7812 fl_set_button(fd_accountInfo->authNoneButton, 0);
7813 fl_deactivate_object(fd_accountInfo->telInput);
7814 fl_set_object_lcol(fd_accountInfo->telInput, FL_INACTIVE);
7815 fl_deactivate_object(fd_accountInfo->accInput);
7816 fl_set_object_lcol(fd_accountInfo->accInput, FL_INACTIVE);
7817 fl_deactivate_object(fd_accountInfo->pswInput);
7818 fl_set_object_lcol(fd_accountInfo->pswInput, FL_INACTIVE);
7819 fl_deactivate_object(fd_accountInfo->UNInput);
7820 fl_set_object_lcol(fd_accountInfo->UNInput, FL_INACTIVE);
7821 fl_deactivate_object(fd_accountInfo->remoteInput);
7822 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_INACTIVE);
7823 fl_deactivate_object(fd_accountInfo->ispPttDropChoice);
7824 fl_set_object_lcol(fd_accountInfo->ispPttDropChoice,
7825 FL_INACTIVE);
7826 fl_deactivate_object(fd_accountInfo->ispZoneDropChoice);
7827 fl_set_object_lcol(fd_accountInfo->ispZoneDropChoice,
7828 FL_INACTIVE);
7829 IFC_accountInfo.cur = IFC_accountInfo.dflt = 0;
7830 IFC_accountInfo.new = 0;
7831 IFC_accountInfo.modified = 0;
7832 IFC_accountInfo.descr[0] = 0;
7833 currentPTT = PTT_GR_EPAK;
7834 global.costPTT = currentPTT;
7835 }
7836 else {
7837 fl_activate_object(fd_accountInfo->accountInfoCopy);
7838 fl_set_object_lcol(fd_accountInfo->accountInfoCopy, FL_LCOL);
7839 fl_activate_object(fd_accountInfo->accountInfoDelete);
7840 fl_set_object_lcol(fd_accountInfo->accountInfoDelete, FL_LCOL);
7841 fl_activate_object(fd_accountInfo->ISPDefault);
7842 fl_set_object_lcol(fd_accountInfo->ISPDefault, FL_WHITE);
7843 fl_activate_object(fd_accountInfo->ISPAutoDial);
7844 fl_set_object_lcol(fd_accountInfo->ISPAutoDial, FL_WHITE);
7845 fl_activate_object(fd_accountInfo->autoRedial);
7846 fl_set_object_lcol(fd_accountInfo->autoRedial, FL_WHITE);
7847 fl_activate_object(fd_accountInfo->telInput);
7848 fl_set_object_lcol(fd_accountInfo->telInput, FL_WHITE);
7849 fl_activate_object(fd_accountInfo->authType);
7850 fl_set_object_lcol(fd_accountInfo->authType, FL_WHITE);
7851 adjustPAPCap();
7852 for (i=0; i<global.numISPs; i++)
7853 fl_add_browser_line(fd_accountInfo->ISPBrowser,
7854 xispOptions[i+1].descr);
7855 fl_set_browser_topline(fd_accountInfo->ISPBrowser,
7856 currentRC);
7857 fl_select_browser_line(fd_accountInfo->ISPBrowser, currentRC);
7858 fl_set_input(fd_renameISP->ISPNameInput,
7859 xispOptions[currentRC].descr);
7860 strcpy(IFC_accountInfo.descr, xispOptions[currentRC].descr);
7861 if (global.dfltISP == currentRC)
7862 fl_set_button(fd_accountInfo->ISPDefault, 1);
7863 else
7864 fl_set_button(fd_accountInfo->ISPDefault, 0);
7865 if (p_xisprc->operOpts & STARTUP_DIAL)
7866 fl_set_button(fd_accountInfo->ISPAutoDial, 1);
7867 else
7868 fl_set_button(fd_accountInfo->ISPAutoDial, 0);
7869 if (p_xisprc->operOpts & AUTO_REDIAL)
7870 fl_set_button(fd_accountInfo->autoRedial, 1);
7871 else
7872 fl_set_button(fd_accountInfo->autoRedial, 0);
7873 IFC_accountInfo.cur = currentRC;
7874 IFC_accountInfo.dflt = global.dfltISP;
7875 IFC_accountInfo.new = 0;
7876 IFC_accountInfo.modified = 0;
7877 for (i=0; i<p_xisprc->numPhones; i++) {
7878 if (i) strcat(phone, ";");
7879 strcat(phone, p_xisprc->phone[i]);
7880 }
7881 fl_set_input(fd_accountInfo->telInput, phone);
7882 fl_set_input(fd_accountInfo->accInput, p_xisprc->account);
7883 if (*(p_xisprc->account))
7884 pdecode(ppasswd, p_xisprc->passwd);
7885 fl_set_input(fd_accountInfo->pswInput, ppasswd);
7886 fl_set_input(fd_accountInfo->UNInput, p_xisprc->name);
7887 fl_set_input(fd_accountInfo->remoteInput, p_xisprc->rname);
7888 fl_set_button(fd_accountInfo->authPAPButton, 0);
7889 fl_set_button(fd_accountInfo->authPAPSButton, 0);
7890 fl_set_button(fd_accountInfo->authCHAPSButton, 0);
7891 fl_set_button(fd_accountInfo->authNoneButton, 0);
7892 if (p_xisprc->operOpts & PAP_LOGIN) {
7893 fl_set_button(fd_accountInfo->authPAPButton, 1);
7894 fl_activate_object(fd_accountInfo->accInput);
7895 fl_set_object_lcol(fd_accountInfo->accInput, FL_WHITE);
7896 fl_activate_object(fd_accountInfo->pswInput);
7897 fl_set_object_lcol(fd_accountInfo->pswInput, FL_WHITE);
7898 fl_deactivate_object(fd_accountInfo->UNInput);
7899 fl_set_object_lcol(fd_accountInfo->UNInput, FL_INACTIVE);
7900 fl_deactivate_object(fd_accountInfo->remoteInput);
7901 fl_set_object_lcol(fd_accountInfo->remoteInput,
7902 FL_INACTIVE);
7903 }
7904 else if (p_xisprc->operOpts & PAPS_LOGIN) {
7905 fl_set_button(fd_accountInfo->authPAPSButton, 1);
7906 fl_deactivate_object(fd_accountInfo->accInput);
7907 fl_set_object_lcol(fd_accountInfo->accInput, FL_INACTIVE);
7908 fl_deactivate_object(fd_accountInfo->pswInput);
7909 fl_set_object_lcol(fd_accountInfo->pswInput, FL_INACTIVE);
7910 fl_activate_object(fd_accountInfo->UNInput);
7911 fl_set_object_lcol(fd_accountInfo->UNInput, FL_WHITE);
7912 fl_activate_object(fd_accountInfo->remoteInput);
7913 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_WHITE);
7914 }
7915 else if (p_xisprc->operOpts & CHAPS_LOGIN) {
7916 fl_set_button(fd_accountInfo->authCHAPSButton, 1);
7917 fl_deactivate_object(fd_accountInfo->accInput);
7918 fl_set_object_lcol(fd_accountInfo->accInput, FL_INACTIVE);
7919 fl_deactivate_object(fd_accountInfo->pswInput);
7920 fl_set_object_lcol(fd_accountInfo->pswInput, FL_INACTIVE);
7921 fl_activate_object(fd_accountInfo->UNInput);
7922 fl_set_object_lcol(fd_accountInfo->UNInput, FL_WHITE);
7923 fl_activate_object(fd_accountInfo->remoteInput);
7924 fl_set_object_lcol(fd_accountInfo->remoteInput, FL_WHITE);
7925 }
7926 else {
7927 fl_set_button(fd_accountInfo->authNoneButton, 1);
7928 fl_activate_object(fd_accountInfo->accInput);
7929 fl_set_object_lcol(fd_accountInfo->accInput, FL_WHITE);
7930 fl_activate_object(fd_accountInfo->pswInput);
7931 fl_set_object_lcol(fd_accountInfo->pswInput, FL_WHITE);
7932 fl_deactivate_object(fd_accountInfo->UNInput);
7933 fl_set_object_lcol(fd_accountInfo->UNInput, FL_INACTIVE);
7934 fl_deactivate_object(fd_accountInfo->remoteInput);
7935 fl_set_object_lcol(fd_accountInfo->remoteInput,
7936 FL_INACTIVE);
7937 }
7938 currentPTT = p_xisprc->ispPTT;
7939 global.costPTT = currentPTT;
7940 }
7941 p_ptt = &ptt[currentPTT];
7942 p_ptt->current_zone = p_xisprc->ispZone;
7943 IFC_accountInfo.udata = currentPTT |
7944 (p_ptt->current_zone << 8);
7945 fl_clear_choice(fd_accountInfo->ispPttDropChoice);
7946 fl_clear_choice(fd_accountInfo->ispZoneDropChoice);
7947 if (!(global.logOpts & LOG_NONE) || (global.logOpts & COST_READOUT)
7948 )
7949 {
7950 fl_activate_object(fd_accountInfo->ispPttDropChoice);
7951 fl_set_object_lcol(fd_accountInfo->ispPttDropChoice,
7952 FL_WHITE);
7953 fl_activate_object(fd_accountInfo->ispZoneDropChoice);
7954 fl_set_object_lcol(fd_accountInfo->ispZoneDropChoice,
7955 FL_WHITE);
7956 for (i=0; i<global.numPTTs; i++)
7957 fl_addto_choice(fd_accountInfo->ispPttDropChoice,
7958 clipStr(ptt[i].name, FL_MEDIUM_SIZE,
7959 FL_BOLD_STYLE, 235));
7960 fl_set_choice(fd_accountInfo->ispPttDropChoice,
7961 currentPTT+1);
7962 for (i=0; i<p_ptt->num_zones; i++)
7963 fl_addto_choice(fd_accountInfo->ispZoneDropChoice,
7964 clipStr(p_ptt->zone_name[i], FL_MEDIUM_SIZE,
7965 FL_BOLD_STYLE, 235));
7966 fl_set_choice(fd_accountInfo->ispZoneDropChoice,
7967 p_ptt->current_zone+1);
7968 }
7969 else {
7970 fl_deactivate_object(fd_accountInfo->ispPttDropChoice);
7971 fl_set_object_lcol(fd_accountInfo->ispPttDropChoice,
7972 FL_INACTIVE);
7973 fl_deactivate_object(fd_accountInfo->ispZoneDropChoice);
7974 fl_set_object_lcol(fd_accountInfo->ispZoneDropChoice,
7975 FL_INACTIVE);
7976 }
7977 fd_accountInfo->ldata = p_xisprc->operOpts;
7978 fd_logInfo->vdata = NULL; /* used as ISP database resize flag */
7979 if (! nohints) fl_set_timer(fd_accountInfo->tipTimer, HINT_TRIGGER);
7980 break;
7981 }
7982
7983 case OPTIONS_DIALING: {
7984 sprintf(dflt, "%d", p_xisprc->maxAttempts);
7985 fl_set_input(fd_dialInfo->rtrInput, dflt);
7986 sprintf(dflt, "%d", p_xisprc->sleepDelay);
7987 fl_set_input(fd_dialInfo->dlyInput, dflt);
7988 sprintf(dflt, "%d", p_xisprc->connectWait);
7989 fl_set_input(fd_dialInfo->CNWaitInput, dflt);
7990 sprintf(dflt, "%d", p_xisprc->LCPWait);
7991 fl_set_input(fd_dialInfo->LCPWaitInput, dflt);
7992 if (p_xisprc->operOpts & MANUAL_LOGIN) {
7993 fl_set_button(fd_dialInfo->TTYesButton, 1);
7994 fl_set_button(fd_dialInfo->TTNoButton, 0);
7995 fl_activate_object(fd_dialInfo->TSGroup);
7996 fl_set_object_lcol(fd_dialInfo->TSGroup,FL_WHITE);
7997 fl_deactivate_object(fd_dialInfo->ALGroup);
7998 fl_set_object_lcol(fd_dialInfo->ALGroup,FL_INACTIVE);
7999 }
8000 else {
8001 fl_set_button(fd_dialInfo->TTYesButton, 0);
8002 fl_set_button(fd_dialInfo->TTNoButton, 1);
8003 fl_deactivate_object(fd_dialInfo->TSGroup);
8004 fl_set_object_lcol(fd_dialInfo->TSGroup,FL_INACTIVE);
8005 fl_activate_object(fd_dialInfo->ALGroup);
8006 fl_set_object_lcol(fd_dialInfo->ALGroup,FL_WHITE);
8007 }
8008 if (p_xisprc->operOpts & CALL_BACK) {
8009 fl_activate_object(fd_dialInfo->CBOptions);
8010 fl_set_object_lcol(fd_dialInfo->CBOptions,FL_LCOL);
8011 fl_set_button(fd_dialInfo->CBYesButton, 1);
8012 fl_set_button(fd_dialInfo->CBNoButton, 0);
8013 }
8014 else {
8015 fl_deactivate_object(fd_dialInfo->CBOptions);
8016 fl_set_object_lcol(fd_dialInfo->CBOptions,FL_INACTIVE);
8017 fl_set_button(fd_dialInfo->CBYesButton, 0);
8018 fl_set_button(fd_dialInfo->CBNoButton, 1);
8019 }
8020 if (p_xisprc->operOpts & CONNECT_BELL) {
8021 fl_set_button(fd_dialInfo->RBYesButton, 1);
8022 fl_set_button(fd_dialInfo->RBNoButton, 0);
8023 }
8024 else {
8025 fl_set_button(fd_dialInfo->RBYesButton, 0);
8026 fl_set_button(fd_dialInfo->RBNoButton, 1);
8027 }
8028 for (i=0; i<ml; i++) {
8029 strcat(slines, p_xisprc->sline[i]);
8030 if (i < (ml-1)) strcat(slines, "\n");
8031 }
8032 fl_set_input(fd_dialInfo->expectInput, slines);
8033 slines[0] = 0;
8034 for (i=0; i<ml; i++) {
8035 strcat(slines, p_xisprc->sline[MAXNUM_SLINES+i]);
8036 if (i < (ml-1)) strcat(slines, "\n");
8037 }
8038 fl_set_input(fd_dialInfo->sendInput, slines);
8039 wasTab = 0;
8040 sprintf(dflt, "%d", p_xisprc->termW);
8041 fl_set_input(fd_dialInfo->columnsInput, dflt);
8042 sprintf(dflt, "%d", p_xisprc->termH);
8043 fl_set_input(fd_dialInfo->rowsInput, dflt);
8044 fd_dialInfo->ldata = p_xisprc->operOpts;
8045 if (! nohints) fl_set_timer(fd_dialInfo->tipTimer, HINT_TRIGGER);
8046 break;
8047 }
8048
8049 case OPTIONS_COMM: {
8050 fl_set_input(fd_commInfo->deviceInput, p_xisprc->modemDevice);
8051 fl_set_input(fd_commInfo->modemResetInput,
8052 p_xisprc->modemReset);
8053 fl_set_input(fd_commInfo->modemInitInput,
8054 p_xisprc->modemInit);
8055 fl_set_input(fd_commInfo->modemConnectInput,
8056 p_xisprc->modemConnect);
8057 if (p_xisprc->operOpts & MODEM_TONEDIAL) {
8058 fl_set_button(fd_commInfo->toneButton, 1);
8059 fl_set_button(fd_commInfo->ISDNButton, 0);
8060 fl_set_button(fd_commInfo->pulseButton, 0);
8061 }
8062 else if (p_xisprc->operOpts & MODEM_ISDNDIAL) {
8063 fl_set_button(fd_commInfo->toneButton, 0);
8064 fl_set_button(fd_commInfo->ISDNButton, 1);
8065 fl_set_button(fd_commInfo->pulseButton, 0);
8066 }
8067 else {
8068 fl_set_button(fd_commInfo->toneButton, 0);
8069 fl_set_button(fd_commInfo->ISDNButton, 0);
8070 fl_set_button(fd_commInfo->pulseButton, 1);
8071 }
8072 adjustCompCap();
8073 if (p_xisprc->operOpts & BSD_COMPRESS) {
8074 fl_set_button(fd_commInfo->SWCBSDButton, 1);
8075 fl_set_button(fd_commInfo->SWCDeflateButton, 0);
8076 fl_set_button(fd_commInfo->SWCOffButton, 0);
8077 fl_activate_object(fd_commInfo->SWCInput);
8078 fl_set_object_lcol(fd_commInfo->SWCInput,FL_WHITE);
8079 }
8080 else if (p_xisprc->operOpts & DEFL_COMPRESS) {
8081 fl_set_button(fd_commInfo->SWCBSDButton, 0);
8082 fl_set_button(fd_commInfo->SWCDeflateButton, 1);
8083 fl_set_button(fd_commInfo->SWCOffButton, 0);
8084 fl_activate_object(fd_commInfo->SWCInput);
8085 fl_set_object_lcol(fd_commInfo->SWCInput,FL_WHITE);
8086 }
8087 else {
8088 fl_set_button(fd_commInfo->SWCBSDButton, 0);
8089 fl_set_button(fd_commInfo->SWCDeflateButton, 0);
8090 fl_set_button(fd_commInfo->SWCOffButton, 1);
8091 fl_deactivate_object(fd_commInfo->SWCInput);
8092 fl_set_object_lcol(fd_commInfo->SWCInput,FL_INACTIVE);
8093 }
8094 IFC_commInfo.custom = 1;
8095 for (i=0; i<MAXNUM_SPEEDS; i++) {
8096 if (p_xisprc->modemSpeed == knownSpeed[i]) {
8097 IFC_commInfo.custom = 0;
8098 fl_set_button(fd_commInfo->speedButton[i], 1);
8099 }
8100 else
8101 fl_set_button(fd_commInfo->speedButton[i], 0);
8102 }
8103 if (IFC_commInfo.custom) {
8104 fl_set_button(fd_commInfo->speedButton[MAXNUM_SPEEDS], 1);
8105 fl_activate_object(fd_commInfo->customSpeedInput);
8106 }
8107 else {
8108 fl_set_button(fd_commInfo->speedButton[MAXNUM_SPEEDS], 0);
8109 fl_deactivate_object(fd_commInfo->customSpeedInput);
8110 }
8111 IFC_commInfo.speed = p_xisprc->modemSpeed;
8112 sprintf(speed, "%u", p_xisprc->modemSpeed);
8113 fl_set_input(fd_commInfo->customSpeedInput, speed);
8114 if (p_xisprc->operOpts & HW_FLOWCTRL) {
8115 fl_set_button(fd_commInfo->HWButton, 1);
8116 fl_set_button(fd_commInfo->SWButton, 0);
8117 }
8118 else {
8119 fl_set_button(fd_commInfo->HWButton, 0);
8120 fl_set_button(fd_commInfo->SWButton, 1);
8121 }
8122 if (p_xisprc->operOpts & ESCAPE_ON) {
8123 fl_set_button(fd_commInfo->escapeYesButton, 1);
8124 fl_set_button(fd_commInfo->escapeNoButton, 0);
8125 fl_activate_object(fd_commInfo->escapeInput);
8126 fl_set_object_lcol(fd_commInfo->escapeInput,FL_WHITE);
8127 }
8128 else {
8129 fl_set_button(fd_commInfo->escapeYesButton, 0);
8130 fl_set_button(fd_commInfo->escapeNoButton, 1);
8131 fl_deactivate_object(fd_commInfo->escapeInput);
8132 fl_set_object_lcol(fd_commInfo->escapeInput,FL_INACTIVE);
8133 }
8134 sprintf(dflt, "%d", p_xisprc->compLevel);
8135 fl_set_input(fd_commInfo->SWCInput, dflt);
8136 IFC_commInfo.operOpts = p_xisprc->operOpts;
8137 fl_set_input(fd_commInfo->modemDialInput, p_xisprc->dialExtra);
8138 fl_set_input(fd_commInfo->asyncmapInput,
8139 p_xisprc->asyncmap);
8140 fl_set_input(fd_commInfo->escapeInput,
8141 p_xisprc->escape);
8142 if (! nohints) fl_set_timer(fd_commInfo->tipTimer, HINT_TRIGGER);
8143 break;
8144 }
8145
8146 case OPTIONS_TCPIP: {
8147 adjustAutoDNSCap();
8148 IPToStr(p_xisprc->localIP, ipdns);
8149 fl_set_input(fd_tcpipInfo->localIPInput, ipdns);
8150 IPToStr(p_xisprc->remoteIP, ipdns);
8151 fl_set_input(fd_tcpipInfo->remoteIPInput, ipdns);
8152 IPToStr(p_xisprc->netmask, ipdns);
8153 fl_set_input(fd_tcpipInfo->NMInput, ipdns);
8154 IPToStr(p_xisprc->dns1, ipdns);
8155 fl_set_input(fd_tcpipInfo->pDNSInput, ipdns);
8156 IPToStr(p_xisprc->dns2, ipdns);
8157 fl_set_input(fd_tcpipInfo->sDNSInput, ipdns);
8158 fl_set_input(fd_tcpipInfo->domainInput, p_xisprc->domainname);
8159 if (! strlen(p_xisprc->domainname))
8160 p_xisprc->operOpts &= ~DEFAULT_DOMAIN;
8161 if (p_xisprc->operOpts & ACCEPT_LOCALIP) {
8162 fl_set_button(fd_tcpipInfo->ALYesButton, 1);
8163 fl_set_button(fd_tcpipInfo->ALNoButton, 0);
8164 fl_deactivate_object(fd_tcpipInfo->localIPInput);
8165 fl_set_object_lcol(fd_tcpipInfo->localIPInput, FL_INACTIVE);
8166 }
8167 else {
8168 fl_set_button(fd_tcpipInfo->ALYesButton, 0);
8169 fl_set_button(fd_tcpipInfo->ALNoButton, 1);
8170 fl_activate_object(fd_tcpipInfo->localIPInput);
8171 fl_set_object_lcol(fd_tcpipInfo->localIPInput, FL_WHITE);
8172 }
8173 if (p_xisprc->operOpts & ACCEPT_REMOTEIP) {
8174 fl_set_button(fd_tcpipInfo->ARYesButton, 1);
8175 fl_set_button(fd_tcpipInfo->ARNoButton, 0);
8176 fl_deactivate_object(fd_tcpipInfo->remoteIPInput);
8177 fl_set_object_lcol(fd_tcpipInfo->remoteIPInput, FL_INACTIVE);
8178 }
8179 else {
8180 fl_set_button(fd_tcpipInfo->ARYesButton, 0);
8181 fl_set_button(fd_tcpipInfo->ARNoButton, 1);
8182 fl_activate_object(fd_tcpipInfo->remoteIPInput);
8183 fl_set_object_lcol(fd_tcpipInfo->remoteIPInput, FL_WHITE);
8184 }
8185 if (p_xisprc->operOpts & DEFAULT_ROUTE) {
8186 fl_set_button(fd_tcpipInfo->DRYesButton, 1);
8187 fl_set_button(fd_tcpipInfo->DRNoButton, 0);
8188 }
8189 else {
8190 fl_set_button(fd_tcpipInfo->DRYesButton, 0);
8191 fl_set_button(fd_tcpipInfo->DRNoButton, 1);
8192 }
8193 if (p_xisprc->operOpts & IP_UPDOWN) {
8194 fl_activate_object(fd_tcpipInfo->DNTypeGroup);
8195 fl_set_object_lcol(fd_tcpipInfo->DNTypeGroup,FL_WHITE);
8196 adjustAutoDNSCap();
8197 if (p_xisprc->operOpts & AUTO_DNS) {
8198 fl_set_button(fd_tcpipInfo->DNSNoButton, 0);
8199 fl_set_button(fd_tcpipInfo->DNSAutoButton, 1);
8200 fl_activate_object(fd_tcpipInfo->pDNSInput);
8201 fl_set_object_lcol(fd_tcpipInfo->pDNSInput,FL_WHITE);
8202 fl_activate_object(fd_tcpipInfo->sDNSInput);
8203 fl_set_object_lcol(fd_tcpipInfo->sDNSInput,FL_WHITE);
8204 fl_set_button(fd_tcpipInfo->DNSManualButton, 0);
8205 fl_deactivate_object(fd_tcpipInfo->pDNSInput);
8206 fl_set_object_lcol(fd_tcpipInfo->pDNSInput,FL_INACTIVE);
8207 fl_deactivate_object(fd_tcpipInfo->sDNSInput);
8208 fl_set_object_lcol(fd_tcpipInfo->sDNSInput,FL_INACTIVE);
8209 }
8210 else {
8211 fl_set_button(fd_tcpipInfo->DNSNoButton, 0);
8212 fl_set_button(fd_tcpipInfo->DNSAutoButton, 0);
8213 fl_deactivate_object(fd_tcpipInfo->pDNSInput);
8214 fl_set_object_lcol(fd_tcpipInfo->pDNSInput,FL_INACTIVE);
8215 fl_deactivate_object(fd_tcpipInfo->sDNSInput);
8216 fl_set_object_lcol(fd_tcpipInfo->sDNSInput,FL_INACTIVE);
8217 fl_set_button(fd_tcpipInfo->DNSManualButton, 1);
8218 fl_activate_object(fd_tcpipInfo->pDNSInput);
8219 fl_set_object_lcol(fd_tcpipInfo->pDNSInput,FL_WHITE);
8220 fl_activate_object(fd_tcpipInfo->sDNSInput);
8221 fl_set_object_lcol(fd_tcpipInfo->sDNSInput,FL_WHITE);
8222 }
8223 if (p_xisprc->operOpts & DEFAULT_DOMAIN) {
8224 fl_set_button(fd_tcpipInfo->DNNoButton, 0);
8225 fl_set_button(fd_tcpipInfo->DNYesButton, 1);
8226 fl_activate_object(fd_tcpipInfo->domainInput);
8227 fl_set_object_lcol(fd_tcpipInfo->domainInput,FL_WHITE);
8228 }
8229 else {
8230 fl_set_button(fd_tcpipInfo->DNNoButton, 1);
8231 fl_set_button(fd_tcpipInfo->DNYesButton, 0);
8232 fl_deactivate_object(fd_tcpipInfo->domainInput);
8233 fl_set_object_lcol(fd_tcpipInfo->domainInput,FL_INACTIVE);
8234 }
8235 }
8236 else {
8237 fl_set_button(fd_tcpipInfo->DNSNoButton, 1);
8238 fl_set_button(fd_tcpipInfo->DNSAutoButton, 0);
8239 fl_set_button(fd_tcpipInfo->DNSManualButton, 0);
8240 fl_deactivate_object(fd_tcpipInfo->pDNSInput);
8241 fl_set_object_lcol(fd_tcpipInfo->pDNSInput,FL_INACTIVE);
8242 fl_deactivate_object(fd_tcpipInfo->sDNSInput);
8243 fl_set_object_lcol(fd_tcpipInfo->sDNSInput,FL_INACTIVE);
8244 fl_deactivate_object(fd_tcpipInfo->pDNSInput);
8245 fl_set_object_lcol(fd_tcpipInfo->pDNSInput,FL_INACTIVE);
8246 fl_deactivate_object(fd_tcpipInfo->sDNSInput);
8247 fl_set_object_lcol(fd_tcpipInfo->sDNSInput,FL_INACTIVE);
8248 fl_set_button(fd_tcpipInfo->DNNoButton, 1);
8249 fl_set_button(fd_tcpipInfo->DNYesButton, 0);
8250 fl_deactivate_object(fd_tcpipInfo->DNTypeGroup);
8251 fl_set_object_lcol(fd_tcpipInfo->DNTypeGroup,FL_INACTIVE);
8252 fl_deactivate_object(fd_tcpipInfo->domainInput);
8253 fl_set_object_lcol(fd_tcpipInfo->domainInput,FL_INACTIVE);
8254 }
8255 fd_tcpipInfo->ldata = p_xisprc->operOpts;
8256 sprintf(dflt, "%d", p_xisprc->mtu);
8257 fl_set_input(fd_tcpipInfo->MTUInput, dflt);
8258 sprintf(dflt, "%d", p_xisprc->mru);
8259 fl_set_input(fd_tcpipInfo->MRUInput, dflt);
8260 if (! nohints) fl_set_timer(fd_tcpipInfo->tipTimer, HINT_TRIGGER);
8261 break;
8262 }
8263
8264 case OPTIONS_PATHS:{
8265 fl_set_input(fd_envInfo->pppdPathInput, global.pppdPath);
8266 fl_call_object_callback(fd_envInfo->pppdPathInput);
8267 fl_set_input(fd_envInfo->runPathInput, global.runPath);
8268 fl_call_object_callback(fd_envInfo->runPathInput);
8269 fl_set_input(fd_envInfo->lockPathInput, global.lockPath);
8270 fl_call_object_callback(fd_envInfo->lockPathInput);
8271 fl_set_input(fd_envInfo->chatPathInput, global.chatPath);
8272 fl_call_object_callback(fd_envInfo->chatPathInput);
8273 fl_set_input(fd_envInfo->xispUtilsPathInput, global.utilsPath);
8274 fl_call_object_callback(fd_envInfo->xispUtilsPathInput);
8275 fl_set_input(fd_envInfo->pipePathInput, global.pipePath);
8276 fl_call_object_callback(fd_envInfo->pipePathInput);
8277 IFC_envInfo = global;
8278 if (! nohints) fl_set_timer(fd_envInfo->tipTimer, HINT_TRIGGER);
8279 break;
8280 }
8281
8282 default: break;
8283 }
8284 return;
8285 }
8286
8287 int folderButtonPreH(FL_OBJECT *obj, int event, FL_COORD mx,
8288 FL_COORD my, int key, void *raw_event)
8289 {
8290 int current;
8291 accountInfo_t *a = &IFC_accountInfo;
8292 unsigned char sPTT = (unsigned)a->udata & 0x000000FF;
8293 int newCurrency = strcmp(ptt[currentPTT].currency,ptt[sPTT].currency);
8294
8295 switch (event) {
8296 case FL_PUSH:
8297 current = fl_get_active_folder_number(fd_optsTab->optsFolder);
8298 if (obj != fd_optsTab->accountInfoButton &&
8299 current == OPTIONS_ACCOUNT)
8300 {
8301 if (! newCurrency || (global.logOpts & LOG_NONE))
8302 return !FL_PREEMPT;
8303 if (actionVerify("The PTT for the selected ISP bills you in "
8304 "currency\nwhich is different from the one "
8305 "currently in use. This\nimplies resetting of "
8306 "log files, continue?", 0))
8307 {
8308 currentPTT = sPTT;
8309 global.costPTT = currentPTT;
8310 resetLogs();
8311 }
8312 else
8313 return FL_PREEMPT;
8314 }
8315 break;
8316
8317 default: break;
8318 }
8319 return !FL_PREEMPT;
8320 }
8321
8322 void doOptsFolder(FL_OBJECT *obj, long param)
8323 {
8324 int previous = fl_get_folder_number(obj),
8325 current = fl_get_active_folder_number(obj);
8326
8327 switch (previous) {
8328
8329 case OPTIONS_ACCOUNT: {
8330 doAccountOK(fd_optsTab->optsFolder, 0);
8331 break;
8332 }
8333
8334 case OPTIONS_DIALING: {
8335 doDialOK(fd_optsTab->optsFolder, 0);
8336 break;
8337 }
8338
8339 case OPTIONS_COMM: {
8340 doCommInfoOK(fd_optsTab->optsFolder, 0);
8341 break;
8342 }
8343
8344 case OPTIONS_TCPIP: {
8345 doTcpipInfoOK(fd_optsTab->optsFolder, 0);
8346 break;
8347 }
8348
8349 case OPTIONS_PATHS:{
8350 doEnvInfoOK(fd_optsTab->optsFolder, 0);
8351 break;
8352 }
8353
8354 default: break;
8355 }
8356 prepFolderForm(current);
8357 return;
8358 }
8359
8360 void doOptsTabDone(FL_OBJECT *obj, long param)
8361 {
8362 accountInfo_t *a = &IFC_accountInfo;
8363 unsigned char sPTT = (unsigned)a->udata & 0x000000FF;
8364 int newCurrency = strcmp(ptt[currentPTT].currency,ptt[sPTT].currency);
8365
8366 switch (fl_get_active_folder_number(fd_optsTab->optsFolder)) {
8367
8368 case OPTIONS_ACCOUNT: {
8369 if (!(global.logOpts & LOG_NONE) && newCurrency &&
8370 ! actionVerify("The PTT for the selected ISP bills you in "
8371 "currency\nwhich is different from the one "
8372 "currently in use. This\nimplies resetting of "
8373 "log files, continue?", 0)
8374 )
8375 break;
8376 if (!(global.logOpts & LOG_NONE) && newCurrency)
8377 resetLogs();
8378 doAccountOK(fd_optsTab->optsFolder, 1);
8379 break;
8380 }
8381
8382 case OPTIONS_DIALING: {
8383 doDialOK(fd_optsTab->optsFolder, 1);
8384 break;
8385 }
8386
8387 case OPTIONS_COMM: {
8388 doCommInfoOK(fd_optsTab->optsFolder, 1);
8389 break;
8390 }
8391
8392 case OPTIONS_TCPIP: {
8393 doTcpipInfoOK(fd_optsTab->optsFolder, 1);
8394 break;
8395 }
8396
8397 case OPTIONS_PATHS:{
8398 doEnvInfoOK(fd_optsTab->optsFolder, 1);
8399 break;
8400 }
8401
8402 default: break;
8403 }
8404 return;
8405 }
8406
8407 void doOptsTabCancel(FL_OBJECT *obj, long param)
8408 {
8409 switch (fl_get_active_folder_number(fd_optsTab->optsFolder)) {
8410
8411 case OPTIONS_ACCOUNT: {
8412 doAccountCancel(fd_optsTab->optsFolder, 0);
8413 break;
8414 }
8415
8416 case OPTIONS_DIALING: {
8417 doDialCancel(fd_optsTab->optsFolder, 0);
8418 break;
8419 }
8420
8421 case OPTIONS_COMM: {
8422 doCommInfoCancel(fd_optsTab->optsFolder, 0);
8423 break;
8424 }
8425
8426 case OPTIONS_TCPIP: {
8427 doTcpipInfoCancel(fd_optsTab->optsFolder, 0);
8428 break;
8429 }
8430
8431 case OPTIONS_PATHS:{
8432 doEnvInfoCancel(fd_optsTab->optsFolder, 0);
8433 break;
8434 }
8435
8436 default: break;
8437 }
8438 return;
8439 }
8440
8441
8442 /*+-------------------------------------------------------------------------+
8443 | |
8444 | WM client message processing initialization |
8445 | and raw event processing routine for main form |
8446 | |
8447 +-------------------------------------------------------------------------+*/
8448
8449 Atom Atom_WM_PROTOCOLS, Atom_WM_DELETE_WINDOW;
8450
8451 void initClientMsgProc(void)
8452 {
8453 Atom_WM_PROTOCOLS = XInternAtom(fl_get_display(),
8454 "WM_PROTOCOLS", False);
8455 Atom_WM_DELETE_WINDOW = XInternAtom(fl_get_display(),
8456 "WM_DELETE_WINDOW", False);
8457 XChangeProperty(fl_get_display(), topWin, Atom_WM_PROTOCOLS,
8458 XA_ATOM, 32, PropModeReplace,
8459 (unsigned char *)&Atom_WM_DELETE_WINDOW, 1);
8460 }
8461
8462 int rawEvents(FL_FORM *form, void *xev)
8463 {
8464 XEvent *ev = xev;
8465
8466 switch (ev->type) {
8467 #ifdef XPMANIMATE /* if animation enabled */
8468 case MapNotify: /* figure out if we're */
8469 minimized = 0; /* being minimized or not */
8470 break;
8471
8472 case UnmapNotify:
8473 minimized = 1;
8474 break;
8475 #endif
8476 case ClientMessage: /* if "delete" received */
8477 if (ev->xclient.message_type != /* from window manager */
8478 Atom_WM_PROTOCOLS) break;
8479 if (ev->xclient.data.l[0] !=
8480 (int)Atom_WM_DELETE_WINDOW)
8481 break;
8482 case DestroyNotify: /* or "destroy" from server */
8483 unlink(upidfname); /* then do some cleanup */
8484 break;
8485
8486 default: break;
8487 }
8488 return 0;
8489 }
8490
8491
8492 /*+-------------------------------------------------------------------------+
8493 | |
8494 | Callback routines for exitDialog and window delete handlers |
8495 | |
8496 +-------------------------------------------------------------------------+*/
8497
8498 void doExitOK(FL_OBJECT *obj, long param)
8499 {
8500 if (dialerPID) {
8501 kill(dialerPID, SIGTERM);
8502 mSleep((int)BU_INTERVAL*1000);
8503 }
8504 if (connected && (pppdPID = getPppdPID(devName)))
8505 kill(pppdPID, SIGINT);
8506 exit(0);
8507 }
8508
8509 void doExitCancel(FL_OBJECT *obj, long param)
8510 {
8511 fl_hide_form(fd_exitDialog->exitDialog);
8512 fl_activate_form(fd_topFrame->topFrame);
8513 return;
8514 }
8515
8516 int deleteHandler(FL_FORM *form, void *data)
8517 {
8518 if (form == fd_topFrame->topFrame) {
8519 if (! expert && connected) {
8520 fl_deactivate_form(fd_topFrame->topFrame);
8521 fl_show_form(fd_exitDialog->exitDialog, FL_PLACE_MOUSE,
8522 FL_TRANSIENT, "Exit Dialog");
8523 }
8524 else
8525 fl_call_object_callback(fd_exitDialog->exitOK);
8526 }
8527 else if (form == fd_CBInfo->CBInfo) {
8528 fl_call_object_callback(fd_CBInfo->CBInfoCancel);
8529 }
8530 else if (form == fd_renameISP->renameISP) {
8531 fl_call_object_callback(fd_renameISP->ISPNameEditCancel);
8532 }
8533 else if (form == fd_aboutInfo->aboutInfo) {
8534 fl_call_object_callback(fd_aboutInfo->aboutOK);
8535 }
8536 else if (form == fd_exitDialog->exitDialog) {
8537 fl_call_object_callback(fd_exitDialog->exitCancel);
8538 }
8539 else if (form == fd_helpInfo->helpInfo) {
8540 fl_call_object_callback(fd_helpInfo->helpInfoOK);
8541 }
8542 else if (form == fd_logInfo->logInfo) {
8543 fl_call_object_callback(fd_logInfo->logInfoCancel);
8544 }
8545 else if (form == fd_statInfo->statInfo) {
8546 fl_call_object_callback(fd_statInfo->statInfoOK);
8547 }
8548 else if (form == fd_pttEditor->pttEditor) {
8549 fl_call_object_callback(fd_pttEditor->pttEditCancel);
8550 }
8551 else if (form == fd_renamePTT->renamePTT) {
8552 fl_call_object_callback(fd_renamePTT->PTTNameEditCancel);
8553 }
8554 else if (form == fd_renameZone->renameZone) {
8555 fl_call_object_callback(fd_renameZone->zoneNameEditCancel);
8556 }
8557 else if (form == fd_optsTab->optsTab) {
8558 fl_hide_form(fd_optsTab->optsTab);
8559 fl_activate_object(fd_topFrame->fileMenu);
8560 fl_set_object_lcol(fd_topFrame->fileMenu,FL_LCOL);
8561 }
8562 else if (form == fd_actionVerify->actionVerify) {
8563 fl_call_object_callback(fd_actionVerify->actionVerifyNo);
8564 }
8565 else if (form == fd_alertMessage->alertMessage) {
8566 fl_hide_form(fd_alertMessage->alertMessage);
8567 }
8568 return FL_IGNORE;
8569 }
8570
8571
8572 /*+-------------------------------------------------------------------------+
8573 | |
8574 | Signal trap and exit(3) cleanup routine |
8575 | |
8576 +-------------------------------------------------------------------------+*/
8577
8578 void sigTrap(int signum)
8579 {
8580 char msg[512] = {0};
8581
8582 switch (signum) {
8583
8584 /* SIGINT or SIGTERM: disconnect PPP link and exit */
8585 case SIGINT:
8586 case SIGTERM: {
8587 sprintf(msg, "X-ISP terminated%s.\n",
8588 (progState == CONNECTED)?", disconnecting link":"");
8589 alertMessage("xISP: sigTrap()", 0, 0, msg);
8590 if (dialerPID) {
8591 kill(dialerPID, SIGTERM);
8592 mSleep((int)BU_INTERVAL*1000);
8593 }
8594 if ((pppdPID = getPppdPID(devName)))
8595 kill(pppdPID, SIGINT);
8596 exit(0);
8597 }
8598
8599 /* SIGUSR1: if we are disconnected, press the "Connect" button */
8600 case SIGUSR1: {
8601 if (progState == DISCONNECTED)
8602 fl_call_object_callback(fd_topFrame->conButton);
8603 #ifndef SUNOS41x
8604 signal(SIGUSR1, sigTrap);
8605 #endif
8606 return;
8607 }
8608
8609 /* SIGUSR2: if we are dialing, press the "Interrupt" button,
8610 else, if we are connected, press "Disconnect" */
8611 case SIGUSR2: {
8612 if (progState == DIALING)
8613 fl_call_object_callback(fd_topFrame->intButton);
8614 else if (progState == CONNECTED)
8615 fl_call_object_callback(fd_topFrame->disButton);
8616 #ifndef SUNOS41x
8617 signal(SIGUSR2, sigTrap);
8618 #endif
8619 return;
8620 }
8621
8622 /* By default, bail out if an unknown signal is received */
8623 default: {
8624 sprintf(msg, "X-ISP received signal %d: exiting\n"
8625 "and abandoning link in present condition.", signum);
8626 alertMessage("xISP: sigTrap()", 0, 0, msg);
8627 exit(1);
8628 }
8629 }
8630 }
8631
8632 void registerSignalTrap(void) /* register signals we want to trap */
8633 {
8634 signal(SIGTERM, sigTrap);
8635 signal(SIGINT, sigTrap);
8636 signal(SIGUSR1, sigTrap);
8637 signal(SIGUSR2, sigTrap);
8638 }
8639
8640 #ifdef SUNOS41x
8641 void exitCleanup(int exitStatus, void *arg)
8642 #else
8643 void exitCleanup(void)
8644 #endif
8645 {
8646 if (exitStatus)
8647 alertMessage("Aborting:", 0, 0,
8648 " xISP has terminated abnormally!\n\n"
8649 "Check the standard error output (wherever\n"
8650 "that may be redirected) or re-run xisp from\n"
8651 "the command line (e.g. from within an xterm\n"
8652 "window) and check the error log.");
8653 fl_finish();
8654 unlink(upidfname);
8655 }
8656
8657
8658 /*+-------------------------------------------------------------------------+
8659 | |
8660 | Command line options & Resources - Routines |
8661 | |
8662 +-------------------------------------------------------------------------+*/
8663
8664 /* Process arguments parsed in resources */
8665
8666 void processArgs(void)
8667 {
8668 int flags;
8669
8670 flags = XParseGeometry(geoms, /* parse geometry from */
8671 &winPosX, &winPosY, /* the input string */
8672 &winWidth, &winHeight);
8673 if ((flags & WidthValue) && /* size specified? */
8674 (flags & HeightValue)) {
8675 fl_set_form_size(fd_topFrame->topFrame, /* yes, adjust top form */
8676 winWidth, winHeight);
8677 }
8678 if ((flags & XValue) && (flags && YValue)) { /* if position specified */
8679 if (flags & XNegative) /* account for negative */
8680 winPosX = -winWidth; /* coordinate values */
8681 if (flags & YNegative)
8682 winPosY = -winHeight;
8683 fl_set_form_position(fd_topFrame->topFrame, /* adjust top form */
8684 winPosX, winPosY); /* size and change */
8685 placementMethod = FL_PLACE_POSITION; /* placement method */
8686 }
8687 if (iconic) /* startup as iconic? */
8688 placementMethod = FL_PLACE_ICONIC; /* yup, change placement */
8689 if (clISP > 0 && clISP <= global.numISPs) {
8690 currentRC = clISP; /* ISP selected from */
8691 p_xisprc = &xispOptions[currentRC]; /* command line */
8692 fl_set_choice(fd_topFrame->ISPDropChoice,
8693 currentRC);
8694 }
8695 if (expert) /* "-expert" implies */
8696 nohints = 1; /* "-nohints" */
8697 if (global.logOpts & LOG_HINTS) { /* if hints enabled from */
8698 if (nohints) { /* RC file & "-nohints" */
8699 global.logOpts &= ~LOG_HINTS; /* selected => disable */
8700 writeXisprc(rcfname, xispOptions, /* hints in log opts and */
8701 &global); /* update the RC file */
8702 }
8703 } /* else, when hints off */
8704 else /* from RC file, they */
8705 nohints = 1; /* can only be turned on */
8706 if (nohints) /* from "File" menu */
8707 fl_set_menu(fd_topFrame->fileMenu, /* also adjust the menu */
8708 "Options . . .|Enable hints|Exit"); /* item according to */
8709 else /* the state of the */
8710 fl_set_menu(fd_topFrame->fileMenu, /* hints flag */
8711 "Options . . .|Disable hints|Exit");
8712 }
8713
8714
8715 /*+-------------------------------------------------------------------------+
8716 | |
8717 | Main |
8718 | |
8719 +-------------------------------------------------------------------------+*/
8720
8721 int main(int argc, char *argv[])
8722 {
8723 Pixmap icon, imask;
8724 char *rcsp;
8725 int tmp, i, newCurrency;
8726 xisprc_t *p;
8727 uid_t euid = geteuid();
8728 uid_t ruid = getuid();
8729
8730 /*
8731 * Perform initializations and sanity checks
8732 */
8733 registerSignalTrap(); /* register sig handlers */
8734 rcsp = RCSid; /* keep compiler quiet */
8735 umask(077); /* owner read/write only */
8736 pcode_init(); /* init passwd coding */
8737 initUIFnames(); /* initialize file names */
8738
8739 if (seteuid(ruid) == -1) /* switch to real UID */
8740 (void) fprintf(stderr, "seteuid(%d): %s\n", /* just before X11 init */
8741 (int)ruid, Strerror(errno));
8742 colorSqueeze(); /* reduce colormap usage */
8743 fl_initialize(&argc, argv, "xISP", /* initialize forms GUI */
8744 options, NUMOPTS);
8745 fl_get_app_resources(resources, NUMOPTS); /* parse any resources */
8746 fontSelect(); /* select desired fonts */
8747 if (seteuid(euid) == -1) /* switch back to */
8748 (void) fprintf(stderr, "seteuid(%d): %s\n", /* effective UID after */
8749 (int)euid, Strerror(errno)); /* X11 initialization */
8750 bgColor(bgcols); /* parse user bg color */
8751 fd_actionVerify = create_form_actionVerify(); /* create some forms now */
8752 fd_alertMessage = create_form_alertMessage();
8753 #ifdef SUNOS41x
8754 on_exit(exitCleanup, 0); /* register cleanup proc */
8755 #else
8756 atexit(exitCleanup);
8757 #endif
8758
8759 /*
8760 * Set locale LC_NUMERIC = C otherwise
8761 * floating point numbers might not work for
8762 * everybody (users in Greece, for example :))
8763 */
8764 setlocale(LC_NUMERIC, "C");
8765
8766 readXisprc(rcfname, &xispOptions, &global); /* try reading RC file */
8767 tmp = global.numPTTs; /* save RC's num of PTTs */
8768 initUDFnames(&global); /* user spec. file names */
8769 currentRC = global.dfltISP; /* set default ISP */
8770 p_xisprc = &xispOptions[currentRC];
8771 logs_init(&global, logdirname, /* init logging module */
8772 costfname, logfname, pttfname);
8773 readXispPTTs(&ptt, &global); /* read PTT database and */
8774 for (i=0; i<global.numISPs; i++) { /* perform sanity check */
8775 p = &xispOptions[i+1]; /* on the PTT and zone */
8776 if (p->ispPTT> global.numPTTs-1) /* selection for all */
8777 p->ispPTT = global.numPTTs-1; /* ISPs in the RC file */
8778 if (p->ispZone> ptt[p->ispPTT].num_zones-1)
8779 p->ispZone= ptt[p->ispPTT].num_zones-1;
8780 }
8781 dialerFD = namedPipe(Pipe); /* create/open pipe */
8782 fd_instanceCheck = create_form_instanceCheck(); /* create this form now */
8783 recordPID(); /* check/write PID file */
8784
8785 fd_topFrame = create_form_topFrame(); /* create the rest of */
8786 fd_accountInfo = create_form_accountInfo(); /* the program forms */
8787 fd_dialInfo = create_form_dialInfo();
8788 fd_CBInfo = create_form_CBInfo();
8789 fd_aboutInfo = create_form_aboutInfo();
8790 fd_exitDialog = create_form_exitDialog();
8791 fd_renameISP = create_form_renameISP();
8792 fd_helpInfo = create_form_helpInfo();
8793 fd_commInfo = create_form_commInfo();
8794 fd_tcpipInfo = create_form_tcpipInfo();
8795 fd_logInfo = create_form_logInfo();
8796 fd_statInfo = create_form_statInfo();
8797 fd_pttEditor = create_form_pttEditor();
8798 fd_renamePTT = create_form_renamePTT();
8799 fd_renameZone = create_form_renameZone();
8800 fd_envInfo = create_form_envInfo();
8801 fd_optsTab = create_form_optsTab();
8802
8803 (void) pppdVersion(); /* check pppd version */
8804 processArgs(); /* process arguments */
8805 #ifdef XPMANIMATE
8806 prepAnimPixmaps(); /* prep animation pixmaps */
8807 #endif
8808 tcid = fl_create_bitmap_cursor(timer_cursor, /* create custom cursor */
8809 timer_mask, TIMER_CURSOR_WIDTH,
8810 TIMER_CURSOR_HEIGHT, 7, 0);
8811 fl_set_atclose(deleteHandler, NULL); /* fdelete() callback */
8812 /*
8813 * No abort exceptions beyond this point
8814 */
8815 newCurrency = /* if currencies for PTT */
8816 strcmp(ptt[p_xisprc->ispPTT].currency, /* used by the default */
8817 ptt[global.costPTT].currency); /* ISP and PTT last used */
8818 if (!(global.logOpts&LOG_NONE)&&newCurrency) { /* for cost calculation */
8819 if (actionVerify("The PTT for the default " /* & logging don't match */
8820 "ISP bills you in currency\nwhich is " /* then prompt user with */
8821 "different from the one used by the " /* choice. */
8822 "last\nISP you connected with. This "
8823 "implies resetting of\nlog files, "
8824 "continue?\n\n"
8825 "If you choose \"Yes\", your logs "
8826 "will be reset, if\nyou choose \"No\""
8827 ", the first ISP in your database\n"
8828 "using a PTT with matching currency "
8829 "will be\nselected as default instead.",
8830 0)
8831 ) /* if the default ISP is */
8832 resetLogs(); /* selected, reset logs */
8833 else { /* else, search for ISP */
8834 for (i=1; i<(global.numISPs+1); i++) /* which uses the PTT */
8835 if (xispOptions[i].ispPTT == /* last used for cost */
8836 global.costPTT /* calculation & logging */
8837 )
8838 break;
8839 if (i > global.numISPs) { /* if it's not found in */
8840 alertMessage("xISP: PTT problem", /* the ISP data-base, */
8841 0,0, "The PTT (and associated " /* use the default with */
8842 "currency) used when you\n" /* its associated PTT, */
8843 "last invoked xISP does not " /* and reset the logs */
8844 "appear to be related to\n"
8845 "any of the ISPs listed in "
8846 "your database. Your default\n"
8847 "ISP will be used instead ("
8848 "your log files shall be reset).");
8849 resetLogs();
8850 }
8851 else { /* if indeed it is found */
8852 currentRC = i; /* in the ISP data-base, */
8853 p_xisprc = &xispOptions[currentRC]; /* switch to this ISP */
8854 fl_set_choice(fd_topFrame->
8855 ISPDropChoice, currentRC);
8856 }
8857 }
8858 }
8859 currentPTT = p_xisprc->ispPTT; /* set PTT of default ISP */
8860 global.costPTT = currentPTT;
8861 if (tmp != global.numPTTs) /* num of PTTs changed? */
8862 writeXisprc(rcfname, xispOptions, &global); /* yes, update RC file */
8863 p_ptt = &ptt[currentPTT]; /* load selected PTT */
8864 if (global.logOpts & COST_READOUT) /* zero call cost if it */
8865 fl_set_object_label(fd_topFrame->logText, /* is the preferred on- */
8866 costStr(p_ptt, 0.0)); /* line counter style */
8867 p_ptt->current_zone = p_xisprc->ispZone;
8868 if (! (global.logOpts & LOG_NONE)) { /* if logging is on */
8869 readXispCost(&totalTime, &totalCost); /* read the costs file */
8870 if (p_ptt->attribs & PTT_BY_UNIT) /* if the selected PTT */
8871 totalUnits = totalCost / /* charges by unit, then */
8872 p_ptt->cost_quantum; /* derive units from cost */
8873 }
8874 fl_set_app_mainform(fd_topFrame->topFrame); /* indicate master form */
8875 topWin = fl_show_form(fd_topFrame->topFrame, /* realize top-level */
8876 placementMethod, FL_FULLBORDER, /* window and save its */
8877 "X-ISP"); /* ID for later use */
8878 if (! nohints) fl_set_timer( /* set tip one-shot timer */
8879 fd_topFrame->tipTimer, HINT_TRIGGER);
8880 initClientMsgProc(); /* init WM msg processing */
8881 fl_addto_selected_xevent(topWin, /* add event mask to one */
8882 StructureNotifyMask|SubstructureNotifyMask); /* selected for top form */
8883 fl_register_raw_callback(fd_topFrame->topFrame, /* install top form */
8884 StructureNotifyMask|SubstructureNotifyMask| /* augmented event hook */
8885 FL_ALL_EVENT, rawEvents);
8886 fl_get_pixmap_pixmap(fd_topFrame->topIcon, /* use as window icon */
8887 &icon, &imask); /* the same as that on */
8888 fl_winicon(topWin, icon, imask); /* the main form */
8889 #ifdef XPMANIMATE /* animation uses same */
8890 amask = imask; /* transparency mask */
8891 #endif
8892
8893 possibleActions(DISCONNECTED); /* mark possible actions */
8894
8895 if (p_xisprc->operOpts & STARTUP_DIAL || /* dial ISP on startup? */
8896 autodial) { /* also when forced */
8897 XFlush(fl_get_display()); /* yes, flush drawing */
8898 fl_call_object_callback( /* and push "Connect" */
8899 fd_topFrame->conButton);
8900 }
8901
8902 fl_do_forms(); /* enter main loop */
8903
8904 return 0;
8905 }
8906
8907
8908 /*+-------------------------------------------------------------------------+
8909 | |
8910 | Program forms created with fdesign and annotated by hand |
8911 | |
8912 +-------------------------------------------------------------------------+*/
8913
8914 FD_instanceCheck *create_form_instanceCheck(void)
8915 {
8916 FL_OBJECT *obj;
8917 FD_instanceCheck *fdui = (FD_instanceCheck *) fl_calloc(1, sizeof(*fdui));
8918
8919 fdui->instanceCheck = fl_bgn_form(FL_NO_BOX, 429, 163);
8920 obj = fl_add_box(FL_FLAT_BOX,0,0,429,163,"");
8921 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
8922 obj = fl_add_pixmap(FL_NORMAL_PIXMAP,21,17,14,36,"");
8923 fl_set_object_resize(obj, FL_RESIZE_NONE);
8924 fl_set_object_gravity(obj, FL_West, FL_West);
8925 fl_set_pixmap_data(obj, excl_xpm);
8926 obj = fl_add_text(FL_NORMAL_TEXT,41,13,361,21,
8927 "X-ISP: can't run two instances simultaneously!");
8928 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
8929 fl_set_object_lcolor(obj,FL_WHITE);
8930 fl_set_object_lsize(obj,FL_MEDIUM_SIZE);
8931 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
8932 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
8933 fl_set_object_resize(obj, FL_RESIZE_NONE);
8934 fdui->msgString = obj = fl_add_text(FL_NORMAL_TEXT,41,37,371,75,"");
8935 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
8936 fl_set_object_lcolor(obj,FL_WHITE);
8937 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
8938 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
8939 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
8940 fl_set_object_resize(obj, FL_RESIZE_NONE);
8941 fdui->instanceCheckAbort = obj = fl_add_button(FL_RETURN_BUTTON,328,121,
8942 79,27,"Abort");
8943 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
8944 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
8945 fl_set_object_resize(obj, FL_RESIZE_NONE);
8946 fl_set_object_bw(obj, -2);
8947 fdui->instanceCheckContinue = obj = fl_add_button(FL_NORMAL_BUTTON,227,121,
8948 79,27,"Continue");
8949 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
8950 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
8951 fl_set_object_resize(obj, FL_RESIZE_NONE);
8952 fl_set_object_bw(obj, -2);
8953 fl_end_form();
8954
8955 fdui->instanceCheck->fdui = fdui;
8956
8957 return fdui;
8958 }
8959
8960 FD_topFrame *create_form_topFrame(void)
8961 {
8962 FL_OBJECT *obj;
8963 FD_topFrame *fdui = (FD_topFrame *) fl_calloc(1, sizeof(*fdui));
8964 int i;
8965
8966 fdui->topFrame = fl_bgn_form(FL_NO_BOX, 292, 220);
8967 fl_set_form_minsize(fdui->topFrame, 292,220);
8968 obj = fl_add_box(FL_FLAT_BOX,0,0,292,220,"");
8969 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
8970 fdui->conButton = obj = fl_add_button(FL_NORMAL_BUTTON,7,67,69,26,
8971 "Connect");
8972 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
8973 fl_set_object_resize(obj, FL_RESIZE_NONE);
8974 fl_set_object_callback(obj,doConnect,0);
8975 fl_set_object_bw(obj, -2);
8976 fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
8977 fdui->intButton = obj = fl_add_button(FL_NORMAL_BUTTON,7,93,69,26,
8978 "Interrupt");
8979 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
8980 fl_set_object_resize(obj, FL_RESIZE_NONE);
8981 fl_set_object_callback(obj,doInterrupt,0);
8982 fl_set_object_bw(obj, -2);
8983 fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
8984 fdui->disButton = obj = fl_add_button(FL_NORMAL_BUTTON,7,119,69,26,
8985 "Disconnect");
8986 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
8987 fl_set_object_resize(obj, FL_RESIZE_NONE);
8988 fl_set_object_callback(obj,doDisconnect,0);
8989 fl_set_object_bw(obj, -2);
8990 fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
8991 obj = fl_add_box(FL_UP_BOX,0,0,292,29,"");
8992 fl_set_object_bw(obj, -2);
8993 fl_set_object_resize(obj, FL_RESIZE_X);
8994 fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
8995 fdui->fileMenu = obj = fl_add_menu(FL_PULLDOWN_MENU,9,4,30,19,"File");
8996 fl_set_object_boxtype(obj,FL_FLAT_BOX);
8997 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
8998 fl_set_object_lalign(obj,FL_ALIGN_LEFT);
8999 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9000 fl_set_object_resize(obj, FL_RESIZE_NONE);
9001 fl_set_object_callback(obj,doFile,0);
9002 fl_set_object_gravity(obj, FL_NorthWest, FL_NorthWest);
9003 fl_set_object_shortcut(obj, "#F", 1);
9004 if (nohints)
9005 fl_set_menu(obj,"Options . . .|Enable hints|Exit");
9006 else
9007 fl_set_menu(obj,"Options . . .|Disable hints|Exit");
9008 fl_setpup_default_cursor(XC_arrow);
9009 fdui->logMenu = obj = fl_add_menu(FL_PULLDOWN_MENU,45,4,58,19,"Logging");
9010 fl_set_object_boxtype(obj,FL_FLAT_BOX);
9011 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9012 fl_set_object_lalign(obj,FL_ALIGN_LEFT);
9013 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9014 fl_set_object_resize(obj, FL_RESIZE_NONE);
9015 fl_set_object_callback(obj,doLogging,0);
9016 fl_set_object_gravity(obj, FL_NorthWest, FL_NorthWest);
9017 fl_set_object_shortcut(obj, "#L", 1);
9018 fl_set_menu(obj,"Options . . .|Statistics . . .");
9019 if (global.logOpts & LOG_NONE)
9020 fl_set_menu_item_mode(obj, 2, FL_PUP_GREY);
9021 fl_setpup_default_cursor(XC_arrow);
9022 fdui->hlpMenu = obj = fl_add_menu(FL_PULLDOWN_MENU,250,4,35,19,"Help");
9023 fl_set_object_boxtype(obj,FL_FLAT_BOX);
9024 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9025 fl_set_object_lalign(obj,FL_ALIGN_RIGHT);
9026 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9027 fl_set_object_resize(obj, FL_RESIZE_NONE);
9028 fl_set_object_callback(obj,doHelp,0);
9029 fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
9030 fl_set_object_shortcut(obj, "#H", 1);
9031 fl_set_menu(obj, "About xISP|General Info");
9032 fl_setpup_default_cursor(XC_arrow);
9033 fdui->lstBrowser = obj = fl_add_browser(FL_NORMAL_BROWSER,80,66,205,79,"");
9034 fl_set_object_boxtype(obj,FL_DOWN_BOX);
9035 fl_set_object_color(obj,FL_TOP_BCOL,FL_CYAN);
9036 fl_set_browser_hscrollbar(obj, FL_OFF);
9037 fl_set_browser_scrollbarsize(obj, 16, 16);
9038 fl_set_object_bw(obj, -2);
9039 fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast);
9040 obj = fl_add_box(FL_EMBOSSED_BOX,108,35,177,26,"");
9041 fl_set_object_color(obj,FL_TOP_BCOL,FL_COL1);
9042 fl_set_object_resize(obj, FL_RESIZE_X);
9043 fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
9044 fdui->ISPDropChoice = obj = fl_add_choice(FL_DROPLIST_CHOICE,111,38,172,
9045 21,"");
9046 fl_set_object_boxtype(obj,FL_FLAT_BOX);
9047 fl_set_object_color(obj,FL_TOP_BCOL,FL_BLACK);
9048 fl_set_object_callback(obj,doISPDropChoice,0);
9049 fl_set_object_resize(obj, FL_RESIZE_X);
9050 fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
9051 fl_set_choice_fontsize(obj,FL_NORMAL_SIZE);
9052 for (i=0; i<global.numISPs; i++)
9053 if (*(xispOptions[i+1].descr))
9054 fl_addto_choice(obj,
9055 clipStr(xispOptions[i+1].descr, FL_NORMAL_SIZE,
9056 FL_NORMAL_STYLE, 150));
9057 fl_set_choice(obj, currentRC);
9058 obj = fl_add_text(FL_NORMAL_TEXT,80,35,30,26,"ISP:");
9059 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9060 fl_set_object_lcolor(obj,FL_WHITE);
9061 fl_set_object_color(obj,FL_INACTIVE,FL_MCOL);
9062 fl_set_object_lcolor(obj,FL_WHITE);
9063 fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
9064 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9065 fl_set_object_resize(obj, FL_RESIZE_X);
9066 fl_set_object_gravity(obj, FL_NorthWest, FL_NorthWest);
9067 obj = fl_add_text(FL_NORMAL_TEXT,7,152,69,36," Current\n Status:");
9068 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9069 fl_set_object_color(obj,FL_INACTIVE,FL_MCOL);
9070 fl_set_object_lcolor(obj,FL_WHITE);
9071 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9072 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9073 fl_set_object_resize(obj, FL_RESIZE_X);
9074 fl_set_object_gravity(obj, FL_SouthWest, FL_West);
9075 fdui->statusText = obj = fl_add_text(FL_NORMAL_TEXT,7,186,69,28,"OFF-LINE");
9076 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9077 fl_set_object_color(obj,FL_BLACK,FL_MCOL);
9078 fl_set_object_lcolor(obj,FL_WHITE);
9079 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
9080 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9081 fl_set_object_resize(obj, FL_RESIZE_NONE);
9082 fl_set_object_gravity(obj, FL_SouthWest, FL_West);
9083 obj = fl_add_text(FL_NORMAL_TEXT,74,152,58,36," Modem\n Speed:");
9084 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9085 fl_set_object_color(obj,FL_INACTIVE,FL_MCOL);
9086 fl_set_object_lcolor(obj,FL_WHITE);
9087 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9088 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9089 fl_set_object_resize(obj, FL_RESIZE_X);
9090 fl_set_object_gravity(obj, FL_SouthWest, FL_West);
9091 fdui->speedText = obj = fl_add_text(FL_NORMAL_TEXT,74,186,58,28,
9092 EMPTY_SPEED);
9093 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9094 fl_set_object_color(obj,FL_BLACK,FL_MCOL);
9095 fl_set_object_lcolor(obj,FL_WHITE);
9096 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
9097 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9098 fl_set_object_resize(obj, FL_RESIZE_X);
9099 fl_set_object_gravity(obj, FL_SouthWest, FL_West);
9100 obj = fl_add_text(FL_NORMAL_TEXT,130,152,97,36," Assigned\n IP Address:");
9101 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9102 fl_set_object_color(obj,FL_INACTIVE,FL_MCOL);
9103 fl_set_object_lcolor(obj,FL_WHITE);
9104 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9105 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9106 fl_set_object_resize(obj, FL_RESIZE_X);
9107 fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
9108 fdui->IPText = obj = fl_add_text(FL_NORMAL_TEXT,130,186,97,28,EMPTY_IP);
9109 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9110 fl_set_object_color(obj,FL_BLACK,FL_MCOL);
9111 fl_set_object_lcolor(obj,FL_WHITE);
9112 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
9113 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9114 fl_set_object_resize(obj, FL_RESIZE_X);
9115 fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
9116 fl_set_object_posthandler(obj, select_IPText);
9117 fdui->logDescr = obj = fl_add_text(FL_NORMAL_TEXT,225,152,61,36,
9118 (global.logOpts & COST_READOUT)? RCOST_STR:RTIME_STR);
9119 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9120 fl_set_object_color(obj,FL_INACTIVE,FL_MCOL);
9121 fl_set_object_lcolor(obj,FL_WHITE);
9122 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9123 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9124 fl_set_object_resize(obj, FL_RESIZE_X);
9125 fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
9126 fdui->logText = obj = fl_add_text(FL_NORMAL_TEXT,225,186,61,28,
9127 (global.logOpts & COST_READOUT)? "":EMPTY_TIME);
9128 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9129 fl_set_object_color(obj,FL_BLACK,FL_MCOL);
9130 fl_set_object_lcolor(obj,FL_WHITE);
9131 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
9132 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9133 fl_set_object_resize(obj, FL_RESIZE_X);
9134 fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
9135 fdui->topIcon = obj = fl_add_pixmap(FL_NORMAL_PIXMAP,7,32,68,30,"");
9136 fl_set_object_resize(obj, FL_RESIZE_NONE);
9137 fl_set_object_gravity(obj, FL_NorthWest, FL_NorthWest);
9138 fl_set_pixmap_data(obj, xisp_xpm);
9139 #ifdef XPMANIMATE
9140 fl_set_object_dblbuffer(obj, 1);
9141 #endif
9142
9143 btimer = fl_add_timer(FL_HIDDEN_TIMER, /* timer for browser */
9144 0, 0, 0, 0, NULL);
9145 ctimer = fl_add_timer(FL_HIDDEN_TIMER, /* connection time */
9146 0, 0, 0, 0, NULL);
9147 ltimer = fl_add_timer(FL_HIDDEN_TIMER, /* link status */
9148 0, 0, 0, 0, NULL);
9149 #ifdef XPMANIMATE
9150 xpmtimer = fl_add_timer(FL_HIDDEN_TIMER, /* pixmap animation */
9151 0, 0, 0, 0, NULL);
9152 #endif
9153 fl_set_object_callback(btimer, doBUpdate, 0); /* register callbacks */
9154 fl_set_object_callback(ctimer, doCTupdate, 0);
9155 fl_set_object_callback(ltimer, doLPupdate, 0);
9156 #ifdef XPMANIMATE
9157 fl_set_object_callback(xpmtimer, doXPMUpdate, 0);
9158 #endif
9159 fl_set_timer(btimer, 0.0); /* initialize timers */
9160 fl_set_timer(ctimer, 0.0);
9161 fl_set_timer(ltimer, 0.0);
9162 #ifdef XPMANIMATE
9163 fl_set_timer(xpmtimer, 0.0);
9164 #endif
9165
9166 fdui->tipTimer = obj = fl_add_timer(FL_HIDDEN_TIMER, 0,0,0,0,"");
9167 fl_set_timer(obj, 0.0);
9168 fl_set_object_callback(obj,doStartupTip,0);
9169
9170 fl_end_form();
9171
9172 fdui->topFrame->fdui = fdui;
9173
9174 return fdui;
9175 }
9176
9177 FD_accountInfo *create_form_accountInfo(void)
9178 {
9179 FL_OBJECT *obj;
9180 FD_accountInfo *fdui = (FD_accountInfo *) fl_calloc(1, sizeof(*fdui));
9181
9182 fdui->accountInfo = fl_bgn_form(FL_NO_BOX, 540, 350);
9183 obj = fl_add_box(FL_FLAT_BOX,0,0,540,350,"");
9184 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
9185 fl_set_object_resize(obj, FL_RESIZE_NONE);
9186 fdui->telInput = obj = fl_add_input(FL_NORMAL_INPUT,320,12,206,27,
9187 "Phone no(s):");
9188 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9189 fl_set_object_lcolor(obj,FL_WHITE);
9190 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9191 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9192 fl_set_object_resize(obj, FL_RESIZE_NONE);
9193 fl_set_object_callback(obj,doTelNoInput,0);
9194 fl_set_input_maxchars(obj, MAXNUM_TELS*(MAXLEN_PHONE+1));
9195 fdui->accInput = obj = fl_add_input(FL_NORMAL_INPUT,320,42,206,27,
9196 "Account name:");
9197 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9198 fl_set_object_lcolor(obj,FL_WHITE);
9199 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9200 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9201 fl_set_object_resize(obj, FL_RESIZE_NONE);
9202 fl_set_object_callback(obj,doAccountInput,0);
9203 fl_set_input_maxchars(obj, MAXLEN_ACCOUNT);
9204 fdui->pswInput = obj = fl_add_input(FL_SECRET_INPUT,320,72,206,27,
9205 "Password:");
9206 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9207 fl_set_object_lcolor(obj,FL_WHITE);
9208 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9209 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9210 fl_set_object_resize(obj, FL_RESIZE_NONE);
9211 fl_set_object_callback(obj,doPasswdInput,0);
9212 fl_set_input_maxchars(obj, MAXLEN_PASSWD);
9213 /*
9214 Change secret input character from ' ' to '*';
9215 look in xisp.h for explanations and details
9216 */
9217 ((SPEC *)(obj->spec))->field_char = '*';
9218 obj = fl_add_frame(FL_ENGRAVED_FRAME,14,215,214,120,"");
9219 fl_set_object_color(obj,FL_COL1,FL_COL1);
9220 obj = fl_add_text(FL_NORMAL_TEXT,21,205,151,19,"Authentication protocol:");
9221 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9222 fl_set_object_lcolor(obj,FL_WHITE);
9223 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9224 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9225 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9226 fdui->UNInput = obj = fl_add_input(FL_NORMAL_INPUT,320,102,206,27,
9227 "User/Name:");
9228 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9229 fl_set_object_lcolor(obj,FL_WHITE);
9230 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9231 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9232 fl_set_object_resize(obj, FL_RESIZE_NONE);
9233 fl_set_object_callback(obj,doUNInput,0);
9234 fl_set_input_maxchars(obj, MAXLEN_UNR);
9235 fdui->remoteInput = obj = fl_add_input(FL_NORMAL_INPUT,320,132,206,27,
9236 "Remote name:");
9237 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9238 fl_set_object_lcolor(obj,FL_WHITE);
9239 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9240 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9241 fl_set_object_resize(obj, FL_RESIZE_NONE);
9242 fl_set_object_callback(obj,doRemoteInput,0);
9243 fl_set_input_maxchars(obj, MAXLEN_UNR);
9244 obj = fl_add_box(FL_EMBOSSED_BOX,320,162,206,28,"");
9245 fdui->ispPttDropChoice = obj = fl_add_choice(FL_DROPLIST_CHOICE,323,165,200,
9246 22,"PTT: ");
9247 fl_set_object_boxtype(obj,FL_FLAT_BOX);
9248 fl_set_object_lcolor(obj,FL_WHITE);
9249 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9250 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9251 fl_set_object_callback(obj,doIspPttDropChoice,0);
9252 fl_set_choice_fontstyle(obj, FL_BOLD_STYLE);
9253 fl_set_choice_align(obj, FL_ALIGN_LEFT);
9254 obj = fl_add_box(FL_EMBOSSED_BOX,320,193,206,28,"");
9255 fdui->ispZoneDropChoice = obj = fl_add_choice(FL_DROPLIST_CHOICE,323,196,200,
9256 22,"Zone: ");
9257 fl_set_object_boxtype(obj,FL_FLAT_BOX);
9258 fl_set_object_lcolor(obj,FL_WHITE);
9259 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9260 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9261 fl_set_object_callback(obj,doIspZoneDropChoice,0);
9262 fl_set_choice_fontstyle(obj, FL_BOLD_STYLE);
9263 fl_set_choice_align(obj, FL_ALIGN_LEFT);
9264
9265 fdui->authType = fl_bgn_group();
9266 fdui->authPAPButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,22,300,190,
9267 25,"PAP (pppd-2.2.0 or earlier)");
9268 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9269 fl_set_object_lcolor(obj,FL_WHITE);
9270 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9271 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9272 fl_set_object_resize(obj, FL_RESIZE_NONE);
9273 fl_set_object_callback(obj,doAuthPAPButton,0);
9274 fdui->authNoneButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,22,225,60,
9275 25,"None");
9276 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9277 fl_set_object_lcolor(obj,FL_WHITE);
9278 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9279 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9280 fl_set_object_resize(obj, FL_RESIZE_NONE);
9281 fl_set_object_callback(obj,doAuthNoneButton,0);
9282 fdui->authPAPSButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,22,250,62,
9283 25,"PAP");
9284 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9285 fl_set_object_lcolor(obj,FL_WHITE);
9286 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9287 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9288 fl_set_object_resize(obj, FL_RESIZE_NONE);
9289 fl_set_object_callback(obj,doAuthPAPSButton,0);
9290 fdui->authCHAPSButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,22,275,197,
9291 25,"CHAP (needed for NT-RAS)");
9292 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9293 fl_set_object_lcolor(obj,FL_WHITE);
9294 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9295 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9296 fl_set_object_resize(obj, FL_RESIZE_NONE);
9297 fl_set_object_callback(obj,doAuthCHAPSButton,0);
9298 fl_end_group();
9299
9300 obj = fl_add_text(FL_NORMAL_TEXT,9,3,209,39,
9301 "ISP name(s):\n(click selects, double-click edits)");
9302 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9303 fl_set_object_lcolor(obj,FL_WHITE);
9304 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9305 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9306 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9307 fl_set_object_resize(obj, FL_RESIZE_NONE);
9308 fdui->ISPBrowser = obj = fl_add_browser(FL_HOLD_BROWSER,13,43,203,123,"");
9309 fl_set_object_color(obj,FL_TOP_BCOL,FL_CYAN);
9310 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9311 fl_set_object_resize(obj, FL_RESIZE_NONE);
9312 fl_set_object_callback(obj,doISPPick,0);
9313 fl_set_browser_dblclick_callback(obj,doISPPickNEdit,0);
9314 fl_set_browser_fontsize(obj,FL_NORMAL_SIZE);
9315 fl_set_browser_scrollbarsize(obj, 16, 16);
9316 fl_set_object_bw(obj, -2);
9317 fdui->accountInfoAdd = obj = fl_add_button(FL_NORMAL_BUTTON,13,170,51,27,
9318 "Add");
9319 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9320 fl_set_object_resize(obj, FL_RESIZE_NONE);
9321 fl_set_object_callback(obj,doAccountInfoAdd,0);
9322 fl_set_object_bw(obj, -2);
9323 fdui->accountInfoDelete = obj = fl_add_button(FL_NORMAL_BUTTON,166,170,50,27,
9324 "Delete");
9325 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9326 fl_set_object_resize(obj, FL_RESIZE_NONE);
9327 fl_set_object_callback(obj,doAccountInfoDelete,0);
9328 fl_set_object_bw(obj, -2);
9329 fdui->accountInfoCopy = obj = fl_add_button(FL_NORMAL_BUTTON,64,170,51,27,
9330 "Copy");
9331 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9332 fl_set_object_resize(obj, FL_RESIZE_NONE);
9333 fl_set_object_callback(obj,doAccountInfoCopy,0);
9334 fl_set_object_bw(obj, -2);
9335 fdui->accountInfoPaste = obj = fl_add_button(FL_NORMAL_BUTTON,115,170,51,27,
9336 "Paste");
9337 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9338 fl_set_object_resize(obj, FL_RESIZE_NONE);
9339 fl_set_object_callback(obj,doAccountInfoPaste,0);
9340 fl_set_object_bw(obj, -2);
9341 obj = fl_add_frame(FL_ENGRAVED_FRAME,244,241,180,94,"");
9342 fl_set_object_color(obj,FL_COL1,FL_COL1);
9343 obj = fl_add_text(FL_NORMAL_TEXT,251,231,85,19,"ISP Options:");
9344 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9345 fl_set_object_lcolor(obj,FL_WHITE);
9346 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9347 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9348 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9349 fdui->autoRedial = obj = fl_add_checkbutton(FL_PUSH_BUTTON,249,300,164,25,
9350 "Re-dial dropped links");
9351 fl_set_object_color(obj,FL_COL1,FL_WHEAT);
9352 fl_set_object_lcolor(obj,FL_WHITE);
9353 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9354 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9355 fl_set_object_resize(obj, FL_RESIZE_NONE);
9356 fl_set_object_callback(obj,doAutoRedial,0);
9357 fl_set_button(obj, (p_xisprc->operOpts & AUTO_REDIAL)? 1:0);
9358 fdui->ISPDefault = obj = fl_add_checkbutton(FL_PUSH_BUTTON,249,250,102,25,
9359 "Default ISP");
9360 fl_set_object_color(obj,FL_COL1,FL_WHEAT);
9361 fl_set_object_lcolor(obj,FL_WHITE);
9362 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9363 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9364 fl_set_object_callback(obj,doISPDefault,0);
9365 fdui->ISPAutoDial = obj = fl_add_checkbutton(FL_PUSH_BUTTON,249,275,167,25,
9366 "Auto-dial upon startup");
9367 fl_set_object_color(obj,FL_COL1,FL_WHEAT);
9368 fl_set_object_lcolor(obj,FL_WHITE);
9369 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9370 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9371 fl_set_object_callback(obj,doISPAutoDial,0);
9372 obj = fl_add_text(FL_NORMAL_TEXT,433,235,96,114,"On this form you\ndefine "
9373 "your ISPs\ni.e. the account\nnames, passwords,\n"
9374 "authentication and\nPTT information,\nas well as "
9375 "special\nISP attributes.");
9376 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9377 fl_set_object_lcolor(obj,FL_WHITE);
9378 fl_set_object_lalign(obj,FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
9379 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9380
9381 fdui->tipTimer = obj = fl_add_timer(FL_HIDDEN_TIMER, 0,0,0,0,"");
9382 fl_set_timer(obj, 0.0);
9383 fl_set_object_callback(obj,doAccountInfoTip,0);
9384 fl_end_form();
9385
9386 fdui->accountInfo->fdui = fdui;
9387
9388 return fdui;
9389 }
9390
9391 FD_dialInfo *create_form_dialInfo(void)
9392 {
9393 FL_OBJECT *obj;
9394 FD_dialInfo *fdui = (FD_dialInfo *) fl_calloc(1, sizeof(*fdui));
9395
9396 fdui->dialInfo = fl_bgn_form(FL_NO_BOX, 540, 350);
9397 obj = fl_add_box(FL_FLAT_BOX,0,0,540,350,"");
9398 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
9399 fl_set_object_resize(obj, FL_RESIZE_NONE);
9400 obj = fl_add_frame(FL_ENGRAVED_FRAME,225,20,300,104,"");
9401 fl_set_object_color(obj,FL_COL1,FL_COL1);
9402 obj = fl_add_frame(FL_ENGRAVED_FRAME,13,20,195,316,"");
9403 fl_set_object_color(obj,FL_COL1,FL_COL1);
9404 obj = fl_add_text(FL_NORMAL_TEXT,18,7,96,23,"Dialer options:");
9405 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9406 fl_set_object_lcolor(obj,FL_WHITE);
9407 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9408 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9409 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9410 fdui->rtrInput = obj = fl_add_input(FL_INT_INPUT,146,34,40,27,
9411 "Maximum tries:");
9412 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9413 fl_set_object_lcolor(obj,FL_WHITE);
9414 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9415 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9416 fl_set_object_resize(obj, FL_RESIZE_NONE);
9417 fl_set_object_callback(obj,doRetryInput,0);
9418 fl_set_input_maxchars(obj, MAXDIG_RETRY);
9419 fl_set_input_filter(obj, byteFilter);
9420 fdui->dlyInput = obj = fl_add_input(FL_INT_INPUT,146,74,40,27,
9421 "Inter-dialing\ndelay (seconds):");
9422 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9423 fl_set_object_lcolor(obj,FL_WHITE);
9424 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9425 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9426 fl_set_object_resize(obj, FL_RESIZE_NONE);
9427 fl_set_object_callback(obj,doDelayInput,0);
9428 fl_set_input_maxchars(obj, MAXDIG_DELAY);
9429 fl_set_input_filter(obj, byteFilter);
9430 fdui->CNWaitInput = obj = fl_add_input(FL_INT_INPUT,146,114,40,27,
9431 "Modem connection\ntimeout (seconds):");
9432 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9433 fl_set_object_lcolor(obj,FL_WHITE);
9434 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9435 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9436 fl_set_object_resize(obj, FL_RESIZE_NONE);
9437 fl_set_object_callback(obj,doCNWaitInput,0);
9438 fl_set_input_maxchars(obj, MAXDIG_CNWAIT);
9439 fl_set_input_filter(obj, byteFilter);
9440 fdui->LCPWaitInput = obj = fl_add_input(FL_INT_INPUT,146,154,40,27,
9441 "Network connection\ntimeout (seconds):");
9442 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9443 fl_set_object_lcolor(obj,FL_WHITE);
9444 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9445 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9446 fl_set_object_resize(obj, FL_RESIZE_NONE);
9447 fl_set_object_callback(obj,doLCPWaitInput,0);
9448 fl_set_input_maxchars(obj, MAXDIG_LCPWAIT);
9449 fl_set_input_filter(obj, byteFilter);
9450 obj = fl_add_text(FL_NORMAL_TEXT,29,197,98,37,"Ring bell when\nconnected:");
9451 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9452 fl_set_object_lcolor(obj,FL_WHITE);
9453 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9454 fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
9455 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9456
9457 fdui->RBGroup = fl_bgn_group();
9458 fdui->RBYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,132,194,57,
9459 25,"Yes");
9460 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9461 fl_set_object_lcolor(obj,FL_WHITE);
9462 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9463 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9464 fl_set_object_resize(obj, FL_RESIZE_NONE);
9465 fl_set_object_callback(obj,doRBYesButton,0);
9466 fdui->RBNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,132,214,54,
9467 25,"No");
9468 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9469 fl_set_object_lcolor(obj,FL_WHITE);
9470 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9471 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9472 fl_set_object_resize(obj, FL_RESIZE_NONE);
9473 fl_set_object_callback(obj,doRBNoButton,0);
9474 fl_end_group();
9475
9476 obj = fl_add_text(FL_NORMAL_TEXT,37,246,91,37,"ISP server\nwill call back:");
9477 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9478 fl_set_object_lcolor(obj,FL_WHITE);
9479 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9480 fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
9481 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9482
9483 fdui->CBGroup = fl_bgn_group();
9484 fdui->CBYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,132,243,58,
9485 25,"Yes");
9486 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9487 fl_set_object_lcolor(obj,FL_WHITE);
9488 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9489 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9490 fl_set_object_resize(obj, FL_RESIZE_NONE);
9491 fl_set_object_callback(obj,doCBYesButton,0);
9492 fdui->CBNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,132,263,58,
9493 25,"No");
9494 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9495 fl_set_object_lcolor(obj,FL_WHITE);
9496 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9497 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9498 fl_set_object_resize(obj, FL_RESIZE_NONE);
9499 fl_set_object_callback(obj,doCBNoButton,0);
9500 fl_end_group();
9501
9502 fdui->CBOptions = obj = fl_add_button(FL_NORMAL_BUTTON,40,293,142,27,
9503 "Call-back Options");
9504 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9505 fl_set_object_resize(obj, FL_RESIZE_NONE);
9506 fl_set_object_callback(obj,doCBOptions,0);
9507 fl_set_object_bw(obj, -2);
9508 obj = fl_add_text(FL_NORMAL_TEXT,230,7,92,23,"Manual Login:");
9509 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9510 fl_set_object_lcolor(obj,FL_WHITE);
9511 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9512 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9513 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9514 obj = fl_add_text(FL_NORMAL_TEXT,236,29,261,19,
9515 "Do you want a terminal after connection?");
9516 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9517 fl_set_object_lcolor(obj,FL_WHITE);
9518 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9519 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9520 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9521
9522 fdui->TTGroup = fl_bgn_group();
9523 fdui->TTYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,282,52,58,
9524 25,"Yes");
9525 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9526 fl_set_object_lcolor(obj,FL_WHITE);
9527 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9528 fl_set_object_lstyle(obj,FL_SHADOW_STYLE);
9529 fl_set_object_resize(obj, FL_RESIZE_NONE);
9530 fl_set_object_callback(obj,doTTYesButton,0);
9531 fdui->TTNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,392,52,55,
9532 25,"No");
9533 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9534 fl_set_object_lcolor(obj,FL_WHITE);
9535 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9536 fl_set_object_lstyle(obj,FL_SHADOW_STYLE);
9537 fl_set_object_resize(obj, FL_RESIZE_NONE);
9538 fl_set_object_callback(obj,doTTNoButton,0);
9539 fl_end_group();
9540
9541 fdui->TSGroup = fl_bgn_group();
9542 fdui->columnsInput = obj = fl_add_input(FL_INT_INPUT,353,85,40,27,
9543 "Terminal columns:");
9544 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9545 fl_set_object_lcolor(obj,FL_WHITE);
9546 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9547 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9548 fl_set_object_resize(obj, FL_RESIZE_NONE);
9549 fl_set_object_callback(obj,doColumnsInput,0);
9550 fl_set_input_maxchars(obj, 3);
9551 fl_set_input_filter(obj, byteFilter);
9552 fdui->rowsInput = obj = fl_add_input(FL_INT_INPUT,463,85,40,27,"and rows:");
9553 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9554 fl_set_object_lcolor(obj,FL_WHITE);
9555 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9556 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9557 fl_set_object_resize(obj, FL_RESIZE_NONE);
9558 fl_set_object_callback(obj,doRowsInput,0);
9559 fl_set_input_maxchars(obj, 3);
9560 fl_set_input_filter(obj, byteFilter);
9561 fl_end_group();
9562
9563 fdui->ALGroup = fl_bgn_group();
9564 obj = fl_add_text(FL_NORMAL_TEXT,219,130,107,23,"Automatic Login:");
9565 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9566 fl_set_object_lcolor(obj,FL_WHITE);
9567 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9568 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9569 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9570 obj = fl_add_text(FL_NORMAL_TEXT,218,150,60,19,"Expect:");
9571 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9572 fl_set_object_lcolor(obj,FL_WHITE);
9573 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9574 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9575 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9576 obj = fl_add_text(FL_NORMAL_TEXT,329,150,46,19,"Send:");
9577 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9578 fl_set_object_lcolor(obj,FL_WHITE);
9579 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9580 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9581 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9582 fdui->expectInput = obj = fl_add_input(FL_MULTILINE_INPUT,224,171,104,
9583 166,"");
9584 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9585 fl_set_object_resize(obj, FL_RESIZE_NONE);
9586 fl_set_object_callback(obj,doExpectInput,0);
9587 fl_set_input_filter(obj, expectFilter);
9588 fl_set_input_return(obj, FL_RETURN_ALWAYS);
9589 fl_set_object_prehandler(obj, slinePreH);
9590 fl_set_input_hscrollbar(obj, FL_OFF);
9591 fl_set_input_scrollbarsize(obj, 16, 16);
9592 fl_set_object_bw(obj, -2);
9593 fdui->sendInput = obj = fl_add_input(FL_MULTILINE_INPUT,334,171,104,
9594 166,"");
9595 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9596 fl_set_object_resize(obj, FL_RESIZE_NONE);
9597 fl_set_object_callback(obj,doSendInput,0);
9598 fl_set_input_filter(obj, sendFilter);
9599 fl_set_input_return(obj, FL_RETURN_ALWAYS);
9600 fl_set_object_prehandler(obj, slinePreH);
9601 fl_set_input_hscrollbar(obj, FL_OFF);
9602 fl_set_input_scrollbarsize(obj, 16, 16);
9603 fl_set_object_bw(obj, -2);
9604 fl_end_group();
9605
9606 obj = fl_add_text(FL_NORMAL_TEXT,440,177,96,168,"On this form you\ndefine "
9607 "parameters\nrelated to dialing\nthe selected ISP,\nand "
9608 "to the login\nmethod.\nCall-back options"
9609 "\nare also available\nbut note that the\nremote end must"
9610 "\nbe appropriately\nconfigured.");
9611 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9612 fl_set_object_lcolor(obj,FL_WHITE);
9613 fl_set_object_lalign(obj,FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
9614 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9615
9616 fdui->tipTimer = obj = fl_add_timer(FL_HIDDEN_TIMER, 0,0,0,0,"");
9617 fl_set_timer(obj, 0.0);
9618 fl_set_object_callback(obj,doDialInfoTip,0);
9619 fl_end_form();
9620
9621 fdui->dialInfo->fdui = fdui;
9622
9623 return fdui;
9624 }
9625
9626 FD_CBInfo *create_form_CBInfo(void)
9627 {
9628 FL_OBJECT *obj;
9629 FD_CBInfo *fdui = (FD_CBInfo *) fl_calloc(1, sizeof(*fdui));
9630
9631 fdui->CBInfo = fl_bgn_form(FL_NO_BOX, 444, 306);
9632 obj = fl_add_box(FL_FLAT_BOX,0,0,444,306,"");
9633 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
9634 fdui->CBInfoOK = obj = fl_add_button(FL_NORMAL_BUTTON,112,267,79,27,"OK");
9635 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9636 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9637 fl_set_object_resize(obj, FL_RESIZE_NONE);
9638 fl_set_object_callback(obj,doCBInfoOK,0);
9639 fl_set_object_bw(obj, -2);
9640 fdui->CBInfoCancel = obj = fl_add_button(FL_NORMAL_BUTTON,247,267,79,27,
9641 "Cancel");
9642 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9643 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9644 fl_set_object_resize(obj, FL_RESIZE_NONE);
9645 fl_set_object_callback(obj,doCBInfoCancel,0);
9646 fl_set_object_bw(obj, -2);
9647 fdui->CBdlyInput = obj = fl_add_input(FL_NORMAL_INPUT,160,10,40,27,
9648 "Call-back delay (sec):");
9649 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9650 fl_set_object_lcolor(obj,FL_WHITE);
9651 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9652 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9653 fl_set_object_resize(obj, FL_RESIZE_NONE);
9654 fl_set_object_callback(obj,doCBDelayInput,0);
9655 fl_set_input_maxchars(obj, MAXDIG_CBDELAY);
9656
9657 obj = fl_add_frame(FL_ENGRAVED_FRAME,15,55,184,123,"");
9658 fl_set_object_color(obj,FL_COL1,FL_COL1);
9659 obj = fl_add_text(FL_NORMAL_TEXT,20,42,140,23,"Call-back Login Type:");
9660 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9661 fl_set_object_lcolor(obj,FL_WHITE);
9662 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9663 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9664 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9665
9666 fdui->LTGroup = fl_bgn_group();
9667 fdui->LTScriptedButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,31,70,
9668 138,25,"Auto (via call-\nback script lines)");
9669 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9670 fl_set_object_lcolor(obj,FL_WHITE);
9671 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9672 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9673 fl_set_object_resize(obj, FL_RESIZE_NONE);
9674 fl_set_object_callback(obj,doLTScriptedButton,0);
9675 fdui->LTTerminalButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,31,107,
9676 145,25,"Terminal after call-\nback connection");
9677 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9678 fl_set_object_lcolor(obj,FL_WHITE);
9679 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9680 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9681 fl_set_object_resize(obj, FL_RESIZE_NONE);
9682 fl_set_object_callback(obj,doLTTerminalButton,0);
9683 fdui->LTRASButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,32,144,
9684 145,25,"NT RAS call-back");
9685 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
9686 fl_set_object_lcolor(obj,FL_WHITE);
9687 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9688 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9689 fl_set_object_resize(obj, FL_RESIZE_NONE);
9690 fl_set_object_callback(obj,doLTRASButton,0);
9691 fl_end_group();
9692
9693 fdui->TSGroup = fl_bgn_group();
9694 fdui->columnsInput = obj = fl_add_input(FL_INT_INPUT,213,189,40,27,
9695 "Manual terminal columns:");
9696 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9697 fl_set_object_lcolor(obj,FL_WHITE);
9698 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9699 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9700 fl_set_object_resize(obj, FL_RESIZE_NONE);
9701 fl_set_object_callback(obj,doCBColumnsInput,0);
9702 fl_set_input_maxchars(obj, 3);
9703 fl_set_input_filter(obj, byteFilter);
9704 fdui->rowsInput = obj = fl_add_input(FL_INT_INPUT,301,189,40,27,"rows:");
9705 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9706 fl_set_object_lcolor(obj,FL_WHITE);
9707 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9708 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9709 fl_set_object_resize(obj, FL_RESIZE_NONE);
9710 fl_set_object_callback(obj,doCBRowsInput,0);
9711 fl_set_input_maxchars(obj, 3);
9712 fl_set_input_filter(obj, byteFilter);
9713 fl_end_group();
9714
9715 fdui->CBTelInput = obj = fl_add_input(FL_NORMAL_INPUT,213,226,215,28,
9716 "NT RAS call-back phone number:");
9717 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9718 fl_set_object_lcolor(obj,FL_WHITE);
9719 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9720 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9721 fl_set_object_resize(obj, FL_RESIZE_NONE);
9722 fl_set_object_callback(obj,doCBTelInput,0);
9723 fl_set_input_maxchars(obj, MAXLEN_PHONE+1);
9724
9725 fdui->ALGroup = fl_bgn_group();
9726 obj = fl_add_text(FL_NORMAL_TEXT,208,34,60,19,"Expect:");
9727 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9728 fl_set_object_lcolor(obj,FL_WHITE);
9729 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9730 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9731 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9732 obj = fl_add_text(FL_NORMAL_TEXT,320,34,46,19,"Send:");
9733 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9734 fl_set_object_lcolor(obj,FL_WHITE);
9735 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9736 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9737 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9738 obj = fl_add_text(FL_NORMAL_TEXT,208,14,141,21,"Call-back script lines:");
9739 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9740 fl_set_object_lcolor(obj,FL_WHITE);
9741 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9742 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9743 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9744 fdui->CBExpectInput = obj = fl_add_input(FL_MULTILINE_INPUT,213,55,104,
9745 124,"");
9746 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9747 fl_set_object_resize(obj, FL_RESIZE_NONE);
9748 fl_set_object_callback(obj,doCBExpectInput,0);
9749 fl_set_input_filter(obj, CBExpectFilter);
9750 fl_set_input_return(obj, FL_RETURN_ALWAYS);
9751 fl_set_object_prehandler(obj, slinePreH);
9752 fl_set_input_hscrollbar(obj, FL_OFF);
9753 fl_set_input_vscrollbar(obj, FL_OFF);
9754 fl_set_input_scrollbarsize(obj, 16, 16);
9755 fl_set_object_bw(obj, -2);
9756 fdui->CBSendInput = obj = fl_add_input(FL_MULTILINE_INPUT,324,55,104,
9757 124,"");
9758 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9759 fl_set_object_resize(obj, FL_RESIZE_NONE);
9760 fl_set_object_callback(obj,doCBSendInput,0);
9761 fl_set_input_filter(obj, CBSendFilter);
9762 fl_set_input_return(obj, FL_RETURN_ALWAYS);
9763 fl_set_object_prehandler(obj, slinePreH);
9764 fl_set_input_hscrollbar(obj, FL_OFF);
9765 fl_set_input_vscrollbar(obj, FL_OFF);
9766 fl_set_input_scrollbarsize(obj, 16, 16);
9767 fl_set_object_bw(obj, -2);
9768 fl_end_group();
9769
9770 fdui->tipTimer = obj = fl_add_timer(FL_HIDDEN_TIMER, 0,0,0,0,"");
9771 fl_set_timer(obj, 0.0);
9772 fl_set_object_callback(obj,doCBInfoTip,0);
9773 fl_end_form();
9774
9775 fdui->CBInfo->fdui = fdui;
9776
9777 return fdui;
9778 }
9779
9780 FD_aboutInfo *create_form_aboutInfo(void)
9781 {
9782 FL_OBJECT *obj;
9783 FD_aboutInfo *fdui = (FD_aboutInfo *) fl_calloc(1, sizeof(*fdui));
9784 char vstr[32] = {0};
9785
9786 fdui->aboutInfo = fl_bgn_form(FL_NO_BOX, 205, 150);
9787 obj = fl_add_box(FL_FLAT_BOX,0,0,205,150,"");
9788 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
9789 fl_set_object_resize(obj, FL_RESIZE_NONE);
9790 obj = fl_add_pixmap(FL_NORMAL_PIXMAP,13,17,68,30,"");
9791 fl_set_object_resize(obj, FL_RESIZE_NONE);
9792 fl_set_object_gravity(obj, FL_West, FL_West);
9793 fl_set_pixmap_data(obj, xisp_xpm);
9794 sprintf(vstr, "X-ISP V.%s%s\ncoded by:", Version, PatchLevel);
9795 fdui->verString = obj = fl_add_text(FL_NORMAL_TEXT,81,13,116,40, vstr);
9796 fl_set_object_color(obj,FL_INDIANRED,FL_TOP_BCOL);
9797 fl_set_object_lcolor(obj,FL_WHITE);
9798 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9799 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
9800 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9801 fl_set_object_resize(obj, FL_RESIZE_NONE);
9802 obj = fl_add_text(FL_NORMAL_TEXT,30,53,148,40,
9803 "Dimitrios P. Bouras\ndbouras@hol.gr");
9804 fl_set_object_color(obj,FL_INDIANRED,FL_TOP_BCOL);
9805 fl_set_object_lcolor(obj,FL_WHITE);
9806 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9807 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
9808 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9809 fl_set_object_resize(obj, FL_RESIZE_NONE);
9810 fdui->aboutOK = obj = fl_add_button(FL_RETURN_BUTTON,64,106,79,27,"Dismiss");
9811 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9812 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9813 fl_set_object_resize(obj, FL_RESIZE_NONE);
9814 fl_set_object_callback(obj,doAboutOK,0);
9815 fl_set_object_bw(obj, -2);
9816 fl_end_form();
9817
9818 fdui->aboutInfo->fdui = fdui;
9819
9820 return fdui;
9821 }
9822
9823 FD_exitDialog *create_form_exitDialog(void)
9824 {
9825 FL_OBJECT *obj;
9826 FD_exitDialog *fdui = (FD_exitDialog *) fl_calloc(1, sizeof(*fdui));
9827
9828 fdui->exitDialog = fl_bgn_form(FL_NO_BOX, 230, 117);
9829 obj = fl_add_box(FL_FLAT_BOX,0,0,230,117,"");
9830 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
9831 fdui->exitOK = obj = fl_add_button(FL_RETURN_BUTTON,19,77,79,27,"OK");
9832 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9833 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9834 fl_set_object_resize(obj, FL_RESIZE_NONE);
9835 fl_set_object_callback(obj,doExitOK,0);
9836 fl_set_object_bw(obj, -2);
9837 fdui->exitCancel = obj = fl_add_button(FL_NORMAL_BUTTON,134,77,79,27,
9838 "Cancel");
9839 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9840 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9841 fl_set_object_resize(obj, FL_RESIZE_NONE);
9842 fl_set_object_callback(obj,doExitCancel,0);
9843 fl_set_object_bw(obj, -2);
9844 obj = fl_add_text(FL_NORMAL_TEXT,56,9,150,59,
9845 "Are you sure you\nwant to exit X-ISP and\ndisconnect the link?");
9846 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9847 fl_set_object_lcolor(obj,FL_WHITE);
9848 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9849 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9850 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9851 fl_set_object_resize(obj, FL_RESIZE_NONE);
9852 fdui->exitIcon = obj = fl_add_pixmap(FL_NORMAL_PIXMAP,25,21,14,36,"");
9853 fl_set_object_resize(obj, FL_RESIZE_NONE);
9854 fl_set_object_gravity(obj, FL_West, FL_West);
9855 fl_set_pixmap_data(obj, excl_xpm);
9856 fl_end_form();
9857
9858 fdui->exitDialog->fdui = fdui;
9859
9860 return fdui;
9861 }
9862
9863 FD_renameISP *create_form_renameISP(void)
9864 {
9865 FL_OBJECT *obj;
9866 FD_renameISP *fdui = (FD_renameISP *) fl_calloc(1, sizeof(*fdui));
9867
9868 fdui->renameISP = fl_bgn_form(FL_NO_BOX, 219, 112);
9869 obj = fl_add_box(FL_FLAT_BOX,0,0,219,112,"");
9870 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
9871 obj = fl_add_text(FL_NORMAL_TEXT,7,4,145,24,"Enter ISP Description:");
9872 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9873 fl_set_object_lcolor(obj,FL_WHITE);
9874 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9875 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9876 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9877 fdui->ISPNameInput = obj = fl_add_input(FL_NORMAL_INPUT,12,29,194,28,"");
9878 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
9879 fl_set_object_lcol(obj,FL_WHITE);
9880 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9881 fl_set_object_lalign(obj,FL_ALIGN_TOP_LEFT);
9882 fl_set_object_resize(obj, FL_RESIZE_NONE);
9883 fl_set_object_callback(obj,doISPNameInput,0);
9884 fl_set_input_maxchars(obj, MAXLEN_DESCR);
9885 fdui->ISPNameEditOK = obj = fl_add_button(FL_RETURN_BUTTON,12,71,79,27,"OK");
9886 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9887 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9888 fl_set_object_resize(obj, FL_RESIZE_NONE);
9889 fl_set_object_callback(obj,doISPNameEditOK,0);
9890 fl_set_object_bw(obj, -2);
9891 fdui->ISPNameEditCancel = obj = fl_add_button(FL_NORMAL_BUTTON,127,71,79,27,
9892 "Cancel");
9893 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9894 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9895 fl_set_object_resize(obj, FL_RESIZE_NONE);
9896 fl_set_object_callback(obj,doISPNameEditCancel,0);
9897 fl_set_object_bw(obj, -2);
9898 fl_end_form();
9899
9900 fdui->renameISP->fdui = fdui;
9901
9902 return fdui;
9903 }
9904
9905 FD_helpInfo *create_form_helpInfo(void)
9906 {
9907 FL_OBJECT *obj;
9908 FD_helpInfo *fdui = (FD_helpInfo *) fl_calloc(1, sizeof(*fdui));
9909
9910 fdui->helpInfo = fl_bgn_form(FL_NO_BOX, 510, 480);
9911 obj = fl_add_box(FL_FLAT_BOX,0,0,510,480,"");
9912 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
9913 fdui->helpBrowser = obj = fl_add_browser(FL_NORMAL_BROWSER,10,11,489,423,"");
9914 fl_set_object_color(obj,FL_TOP_BCOL,FL_CYAN);
9915 fl_set_browser_fontsize(obj,FL_NORMAL_SIZE);
9916 fl_set_browser_scrollbarsize(obj, 16, 16);
9917 fl_set_object_bw(obj, -2);
9918 fdui->helpInfoOK = obj = fl_add_button(FL_RETURN_BUTTON,421,444,79,27,"OK");
9919 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9920 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9921 fl_set_object_resize(obj, FL_RESIZE_NONE);
9922 fl_set_object_callback(obj,doHelpInfoOK,0);
9923 fl_set_object_bw(obj, -2);
9924 obj = fl_add_text(FL_NORMAL_TEXT,8,435,329,39,
9925 "To browse, use PgUp, PgDn, and/or up-/down-arrow\n"
9926 "keyboard keys, or the scroll-bar via your mouse.");
9927 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9928 fl_set_object_lcolor(obj,FL_WHITE);
9929 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9930 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9931 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9932 fl_set_object_resize(obj, FL_RESIZE_NONE);
9933 fl_end_form();
9934
9935 fdui->helpInfo->fdui = fdui;
9936
9937 return fdui;
9938 }
9939
9940 FD_alertMessage *create_form_alertMessage(void)
9941 {
9942 FL_OBJECT *obj;
9943 FD_alertMessage *fdui = (FD_alertMessage *) fl_calloc(1, sizeof(*fdui));
9944
9945 fdui->alertMessage = fl_bgn_form(FL_NO_BOX, 320, 122);
9946 obj = fl_add_box(FL_FLAT_BOX,0,0,320,122,"");
9947 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
9948 obj = fl_add_pixmap(FL_NORMAL_PIXMAP,17,20,14,36,"");
9949 fl_set_object_resize(obj, FL_RESIZE_NONE);
9950 fl_set_object_gravity(obj, FL_NorthWest, FL_NorthWest);
9951 fl_set_pixmap_data(obj, excl_xpm);
9952 fdui->alertMessageStr = obj = fl_add_text(FL_NORMAL_TEXT,37,11,266,69,"");
9953 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9954 fl_set_object_lcolor(obj,FL_WHITE);
9955 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9956 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9957 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
9958 fl_set_object_resize(obj, FL_RESIZE_NONE);
9959 fdui->alertMessageDismiss = obj = fl_add_button(FL_RETURN_BUTTON,225,86,
9960 79,27,"Dismiss");
9961 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9962 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
9963 fl_set_object_resize(obj, FL_RESIZE_NONE);
9964 fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
9965 fl_set_object_bw(obj, -2);
9966 fdui->noMoreHints = obj = fl_add_round3dbutton(FL_PUSH_BUTTON,9,86,166,25,
9967 "No more hints please!");
9968 fl_set_object_lcolor(obj,FL_WHITE);
9969 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9970 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9971 fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
9972 fl_end_form();
9973
9974 fdui->alertMessage->fdui = fdui;
9975
9976 return fdui;
9977 }
9978
9979 FD_commInfo *create_form_commInfo(void)
9980 {
9981 FL_OBJECT *obj;
9982 FD_commInfo *fdui = (FD_commInfo *) fl_calloc(1, sizeof(*fdui));
9983
9984 fdui->commInfo = fl_bgn_form(FL_NO_BOX, 540, 350);
9985 obj = fl_add_box(FL_FLAT_BOX,0,0,540,350,"");
9986 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
9987
9988 obj = fl_add_frame(FL_ENGRAVED_FRAME,11,259,237,77,"");
9989 fl_set_object_color(obj,FL_COL1,FL_COL1);
9990 obj = fl_add_text(FL_NORMAL_TEXT,18,249,152,18,"Software Compression:");
9991 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
9992 fl_set_object_lcolor(obj,FL_WHITE);
9993 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
9994 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
9995 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
9996
9997 fdui->SWCType = fl_bgn_group();
9998 fdui->SWCBSDButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,13,268,64,
9999 25,"BSD");
10000 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10001 fl_set_object_lcolor(obj,FL_WHITE);
10002 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10003 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10004 fl_set_object_resize(obj, FL_RESIZE_NONE);
10005 fl_set_object_callback(obj,doSWCBSDButton,0);
10006 fdui->SWCDeflateButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,99,268,80,
10007 25,"Deflate");
10008 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10009 fl_set_object_lcolor(obj,FL_WHITE);
10010 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10011 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10012 fl_set_object_resize(obj, FL_RESIZE_NONE);
10013 fl_set_object_callback(obj,doSWCDeflateButton,0);
10014 fdui->SWCOffButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,180,268,61,
10015 25,"None");
10016 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10017 fl_set_object_lcolor(obj,FL_WHITE);
10018 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10019 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10020 fl_set_object_resize(obj, FL_RESIZE_NONE);
10021 fl_set_object_callback(obj,doSWCOffButton,0);
10022 fl_end_group();
10023
10024 obj = fl_add_frame(FL_ENGRAVED_FRAME,263,14,262,95,"");
10025 fl_set_object_color(obj,FL_COL1,FL_COL1);
10026 obj = fl_add_text(FL_NORMAL_TEXT,270,3,145,20,"Serial Port Baud Rate:");
10027 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10028 fl_set_object_lcolor(obj,FL_WHITE);
10029 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10030 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10031 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10032
10033 fdui->modemSpeedType = fl_bgn_group();
10034 fdui->speedButton[6] = obj = fl_add_checkbutton(FL_RADIO_BUTTON,449,48,65,
10035 25,"57600");
10036 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10037 fl_set_object_lcolor(obj,FL_WHITE);
10038 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10039 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10040 fl_set_object_resize(obj, FL_RESIZE_NONE);
10041 fl_set_object_callback(obj,doSpeedButton,6);
10042 fdui->speedButton[7] = obj = fl_add_checkbutton(FL_RADIO_BUTTON,271,73,75,
10043 25,"115200");
10044 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10045 fl_set_object_lcolor(obj,FL_WHITE);
10046 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10047 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10048 fl_set_object_resize(obj, FL_RESIZE_NONE);
10049 fl_set_object_callback(obj,doSpeedButton,7);
10050 fdui->speedButton[4] = obj = fl_add_checkbutton(FL_RADIO_BUTTON,271,48,65,
10051 25,"19200");
10052 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10053 fl_set_object_lcolor(obj,FL_WHITE);
10054 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10055 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10056 fl_set_object_resize(obj, FL_RESIZE_NONE);
10057 fl_set_object_callback(obj,doSpeedButton,4);
10058 fdui->speedButton[5] = obj = fl_add_checkbutton(FL_RADIO_BUTTON,360,48,65,
10059 25,"38400");
10060 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10061 fl_set_object_lcolor(obj,FL_WHITE);
10062 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10063 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10064 fl_set_object_resize(obj, FL_RESIZE_NONE);
10065 fl_set_object_callback(obj,doSpeedButton,5);
10066 fdui->speedButton[2] = obj = fl_add_checkbutton(FL_RADIO_BUTTON,393,23,59,
10067 25,"4800");
10068 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10069 fl_set_object_lcolor(obj,FL_WHITE);
10070 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10071 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10072 fl_set_object_resize(obj, FL_RESIZE_NONE);
10073 fl_set_object_callback(obj,doSpeedButton,2);
10074 fdui->speedButton[3] = obj = fl_add_checkbutton(FL_RADIO_BUTTON,456,23,59,
10075 25,"9600");
10076 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10077 fl_set_object_lcolor(obj,FL_WHITE);
10078 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10079 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10080 fl_set_object_resize(obj, FL_RESIZE_NONE);
10081 fl_set_object_callback(obj,doSpeedButton,3);
10082 fdui->speedButton[1] = obj = fl_add_checkbutton(FL_RADIO_BUTTON,330,23,59,
10083 25,"2400");
10084 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10085 fl_set_object_lcolor(obj,FL_WHITE);
10086 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10087 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10088 fl_set_object_resize(obj, FL_RESIZE_NONE);
10089 fl_set_object_callback(obj,doSpeedButton,1);
10090 fdui->speedButton[0] = obj = fl_add_checkbutton(FL_RADIO_BUTTON,271,23,58,
10091 25,"1200");
10092 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10093 fl_set_object_lcolor(obj,FL_WHITE);
10094 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10095 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10096 fl_set_object_resize(obj, FL_RESIZE_NONE);
10097 fl_set_object_callback(obj,doSpeedButton,0);
10098 fdui->speedButton[8] = obj = fl_add_checkbutton(FL_RADIO_BUTTON,360,73,75,
10099 25,"Custom:");
10100 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10101 fl_set_object_lcolor(obj,FL_WHITE);
10102 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10103 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10104 fl_set_object_resize(obj, FL_RESIZE_NONE);
10105 fl_set_object_callback(obj,doSpeedButton,8);
10106 fdui->customSpeedInput = obj = fl_add_input(FL_INT_INPUT,438,73,75,27,"");
10107 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10108 fl_set_object_lcolor(obj,FL_WHITE);
10109 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10110 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10111 fl_set_object_resize(obj, FL_RESIZE_NONE);
10112 fl_set_object_callback(obj,doCustomSpeedInput,0);
10113 fl_set_input_maxchars(obj, MAXDIG_BAUDRATE);
10114 fl_end_group();
10115
10116 obj = fl_add_frame(FL_ENGRAVED_FRAME,263,123,262,61,"");
10117 fl_set_object_color(obj,FL_COL1,FL_COL1);
10118 obj = fl_add_text(FL_NORMAL_TEXT,270,112,89,19,"Flow control:");
10119 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10120 fl_set_object_lcolor(obj,FL_WHITE);
10121 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10122 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10123 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10124
10125 fdui->flowCtrlType = fl_bgn_group();
10126 fdui->HWButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,271,130,210,
10127 26,"Hardware (RTS/CTS signals)");
10128 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10129 fl_set_object_lcolor(obj,FL_WHITE);
10130 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10131 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10132 fl_set_object_resize(obj, FL_RESIZE_NONE);
10133 fl_set_object_callback(obj,doHWButton,0);
10134 fdui->SWButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,271,152,250,
10135 25,"Software (XON/XOFF control chars)");
10136 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10137 fl_set_object_lcolor(obj,FL_WHITE);
10138 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10139 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10140 fl_set_object_resize(obj, FL_RESIZE_NONE);
10141 fl_set_object_callback(obj,doSWButton,0);
10142 fl_end_group();
10143
10144 obj = fl_add_frame(FL_ENGRAVED_FRAME,263,198,174,139,"");
10145 fl_set_object_color(obj,FL_COL1,FL_COL1);
10146 obj = fl_add_text(FL_NORMAL_TEXT,270,187,70,21,"Advanced:");
10147 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10148 fl_set_object_lcolor(obj,FL_WHITE);
10149 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10150 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10151 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10152 obj = fl_add_text(FL_NORMAL_TEXT,268,208,60,21,"Escape:");
10153 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10154 fl_set_object_lcolor(obj,FL_WHITE);
10155 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10156 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10157 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10158
10159 fdui->escapeType = fl_bgn_group();
10160 fdui->escapeYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,332,208,55,
10161 25,"Yes");
10162 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10163 fl_set_object_lcolor(obj,FL_WHITE);
10164 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10165 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10166 fl_set_object_resize(obj, FL_RESIZE_NONE);
10167 fl_set_object_callback(obj,doEscapeYesButton,0);
10168 fl_set_button(obj, 1);
10169 fdui->escapeNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,332,231,47,
10170 25,"No");
10171 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10172 fl_set_object_lcolor(obj,FL_WHITE);
10173 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10174 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10175 fl_set_object_resize(obj, FL_RESIZE_NONE);
10176 fl_set_object_callback(obj,doEscapeNoButton,0);
10177 fl_end_group();
10178
10179 obj = fl_add_frame(FL_ENGRAVED_FRAME,11,170,237,75,"");
10180 fl_set_object_color(obj,FL_COL1,FL_COL1);
10181 obj = fl_add_text(FL_NORMAL_TEXT,18,159,102,20,"Dialing method:");
10182 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10183 fl_set_object_lcolor(obj,FL_WHITE);
10184 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10185 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10186 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10187
10188 fdui->modemDialType = fl_bgn_group();
10189 fdui->toneButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,13,179,61,
10190 25,"Tone");
10191 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10192 fl_set_object_lcolor(obj,FL_WHITE);
10193 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10194 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10195 fl_set_object_resize(obj, FL_RESIZE_NONE);
10196 fl_set_object_callback(obj,doToneButton,0);
10197 fdui->pulseButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,99,179,68,
10198 25,"Pulse");
10199 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10200 fl_set_object_lcolor(obj,FL_WHITE);
10201 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10202 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10203 fl_set_object_resize(obj, FL_RESIZE_NONE);
10204 fl_set_object_callback(obj,doPulseButton,0);
10205 fdui->ISDNButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,180,179,63,
10206 25,"ISDN");
10207 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10208 fl_set_object_lcolor(obj,FL_WHITE);
10209 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10210 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10211 fl_set_object_resize(obj, FL_RESIZE_NONE);
10212 fl_set_object_callback(obj,doISDNButton,0);
10213 fl_end_group();
10214
10215 fdui->deviceInput = obj = fl_add_input(FL_NORMAL_INPUT,159,12,90,28,
10216 "Serial port device name:");
10217 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10218 fl_set_object_lcolor(obj,FL_WHITE);
10219 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10220 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10221 fl_set_object_resize(obj, FL_RESIZE_NONE);
10222 fl_set_object_callback(obj,doDeviceInput,0);
10223 fl_set_input_maxchars(obj, MAXLEN_DEVICE);
10224 fdui->modemResetInput = obj = fl_add_input(FL_NORMAL_INPUT,91,50,158,28,
10225 "Modem\nreset string:");
10226 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10227 fl_set_object_lcolor(obj,FL_WHITE);
10228 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10229 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10230 fl_set_object_resize(obj, FL_RESIZE_NONE);
10231 fl_set_object_callback(obj,doModemResetInput,0);
10232 fl_set_input_maxchars(obj, MAXLEN_MDMCMD);
10233 fdui->modemInitInput = obj = fl_add_input(FL_NORMAL_INPUT,126,86,123,28,
10234 "Modem\ninitialization string:");
10235 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10236 fl_set_object_lcolor(obj,FL_WHITE);
10237 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10238 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10239 fl_set_object_resize(obj, FL_RESIZE_NONE);
10240 fl_set_object_callback(obj,doModemInitInput,0);
10241 fl_set_input_maxchars(obj, MAXLEN_MDMCMD);
10242 fdui->modemConnectInput = obj = fl_add_input(FL_NORMAL_INPUT,103,124,146,28,
10243 "Modem\nconnect string:");
10244 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10245 fl_set_object_lcolor(obj,FL_WHITE);
10246 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10247 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10248 fl_set_object_resize(obj, FL_RESIZE_NONE);
10249 fl_set_object_callback(obj,doModemConnectInput,0);
10250 fl_set_input_maxchars(obj, MAXLEN_MDMSTR);
10251 fdui->modemDialInput = obj = fl_add_input(FL_NORMAL_INPUT,109,207,128,28,
10252 "Dialing extras:");
10253 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10254 fl_set_object_lcolor(obj,FL_WHITE);
10255 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10256 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10257 fl_set_object_resize(obj, FL_RESIZE_NONE);
10258 fl_set_object_callback(obj,doModemDialInput,0);
10259 fl_set_input_maxchars(obj, MAXLEN_DIALEXTRA);
10260 fdui->SWCInput = obj = fl_add_input(FL_INT_INPUT,193,297,44,27,
10261 "Compression level (8-15):");
10262 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10263 fl_set_object_lcolor(obj,FL_WHITE);
10264 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10265 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10266 fl_set_object_resize(obj, FL_RESIZE_NONE);
10267 fl_set_object_callback(obj,doSWCInput,0);
10268 fl_set_input_maxchars(obj, MAXDIG_BSDCOMP);
10269 fl_set_input_filter(obj, SWCInputFilter);
10270 fdui->asyncmapInput = obj = fl_add_input(FL_NORMAL_INPUT,344,299,80,28,
10271 "Asyncmap:");
10272 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10273 fl_set_object_lcolor(obj,FL_WHITE);
10274 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10275 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10276 fl_set_object_resize(obj, FL_RESIZE_NONE);
10277 fl_set_object_callback(obj,doAsyncmapInput,0);
10278 fl_set_input_maxchars(obj, MAXDIG_ASYNCMAP);
10279 fl_set_input_filter(obj, AMInputFilter);
10280 fdui->escapeInput = obj = fl_add_input(FL_NORMAL_INPUT,344,258,80,28,
10281 "Byte List:");
10282 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10283 fl_set_object_lcolor(obj,FL_WHITE);
10284 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10285 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10286 fl_set_object_resize(obj, FL_RESIZE_NONE);
10287 fl_set_object_callback(obj,doEscapeInput,0);
10288 fl_set_input_maxchars(obj, MAXLEN_ESCAPE);
10289 fl_set_input_filter(obj, EInputFilter);
10290 obj = fl_add_text(FL_NORMAL_TEXT,440,201,94,140,"On this form you\ndefine "
10291 "(per ISP)\nmodem-specific\nparameters, and\nadjust "
10292 "settings\nrelated to the\nPPP protocol;\nsuch are "
10293 "software\ncompression and\nbyte filtering.");
10294 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10295 fl_set_object_lcolor(obj,FL_WHITE);
10296 fl_set_object_lalign(obj,FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
10297 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10298
10299 fdui->tipTimer = obj = fl_add_timer(FL_HIDDEN_TIMER, 0,0,0,0,"");
10300 fl_set_timer(obj, 0.0);
10301 fl_set_object_callback(obj,doCommInfoTip,0);
10302 fl_end_form();
10303
10304 fdui->commInfo->fdui = fdui;
10305
10306 return fdui;
10307 }
10308
10309 FD_tcpipInfo *create_form_tcpipInfo(void)
10310 {
10311 FL_OBJECT *obj;
10312 FD_tcpipInfo *fdui = (FD_tcpipInfo *) fl_calloc(1, sizeof(*fdui));
10313
10314 fdui->tcpipInfo = fl_bgn_form(FL_NO_BOX, 540, 350);
10315 obj = fl_add_box(FL_FLAT_BOX,0,0,540,350,"");
10316 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
10317 obj = fl_add_frame(FL_ENGRAVED_FRAME,387,16,138,150,"");
10318 fl_set_object_color(obj,FL_COL1,FL_COL1);
10319 obj = fl_add_frame(FL_ENGRAVED_FRAME,15,16,360,150,"");
10320 fl_set_object_color(obj,FL_COL1,FL_COL1);
10321
10322 obj = fl_add_text(FL_NORMAL_TEXT,21,2,129,24,"Addressing/Routing:");
10323 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10324 fl_set_object_lcolor(obj,FL_WHITE);
10325 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10326 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10327 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10328 fdui->localIPInput = obj = fl_add_input(FL_NORMAL_INPUT,252,33,113,28,
10329 "Local IP\naddress:");
10330 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10331 fl_set_object_lcolor(obj,FL_WHITE);
10332 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10333 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10334 fl_set_object_resize(obj, FL_RESIZE_NONE);
10335 fl_set_object_callback(obj,doLocalIPInput,0);
10336 fl_set_input_maxchars(obj, MAXLEN_IP);
10337 fl_set_input_filter(obj, IPInputFilter);
10338
10339 obj = fl_add_text(FL_NORMAL_TEXT,33,28,95,37,"Dynamic local\nIP address:");
10340 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10341 fl_set_object_lcolor(obj,FL_WHITE);
10342 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10343 fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
10344 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10345
10346 fdui->ALTypeGroup = fl_bgn_group();
10347 fdui->ALYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,127,25,58,
10348 25,"Yes");
10349 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10350 fl_set_object_lcolor(obj,FL_WHITE);
10351 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10352 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10353 fl_set_object_resize(obj, FL_RESIZE_NONE);
10354 fl_set_object_callback(obj,doALYesButton,0);
10355 fdui->ALNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,127,45,55,
10356 25,"No");
10357 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10358 fl_set_object_lcolor(obj,FL_WHITE);
10359 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10360 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10361 fl_set_object_resize(obj, FL_RESIZE_NONE);
10362 fl_set_object_callback(obj,doALNoButton,0);
10363 fl_end_group();
10364
10365 fdui->remoteIPInput = obj = fl_add_input(FL_NORMAL_INPUT,252,82,113,28,
10366 "Remote IP\naddress:");
10367 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10368 fl_set_object_lcolor(obj,FL_WHITE);
10369 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10370 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10371 fl_set_object_resize(obj, FL_RESIZE_NONE);
10372 fl_set_object_callback(obj,doRemoteIPInput,0);
10373 fl_set_input_maxchars(obj, MAXLEN_IP);
10374 fl_set_input_filter(obj, IPInputFilter);
10375 obj = fl_add_text(FL_NORMAL_TEXT,20,76,109,37,
10376 "Dynamic remote\nIP address:");
10377 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10378 fl_set_object_lcolor(obj,FL_WHITE);
10379 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10380 fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
10381 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10382
10383 fdui->ARTypeGroup = fl_bgn_group();
10384 fdui->ARYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,127,73,58,
10385 25,"Yes");
10386 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10387 fl_set_object_lcolor(obj,FL_WHITE);
10388 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10389 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10390 fl_set_object_resize(obj, FL_RESIZE_NONE);
10391 fl_set_object_callback(obj,doARYesButton,0);
10392 fdui->ARNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,127,93,55,
10393 25,"No");
10394 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10395 fl_set_object_lcolor(obj,FL_WHITE);
10396 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10397 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10398 fl_set_object_resize(obj, FL_RESIZE_NONE);
10399 fl_set_object_callback(obj,doARNoButton,0);
10400 fl_end_group();
10401
10402 obj = fl_add_text(FL_NORMAL_TEXT,43,132,214,22,
10403 "Add default route to routing table:");
10404 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10405 fl_set_object_lcolor(obj,FL_WHITE);
10406 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10407 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10408 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10409
10410 fdui->DRTypeGroup = fl_bgn_group();
10411 fdui->DRYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,258,132,58,
10412 25,"Yes");
10413 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10414 fl_set_object_lcolor(obj,FL_WHITE);
10415 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10416 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10417 fl_set_object_resize(obj, FL_RESIZE_NONE);
10418 fl_set_object_callback(obj,doDRYesButton,0);
10419 fdui->DRNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,314,132,55,
10420 25,"No");
10421 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10422 fl_set_object_lcolor(obj,FL_WHITE);
10423 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10424 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10425 fl_set_object_resize(obj, FL_RESIZE_NONE);
10426 fl_set_object_callback(obj,doDRNoButton,0);
10427 fl_end_group();
10428
10429 obj = fl_add_text(FL_NORMAL_TEXT,394,2,69,24,"Interface:");
10430 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10431 fl_set_object_lcolor(obj,FL_WHITE);
10432 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10433 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10434 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10435 fdui->NMInput = obj = fl_add_input(FL_NORMAL_INPUT,400,47,113,28,"Netmask:");
10436 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10437 fl_set_object_lcolor(obj,FL_WHITE);
10438 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10439 fl_set_object_lalign(obj,FL_ALIGN_TOP_LEFT);
10440 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10441 fl_set_object_resize(obj, FL_RESIZE_NONE);
10442 fl_set_object_callback(obj,doNMInput,0);
10443 fl_set_input_maxchars(obj, MAXLEN_IP);
10444 fl_set_input_filter(obj, IPInputFilter);
10445 fdui->MTUInput = obj = fl_add_input(FL_INT_INPUT,465,84,48,28,"MTU:");
10446 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10447 fl_set_object_lcolor(obj,FL_WHITE);
10448 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10449 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10450 fl_set_object_resize(obj, FL_RESIZE_NONE);
10451 fl_set_object_callback(obj,doMTUInput,0);
10452 fl_set_input_maxchars(obj, MAXDIG_MTRU);
10453 fdui->MRUInput = obj = fl_add_input(FL_INT_INPUT,465,121,48,28,"MRU:");
10454 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10455 fl_set_object_lcolor(obj,FL_WHITE);
10456 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10457 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10458 fl_set_object_resize(obj, FL_RESIZE_NONE);
10459 fl_set_object_callback(obj,doMRUInput,0);
10460 fl_set_input_maxchars(obj, MAXDIG_MTRU);
10461 obj = fl_add_frame(FL_ENGRAVED_FRAME,15,185,420,150,"");
10462 fl_set_object_color(obj,FL_COL1,FL_COL1);
10463 obj = fl_add_text(FL_NORMAL_TEXT,21,172,214,24,
10464 "DNS support (via ip-up/ip-down):");
10465 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10466 fl_set_object_lcolor(obj,FL_WHITE);
10467 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10468 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10469 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10470
10471 fdui->NRTypeGroup = fl_bgn_group();
10472 fdui->DNSNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,33,195,50,
10473 25,"No");
10474 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10475 fl_set_object_lcolor(obj,FL_WHITE);
10476 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10477 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10478 fl_set_object_resize(obj, FL_RESIZE_NONE);
10479 fl_set_object_callback(obj,doDNSNoButton,0);
10480 fdui->DNSAutoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,33,226,188,
10481 25,"Automatic\n(ISP assigned)");
10482 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10483 fl_set_object_lcolor(obj,FL_WHITE);
10484 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10485 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10486 fl_set_object_resize(obj, FL_RESIZE_NONE);
10487 fl_set_object_callback(obj,doDNSAutoButton,0);
10488 fdui->DNSManualButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,33,258,80,
10489 25,"Manual");
10490 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10491 fl_set_object_lcolor(obj,FL_WHITE);
10492 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10493 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10494 fl_set_object_resize(obj, FL_RESIZE_NONE);
10495 fl_set_object_callback(obj,doDNSManualButton,0);
10496 fl_end_group();
10497
10498 fdui->pDNSInput = obj = fl_add_input(FL_NORMAL_INPUT,312,194,113,28,
10499 "Primary DNS Server:");
10500 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10501 fl_set_object_lcolor(obj,FL_WHITE);
10502 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10503 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10504 fl_set_object_resize(obj, FL_RESIZE_NONE);
10505 fl_set_object_callback(obj,doPDNSInput,0);
10506 fl_set_input_maxchars(obj, MAXLEN_IP);
10507 fl_set_input_filter(obj, IPInputFilter);
10508 fdui->sDNSInput = obj = fl_add_input(FL_NORMAL_INPUT,312,231,113,28,
10509 "Secondary DNS Server:");
10510 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10511 fl_set_object_lcolor(obj,FL_WHITE);
10512 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10513 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10514 fl_set_object_resize(obj, FL_RESIZE_NONE);
10515 fl_set_object_callback(obj,doSDNSInput,0);
10516 fl_set_input_maxchars(obj, MAXLEN_IP);
10517 fl_set_input_filter(obj, IPInputFilter);
10518 fdui->domainInput = obj = fl_add_input(FL_NORMAL_INPUT,312,295,113,28,
10519 "Domain\nname:");
10520 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
10521 fl_set_object_lcolor(obj,FL_WHITE);
10522 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10523 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10524 fl_set_object_resize(obj, FL_RESIZE_NONE);
10525 fl_set_object_callback(obj,doDomainInput,0);
10526
10527 fdui->DNTypeGroup = fl_bgn_group();
10528 obj = fl_add_text(FL_NORMAL_TEXT,20,291,109,37,
10529 "Set resolver\ndefault domain:");
10530 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10531 fl_set_object_lcolor(obj,FL_WHITE);
10532 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10533 fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
10534 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10535 fdui->DNNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,197,298,55,
10536 25,"No");
10537 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10538 fl_set_object_lcolor(obj,FL_WHITE);
10539 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10540 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10541 fl_set_object_resize(obj, FL_RESIZE_NONE);
10542 fl_set_object_callback(obj,doDNNoButton,0);
10543 fdui->DNYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,137,298,58,
10544 25,"Yes");
10545 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10546 fl_set_object_lcolor(obj,FL_WHITE);
10547 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10548 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10549 fl_set_object_resize(obj, FL_RESIZE_NONE);
10550 fl_set_object_callback(obj,doDNYesButton,0);
10551 fl_end_group();
10552
10553 obj = fl_add_text(FL_NORMAL_TEXT,440,187,87,153,"On this form you\nadjust "
10554 "TCP/IP-\nspecific settings.\nYou also have\nthe option "
10555 "to\ndefine DNS\nservers which\nshall be enabled\nonly "
10556 "when you\nconnect to the\nselected ISP.");
10557 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10558 fl_set_object_lcolor(obj,FL_WHITE);
10559 fl_set_object_lalign(obj,FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
10560 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10561
10562 fdui->tipTimer = obj = fl_add_timer(FL_HIDDEN_TIMER, 0,0,0,0,"");
10563 fl_set_timer(obj, 0.0);
10564 fl_set_object_callback(obj,doTcpipInfoTip,0);
10565 fl_end_form();
10566
10567 fdui->tcpipInfo->fdui = fdui;
10568
10569 return fdui;
10570 }
10571
10572 FD_logInfo *create_form_logInfo(void)
10573 {
10574 FL_OBJECT *obj;
10575 FD_logInfo *fdui = (FD_logInfo *) fl_calloc(1, sizeof(*fdui));
10576
10577 fdui->logInfo = fl_bgn_form(FL_NO_BOX, 399, 339);
10578 obj = fl_add_box(FL_FLAT_BOX,0,0,399,339,"");
10579 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
10580 obj = fl_add_frame(FL_ENGRAVED_FRAME,14,19,178,72,"");
10581 obj = fl_add_frame(FL_ENGRAVED_FRAME,206,19,178,72,"");
10582 obj = fl_add_text(FL_NORMAL_TEXT,19,10,163,19,"On-line counter displays:");
10583 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10584 fl_set_object_lcolor(obj,FL_WHITE);
10585 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10586 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10587 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10588
10589 fdui->OLGroup = fl_bgn_group();
10590 fdui->OLTimeButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,19,30,142,
10591 25,"Time (HH:MM:SS)");
10592 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10593 fl_set_object_lcolor(obj,FL_WHITE);
10594 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10595 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10596 fl_set_object_resize(obj, FL_RESIZE_NONE);
10597 fl_set_object_callback(obj,doOLTimeButton,0);
10598 fdui->OLChargeButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,19,54,165,
10599 25,"Telephone call charges");
10600 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10601 fl_set_object_lcolor(obj,FL_WHITE);
10602 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10603 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10604 fl_set_object_resize(obj, FL_RESIZE_NONE);
10605 fl_set_object_callback(obj,doOLChargeButton,0);
10606 fl_end_group();
10607
10608 obj = fl_add_text(FL_NORMAL_TEXT,211,10,141,19,"Keep connection logs:");
10609 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10610 fl_set_object_lcolor(obj,FL_WHITE);
10611 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10612 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10613 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10614
10615 fdui->logGroup = fl_bgn_group();
10616 fdui->logNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,211,31,73,
10617 25,"No");
10618 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10619 fl_set_object_lcolor(obj,FL_WHITE);
10620 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10621 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10622 fl_set_object_resize(obj, FL_RESIZE_NONE);
10623 fl_set_object_callback(obj,doLogNoButton,0);
10624 fdui->logMonthButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,286,31,85,
10625 25,"Monthly");
10626 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10627 fl_set_object_lcolor(obj,FL_WHITE);
10628 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10629 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10630 fl_set_object_resize(obj, FL_RESIZE_NONE);
10631 fl_set_object_callback(obj,doLogMonthButton,0);
10632 fdui->logWeekButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,211,54,73,
10633 25,"Weekly");
10634 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10635 fl_set_object_lcolor(obj,FL_WHITE);
10636 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10637 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10638 fl_set_object_resize(obj, FL_RESIZE_NONE);
10639 fl_set_object_callback(obj,doLogWeekButton,0);
10640 fdui->logBiMonthButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,286,54,88,
10641 25,"Bimonthly");
10642 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10643 fl_set_object_lcolor(obj,FL_WHITE);
10644 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10645 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10646 fl_set_object_resize(obj, FL_RESIZE_NONE);
10647 fl_set_object_callback(obj,doLogBiMonthButton,0);
10648 fl_end_group();
10649
10650 fdui->logInfoOK = obj = fl_add_button(FL_RETURN_BUTTON,232,298,79,27,"OK");
10651 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10652 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
10653 fl_set_object_resize(obj, FL_RESIZE_NONE);
10654 fl_set_object_callback(obj,doLogInfoOK,0);
10655 fl_set_object_bw(obj, -2);
10656 fdui->logInfoCancel = obj = fl_add_button(FL_NORMAL_BUTTON,88,298,79,27,
10657 "Cancel");
10658 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10659 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
10660 fl_set_object_resize(obj, FL_RESIZE_NONE);
10661 fl_set_object_callback(obj,doLogInfoCancel,0);
10662 fl_set_object_bw(obj, -2);
10663 obj = fl_add_text(FL_NORMAL_TEXT,7,96,110,39,"Phone Company\n(PTT):");
10664 fl_set_object_boxtype(obj,FL_NO_BOX);
10665 fl_set_object_lcolor(obj,FL_WHITE);
10666 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10667 fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
10668 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10669 fl_set_object_resize(obj, FL_RESIZE_NONE);
10670 fl_set_object_gravity(obj, FL_South, FL_South);
10671 obj = fl_add_box(FL_EMBOSSED_BOX,118,103,267,28,"");
10672 fl_set_object_color(obj,FL_TOP_BCOL,FL_COL1);
10673 fl_set_object_resize(obj, FL_RESIZE_NONE);
10674 fl_set_object_gravity(obj, FL_South, FL_South);
10675 fdui->pttDropChoice = obj = fl_add_choice(FL_DROPLIST_CHOICE,121,106,
10676 262,22,"");
10677 fl_set_object_boxtype(obj,FL_FLAT_BOX);
10678 fl_set_object_color(obj,FL_TOP_BCOL,FL_BLACK);
10679 fl_set_object_callback(obj,doPttDropChoice,0);
10680 fl_set_object_resize(obj, FL_RESIZE_NONE);
10681 fl_set_object_gravity(obj, FL_South, FL_South);
10682 fl_set_choice_fontsize(obj,FL_NORMAL_SIZE);
10683
10684 obj = fl_add_text(FL_NORMAL_TEXT,9,138,108,28,"Charging Zone:");
10685 fl_set_object_boxtype(obj,FL_NO_BOX);
10686 fl_set_object_lcolor(obj,FL_WHITE);
10687 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10688 fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
10689 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10690 fl_set_object_resize(obj, FL_RESIZE_NONE);
10691 obj = fl_add_box(FL_EMBOSSED_BOX,118,139,267,28,"");
10692 fl_set_object_color(obj,FL_TOP_BCOL,FL_COL1);
10693 fl_set_object_resize(obj, FL_RESIZE_NONE);
10694 fl_set_object_gravity(obj, FL_South, FL_South);
10695 fdui->zoneDropChoice = obj = fl_add_choice(FL_DROPLIST_CHOICE,121,142,
10696 262,22,"");
10697 fl_set_object_boxtype(obj,FL_FLAT_BOX);
10698 fl_set_object_color(obj,FL_TOP_BCOL,FL_BLACK);
10699 fl_set_object_callback(obj,doZoneDropChoice,0);
10700 fl_set_object_resize(obj, FL_RESIZE_NONE);
10701 fl_set_object_gravity(obj, FL_South, FL_South);
10702 fl_set_choice_fontsize(obj,FL_NORMAL_SIZE);
10703
10704 fdui->LogInfoPTTEdit = obj = fl_add_button(FL_NORMAL_BUTTON,72,179,105,27,
10705 "Edit PTT Info");
10706 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10707 fl_set_object_resize(obj, FL_RESIZE_NONE);
10708 fl_set_object_callback(obj,doLogInfoPTTEdit,0);
10709 fl_set_object_bw(obj, -2);
10710 fdui->LogInfoPTTAdd = obj = fl_add_button(FL_NORMAL_BUTTON,177,179,104,27,
10711 "Add PTT");
10712 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10713 fl_set_object_resize(obj, FL_RESIZE_NONE);
10714 fl_set_object_callback(obj,doLogInfoPTTAdd,0);
10715 fl_set_object_bw(obj, -2);
10716 fdui->logInfoPTTRemove = obj = fl_add_button(FL_NORMAL_BUTTON,281,179,104,
10717 27,"Remove PTT");
10718 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10719 fl_set_object_resize(obj, FL_RESIZE_NONE);
10720 fl_set_object_callback(obj,doLogInfoPTTRemove,0);
10721 fl_set_object_bw(obj, -2);
10722 obj = fl_add_text(FL_NORMAL_TEXT,5,214,67,70,
10723 "Phone\ncompany\nbrief info\nbrowser:");
10724 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10725 fl_set_object_lcolor(obj,FL_WHITE);
10726 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10727 fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
10728 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10729 fdui->costBrowser = obj = fl_add_browser(FL_NORMAL_BROWSER,72,217,313,66,"");
10730 fl_set_object_color(obj,FL_TOP_BCOL,FL_CYAN);
10731 fl_set_browser_fontsize(obj,FL_NORMAL_SIZE);
10732 fl_set_browser_hscrollbar(obj, FL_OFF);
10733 fl_set_browser_scrollbarsize(obj, 16, 16);
10734 fl_set_object_bw(obj, -2);
10735 fl_end_form();
10736
10737 fdui->logInfo->fdui = fdui;
10738
10739 /* We do some more custom stuff here */
10740 fdui->cdata = (char *) fl_calloc(MAXLEN_CURRENCY+1, sizeof(char));
10741
10742 return fdui;
10743 }
10744
10745 FD_statInfo *create_form_statInfo(void)
10746 {
10747 FL_OBJECT *obj;
10748 FD_statInfo *fdui = (FD_statInfo *) fl_calloc(1, sizeof(*fdui));
10749
10750 fdui->statInfo = fl_bgn_form(FL_NO_BOX, 463, 257);
10751 obj = fl_add_box(FL_FLAT_BOX,0,0,463,257,"");
10752 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
10753 fdui->statsBrowser = obj = fl_add_browser(FL_NORMAL_BROWSER,13,36,213,95,"");
10754 fl_set_object_color(obj,FL_TOP_BCOL,FL_CYAN);
10755 fl_set_browser_fontsize(obj,FL_NORMAL_SIZE);
10756 fl_set_browser_hscrollbar(obj, FL_OFF);
10757 fl_set_browser_scrollbarsize(obj, 16, 16);
10758 fl_set_object_bw(obj, -2);
10759 obj = fl_add_text(FL_NORMAL_TEXT,10,10,134,21,"Time/Cost statistics:");
10760 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10761 fl_set_object_lcolor(obj,FL_WHITE);
10762 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10763 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10764 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10765 fdui->statsChart = obj = fl_add_chart(FL_BAR_CHART,13,145,213,95,"");
10766 fl_set_object_boxtype(obj,FL_DOWN_BOX);
10767 fl_set_object_color(obj,FL_TOP_BCOL,FL_COL1);
10768 fl_set_object_bw(obj, -2);
10769 obj = fl_add_text(FL_NORMAL_TEXT,235,10,154,21,"Yearly cost breakdown:");
10770 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10771 fl_set_object_lcolor(obj,FL_WHITE);
10772 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10773 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10774 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10775 fdui->pieChart = obj = fl_add_chart(FL_PIE_CHART,236,36,213,167,"");
10776 fl_set_object_boxtype(obj,FL_DOWN_BOX);
10777 fl_set_object_color(obj,FL_TOP_BCOL,FL_COL1);
10778 fl_set_object_bw(obj, -2);
10779 fdui->statInfoOK = obj = fl_add_button(FL_RETURN_BUTTON,370,217,79,27,
10780 "Dismiss");
10781 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10782 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
10783 fl_set_object_resize(obj, FL_RESIZE_NONE);
10784 fl_set_object_callback(obj,doStatsInfoOK,0);
10785 fl_set_object_bw(obj, -2);
10786 fl_end_form();
10787
10788 fdui->statInfo->fdui = fdui;
10789
10790 return fdui;
10791 }
10792
10793 FD_pttEditor *create_form_pttEditor(void)
10794 {
10795 FL_OBJECT *obj;
10796 FD_pttEditor *fdui = (FD_pttEditor *) fl_calloc(1, sizeof(*fdui));
10797
10798 fdui->pttEditor = fl_bgn_form(FL_NO_BOX, 615, 640);
10799 obj = fl_add_box(FL_FLAT_BOX,0,0,615,640,"");
10800 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
10801 obj = fl_add_frame(FL_ENGRAVED_FRAME,14,384,587,242,"");
10802 fl_set_object_color(obj,FL_COL1,FL_COL1);
10803 obj = fl_add_frame(FL_ENGRAVED_FRAME,314,16,287,354,"");
10804 obj = fl_add_frame(FL_ENGRAVED_FRAME,14,153,287,217,"");
10805 fl_set_object_color(obj,FL_COL1,FL_COL1);
10806 obj = fl_add_text(FL_NORMAL_TEXT,21,142,89,20,"PTT charges:");
10807 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10808 fl_set_object_lcolor(obj,FL_WHITE);
10809 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10810 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10811 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10812 fdui->zonePick = obj = fl_add_browser(FL_HOLD_BROWSER,327,46, 260,65,"");
10813 fl_set_object_color(obj,FL_TOP_BCOL,FL_CYAN);
10814 fl_set_object_callback(obj,doZonePick,0);
10815 fl_set_browser_dblclick_callback(obj,doZonePickNEdit,0);
10816 fl_set_browser_fontsize(obj,FL_NORMAL_SIZE);
10817 fl_set_browser_hscrollbar(obj, FL_OFF);
10818 fl_set_browser_scrollbarsize(obj, 16, 16);
10819 fl_set_object_bw(obj, -2);
10820 obj = fl_add_text(FL_NORMAL_TEXT,321,26,274,21,
10821 "Zone: (click picks, double-click edits name)");
10822 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10823 fl_set_object_lcolor(obj,FL_WHITE);
10824 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10825 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10826 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10827 obj = fl_add_text(FL_NORMAL_TEXT,21,373,259,21,
10828 "Category rules (for zone selected above):");
10829 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10830 fl_set_object_lcolor(obj,FL_WHITE);
10831 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10832 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10833 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10834 obj = fl_add_text(FL_NORMAL_TEXT,24,397,115,28,"Category number:");
10835 fl_set_object_boxtype(obj,FL_NO_BOX);
10836 fl_set_object_lcolor(obj,FL_WHITE);
10837 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10838 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10839 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10840 fl_set_object_resize(obj, FL_RESIZE_NONE);
10841 obj = fl_add_text(FL_NORMAL_TEXT,359,589,8,20,":");
10842 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10843 fl_set_object_lcolor(obj,FL_WHITE);
10844 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10845 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10846 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10847 obj = fl_add_text(FL_NORMAL_TEXT,399,590,8,20,":");
10848 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10849 fl_set_object_lcolor(obj,FL_WHITE);
10850 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10851 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10852 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10853 obj = fl_add_text(FL_NORMAL_TEXT,321,545,103,23,"Rule start time:");
10854 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10855 fl_set_object_lcolor(obj,FL_WHITE);
10856 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10857 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10858 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10859 obj = fl_add_text(FL_NORMAL_TEXT,507,590,8,20,":");
10860 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10861 fl_set_object_lcolor(obj,FL_WHITE);
10862 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10863 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10864 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10865 obj = fl_add_text(FL_NORMAL_TEXT,547,591,8,20,":");
10866 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10867 fl_set_object_lcolor(obj,FL_WHITE);
10868 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10869 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10870 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10871 obj = fl_add_text(FL_NORMAL_TEXT,470,545,103,23,"Rule end time:");
10872 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10873 fl_set_object_lcolor(obj,FL_WHITE);
10874 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10875 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10876 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10877 obj = fl_add_text(FL_NORMAL_TEXT,328,565,29,21,"HH");
10878 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10879 fl_set_object_lcolor(obj,FL_WHITE);
10880 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10881 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10882 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10883 obj = fl_add_text(FL_NORMAL_TEXT,368,565,29,21,"MM");
10884 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10885 fl_set_object_lcolor(obj,FL_WHITE);
10886 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10887 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10888 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10889 obj = fl_add_text(FL_NORMAL_TEXT,408,565,29,21,"SS");
10890 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10891 fl_set_object_lcolor(obj,FL_WHITE);
10892 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10893 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10894 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10895 obj = fl_add_text(FL_NORMAL_TEXT,476,566,29,21,"HH");
10896 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10897 fl_set_object_lcolor(obj,FL_WHITE);
10898 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10899 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10900 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10901 obj = fl_add_text(FL_NORMAL_TEXT,516,566,29,21,"MM");
10902 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10903 fl_set_object_lcolor(obj,FL_WHITE);
10904 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10905 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10906 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10907 obj = fl_add_text(FL_NORMAL_TEXT,556,566,29,21,"SS");
10908 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10909 fl_set_object_lcolor(obj,FL_WHITE);
10910 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10911 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
10912 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10913 obj = fl_add_text(FL_NORMAL_TEXT,24,427,103,23,"Category type:");
10914 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10915 fl_set_object_lcolor(obj,FL_WHITE);
10916 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10917 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10918 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10919 fdui->ruleDateStr = obj = fl_add_text(FL_NORMAL_TEXT,321,427,71,21,
10920 "Rule date:");
10921 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10922 fl_set_object_lcolor(obj,FL_WHITE);
10923 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10924 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10925 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10926 fdui->defaultTariffUnits = obj = fl_add_text(FL_NORMAL_TEXT,468,119,118,23,
10927 CUNIT_STR);
10928 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10929 fl_set_object_lcolor(obj,FL_WHITE);
10930 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10931 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10932 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10933 obj = fl_add_text(FL_NORMAL_TEXT,24,338,130,23,"Currency placement:");
10934 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10935 fl_set_object_lcolor(obj,FL_WHITE);
10936 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10937 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10938 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10939 fdui->pttEditOK = obj = fl_add_button(FL_RETURN_BUTTON,13,98,79,27,"OK");
10940 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10941 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
10942 fl_set_object_resize(obj, FL_RESIZE_NONE);
10943 fl_set_object_callback(obj,doPttEditOK,0);
10944 fl_set_object_bw(obj, -2);
10945 fdui->pttEditCancel = obj = fl_add_button(FL_NORMAL_BUTTON,118,98,79,27,
10946 "Cancel");
10947 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10948 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
10949 fl_set_object_resize(obj, FL_RESIZE_NONE);
10950 fl_set_object_callback(obj,doPttEditCancel,0);
10951 fl_set_object_bw(obj, -2);
10952 fdui->ruleTariffUnits = obj = fl_add_text(FL_NORMAL_TEXT,450,400,118,23,
10953 CUNIT_STR);
10954 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
10955 fl_set_object_lcolor(obj,FL_WHITE);
10956 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10957 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
10958 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
10959 fdui->pttEditHelp = obj = fl_add_button(FL_NORMAL_BUTTON,223,98,79,27,
10960 "Help");
10961 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10962 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
10963 fl_set_object_resize(obj, FL_RESIZE_NONE);
10964 fl_set_object_callback(obj,doPttEditHelp,0);
10965 fl_set_object_bw(obj, -2);
10966
10967 fdui->CMType = fl_bgn_group();
10968 fdui->CUnitButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,22,165,78,
10969 25,"By unit");
10970 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10971 fl_set_object_lcolor(obj,FL_WHITE);
10972 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10973 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10974 fl_set_object_resize(obj, FL_RESIZE_NONE);
10975 fl_set_object_callback(obj,doCUnitButton,0);
10976 fdui->CMinuteButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,22,200,95,
10977 25,"Per minute");
10978 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10979 fl_set_object_lcolor(obj,FL_WHITE);
10980 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10981 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10982 fl_set_object_resize(obj, FL_RESIZE_NONE);
10983 fl_set_object_callback(obj,doCMinuteButton,0);
10984 fdui->CSecondsButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,22,235,117,
10985 25,"Per second(s)");
10986 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10987 fl_set_object_lcolor(obj,FL_WHITE);
10988 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
10989 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
10990 fl_set_object_resize(obj, FL_RESIZE_NONE);
10991 fl_set_object_callback(obj,doCSecondsButton,0);
10992 fl_end_group();
10993
10994
10995 fdui->CPType = fl_bgn_group();
10996 fdui->CPLButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,160,338,56,
10997 25,"Left");
10998 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
10999 fl_set_object_lcolor(obj,FL_WHITE);
11000 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11001 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11002 fl_set_object_resize(obj, FL_RESIZE_NONE);
11003 fl_set_object_callback(obj,doCPLButton,0);
11004 fdui->CPRButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,225,338,65,
11005 25,"Right");
11006 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11007 fl_set_object_lcolor(obj,FL_WHITE);
11008 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11009 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11010 fl_set_object_resize(obj, FL_RESIZE_NONE);
11011 fl_set_object_callback(obj,doCPRButton,0);
11012 fl_end_group();
11013
11014 fdui->MCType = fl_bgn_group();
11015 fdui->MLLButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,325,168,185,
11016 25,"Linear, same for all zones");
11017 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11018 fl_set_object_lcolor(obj,FL_WHITE);
11019 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11020 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11021 fl_set_object_resize(obj, FL_RESIZE_NONE);
11022 fl_set_object_callback(obj,doMLLButton,0);
11023 fdui->MLNButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,325,193,185,
11024 25,"Non-linear, zone specific");
11025 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11026 fl_set_object_lcolor(obj,FL_WHITE);
11027 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11028 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11029 fl_set_object_resize(obj, FL_RESIZE_NONE);
11030 fl_set_object_callback(obj,doMLNButton,0);
11031 fl_end_group();
11032
11033 fdui->ruleCounter = obj = fl_add_counter(FL_NORMAL_COUNTER,154,401,
11034 135,23,"");
11035 fl_set_object_color(obj,FL_MCOL,FL_BLACK);
11036 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11037 fl_set_object_lalign(obj,FL_ALIGN_LEFT);
11038 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11039 fl_set_object_resize(obj, FL_RESIZE_NONE);
11040 fl_set_object_callback(obj,doRuleCounter,0);
11041 fl_set_counter_precision(obj, 0);
11042 fl_set_counter_step(obj, 1, 5);
11043 obj = fl_add_text(FL_NORMAL_TEXT,322,5,112,21,"Zone information:");
11044 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11045 fl_set_object_lcolor(obj,FL_WHITE);
11046 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11047 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11048 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11049
11050 fdui->ZEDType = fl_bgn_group();
11051 fdui->ZEDYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,325,263,53,
11052 25,"Yes");
11053 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11054 fl_set_object_lcolor(obj,FL_WHITE);
11055 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11056 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11057 fl_set_object_resize(obj, FL_RESIZE_NONE);
11058 fl_set_object_callback(obj,doZEDYesButton,0);
11059 fdui->ZEDNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,390,263,53,
11060 25,"No");
11061 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11062 fl_set_object_lcolor(obj,FL_WHITE);
11063 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11064 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11065 fl_set_object_resize(obj, FL_RESIZE_NONE);
11066 fl_set_object_callback(obj,doZEDNoButton,0);
11067 fl_end_group();
11068
11069 fdui->REDType = fl_bgn_group();
11070 fdui->RDYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,38,594,53,
11071 25,"Yes");
11072 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11073 fl_set_object_lcolor(obj,FL_WHITE);
11074 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11075 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11076 fl_set_object_resize(obj, FL_RESIZE_NONE);
11077 fl_set_object_callback(obj,doRDYesButton,0);
11078 fdui->RDNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,99,594,53,
11079 25,"No");
11080 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11081 fl_set_object_lcolor(obj,FL_WHITE);
11082 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11083 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11084 fl_set_object_resize(obj, FL_RESIZE_NONE);
11085 fl_set_object_callback(obj,doRDNoButton,0);
11086 fl_end_group();
11087
11088
11089 fdui->CTType = fl_bgn_group();
11090 fdui->TWDButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,28,450,83,
11091 25,"Weekday");
11092 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11093 fl_set_object_lcolor(obj,FL_WHITE);
11094 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11095 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11096 fl_set_object_resize(obj, FL_RESIZE_NONE);
11097 fl_set_object_callback(obj,doTButton,2);
11098 fdui->TSDButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,28,473,87,
11099 25,"Saturday");
11100 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11101 fl_set_object_lcolor(obj,FL_WHITE);
11102 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11103 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11104 fl_set_object_resize(obj, FL_RESIZE_NONE);
11105 fl_set_object_callback(obj,doTButton,3);
11106 fdui->THRButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,28,519,127,
11107 25,"Holiday-relative");
11108 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11109 fl_set_object_lcolor(obj,FL_WHITE);
11110 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11111 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11112 fl_set_object_resize(obj, FL_RESIZE_NONE);
11113 fl_set_object_callback(obj,doTButton,6);
11114 fdui->TUDButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,160,473,83,
11115 25,"Sunday");
11116 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11117 fl_set_object_lcolor(obj,FL_WHITE);
11118 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11119 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11120 fl_set_object_resize(obj, FL_RESIZE_NONE);
11121 fl_set_object_callback(obj,doTButton,4);
11122 fdui->TWEButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,28,496,84,
11123 25,"Weekend");
11124 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11125 fl_set_object_lcolor(obj,FL_WHITE);
11126 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11127 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11128 fl_set_object_resize(obj, FL_RESIZE_NONE);
11129 fl_set_object_callback(obj,doTButton,5);
11130 fdui->THAButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,160,519,134,
11131 25,"Holiday-absolute");
11132 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11133 fl_set_object_lcolor(obj,FL_WHITE);
11134 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11135 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11136 fl_set_object_resize(obj, FL_RESIZE_NONE);
11137 fl_set_object_callback(obj,doTButton,7);
11138 fdui->TWDSButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,160,450,132,
11139 25,"Weekday-special");
11140 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11141 fl_set_object_lcolor(obj,FL_WHITE);
11142 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11143 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11144 fl_set_object_resize(obj, FL_RESIZE_NONE);
11145 fl_set_object_callback(obj,doTButton,8);
11146 fdui->TWESButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,160,496,132,
11147 25,"Weekend-special");
11148 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11149 fl_set_object_lcolor(obj,FL_WHITE);
11150 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11151 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11152 fl_set_object_resize(obj, FL_RESIZE_NONE);
11153 fl_set_object_callback(obj,doTButton,9);
11154 fdui->TAWButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,28,542,88,
11155 25,"All-week");
11156 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11157 fl_set_object_lcolor(obj,FL_WHITE);
11158 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11159 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11160 fl_set_object_resize(obj, FL_RESIZE_NONE);
11161 fl_set_object_callback(obj,doTButton,1);
11162 fl_end_group();
11163
11164
11165 fdui->ZMLType = fl_bgn_group();
11166 fdui->ZMLYesButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,180,594,53,
11167 25,"Yes");
11168 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11169 fl_set_object_lcolor(obj,FL_WHITE);
11170 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11171 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11172 fl_set_object_resize(obj, FL_RESIZE_NONE);
11173 fl_set_object_callback(obj,doZMLYesButton,0);
11174 fdui->ZMLNoButton = obj = fl_add_checkbutton(FL_RADIO_BUTTON,241,594,53,
11175 25,"No");
11176 fl_set_object_color(obj,FL_MCOL,FL_WHEAT);
11177 fl_set_object_lcolor(obj,FL_WHITE);
11178 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11179 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11180 fl_set_object_resize(obj, FL_RESIZE_NONE);
11181 fl_set_object_callback(obj,doZMLNoButton,0);
11182 fl_end_group();
11183
11184
11185 fdui->pttNameInput = obj = fl_add_input(FL_NORMAL_INPUT,80,11,222,28,
11186 "PTT name:");
11187 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11188 fl_set_object_lcolor(obj,FL_WHITE);
11189 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11190 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11191 fl_set_object_resize(obj, FL_RESIZE_NONE);
11192 fl_set_object_callback(obj,doPttNameInput,0);
11193 fl_set_input_maxchars(obj, MAXLEN_PTTNAME);
11194 fdui->zonesInput = obj = fl_add_input(FL_NORMAL_INPUT,109,48,36,27,
11195 "Charging zones:");
11196 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11197 fl_set_object_lcolor(obj,FL_WHITE);
11198 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11199 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11200 fl_set_object_resize(obj, FL_RESIZE_NONE);
11201 fl_set_object_callback(obj,doZonesInput,0);
11202 fl_set_input_maxchars(obj, 1);
11203 fdui->categoriesInput = obj = fl_add_input(FL_NORMAL_INPUT,266,48,36,27,
11204 "Categories/zone:");
11205 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11206 fl_set_object_lcolor(obj,FL_WHITE);
11207 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11208 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11209 fl_set_object_resize(obj, FL_RESIZE_NONE);
11210 fl_set_object_callback(obj,doCategoriesInput,0);
11211 fl_set_input_maxchars(obj, 2);
11212 fdui->minUnitsInput = obj = fl_add_input(FL_NORMAL_INPUT,235,165,50,27,
11213 "Minimum units:");
11214 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11215 fl_set_object_lcolor(obj,FL_WHITE);
11216 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11217 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11218 fl_set_object_resize(obj, FL_RESIZE_NONE);
11219 fl_set_object_callback(obj,doMinUnitsInput,0);
11220 fl_set_input_maxchars(obj, 2);
11221 fdui->minCostInput = obj = fl_add_input(FL_NORMAL_INPUT,235,200,50,27,
11222 "Minimum cost:");
11223 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11224 fl_set_object_lcolor(obj,FL_WHITE);
11225 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11226 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11227 fl_set_object_resize(obj, FL_RESIZE_NONE);
11228 fl_set_object_callback(obj,doMinCostInput,0);
11229 fl_set_input_maxchars(obj, 6);
11230 fdui->CSecondsInput = obj = fl_add_input(FL_NORMAL_INPUT,235,235,50,27,
11231 "Period (sec):");
11232 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11233 fl_set_object_lcolor(obj,FL_WHITE);
11234 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11235 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11236 fl_set_object_resize(obj, FL_RESIZE_NONE);
11237 fl_set_object_callback(obj,doCSecondsInput,0);
11238 fl_set_input_maxchars(obj, 2);
11239 fdui->unitPriceInput = obj = fl_add_input(FL_NORMAL_INPUT,110,270,55,27,
11240 "Price/unit:");
11241 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11242 fl_set_object_lcolor(obj,FL_WHITE);
11243 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11244 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11245 fl_set_object_resize(obj, FL_RESIZE_NONE);
11246 fl_set_object_callback(obj,doUnitPriceInput,0);
11247 fl_set_input_maxchars(obj, 8);
11248 fdui->currencyInput = obj = fl_add_input(FL_NORMAL_INPUT,235,270,50,27,
11249 "Currency:");
11250 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11251 fl_set_object_lcolor(obj,FL_WHITE);
11252 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11253 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11254 fl_set_object_resize(obj, FL_RESIZE_NONE);
11255 fl_set_object_callback(obj,doCurrencyInput,0);
11256 fl_set_input_maxchars(obj, MAXLEN_CURRENCY);
11257 fdui->decimalsInput = obj = fl_add_input(FL_NORMAL_INPUT,235,305,50,27,
11258 "Decimal digits for bill printouts:");
11259 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11260 fl_set_object_lcolor(obj,FL_WHITE);
11261 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11262 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11263 fl_set_object_resize(obj, FL_RESIZE_NONE);
11264 fl_set_object_callback(obj,doDecimalsInput,0);
11265 fl_set_input_maxchars(obj, 1);
11266 fdui->baseChargeInput = obj = fl_add_input(FL_NORMAL_INPUT,412,118,55,27,
11267 "Default tariff:");
11268 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11269 fl_set_object_lcolor(obj,FL_WHITE);
11270 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11271 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11272 fl_set_object_resize(obj, FL_RESIZE_NONE);
11273 fl_set_object_callback(obj,doBaseChargeInput,0);
11274 fl_set_input_maxchars(obj, 6);
11275
11276 fdui->TimeChargeType = fl_bgn_group();
11277 fdui->MLSecondsInput = obj = fl_add_input(FL_NORMAL_INPUT,539,214,46,27,
11278 "Length for this zone (seconds):");
11279 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11280 fl_set_object_lcolor(obj,FL_WHITE);
11281 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11282 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11283 fl_set_object_resize(obj, FL_RESIZE_NONE);
11284 fl_set_object_callback(obj,doMLSecondsInput,0);
11285 fl_set_input_maxchars(obj, 4);
11286 obj = fl_add_text(FL_NORMAL_TEXT,322,242,182,23,
11287 "Extra discount for this zone:");
11288 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11289 fl_set_object_lcolor(obj,FL_WHITE);
11290 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11291 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11292 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11293 obj = fl_add_text(FL_NORMAL_TEXT,322,146,182,23,
11294 "Minimum charge time length:");
11295 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11296 fl_set_object_lcolor(obj,FL_WHITE);
11297 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11298 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11299 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11300 fdui->RDStr = obj = fl_add_text(FL_NORMAL_TEXT,24,571,131,23,
11301 "Apply zone discount:");
11302 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11303 fl_set_object_lcolor(obj,FL_WHITE);
11304 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11305 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11306 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11307 fdui->ZMLStr = obj = fl_add_text(FL_NORMAL_TEXT,172,555,125,38,
11308 "Zero minimum\ncharge time length:");
11309 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11310 fl_set_object_lcolor(obj,FL_WHITE);
11311 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11312 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11313 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11314 fl_end_group();
11315
11316 fdui->DiscountType = fl_bgn_group();
11317 fdui->discountInput = obj = fl_add_input(FL_NORMAL_INPUT,528,262,41,27,
11318 "Discount:");
11319 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11320 fl_set_object_lcolor(obj,FL_WHITE);
11321 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11322 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11323 fl_set_object_resize(obj, FL_RESIZE_NONE);
11324 fl_set_object_callback(obj,doDiscountInput,0);
11325 fl_set_input_maxchars(obj, 4);
11326 fdui->PCSymbol = obj = fl_add_text(FL_NORMAL_TEXT,569,265,21,23,"%");
11327 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11328 fl_set_object_lcolor(obj,FL_WHITE);
11329 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11330 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11331 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11332 obj = fl_add_text(FL_NORMAL_TEXT,328,291,229,20,
11333 "Call start time must not be between:");
11334 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11335 fl_set_object_lcolor(obj,FL_WHITE);
11336 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11337 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11338 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11339 obj = fl_add_text(FL_NORMAL_TEXT,360,333,8,20,":");
11340 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11341 fl_set_object_lcolor(obj,FL_WHITE);
11342 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11343 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11344 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11345 obj = fl_add_text(FL_NORMAL_TEXT,400,334,8,20,":");
11346 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11347 fl_set_object_lcolor(obj,FL_WHITE);
11348 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11349 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11350 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11351 obj = fl_add_text(FL_NORMAL_TEXT,329,309,29,21,"HH");
11352 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11353 fl_set_object_lcolor(obj,FL_WHITE);
11354 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11355 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11356 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11357 obj = fl_add_text(FL_NORMAL_TEXT,369,309,29,21,"MM");
11358 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11359 fl_set_object_lcolor(obj,FL_WHITE);
11360 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11361 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11362 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11363 obj = fl_add_text(FL_NORMAL_TEXT,409,309,29,21,"SS");
11364 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11365 fl_set_object_lcolor(obj,FL_WHITE);
11366 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11367 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11368 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11369 fdui->ZSHInput = obj = fl_add_input(FL_NORMAL_INPUT,329,331,30,27,"");
11370 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11371 fl_set_object_lcolor(obj,FL_WHITE);
11372 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11373 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11374 fl_set_object_resize(obj, FL_RESIZE_NONE);
11375 fl_set_object_callback(obj,doZSInput,0);
11376 fl_set_input_maxchars(obj, 2);
11377 fdui->ZSMInput = obj = fl_add_input(FL_NORMAL_INPUT,369,331,30,27,"");
11378 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11379 fl_set_object_lcolor(obj,FL_WHITE);
11380 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11381 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11382 fl_set_object_resize(obj, FL_RESIZE_NONE);
11383 fl_set_object_callback(obj,doZSInput,1);
11384 fl_set_input_maxchars(obj, 2);
11385 fdui->ZSSInput = obj = fl_add_input(FL_NORMAL_INPUT,409,331,30,27,"");
11386 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11387 fl_set_object_lcolor(obj,FL_WHITE);
11388 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11389 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11390 fl_set_object_resize(obj, FL_RESIZE_NONE);
11391 fl_set_object_callback(obj,doZSInput,2);
11392 fl_set_input_maxchars(obj, 2);
11393 obj = fl_add_text(FL_NORMAL_TEXT,442,332,30,23,"and");
11394 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11395 fl_set_object_lcolor(obj,FL_WHITE);
11396 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11397 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11398 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11399 obj = fl_add_text(FL_NORMAL_TEXT,506,333,8,20,":");
11400 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11401 fl_set_object_lcolor(obj,FL_WHITE);
11402 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11403 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11404 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11405 obj = fl_add_text(FL_NORMAL_TEXT,546,334,8,20,":");
11406 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11407 fl_set_object_lcolor(obj,FL_WHITE);
11408 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11409 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11410 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11411 obj = fl_add_text(FL_NORMAL_TEXT,475,309,29,21,"HH");
11412 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11413 fl_set_object_lcolor(obj,FL_WHITE);
11414 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11415 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11416 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11417 obj = fl_add_text(FL_NORMAL_TEXT,515,309,29,21,"MM");
11418 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11419 fl_set_object_lcolor(obj,FL_WHITE);
11420 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11421 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11422 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11423 obj = fl_add_text(FL_NORMAL_TEXT,555,309,29,21,"SS");
11424 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11425 fl_set_object_lcolor(obj,FL_WHITE);
11426 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11427 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11428 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11429 fdui->ZEHInput = obj = fl_add_input(FL_NORMAL_INPUT,475,331,30,27,"");
11430 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11431 fl_set_object_lcolor(obj,FL_WHITE);
11432 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11433 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11434 fl_set_object_resize(obj, FL_RESIZE_NONE);
11435 fl_set_object_callback(obj,doZEInput,0);
11436 fl_set_input_maxchars(obj, 2);
11437 fdui->ZEMInput = obj = fl_add_input(FL_NORMAL_INPUT,515,331,30,27,"");
11438 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11439 fl_set_object_lcolor(obj,FL_WHITE);
11440 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11441 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11442 fl_set_object_resize(obj, FL_RESIZE_NONE);
11443 fl_set_object_callback(obj,doZEInput,1);
11444 fl_set_input_maxchars(obj, 2);
11445 fdui->ZESInput = obj = fl_add_input(FL_NORMAL_INPUT,555,331,30,27,"");
11446 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11447 fl_set_object_lcolor(obj,FL_WHITE);
11448 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11449 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11450 fl_set_object_resize(obj, FL_RESIZE_NONE);
11451 fl_set_object_callback(obj,doZEInput,2);
11452 fl_set_input_maxchars(obj, 2);
11453 fl_end_group();
11454
11455 fdui->ruleChargeInput = obj = fl_add_input(FL_NORMAL_INPUT,394,399,55,27,
11456 "Rule tariff:");
11457 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11458 fl_set_object_lcolor(obj,FL_WHITE);
11459 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11460 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11461 fl_set_object_resize(obj, FL_RESIZE_NONE);
11462 fl_set_object_callback(obj,doRuleChargeInput,0);
11463 fl_set_input_maxchars(obj, 6);
11464
11465 fdui->CalDateType = fl_bgn_group();
11466 fdui->RDMInput = obj = fl_add_input(FL_NORMAL_INPUT,512,444,30,27,
11467 "Calendar date (MM/DD):");
11468 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11469 fl_set_object_lcolor(obj,FL_WHITE);
11470 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11471 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11472 fl_set_object_resize(obj, FL_RESIZE_NONE);
11473 fl_set_object_callback(obj,doRDInput,0);
11474 fl_set_input_maxchars(obj, 2);
11475 fdui->RDDInput = obj = fl_add_input(FL_NORMAL_INPUT,554,444,30,27,"/");
11476 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11477 fl_set_object_lcolor(obj,FL_WHITE);
11478 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11479 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11480 fl_set_object_resize(obj, FL_RESIZE_NONE);
11481 fl_set_object_callback(obj,doRDInput,1);
11482 fl_set_input_maxchars(obj, 2);
11483 fl_end_group();
11484
11485
11486 fdui->EndDateType = fl_bgn_group();
11487 fdui->RDEMInput = obj = fl_add_input(FL_NORMAL_INPUT,512,479,30,27,
11488 "End date (MM/DD):");
11489 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11490 fl_set_object_lcolor(obj,FL_WHITE);
11491 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11492 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11493 fl_set_object_resize(obj, FL_RESIZE_NONE);
11494 fl_set_object_callback(obj,doRDEInput,0);
11495 fl_set_input_maxchars(obj, 2);
11496 fdui->RDEDInput = obj = fl_add_input(FL_NORMAL_INPUT,554,479,30,27,"/");
11497 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11498 fl_set_object_lcolor(obj,FL_WHITE);
11499 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11500 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11501 fl_set_object_resize(obj, FL_RESIZE_NONE);
11502 fl_set_object_callback(obj,doRDEInput,1);
11503 fl_set_input_maxchars(obj, 2);
11504 fl_end_group();
11505
11506 fdui->relDateInput = obj = fl_add_input(FL_NORMAL_INPUT,549,514,36,27,
11507 "Day relative to Easter Sunday:");
11508 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11509 fl_set_object_lcolor(obj,FL_WHITE);
11510 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11511 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11512 fl_set_object_resize(obj, FL_RESIZE_NONE);
11513 fl_set_object_callback(obj,doRelDateInput,0);
11514 fl_set_input_maxchars(obj, 3);
11515 fdui->RSHInput = obj = fl_add_input(FL_NORMAL_INPUT,328,587,30,27,"");
11516 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11517 fl_set_object_lcolor(obj,FL_WHITE);
11518 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11519 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11520 fl_set_object_resize(obj, FL_RESIZE_NONE);
11521 fl_set_object_callback(obj,doRSInput,0);
11522 fl_set_input_maxchars(obj, 2);
11523 fdui->RSMInput = obj = fl_add_input(FL_NORMAL_INPUT,368,587,30,27,"");
11524 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11525 fl_set_object_lcolor(obj,FL_WHITE);
11526 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11527 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11528 fl_set_object_resize(obj, FL_RESIZE_NONE);
11529 fl_set_object_callback(obj,doRSInput,1);
11530 fl_set_input_maxchars(obj, 2);
11531 fdui->RSSInput = obj = fl_add_input(FL_NORMAL_INPUT,408,587,30,27,"");
11532 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11533 fl_set_object_lcolor(obj,FL_WHITE);
11534 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11535 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11536 fl_set_object_resize(obj, FL_RESIZE_NONE);
11537 fl_set_object_callback(obj,doRSInput,2);
11538 fl_set_input_maxchars(obj, 2);
11539 fdui->REHInput = obj = fl_add_input(FL_NORMAL_INPUT,476,588,30,27,"");
11540 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11541 fl_set_object_lcolor(obj,FL_WHITE);
11542 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11543 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11544 fl_set_object_resize(obj, FL_RESIZE_NONE);
11545 fl_set_object_callback(obj,doREInput,0);
11546 fl_set_input_maxchars(obj, 2);
11547 fdui->REMInput = obj = fl_add_input(FL_NORMAL_INPUT,516,588,30,27,"");
11548 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11549 fl_set_object_lcolor(obj,FL_WHITE);
11550 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11551 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11552 fl_set_object_resize(obj, FL_RESIZE_NONE);
11553 fl_set_object_callback(obj,doREInput,1);
11554 fl_set_input_maxchars(obj, 2);
11555 fdui->RESInput = obj = fl_add_input(FL_NORMAL_INPUT,556,588,30,27,"");
11556 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11557 fl_set_object_lcolor(obj,FL_WHITE);
11558 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11559 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11560 fl_set_object_resize(obj, FL_RESIZE_NONE);
11561 fl_set_object_callback(obj,doREInput,2);
11562 fl_set_input_maxchars(obj, 2);
11563 fl_end_form();
11564
11565 fdui->pttEditor->fdui = fdui;
11566
11567 return fdui;
11568 }
11569
11570 FD_renameZone *create_form_renameZone(void)
11571 {
11572 FL_OBJECT *obj;
11573 FD_renameZone *fdui = (FD_renameZone *) fl_calloc(1, sizeof(*fdui));
11574
11575 fdui->renameZone = fl_bgn_form(FL_NO_BOX, 219, 112);
11576 obj = fl_add_box(FL_FLAT_BOX,0,0,219,112,"");
11577 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
11578 obj = fl_add_text(FL_NORMAL_TEXT,7,3,143,24,"Charging zone name:");
11579 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11580 fl_set_object_lcolor(obj,FL_WHITE);
11581 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11582 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11583 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11584 fdui->zoneNameInput = obj = fl_add_input(FL_NORMAL_INPUT,12,28,194,28,"");
11585 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11586 fl_set_object_lcolor(obj,FL_WHITE);
11587 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11588 fl_set_object_lalign(obj,FL_ALIGN_TOP_LEFT);
11589 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11590 fl_set_object_resize(obj, FL_RESIZE_NONE);
11591 fl_set_object_callback(obj,doZoneNameInput,0);
11592 fl_set_input_maxchars(obj, MAXLEN_ZNAME);
11593 fdui->zoneNameEditOK = obj = fl_add_button(FL_RETURN_BUTTON,12,70,79,27,
11594 "OK");
11595 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11596 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11597 fl_set_object_resize(obj, FL_RESIZE_NONE);
11598 fl_set_object_callback(obj,doZoneNameEditOK,0);
11599 fl_set_object_bw(obj, -2);
11600 fdui->zoneNameEditCancel = obj = fl_add_button(FL_NORMAL_BUTTON,127,70,79,
11601 27,"Cancel");
11602 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11603 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11604 fl_set_object_resize(obj, FL_RESIZE_NONE);
11605 fl_set_object_callback(obj,doZoneNameEditCancel,0);
11606 fl_set_object_bw(obj, -2);
11607 fl_end_form();
11608
11609 fdui->renameZone->fdui = fdui;
11610
11611 return fdui;
11612 }
11613
11614 FD_renamePTT *create_form_renamePTT(void)
11615 {
11616 FL_OBJECT *obj;
11617 FD_renamePTT *fdui = (FD_renamePTT *) fl_calloc(1, sizeof(*fdui));
11618
11619 fdui->renamePTT = fl_bgn_form(FL_NO_BOX, 219, 112);
11620 obj = fl_add_box(FL_FLAT_BOX,0,0,219,112,"");
11621 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
11622 obj = fl_add_text(FL_NORMAL_TEXT,8,3,145,24,"Phone company name:");
11623 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11624 fl_set_object_lcolor(obj,FL_WHITE);
11625 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11626 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11627 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11628 fdui->PTTNameInput = obj = fl_add_input(FL_NORMAL_INPUT,12,28,194,28,"");
11629 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11630 fl_set_object_lcolor(obj,FL_WHITE);
11631 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11632 fl_set_object_lalign(obj,FL_ALIGN_TOP_LEFT);
11633 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11634 fl_set_object_resize(obj, FL_RESIZE_NONE);
11635 fl_set_object_callback(obj,doPTTNameInput,0);
11636 fl_set_input_maxchars(obj, MAXLEN_PTTNAME);
11637 fdui->PTTNameEditOK = obj = fl_add_button(FL_RETURN_BUTTON,12,70,79,27,"OK");
11638 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11639 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11640 fl_set_object_resize(obj, FL_RESIZE_NONE);
11641 fl_set_object_callback(obj,doPTTNameEditOK,0);
11642 fl_set_object_bw(obj, -2);
11643 fdui->PTTNameEditCancel = obj = fl_add_button(FL_NORMAL_BUTTON,127,70,79,
11644 27,"Cancel");
11645 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11646 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11647 fl_set_object_resize(obj, FL_RESIZE_NONE);
11648 fl_set_object_callback(obj,doPTTNameEditCancel,0);
11649 fl_set_object_bw(obj, -2);
11650 fl_end_form();
11651
11652 fdui->renamePTT->fdui = fdui;
11653
11654 return fdui;
11655 }
11656
11657 FD_actionVerify *create_form_actionVerify(void)
11658 {
11659 FL_OBJECT *obj;
11660 FD_actionVerify *fdui = (FD_actionVerify *) fl_calloc(1, sizeof(*fdui));
11661
11662 fdui->actionVerify = fl_bgn_form(FL_NO_BOX, 300, 117);
11663 obj = fl_add_box(FL_FLAT_BOX,0,0,300,117,"");
11664 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
11665 obj = fl_add_pixmap(FL_NORMAL_PIXMAP,17,20,14,36,"");
11666 fl_set_object_resize(obj, FL_RESIZE_NONE);
11667 fl_set_object_gravity(obj, FL_West, FL_West);
11668 fl_set_pixmap_data(obj, excl_xpm);
11669 fdui->actionVerifyNo = obj = fl_add_button(FL_RETURN_BUTTON,54,71,79,
11670 27,"No");
11671 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11672 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11673 fl_set_object_resize(obj, FL_RESIZE_NONE);
11674 fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
11675 fl_set_object_bw(obj, -2);
11676 fdui->actionVerifyYes = obj = fl_add_button(FL_NORMAL_BUTTON,169,71,79,
11677 27,"Yes");
11678 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11679 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11680 fl_set_object_resize(obj, FL_RESIZE_NONE);
11681 fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
11682 fl_set_object_bw(obj, -2);
11683 fdui->actionVerifyStr = obj = fl_add_text(FL_NORMAL_TEXT,37,16,246,43,"");
11684 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11685 fl_set_object_lcolor(obj,FL_WHITE);
11686 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11687 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11688 fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE);
11689 fl_set_object_resize(obj, FL_RESIZE_NONE);
11690 fl_end_form();
11691
11692 fdui->actionVerify->fdui = fdui;
11693
11694 return fdui;
11695 }
11696
11697 FD_envInfo *create_form_envInfo(void)
11698 {
11699 FL_OBJECT *obj;
11700 FD_envInfo *fdui = (FD_envInfo *) fl_calloc(1, sizeof(*fdui));
11701
11702 fdui->envInfo = fl_bgn_form(FL_NO_BOX, 540, 350);
11703 obj = fl_add_box(FL_FLAT_BOX,0,0,540,350,"");
11704 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
11705 fdui->pppdPathInput = obj = fl_add_input(FL_NORMAL_INPUT,249,46,126,27,
11706 "Path to the pppd daemon:");
11707 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11708 fl_set_object_lcolor(obj,FL_WHITE);
11709 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11710 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11711 fl_set_object_resize(obj, FL_RESIZE_NONE);
11712 fl_set_object_callback(obj,doPppdPathInput,0);
11713 fl_set_input_maxchars(obj, MAXLEN_PATH);
11714 fdui->runPathInput = obj = fl_add_input(FL_NORMAL_INPUT,249,92,126,27,
11715 "Path to pppd process ID \n files (e.g. ppp0.pid):");
11716 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11717 fl_set_object_lcolor(obj,FL_WHITE);
11718 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11719 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11720 fl_set_object_resize(obj, FL_RESIZE_NONE);
11721 fl_set_object_callback(obj,doRunPathInput,0);
11722 fl_set_input_maxchars(obj, MAXLEN_PATH);
11723 fdui->lockPathInput = obj = fl_add_input(FL_NORMAL_INPUT,249,138,126,27,
11724 "Path to pppd lock file(s) for the \n modem device(s) (e.g. LCK..ttyS1):");
11725 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11726 fl_set_object_lcolor(obj,FL_WHITE);
11727 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11728 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11729 fl_set_object_resize(obj, FL_RESIZE_NONE);
11730 fl_set_object_callback(obj,doLockPathInput,0);
11731 fl_set_input_maxchars(obj, MAXLEN_PATH);
11732 fdui->chatPathInput = obj = fl_add_input(FL_NORMAL_INPUT,249,184,126,27,
11733 "Path to the chat program:");
11734 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11735 fl_set_object_lcolor(obj,FL_WHITE);
11736 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11737 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11738 fl_set_object_resize(obj, FL_RESIZE_NONE);
11739 fl_set_object_callback(obj,doChatPathInput,0);
11740 fl_set_input_maxchars(obj, MAXLEN_PATH);
11741 fdui->xispUtilsPathInput = obj = fl_add_input(FL_NORMAL_INPUT,249,230,126,27,
11742 "Path to xISP helper programs \n(xispdial & xispterm):");
11743 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11744 fl_set_object_lcolor(obj,FL_WHITE);
11745 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11746 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11747 fl_set_object_resize(obj, FL_RESIZE_NONE);
11748 fl_set_object_callback(obj,doXispUtilsPathInput,0);
11749 fl_set_input_maxchars(obj, MAXLEN_PATH);
11750 fdui->pipePathInput = obj = fl_add_input(FL_NORMAL_INPUT,249,276,126,27,
11751 "Path to the xISP named-pipe:");
11752 fl_set_object_boxtype(obj,FL_EMBOSSED_BOX);
11753 fl_set_object_lcolor(obj,FL_WHITE);
11754 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11755 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11756 fl_set_object_resize(obj, FL_RESIZE_NONE);
11757 fl_set_object_callback(obj,doPipePathInput,0);
11758 fl_set_input_maxchars(obj, MAXLEN_PATH);
11759 fdui->pppdDefault = obj = fl_add_button(FL_NORMAL_BUTTON,381,47,71,25,
11760 "Default");
11761 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11762 fl_set_object_resize(obj, FL_RESIZE_NONE);
11763 fl_set_object_callback(obj,doPppdDefault,0);
11764 fl_set_object_bw(obj, -2);
11765 fdui->runDefault = obj = fl_add_button(FL_NORMAL_BUTTON,381,93,71,25,
11766 "Default");
11767 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11768 fl_set_object_resize(obj, FL_RESIZE_NONE);
11769 fl_set_object_callback(obj,doRunDefault,0);
11770 fl_set_object_bw(obj, -2);
11771 fdui->lockDefault = obj = fl_add_button(FL_NORMAL_BUTTON,381,139,71,25,
11772 "Default");
11773 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11774 fl_set_object_resize(obj, FL_RESIZE_NONE);
11775 fl_set_object_callback(obj,doLockDefault,0);
11776 fl_set_object_bw(obj, -2);
11777 fdui->chatDefault = obj = fl_add_button(FL_NORMAL_BUTTON,381,185,71,25,
11778 "Default");
11779 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11780 fl_set_object_resize(obj, FL_RESIZE_NONE);
11781 fl_set_object_callback(obj,doChatDefault,0);
11782 fl_set_object_bw(obj, -2);
11783 fdui->xispUtilsDefault = obj = fl_add_button(FL_NORMAL_BUTTON,381,231,71,25,
11784 "Default");
11785 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11786 fl_set_object_resize(obj, FL_RESIZE_NONE);
11787 fl_set_object_callback(obj,doXispUtilsDefault,0);
11788 fl_set_object_bw(obj, -2);
11789 fdui->pipeDefault = obj = fl_add_button(FL_NORMAL_BUTTON,381,277,71,25,
11790 "Default");
11791 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11792 fl_set_object_resize(obj, FL_RESIZE_NONE);
11793 fl_set_object_callback(obj,doPipeDefault,0);
11794 fl_set_object_bw(obj, -2);
11795 obj = fl_add_text(FL_NORMAL_TEXT,452,26,55,19,"Status:");
11796 fl_set_object_color(obj,FL_INDIANRED,FL_MCOL);
11797 fl_set_object_lcolor(obj,FL_WHITE);
11798 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11799 fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
11800 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11801 fdui->pppdStatus = obj = fl_add_text(FL_NORMAL_TEXT,457,47,45,24,"");
11802 fl_set_object_boxtype(obj,FL_FLAT_BOX);
11803 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11804 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11805 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11806 fdui->runStatus = obj = fl_add_text(FL_NORMAL_TEXT,457,93,45,24,"");
11807 fl_set_object_boxtype(obj,FL_FLAT_BOX);
11808 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11809 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11810 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11811 fdui->lockStatus = obj = fl_add_text(FL_NORMAL_TEXT,457,139,45,24,"");
11812 fl_set_object_boxtype(obj,FL_FLAT_BOX);
11813 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11814 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11815 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11816 fdui->chatStatus = obj = fl_add_text(FL_NORMAL_TEXT,457,185,45,24,"");
11817 fl_set_object_boxtype(obj,FL_FLAT_BOX);
11818 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11819 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11820 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11821 fdui->utilsStatus = obj = fl_add_text(FL_NORMAL_TEXT,457,231,45,24,"");
11822 fl_set_object_boxtype(obj,FL_FLAT_BOX);
11823 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11824 fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
11825 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11826
11827 fdui->tipTimer = obj = fl_add_timer(FL_HIDDEN_TIMER, 0,0,0,0,"");
11828 fl_set_timer(obj, 0.0);
11829 fl_set_object_callback(obj,doEnvInfoTip,0);
11830 fl_end_form();
11831
11832 fdui->envInfo->fdui = fdui;
11833
11834 return fdui;
11835 }
11836
11837 FD_optsTab *create_form_optsTab(void)
11838 {
11839 FL_OBJECT *obj;
11840 FD_optsTab *fdui = (FD_optsTab *) fl_calloc(1, sizeof(*fdui));
11841
11842 fl_set_default_tabfolder_corner(2);
11843 fdui->optsTab = fl_bgn_form(FL_NO_BOX, 555, 429);
11844 obj = fl_add_box(FL_FLAT_BOX,0,0,555,429,"");
11845 fl_set_object_color(obj,FL_GREEN,FL_COL1);
11846 fdui->optsFolder = obj = fl_add_tabfolder(FL_TOP_TABFOLDER,5,5,545,378,"");
11847 fl_set_object_boxtype(obj,FL_UP_BOX);
11848 fl_set_object_bw(obj, -2);
11849 fl_set_object_bw(obj->next, -2);
11850 fl_set_object_color(obj,FL_INDIANRED,FL_COL1);
11851 fl_set_object_callback(obj,doOptsFolder,0);
11852 fl_set_object_lcolor(obj,FL_WHITE);
11853 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11854 fl_set_object_lstyle(obj,FL_BOLD_STYLE+FL_SHADOW_STYLE);
11855 fdui->accountInfoButton = obj =
11856 fl_addto_tabfolder(fdui->optsFolder, " Accounts ",
11857 fd_accountInfo->accountInfo);
11858 fl_set_object_prehandler(obj, folderButtonPreH);
11859 fdui->dialInfoButton = obj =
11860 fl_addto_tabfolder(fdui->optsFolder, " Dialing/Login ",
11861 fd_dialInfo->dialInfo);
11862 fl_set_object_prehandler(obj, folderButtonPreH);
11863 fdui->commInfoButton = obj =
11864 fl_addto_tabfolder(fdui->optsFolder, " MODEM ",
11865 fd_commInfo->commInfo);
11866 fl_set_object_prehandler(obj, folderButtonPreH);
11867 fdui->tcpipInfoButton = obj =
11868 fl_addto_tabfolder(fdui->optsFolder, " TCP/IP Options ",
11869 fd_tcpipInfo->tcpipInfo);
11870 fl_set_object_prehandler(obj, folderButtonPreH);
11871 fdui->envInfoButton = obj =
11872 fl_addto_tabfolder(fdui->optsFolder, " Program Paths ",
11873 fd_envInfo->envInfo);
11874 fl_set_object_prehandler(obj, folderButtonPreH);
11875 fdui->optsTabDone = obj = fl_add_button(FL_NORMAL_BUTTON,361,392,79,27,
11876 "Done");
11877 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11878 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11879 fl_set_object_resize(obj, FL_RESIZE_NONE);
11880 fl_set_object_callback(obj,doOptsTabDone,0);
11881 fl_set_object_bw(obj, -2);
11882 fdui->optsTabCancel = obj = fl_add_button(FL_NORMAL_BUTTON,460,392,79,27,
11883 "Cancel");
11884 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
11885 fl_set_object_lstyle(obj,FL_BOLD_STYLE);
11886 fl_set_object_resize(obj, FL_RESIZE_NONE);
11887 fl_set_object_callback(obj,doOptsTabCancel,0);
11888 fl_set_object_bw(obj, -2);
11889 fl_end_form();
11890
11891 fdui->optsTab->fdui = fdui;
11892
11893 return fdui;
11894 }
11895
11896