~ubuntu-branches/debian/jessie/acfax/jessie

« back to all changes in this revision

Viewing changes to .pc/fix-type-of-main.patch/acfax.c

  • Committer: Package Import Robot
  • Author(s): Colin Tuckley
  • Date: 2014-02-10 20:23:51 UTC
  • Revision ID: package-import@ubuntu.com-20140210202351-id1r9lub15jv2dti
Tags: 981011-16
* Convert to source format 3.0 (quilt)
* Remove refs to unused and deprecated getwd
* Change Arch to linux-any since osspd isn't available elsewhere
* Fix various implicit def warnings by adding required .h file includes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    ACfax - Fax reception with X11-interface for amateur radio
 
3
    Copyright (C) 1995-1998 Andreas Czechanowski, DL4SDC
 
4
 
 
5
    This program is free software; you can redistribute it and/or modify
 
6
    it under the terms of the GNU General Public License as published by
 
7
    the Free Software Foundation; either version 2 of the License, or
 
8
    (at your option) any later version.
 
9
 
 
10
    This program is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with this program; if not, write to the Free Software Foundation,
 
17
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 
 
19
    andreas.czechanowski@ins.uni-stuttgart.de
 
20
*/
 
21
    
 
22
/*
 
23
 * acfax.c - the main program
 
24
 */
 
25
 
 
26
#include <stdio.h>
 
27
#include <stdlib.h>
 
28
#include <math.h>
 
29
#include <X11/Intrinsic.h>
 
30
#include <X11/StringDefs.h>
 
31
#include <X11/Shell.h>
 
32
#ifdef USE_XAW3D
 
33
#include <X11/Xaw3d/ThreeD.h>
 
34
#include <X11/Xaw3d/Form.h>
 
35
#include <X11/Xaw3d/MenuButton.h>
 
36
#include <X11/Xaw3d/Toggle.h>
 
37
#include <X11/Xaw3d/Viewport.h>
 
38
#include <X11/Xaw3d/Box.h>
 
39
#include <X11/Xaw3d/SimpleMenu.h>
 
40
#include <X11/Xaw3d/SmeBSB.h>
 
41
#include <X11/Xaw3d/AsciiText.h>
 
42
#else
 
43
#include <X11/Xaw/Form.h>
 
44
#include <X11/Xaw/MenuButton.h>
 
45
#include <X11/Xaw/Toggle.h>
 
46
#include <X11/Xaw/Viewport.h>
 
47
#include <X11/Xaw/Box.h>
 
48
#include <X11/Xaw/SimpleMenu.h>
 
49
#include <X11/Xaw/SmeBSB.h>
 
50
#include <X11/Xaw/AsciiText.h>
 
51
#endif
 
52
#include "Canvas.h"
 
53
#include "global.h"
 
54
#include "mod_demod.h"
 
55
#include "sblaster.h"
 
56
#include "x_image.h"
 
57
#include "fax_funcs.h"
 
58
#include "widgets.h"
 
59
 
 
60
static char *fallbacks[] = {
 
61
  "*background: grey80",
 
62
  "*foreground: black",
 
63
  "*menuform*filebut.label: file-ops",
 
64
  "*menuform*filebut*file_mw.label: Image-file ops :",
 
65
  "*menuform*filebut*autosave.label: save (auto filename)",
 
66
  "*menuform*filebut*saveas.label: save as...",
 
67
  "*menuform*filebut*close.label: close savefile",
 
68
  "*menuform*filebut*quit.label: quit ACfax",
 
69
  "*optbut.label: Options...",
 
70
  "*modebut.label: Modes...",
 
71
/*  "*msg_shell*msg_ok.label: -OK-", */
 
72
  "*canvas.width: 1280",
 
73
  "*canvas.height: 1024",
 
74
  "*modemform*modemdesc.background: beige",
 
75
  "*modemform*modemdesc.label: modem settings",
 
76
  "*modemform*modinfo.background: beige",
 
77
  "*modemform*modinfo.label: modem\\ntype",
 
78
  "*modemform*filinfo.background: beige",
 
79
  "*modemform*filinfo.label: filter\\nselect",
 
80
  "*modemform*mflt1.label: narrow filter",
 
81
  "*modemform*mflt2.label: middle filter",
 
82
  "*modemform*mflt3.label: wide filter",
 
83
  "*modemform*fmdevinfo.background: beige",
 
84
  "*modemform*fmdevinfo.label: FM deviation (+/- Hz)",
 
85
  "*modemform*siginfo.background: beige",
 
86
  "*modemform*siginfo.label: Signal",
 
87
  "*faxctrls*runinfo.background: beige",
 
88
  "*faxctrls*runinfo.label: operation\\ncontrol",
 
89
  "*faxctrls*dirinfo.background: beige",
 
90
  "*faxctrls*dirinfo.label: writing\\ndirection",
 
91
  "*faxctrls*polinfo.background: beige",
 
92
  "*faxctrls*polinfo.label: image\\npolarity",
 
93
  "*faxctrls*phsinfo.background: beige",
 
94
  "*faxctrls*phsinfo.label: sync\\npolarity",
 
95
  "*faxctrls*adjinfo.background: beige",
 
96
  "*faxctrls*adjinfo.label: image\\nadjust",
 
97
  "*faxparams*numinfo.background: beige",
 
98
  "*faxparams*numinfo.label: numeric FAX-parameters",
 
99
  "*faxparams*statxt.label: APT start:",
 
100
  "*faxparams*stotxt.label: stop:",
 
101
  "*faxparams*lpmtxt.label: LPM:",
 
102
  "*faxparams*ioctxt.label: IOC:",
 
103
  NULL
 
104
};
 
105
 
 
106
struct prginfo {
 
107
  String callsign;
 
108
  String sizedesc;
 
109
} prg_info;
 
110
 
 
111
Display *dpy;           /* the X-Display to use */
 
112
Screen  *scr;           /* screen of the display */
 
113
Pixmap  cpxmap;         /* The "backing store" for the canvas-widget */
 
114
GC      cgc;            /* GC for XPutImage from horimage/verimage to cpxmap */
 
115
/* XEvent       event;       for XtAppNextEvent / XtDispatchEvent */
 
116
/* unsigned canwid;     width of canvas-widget */
 
117
/* unsigned canhei;     height of canvas-widget */
 
118
/* Colormap cmap, rootcmap;  colormap we use, and default-colormap */
 
119
/* unsigned coltab[256];     mapping table linear grayscale->pixel-value */
 
120
/* char cused[256];     table indicating used pixel-values */
 
121
int     mode_lock = 0;  /* locks the operation control callback */
 
122
/* int  xpos, ypos;     position to fill with data */
 
123
/* int  ixoc;           number of pixels of one scan-line / PI */
 
124
/* int  right2left;     boolean indicating reverse line writing direction */
 
125
/* int  bot2top;        boolean indicating reverse line stacking direction */
 
126
/* int  mod_mode;       can be MOD_FM or MOD_AM */
 
127
/* int  fax_state;      one of FAX_APT, FAX_PHAS or FAX_RX */
 
128
/* int  max_val;        maximum level for demodulated output */
 
129
/* int  aptstart;       possible APT start values */
 
130
/* int  aptstop;        possible APT stop values */
 
131
int     save_width;     /* width of scan-line in pixels for saving */
 
132
struct fileshell_args   save_fsa; /* structure for file-save */
 
133
struct fileshell_args   load_fsa; /* structure for file-load */
 
134
 
 
135
XtAppContext    mainapp;
 
136
Widget  toplevel;
 
137
/*
 
138
Widget  last;           / just for convenience.... /
 
139
Widget  form,           / where to put it all in /
 
140
        vport,          / a viewport to look thru onto the canvas /
 
141
        canvas;         / widget holding picture using XImages /
 
142
*/
 
143
/*
 
144
Widget  menuform,
 
145
        filebut,        / buttons in the top-line : "file" /
 
146
        modebut,        / mode-select button /
 
147
        optbut;         / option-select button /
 
148
Widget  file_mw,        / popup-menu for "file" /
 
149
        file_saveas,    / menu-item "save as" /
 
150
        file_close,     / menu-item "close savefile" /
 
151
        file_autosave;  / menu-item "save (auto filename) /
 
152
Widget  msg_shell,      / popup-shell for aux. messages /
 
153
        msg_form,       / form widget holding... /
 
154
        msg_text,       / displayed text /
 
155
        msg_ok;         / additional button (Ok/cancel/confirm/...) /
 
156
Widget  modemform,
 
157
        faxformA,
 
158
        faxformB;
 
159
Widget  modeminfo,
 
160
        mmode,
 
161
        fmdevinfo,
 
162
        fmdevval,
 
163
        fmdevtxt;
 
164
Widget  runinfo,
 
165
        rmstop,
 
166
        rmsyn,
 
167
        rmrun;
 
168
Widget  dirinfo,
 
169
        dirhv,
 
170
        dirlr,
 
171
        dirtb,
 
172
        polinfo,
 
173
        norinv;
 
174
Widget  phsinfo,
 
175
        posneg,
 
176
        statxt,
 
177
        staval,
 
178
        stotxt,
 
179
        stoval;
 
180
Widget  numinfo,
 
181
        lpmtxt,
 
182
        lpmval,
 
183
        ioctxt,
 
184
        iocval;
 
185
Widget  adjinfo,
 
186
        lshift,
 
187
        azimut;
 
188
 
 
189
*/
 
190
 
 
191
/*
 
192
Pixmap  px_horiz,
 
193
        px_vert,
 
194
        px_right,
 
195
        px_left,
 
196
        px_top,
 
197
        px_bottom,
 
198
        px_normal,
 
199
        px_invers,
 
200
        px_nphs,
 
201
        px_iphs,
 
202
        px_azimut,
 
203
        px_shift,
 
204
        px_stop,
 
205
        px_syn,
 
206
        px_run,
 
207
        px_mam,
 
208
        px_mfm,
 
209
        px_narrow,
 
210
        px_middle,
 
211
        px_wide;
 
212
*/
 
213
 
 
214
#define elofs(element) XtOffsetOf(struct prginfo, element)
 
215
 
 
216
static XtResource resources[] = {
 
217
  { "callsign", "Callsign", XtRString, sizeof(String),
 
218
    elofs(callsign), XtRImmediate, (XtPointer)"nocall" },
 
219
  { "size", "Size", XtRString, sizeof(String),
 
220
    elofs(sizedesc), XtRImmediate, (XtPointer)"double" },
 
221
};
 
222
 
 
223
static XrmOptionDescRec options[] = {
 
224
  { "-callsign", ".callsign", XrmoptionSepArg, (XtPointer)NULL },
 
225
  { "-size",     ".size",     XrmoptionSepArg, (XtPointer)NULL },
 
226
};
 
227
 
 
228
static  void usage(char *);
 
229
/* void create_widgets(void); */
 
230
/* void create_pixmaps(Widget); */
 
231
void    update_pxm(XImage *, int, int, int, int, unsigned, unsigned);
 
232
void    num_input(Widget, XEvent *, String *, Cardinal *);
 
233
void    show_values(void);
 
234
void    op_changed(int);
 
235
void    modmode_cb(Widget, XtPointer, XtPointer);
 
236
void    filtsel_cb(Widget, XtPointer, XtPointer);
 
237
void    stastop_cb(Widget, XtPointer, XtPointer);
 
238
void    dirhv_cb(Widget, XtPointer, XtPointer);
 
239
void    dirlr_cb(Widget, XtPointer, XtPointer);
 
240
void    dirtb_cb(Widget, XtPointer, XtPointer);
 
241
void    norinv_cb(Widget, XtPointer, XtPointer);
 
242
void    posneg_cb(Widget, XtPointer, XtPointer);
 
243
void    lshift_cb(Widget, XtPointer, XtPointer);
 
244
void    lshift_trigger(Widget, XtPointer, XtPointer);
 
245
void    azimut_cb(Widget, XtPointer, XtPointer);
 
246
void    azimut_trigger(Widget, XtPointer, XtPointer);
 
247
void    namesave_cb(Widget, XtPointer, XtPointer);
 
248
void    savefile_act(char *);
 
249
void    autosave_cb(Widget, XtPointer, XtPointer);
 
250
void    closesave_cb(Widget, XtPointer, XtPointer);
 
251
void    quit_cb(Widget, XtPointer, XtPointer);
 
252
 
 
253
XtTranslations txt_trans;
 
254
XtActionsRec acts[] = {
 
255
        { "num-in", (XtActionProc)num_input },
 
256
  };
 
257
 
 
258
#ifndef HAVE_LTOA
 
259
/* simple, fast integer to string conversion */
 
260
char *ltoa(int n)
 
261
{
 
262
  static char res[16];
 
263
  int i, f[16];
 
264
  int d, p;
 
265
 
 
266
  d = 0;        /* 0 digits */
 
267
  p = 0;        /* 0 chars in string */
 
268
  /* allow to handle negative numbers */
 
269
  if (n < 0) {  
 
270
    res[p++] = '-';
 
271
  }
 
272
 
 
273
  /* calculate all the fractional parts */
 
274
  do {
 
275
    i = n / 10;
 
276
    f[d++] = n % 10;
 
277
    n = i;
 
278
  } while (i != 0);
 
279
 
 
280
  /* concatenate to string in reverse order */
 
281
  while (d) {
 
282
    res[p++] = f[--d] + '0';
 
283
  }
 
284
 
 
285
  /* terminate string */
 
286
  res[p] = '\0';
 
287
 
 
288
  return res;
 
289
}
 
290
#endif
 
291
 
 
292
static void usage(char *prgname)
 
293
{
 
294
  fprintf(stderr, "Usage : %s [Options]\n"
 
295
    "  Known options are :\n"
 
296
    "  -callsign callsign\n"
 
297
    "  -width {normal|double}\n", prgname);
 
298
}
 
299
 
 
300
/*
 
301
void create_pixmaps(Widget wid)
 
302
{
 
303
#include "bitmaps/horiz.bit"
 
304
#include "bitmaps/vert.bit"
 
305
#include "bitmaps/left.bit"
 
306
#include "bitmaps/right.bit"
 
307
#include "bitmaps/top.bit"
 
308
#include "bitmaps/bottom.bit"
 
309
#include "bitmaps/nphs.bit"
 
310
#include "bitmaps/iphs.bit"
 
311
#include "bitmaps/normal.bit"
 
312
#include "bitmaps/invers.bit"
 
313
#include "bitmaps/azimut.bit"
 
314
#include "bitmaps/shift.bit"
 
315
#include "bitmaps/stop.bit"
 
316
#include "bitmaps/syn.bit"
 
317
#include "bitmaps/run.bit"
 
318
#include "bitmaps/ammod.bit"
 
319
#include "bitmaps/fmmod.bit"
 
320
#include "bitmaps/narrow.bit"
 
321
#include "bitmaps/middle.bit"
 
322
#include "bitmaps/wide.bit"
 
323
  Window win;
 
324
 
 
325
  win = XtWindow(wid);
 
326
  px_horiz = XCreateBitmapFromData(dpy, win, horiz_bits, horiz_width, horiz_height);
 
327
  px_vert = XCreateBitmapFromData(dpy, win, vert_bits, vert_width, vert_height);
 
328
  px_right = XCreateBitmapFromData(dpy, win, right_bits, right_width, right_height);
 
329
  px_left = XCreateBitmapFromData(dpy, win, left_bits, left_width, left_height);
 
330
  px_top = XCreateBitmapFromData(dpy, win, top_bits, top_width, top_height);
 
331
  px_bottom = XCreateBitmapFromData(dpy, win, bottom_bits, bottom_width, bottom_height);
 
332
  px_nphs = XCreateBitmapFromData(dpy, win, nphs_bits, nphs_width, nphs_height);
 
333
  px_iphs = XCreateBitmapFromData(dpy, win, iphs_bits, iphs_width, iphs_height);
 
334
  px_normal = XCreateBitmapFromData(dpy, win, normal_bits, normal_width, normal_height);
 
335
  px_invers = XCreateBitmapFromData(dpy, win, invers_bits, invers_width, invers_height);
 
336
  px_azimut = XCreateBitmapFromData(dpy, win, azimut_bits, azimut_width, azimut_height);
 
337
  px_shift = XCreateBitmapFromData(dpy, win, shift_bits, shift_width, shift_height);
 
338
  px_stop = XCreateBitmapFromData(dpy, win, stop_bits, stop_width, stop_height);
 
339
  px_syn = XCreateBitmapFromData(dpy, win, syn_bits, syn_width, syn_height);
 
340
  px_run = XCreateBitmapFromData(dpy, win, run_bits, run_width, run_height);
 
341
  px_mam = XCreateBitmapFromData(dpy, win, ammod_bits, ammod_width, ammod_height);
 
342
  px_mfm = XCreateBitmapFromData(dpy, win, fmmod_bits, fmmod_width, fmmod_height);
 
343
  px_narrow = XCreateBitmapFromData(dpy, win, narrow_bits, narrow_width, narrow_height);
 
344
  px_middle = XCreateBitmapFromData(dpy, win, middle_bits, middle_width, middle_height);
 
345
  px_wide = XCreateBitmapFromData(dpy, win, wide_bits, wide_width, wide_height);
 
346
 
 
347
  XtVaSetValues(dirhv, XtNbitmap, px_horiz, NULL);
 
348
  XtVaSetValues(dirlr, XtNbitmap, px_right, NULL);
 
349
  XtVaSetValues(dirtb, XtNbitmap, px_bottom, NULL);
 
350
  XtVaSetValues(norinv, XtNbitmap, px_normal, NULL);
 
351
  XtVaSetValues(posneg, XtNbitmap, px_nphs, NULL);
 
352
  XtVaSetValues(lshift, XtNbitmap, px_shift, NULL);
 
353
  XtVaSetValues(azimut, XtNbitmap, px_azimut, NULL);
 
354
  XtVaSetValues(rmstop, XtNbitmap, px_stop, NULL);
 
355
  XtVaSetValues(rmsyn, XtNbitmap, px_syn, NULL);
 
356
  XtVaSetValues(rmrun, XtNbitmap, px_run, NULL);
 
357
  XtVaSetValues(mmode, XtNbitmap, px_mfm, NULL);
 
358
  XtVaSetValues(mfilter, XtNbitmap, px_middle, NULL);
 
359
}
 
360
*/
 
361
 
 
362
/* copy one of the XImages into the Pixmap of the canvas, and redisplay that
 
363
   portion of the image
 
364
*/
 
365
void update_pxm(XImage *img, int xs, int ys, int xd, int yd,
 
366
        unsigned wid, unsigned hei)
 
367
{
 
368
  XPutImage(dpy, cpxmap, cgc, img, xs, ys, xd, yd, wid, hei);
 
369
  canvasUpdateArea((CanvasWidget)canvas, xd, yd, wid, hei); 
 
370
}
 
371
 
 
372
/* the following makes the gcc happy not to complain about unused arguments */
 
373
/* ARGSUSED */
 
374
void num_input(Widget w, XEvent *event, String *par, Cardinal *npar)
 
375
{
 
376
  int val;
 
377
  String str;
 
378
  char ch[8];
 
379
  
 
380
  XtVaGetValues(w, XtNstring, &str, NULL);
 
381
  val = atoi(str);
 
382
  if (w == num_s.staval) {
 
383
    if (val > 500) val = 500;
 
384
    if (val < 100) val = 100;
 
385
    aptstart = val;
 
386
  } else if (w == num_s.stoval) {
 
387
    if (val > 500) val = 500;
 
388
    if (val < 100) val = 100;
 
389
    aptstop = val;
 
390
  } else if (w == num_s.lpmval) {
 
391
    setup_fax(val, 0, 0, w, 0, 0, 0, 0);
 
392
    val = lpm;
 
393
  } else if (w == num_s.iocval) {
 
394
    setup_fax(0, val, 0, w, 0, 0, 0, 0);
 
395
    val = ixoc;
 
396
  } else if (w == mod_s.fmdevval) {
 
397
    setup_fax(0, 0, 0, w, 0, 0, val, 0);
 
398
    val = devi;
 
399
  }
 
400
  sprintf(ch, "%d", val);
 
401
  XtVaSetValues(w, XtNstring, ch, NULL);
 
402
}
 
403
 
 
404
/* show the numeric fax-parameters and the FM-deviation of the modem */
 
405
void show_values(void)
 
406
{
 
407
  XtVaSetValues(mod_s.fmdevval, XtNstring, ltoa(devi), NULL);
 
408
  XtVaSetValues(num_s.lpmval, XtNstring, ltoa(lpm), NULL);
 
409
  XtVaSetValues(num_s.iocval, XtNstring, ltoa(ixoc), NULL);
 
410
  XtVaSetValues(num_s.staval, XtNstring, ltoa(aptstart), NULL);
 
411
  XtVaSetValues(num_s.stoval, XtNstring, ltoa(aptstop), NULL);
 
412
}
 
413
 
 
414
void op_changed(int mode)
 
415
{
 
416
  mode_lock = 1;
 
417
  switch(mode) {
 
418
    case FAX_APT:
 
419
        XtVaSetValues(run_s.rmstop, XtNstate, True, NULL);
 
420
        break;
 
421
    case FAX_PHAS:
 
422
        XtVaSetValues(run_s.rmsyn, XtNstate, True, NULL);
 
423
        break;
 
424
    case FAX_RX:
 
425
        XtVaSetValues(run_s.rmrun, XtNstate, True, NULL);
 
426
        break;
 
427
  }
 
428
  mode_lock = 0;
 
429
}
 
430
 
 
431
void modmode_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
432
{
 
433
  Boolean st;
 
434
 
 
435
  st = (Boolean)((long)call_data);
 
436
  if (st) {
 
437
    setup_fax(0, 0, 0, w, 0, 0, 0, MOD_AM);
 
438
    XtVaSetValues(mod_s.mmode, XtNbitmap, px_mam, NULL);
 
439
  } else {
 
440
    setup_fax(0, 0, 0, w, 0, 0, 0, MOD_FM);
 
441
    XtVaSetValues(mod_s.mmode, XtNbitmap, px_mfm, NULL);
 
442
  }
 
443
}
 
444
 
 
445
void filtsel_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
446
{
 
447
  int selectn;
 
448
  Pixmap pxm;
 
449
 
 
450
  selectn = (int)client_data;
 
451
  switch (selectn) {
 
452
    case FIL_NARR:
 
453
        pxm = px_narrow;
 
454
        break;
 
455
    case FIL_MIDL:
 
456
        pxm = px_middle;
 
457
        break;
 
458
    case FIL_WIDE:
 
459
        pxm = px_wide;
 
460
        break;
 
461
    default:
 
462
        return;
 
463
  }
 
464
  setup_fax(0, 0, 0, w, 0, 0, 0, selectn);
 
465
  XtVaSetValues(mod_s.mfilter, XtNbitmap, pxm, NULL);
 
466
}
 
467
 
 
468
void stastop_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
469
{
 
470
  Boolean st;
 
471
  unsigned rd;
 
472
 
 
473
  rd = (unsigned)XawToggleGetCurrent(w);
 
474
  st = (Boolean)((long)call_data);
 
475
  fprintf(stderr, "rd = %u, st = %u\n", rd, (unsigned)st);
 
476
  if (rd == 0) {        /* all widgets of the radio-group are unset ? */
 
477
    /* XtVaSetValues(rmstop, XtNstate, True, NULL);  we may call ourself here ! */
 
478
    return;
 
479
  }
 
480
  if (!st) {
 
481
    return;             /* if unset, do not continue */
 
482
  }
 
483
  if (mode_lock) return;
 
484
  switch(rd) {
 
485
    case FAX_APT:
 
486
        fax_rx_stop(0);
 
487
        break;
 
488
    case FAX_PHAS:
 
489
        fax_rx_phase(0);
 
490
        break;
 
491
    case FAX_RX:
 
492
        fax_rx_start(0);
 
493
        break;
 
494
  }
 
495
}
 
496
 
 
497
void syn_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
498
{
 
499
  Boolean st;
 
500
 
 
501
  st = (Boolean)((long)call_data);
 
502
  if (!st) {
 
503
    XtVaSetValues(w, XtNstate, True, NULL); /* we may call ourself here ! */
 
504
    return;             /* if unset, do not continue */
 
505
  }
 
506
  fax_rx_phase(0);
 
507
}
 
508
 
 
509
void run_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
510
{
 
511
  Boolean st;
 
512
 
 
513
  st = (Boolean)((long)call_data);
 
514
  if (!st) {
 
515
    XtVaSetValues(w, XtNstate, True, NULL); /* we may call ourself here ! */
 
516
    return;             /* if unset, do not continue */
 
517
  }
 
518
  fax_rx_start(0);
 
519
}
 
520
 
 
521
void dirhv_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
522
{
 
523
  Boolean st;
 
524
 
 
525
  XtVaGetValues(w, XtNstate, &st, NULL);
 
526
  if (st == True) {
 
527
    setup_fax(0, 0, FAX_VER, w, 0, 0, 0, 0);
 
528
    XtVaSetValues(w, XtNbitmap, px_vert, NULL);
 
529
  } else {
 
530
    setup_fax(0, 0, FAX_HOR, w, 0, 0, 0, 0);
 
531
    XtVaSetValues(w, XtNbitmap, px_horiz, NULL);
 
532
  }
 
533
}
 
534
 
 
535
void dirlr_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
536
{
 
537
  Boolean st;
 
538
 
 
539
  XtVaGetValues(w, XtNstate, &st, NULL);
 
540
  if (st == True) {
 
541
    setup_fax(0, 0, FAX_RIG2LEF, w, 0, 0, 0, 0);
 
542
    XtVaSetValues(w, XtNbitmap, px_left, NULL);
 
543
  } else {
 
544
    setup_fax(0, 0, FAX_LEF2RIG, w, 0, 0, 0, 0);
 
545
    XtVaSetValues(w, XtNbitmap, px_right, NULL);
 
546
  }
 
547
}
 
548
 
 
549
void dirtb_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
550
{
 
551
  Boolean st;
 
552
 
 
553
  XtVaGetValues(w, XtNstate, &st, NULL);
 
554
  if (st == True) {
 
555
    setup_fax(0, 0, FAX_BOT2TOP, w, 0, 0, 0, 0);
 
556
    XtVaSetValues(w, XtNbitmap, px_top, NULL);
 
557
  } else {
 
558
    setup_fax(0, 0, FAX_TOP2BOT, w, 0, 0, 0, 0);
 
559
    XtVaSetValues(w, XtNbitmap, px_bottom, NULL);
 
560
  }
 
561
}
 
562
 
 
563
void norinv_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
564
{
 
565
  Boolean st;
 
566
 
 
567
  XtVaGetValues(w, XtNstate, &st, NULL);
 
568
  if (st == True) {
 
569
    setup_fax(0, 0, FAX_CINV, w, 0, 0, 0, 0);
 
570
    XtVaSetValues(w, XtNbitmap, px_invers, NULL);
 
571
  } else {
 
572
    setup_fax(0, 0, FAX_CNOR, w, 0, 0, 0, 0);
 
573
    XtVaSetValues(w, XtNbitmap, px_normal, NULL);
 
574
  }
 
575
}
 
576
 
 
577
void posneg_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
578
{
 
579
  Boolean st;
 
580
 
 
581
  XtVaGetValues(w, XtNstate, &st, NULL);
 
582
  if (st == True) {
 
583
    setup_fax(0, 0, FAX_PWHT, w, 0, 0, 0, 0);
 
584
    XtVaSetValues(w, XtNbitmap, px_iphs, NULL);
 
585
  } else {
 
586
    setup_fax(0, 0, FAX_PBLK, w, 0, 0, 0, 0);
 
587
    XtVaSetValues(w, XtNbitmap, px_nphs, NULL);
 
588
  }
 
589
}
 
590
 
 
591
void text_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
592
{
 
593
  String s;
 
594
 
 
595
  XtVaGetValues(w, XtNstring, &s, NULL);
 
596
  fprintf(stderr, "text_cb: string = %s\n", s);
 
597
}
 
598
 
 
599
void show_coords(Widget w, XtPointer client_data, XtPointer call_data)
 
600
{
 
601
  XPoint *xp;
 
602
  if (call_data) {
 
603
    xp = (XPoint *) call_data;
 
604
    printf("coords = %d, %d\n", xp->x, xp->y);
 
605
  }
 
606
}
 
607
 
 
608
void lshift_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
609
{
 
610
  XtVaSetValues(adj_s.lshift, XtNsensitive, False, NULL);
 
611
  XtVaSetValues(adj_s.azimut, XtNsensitive, False, NULL);
 
612
  XtVaSetValues(info_s.text, XtNlabel, "move mointer to sync position\n"
 
613
                "and press left mouse button.", NULL);
 
614
  XtVaSetValues(info_s.butn, XtNlabel, "Cancel", NULL);
 
615
  XawFormDoLayout(info_s.form, True);
 
616
  XtAddCallback(canvas, XtNcallback, lshift_trigger, (XtPointer) 1);
 
617
  XtAddCallback(info_s.butn, XtNcallback, lshift_trigger, (XtPointer) 0);
 
618
  XtPopup(info_s.shell, XtGrabNone);
 
619
}
 
620
 
 
621
void lshift_trigger(Widget w, XtPointer client_data, XtPointer call_data)
 
622
{
 
623
  XPoint *xp;
 
624
 
 
625
  if ((unsigned)client_data == 1) {
 
626
    if (call_data) {
 
627
      xp = (XPoint *) call_data;
 
628
      shift_fax_coords(xp->x, xp->y);
 
629
    }
 
630
  }
 
631
  XtRemoveAllCallbacks(canvas, XtNcallback);
 
632
  XtVaSetValues(adj_s.lshift, XtNsensitive, True, NULL);
 
633
  XtVaSetValues(adj_s.azimut, XtNsensitive, True, NULL);
 
634
  XtPopdown(info_s.shell);
 
635
}
 
636
 
 
637
void azimut_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
638
{
 
639
  char message[256];
 
640
  Boolean vertmode;
 
641
 
 
642
  /* do not allow any further keypress on this button */
 
643
  XtVaSetValues(adj_s.azimut, XtNsensitive, False, NULL);
 
644
  XtVaSetValues(adj_s.lshift, XtNsensitive, False, NULL);
 
645
  XtVaGetValues(dir_s.dirhv, XtNstate, &vertmode, NULL);
 
646
  sprintf(message, "move mointer to the first point\n"
 
647
        "on a line that should be %s\n"
 
648
        "and press left mouse button.",
 
649
        (vertmode) ? "horizontal" : "vertical");
 
650
  XtVaSetValues(info_s.text, XtNlabel, message, NULL);
 
651
  XtVaSetValues(info_s.butn, XtNlabel, "Cancel", NULL);
 
652
  XawFormDoLayout(info_s.form, True);
 
653
  XtAddCallback(canvas, XtNcallback, azimut_trigger, (XtPointer) 1);
 
654
  XtAddCallback(info_s.butn, XtNcallback, azimut_trigger, (XtPointer) 0);
 
655
  XtPopup(info_s.shell, XtGrabNone);
 
656
}
 
657
 
 
658
void azimut_trigger(Widget w, XtPointer client_data, XtPointer call_data)
 
659
{
 
660
  XPoint *xp;
 
661
  static int xa, ya;
 
662
 
 
663
  if ((unsigned)client_data == 1) {
 
664
    /* first point, get position into xa, ya */
 
665
    if (call_data) {
 
666
      xp = (XPoint *) call_data;
 
667
      xa = xp->x;
 
668
      ya = xp->y;
 
669
      XtVaSetValues(info_s.text, XtNlabel, "now move pointer to the second point\n"
 
670
                "on that line and press left mouse button.", NULL);
 
671
      XtVaSetValues(info_s.butn, XtNlabel, "Cancel", NULL);
 
672
      /* XawFormDoLayout(info_s.form, True); */
 
673
      XtRemoveAllCallbacks(canvas, XtNcallback);
 
674
      XtAddCallback(canvas, XtNcallback, azimut_trigger, (XtPointer) 2);
 
675
      return;
 
676
    }
 
677
  } else if ((unsigned)client_data == 2) {
 
678
    /* second point, remove the menu from the screen */
 
679
    XtRemoveAllCallbacks(canvas, XtNcallback);
 
680
    if (call_data) {
 
681
      xp = (XPoint *) call_data;
 
682
      correct_fax_azimut(xp->x - xa, xp->y - ya);
 
683
    }
 
684
  }
 
685
  /* remove callbacks from canvas, re-activate azimut and lshift buttons,
 
686
     pop down the shell */
 
687
  XtRemoveAllCallbacks(canvas, XtNcallback);
 
688
  XtVaSetValues(adj_s.azimut, XtNsensitive, True, NULL);
 
689
  XtVaSetValues(adj_s.lshift, XtNsensitive, True, NULL);
 
690
  XtPopdown(info_s.shell);
 
691
}
 
692
 
 
693
void namesave_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
694
{
 
695
  query_filename(&save_fsa);
 
696
}
 
697
 
 
698
void savefile_act(char *name)
 
699
{
 
700
  int ret;
 
701
 
 
702
  ret = save_faxfile(name, save_width);
 
703
  switch(ret) {
 
704
    case SAVE_BUSY:
 
705
        simple_info("Save-file already open !\nClose this file first");
 
706
        break;
 
707
    case SAVE_NPERM:
 
708
        simple_info("Cannot open save-file ?!");
 
709
        break;
 
710
    case SAVE_OK:
 
711
        break;
 
712
  }
 
713
}
 
714
 
 
715
void autosave_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
716
{
 
717
  int ret;
 
718
 
 
719
  ret = save_faxfile(NULL, save_width);
 
720
  switch(ret) {
 
721
    case SAVE_BUSY:
 
722
        simple_info("Save-file already open !\nClose this file first");
 
723
        break;
 
724
    case SAVE_NPERM:
 
725
        simple_info("Cannot open save-file ?!");
 
726
        break;
 
727
    case SAVE_OK:
 
728
        break;
 
729
  }
 
730
}
 
731
 
 
732
void closesave_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
733
{
 
734
  close_faxsave();
 
735
}
 
736
 
 
737
void quit_cb(Widget w, XtPointer client_data, XtPointer call_data)
 
738
{
 
739
    exit(0);
 
740
}
 
741
 
 
742
void main(int argc, char **argv)
 
743
{
 
744
  int i;
 
745
  Pixel respix[20];
 
746
  unsigned nrespix;
 
747
  Dimension wid, hei;
 
748
 
 
749
  toplevel = XtAppInitialize(&mainapp, "ACfax",
 
750
                options, XtNumber(options),
 
751
                &argc, argv,
 
752
                fallbacks,
 
753
                NULL, 0); /* no arguments-list, 0 arguments */
 
754
 
 
755
  XtGetApplicationResources(toplevel, (XtPointer)&prg_info,
 
756
                resources, XtNumber(resources),
 
757
                NULL, 0);
 
758
 
 
759
  dpy = XtDisplay(toplevel);
 
760
  scr = XtScreen(toplevel);
 
761
  XtAppAddActions(mainapp, acts, XtNumber(acts));
 
762
  txt_trans = XtParseTranslationTable("#override \
 
763
                <Key>Return: num-in()\n\
 
764
                <Key>Linefeed: num-in()\n\
 
765
                Ctrl<Key>M: num-in()\n\
 
766
                Ctrl<Key>J: num-in()\n");
 
767
 
 
768
  /* cmap = DefaultColormap(dpy, scr); */
 
769
  /* create widgets */
 
770
  XtVaSetValues(toplevel, XtNtitle, "ACfax display", NULL);
 
771
  create_widgets(toplevel);
 
772
  XtRealizeWidget(toplevel);
 
773
  XtPopup(fax_shell, XtGrabNone);
 
774
  create_pixmaps(fax_form);
 
775
 
 
776
  fprintf(stderr,"allocing cmap\n"); fflush(stderr);
 
777
  for (i=0; i<20; i++) respix[i] = 0;
 
778
  respix[0] = BlackPixelOfScreen(scr);
 
779
  respix[1] = WhitePixelOfScreen(scr);
 
780
  XtVaGetValues(fax_form, XtNforeground, &respix[2],
 
781
        XtNbackground, &respix[3],
 
782
#ifdef USE_XAW3D
 
783
        XtNtopShadowPixel, &respix[4],
 
784
        XtNbottomShadowPixel, &respix[5],
 
785
#endif
 
786
        NULL);
 
787
  XtVaGetValues(mod_s.modemdesc, XtNbackground, &respix[6],
 
788
        NULL);
 
789
  for (i=0; i<13; i++)
 
790
    respix[i+7] = i;
 
791
  nrespix = 20;
 
792
  alloc_cmap(toplevel, respix, nrespix);
 
793
 
 
794
  update_area = update_pxm;
 
795
  mode_notify = op_changed;
 
796
  /* that's a hard one, but should set up all things right.... */
 
797
  XtVaGetValues(canvas, XtNwidth, &wid, XtNheight, &hei, NULL);
 
798
  setup_fax(120, 288, (FAX_CNOR | FAX_CUNFL | FAX_CROT0 |
 
799
        FAX_LEF2RIG | FAX_TOP2BOT | FAX_HOR | FAX_PBLK | FAX_GRAY),
 
800
        toplevel, (unsigned)wid, (unsigned)hei, 500, (MOD_FM | FIL_MIDL));
 
801
  aptstart = 300;
 
802
  aptstop = 450;
 
803
  show_values();
 
804
 
 
805
#if 0
 
806
  for (i=0; i<10; i++)
 
807
    printf("level = %d\n", signal_level());
 
808
#endif
 
809
 
 
810
  receive_on();
 
811
  fprintf(stderr,"filling cmap\n"); fflush(stderr);
 
812
  /* make the colormap active for our shells */
 
813
  XtVaSetValues(toplevel, XtNcolormap, icmap, NULL);
 
814
  XtVaSetValues(fax_shell, XtNcolormap, icmap, NULL);
 
815
  XtVaSetValues(info_s.shell, XtNcolormap, icmap, NULL);
 
816
  /* get the pixmap where we have to draw in, and its GC */
 
817
  cpxmap = canvasGetPixmap ((CanvasWidget)canvas, CanvasPicture);
 
818
  cgc = canvasGetGC ((CanvasWidget)canvas, CanvasDrawGC);
 
819
 
 
820
  fprintf(stderr,"initializing interface for FM reception...\n"); fflush(stderr);
 
821
 
 
822
/*
 
823
  comp_val = max_val >> 1;
 
824
  aptncmax = smpl_sec / 100;
 
825
  ixoc = 576;
 
826
  aptstart = 300;
 
827
  aptstop = 450;
 
828
  bot2top = 0;
 
829
  right2left = 0;
 
830
  core_start = core_dta;
 
831
  smpl_line = (2000 << 16) + 34800;
 
832
*/
 
833
 
 
834
  save_fsa.dir_io = malloc(256);
 
835
  *save_fsa.dir_io = '\0';
 
836
  save_fsa.title = "Save file";
 
837
  save_fsa.file_act = savefile_act;
 
838
  save_width = 1024;
 
839
  /* XtAddCallback(canvas, XtNcallback, show_coords, (XtPointer) NULL); */
 
840
  XtAddCallback(dir_s.dirhv, XtNcallback, dirhv_cb, (XtPointer) NULL);
 
841
  XtAddCallback(dir_s.dirlr, XtNcallback, dirlr_cb, (XtPointer) NULL);
 
842
  XtAddCallback(dir_s.dirtb, XtNcallback, dirtb_cb, (XtPointer) NULL);
 
843
  XtAddCallback(pol_s.norinv, XtNcallback, norinv_cb, (XtPointer) NULL);
 
844
  XtAddCallback(pol_s.posneg, XtNcallback, posneg_cb, (XtPointer) NULL);
 
845
  XtAddCallback(run_s.rmstop, XtNcallback, stastop_cb, (XtPointer) NULL);
 
846
  XtAddCallback(run_s.rmsyn, XtNcallback, stastop_cb, (XtPointer) NULL);
 
847
  XtAddCallback(run_s.rmrun, XtNcallback, stastop_cb, (XtPointer) NULL);
 
848
  XtAddCallback(adj_s.lshift, XtNcallback, lshift_cb, (XtPointer) NULL);
 
849
  XtAddCallback(adj_s.azimut, XtNcallback, azimut_cb, (XtPointer) NULL);
 
850
  XtAddCallback(mod_s.mmode, XtNcallback, modmode_cb, (XtPointer) NULL);
 
851
  XtAddCallback(file_m.autosave, XtNcallback, autosave_cb, (XtPointer) NULL);
 
852
  XtAddCallback(file_m.saveas,  XtNcallback, namesave_cb, (XtPointer) NULL);
 
853
  XtAddCallback(file_m.close, XtNcallback, closesave_cb, (XtPointer) NULL);
 
854
  XtAddCallback(file_m.quit, XtNcallback, quit_cb, (XtPointer) NULL);
 
855
  XtAddCallback(mod_s.mflt1,  XtNcallback, filtsel_cb, (XtPointer)FIL_NARR);
 
856
  XtAddCallback(mod_s.mflt2,  XtNcallback, filtsel_cb, (XtPointer)FIL_MIDL);
 
857
  XtAddCallback(mod_s.mflt3,  XtNcallback, filtsel_cb, (XtPointer)FIL_WIDE);
 
858
 
 
859
/*
 
860
  XtAddCallback(opt_start, XtNcallback, start_callback, (XtPointer) NULL);
 
861
  XtAddCallback(opt_stop, XtNcallback, stop_callback, (XtPointer) NULL);
 
862
*/
 
863
  XtAppMainLoop(mainapp);
 
864
}