/*
**++
**  FACILITY
**	NEWSVARIABLES
**
**  ABSTRACT:
**	Common NEWS and NNTP server variable declarations and defintions
**	Single definition of all global news variables, used to define
**	variables in main program and to reference these variables
**	from other modules.
**
**	If _NNTP_MODULE is defined, the module NEWSVARIABLES.H is used
**	to declare, define and reference common variables in the NNTP server
**	and support programs and modules.
**
**  AUTHOR:
**	Geoff Huston
**
**  COPYRIGHT:
**	Copyright © 1988,1989,1990
**
**  Modification History:
**	V6.1b11  7-May-1997	Mark Martinec   mark.martinec@ijs.si
**	- now this modules is used by the NNTP server and support programs
**	  as well as for the NEWS program. This is to assure that common
**	  variables, used by the support routines in modules common
**	  to NEWS and NNTP server, see the same variable declarations.
**--
**/

#ifndef _NEWSVARIABLES_H
#define _NEWSVARIABLES_H

#if defined(_NEWS_MAIN_PROGRAM) || defined(_NNTP_MAIN_PROGRAM) || defined(_NNTP_SERVER_DRIVER_C)
			/* "global" variables are defined by NEWS.C */
#define global_var
#define iev(v)	= v
#define iv(v)	v
#define DESCRIPT(dsc,val)	$DESCRIPTOR(dsc,val)
#else
			/* ... and used by other modules */
#define global_var	extern
#define iev(v)
#define iv(v)
#define DESCRIPT(dsc,val)	extern struct dsc$descriptor_s dsc
#endif

#ifdef __STDC__
#define def_global_string(str_name,str_size) \
  global_var const int str_name ## _m iev(str_size); \
  global_var char str_name[iv(str_size)]
#else
#define def_global_string(str_name,str_size) \
  global_var const int str_name/**/_m iev(str_size); \
  global_var char str_name[iv(str_size)]
#endif


/* Common to both NEWS and NNTP programs:
 *   these variables are used by support procedures in
 *   modules NEWSRTL, NEWSUTIL3, NEWSDIST, ADD_TRANSFORM and NEWSLOCK,
 *   which are linked with NEWS program as well as with the
 *   NNTP server and support programs
 */

global_var
size_t mem_reserve;	/* minimum free bytes VM before allocs complain */

global_var
int news_lock_alarm iev(0),
    kid,		/* SMG keyboard id */
    kid_valid iev(0),
    gmt_offset iev(0),  /* signed offset in seconds added to GMT to */
                        /* generate local time */
    sysprv_off iev(0),	/* sysprv set / not set flag */
    closing_files iev(0),       /* true only when closefiles() is executing */

       /* some statistics on the usefulness of routine try_to_make_some_space */
    stat_make_space_called iev(0),     /* no. of times the routine was called */
    stat_make_space_succeeded iev(0),  /* no. of times the routine returned 1 */
    stat_make_space_retry_success iev(0),   /* number of times the file create
                                     operation succeeded on the second attempt
                                     after first succesfully calling the
                                     procedure try_to_make_some_space() */

    nntp_client iev(0),	/* this is a remote reader executable */
    nntp_process        /* we are in a NNTP server or NNTP support program */
#if defined(_NNTP_MAIN_PROGRAM) || defined(_NNTP_SERVER_DRIVER_C)
      iev(1);
#else
      iev(0);
#endif

def_global_string(news_node,256);	/* local node name */
def_global_string(news_pathname,256);	/* what goes in the Path: header? */
def_global_string(Node_address,256);	/* Internet node address */
def_global_string(news_timezone,132);
def_global_string(itm_fname,256);	/* article filename */
def_global_string(err_oline,512);	/* error line */

global_var ALIAS_PTR  aliases_list iev(0);
global_var SYS_ENTRY_T  *sysfile   iev(0);
global_var DIST_ENTRY_T *distfile  iev(0);

global_var
struct FAB grpfab,		/* newsgroup file fab */
	   itmfab;		/* newsitem file fab */

global_var
struct RAB grprab,		/* newsgroup file rab */
	   itmrab;		/* newsitem file rab */

global_var
ITM newsitm;			/* newsitem i/o buffer */

global_var
GRPF newsgrp;			/* newsgroup i/o buffer */


/* variables specific to NEWS program: */
#if !defined(_NNTP_MAIN_PROGRAM) && !defined(_NNTP_SERVER_DRIVER_C) && !defined(_NNTP_SERVER_C)

global_var
int   pid,			/* SMG Pasteboard id */
      devrow,			/* SMG device rows */
      devcol,			/* SMG device columns */
      keytab iev(0),		/* SMG key definition table */
      no_more_news iev(0),	/* global flag indicating all registered groups read */
      ga_size iev(0),		/* size of group array */
      ga_malloc,		/* size of memory allocated for group array */
      cur_dir_type iev(DIR_ALL),/* current selection type */
      curr_g iev(0),		/* current group */
      curr_i iev(-1),		/* current item */
      news_context iev(1),	/* news level (1,2,3) */
      old_context iev(1),	/* news level (1,2,3) */
      grp_vd,			/* group display */
      grp_display_size,		/* group display size */
      smg_active iev(0),	/* smg display routines in use */
      pid_created iev(0),	/* no screen at all! */
      trailer_vd,		/* input virtual display */
      g_arrow iev(0),		/* screen group arrow */
      grp_header_vd,
      itm_header_vd,
      gv_size iev(0),
      grp_paste,
      itm_approved,
      forward_posting,
      net_news,
      auto_cre_grp,
      mail_add_expiry iev(0),
      brdcst_line iev(0),
      brdcst_col iev(0),
      daymod iev(1),            /* /DAY qualifier for SKIM */
      verbose iev(1),           /* verbose level on SKIM command function */
      server_call iev(0),       /* call the nntp server update flag */
      vms_major iev(0),         /* VMS Version - major level */
      vms_minor iev(0),         /* VMS Version - minor level */
      mail_self_flag iev(0),
      nntp_proto iev(0),	/* this is a remote reader executable */
      news_readonly iev(0),
      news_captive iev(0),      /* JLH this is for captive NEWS reader accounts */
      parse_level iev(0),	/* current parse position */
      profile_scansize iev(-1),		/* first screen display size */
      nntp_no_posting_allowed iev(0),	/* set on a 201 server opening response */
      nntp_anu_news_server iev(0),	/* set on an ANU NEW implementation of the remote server */
      profile_display_lines iev(0),	/* display line count on opening newsgroup  (nntp) */
      profile_display_postmark iev(0),  /* display postmark on opening newsgroup  (nntp) */
      first_retr_call iev(1),	/* flag to print out nntp progress */
      display_unseen_stack iev(0),
      display_unseen_items iev(0),
      reorder_groups iev(0),
      include_all_groups iev(0),
      profile_filter iev(0),
      initial_classname iev(0),
      v59_file iev(0),
      minfromlen iev(19),
      display_stk iev(0),
      line_editing iev(0),		/* line_editing mode on */
      usedotnewsrc iev(0),		/* rn-style .newsrc support */
      broadcast_trapping_requested iev(1), /* SMG broadcast trapping wanted ? */
      problems_encountered iev(0),/* set to true by the condition handler,
                                   causes cautious NEWSRC writing during exit */
      signalled_error_count iev(0),/* count condition handler invocations;
                                   used to limit infinite loops through
                                   condition handler's ability to unwind or
                                   continue on error */
      session_is_interactive iev(0),    /* controlling keyboard is terminal */
      on_error iev(0),            /* controls how the condition handler reacts
                                   on signals - see 'ON_ERROR_*' constants */
      try_to_quietly_handle_errors iev(1), /* some parts of the code know
                                   how to handle certain more common errors
                                   (like RMS errors during ADD FILE processing).
                                   Setting this value to true (1) indicates that
                                   we prefer a log file entry or quietly handled
                                   error without throwing a signal.
                                   False (0) disables this code-specific
                                   error handling, errors are signalled and
                                   the execution is controlled by the condition
                                   handler (based on the value of 'on_error') */
      mailfile_open iev(0),		/* mail folder open ? */
      confirm_specified iev(0),		/* ask_confirm variable */
      showdirs_val iev(DISPLAY_BY_NEWSGROUPS),
#if FAST_LOAD
      all_loaded iev(0),
      fast_loading iev(0),
#endif
      init_scanning iev(0),
      first_time_user iev(0),
      screen_displays_setup iev(0),     /* screen is initialized and set up */
      pgp_verification_available iev(0),        /* PGPCALL.COM is available */

      fp_open  iev(0),	/* flag to indicate open files which require closing */
      fpa_open iev(0),	/* flag to indicate open files which require closing */
      fpd_open iev(0),	/* flag to indicate open files which require closing */
      displ_subjlen iev(SUBJLEN); /* display size of item subjects and
                                     newsgroup titles. Usually equal to SUBJLEN,
                                     but depends on the screen width */

global_var
unsigned short usr_inp_l,		/* input length */
	       cmd_len,			/* command input string length */
	       mail_flags;

def_global_string(usr_inp,256);		/* input */
def_global_string(cmd,256);		/* command line */
def_global_string(usr_username,33);	/* who is this person anyway ? */
def_global_string(usr_persname,256);
def_global_string(mail_queue,256);
def_global_string(mail_form,256);
def_global_string(mail_editor,256);
def_global_string(Editor,132);		/* editor string */
def_global_string(Viewer,132);		/* view command string */
def_global_string(TPUedit,132);		/* tpu edit string */
def_global_string(TPUview,132);		/* tpu view string */
def_global_string(no_new_item,132);	/* add item error text returned */
def_global_string(news_register,132);	/* register file name */
def_global_string(Mail_file,132);	/* mail temp file name */
def_global_string(Extract_file,132);
def_global_string(Print_file,132);
def_global_string(Print_save_file,132);
def_global_string(Post_file,132);
def_global_string(Organisation_name,132);
def_global_string(newsmgr_dir,132);
def_global_string(print_constant,132);
def_global_string(mail_sig,132);
def_global_string(str_target,132);
def_global_string(nntp_node,256);	/* nntp reader variable */
def_global_string(nntp_currgroup,256);	/* nntp reader variable */
def_global_string(n_class_name,256);
def_global_string(profile_dirstr,132);
def_global_string(profile_reply_to,256)   iev(""); /* reply-to header setting */
def_global_string(profile_endofitm_cmd,256) iev("READ/NEXT");
def_global_string(scangroups,512);
def_global_string(VMS_VERS,11);		/* holds VMS version string */

global_var
FILE *fp,			/* utility file */
     *fpa,
     *fpd,
     *newsrc iev(0);		/* newsrc file */

global_var
jmp_buf env,    		/* outer loop jump back point */
	envdisp;                /* item display jump back point */

global_var
GRP_PTR *ga;

global_var
DPT itmptr,			/* smg display context block : item display */
    textptr;			/*       "                     text display */

global_var
NOTE_RANGE d_itm[iv(NOTE_RANGE_MAX)];

global_var
DIR_CLASS_PTR c_head iev(0),	/* class list and current class pointer */    	
              curr_class iev(0);

global_var
struct marks *m_head iev(0),
             *mk_head iev(0);

SYS_FILTER_T *local_filter iev(0),
             *local_dfilter iev(0);

DESCRIPT(usr_inp_dsc,usr_inp);
DESCRIPT(cmd_dsc,cmd);
DESCRIPT(err_oline_d,err_oline);


#if defined(_NEWS_C) || defined(_NEWSEXTRACT_C) || defined(_NEWSPROFILE_C) || defined(_NEWSRC_C) || defined(_NEWSUTIL2_C)

#if NOGLOBALREF
extern void newscmd();	/* this "lie" yields the proper linkage */
#define CLICMDTBL (int *)newscmd
#else
globalref int newscmd;
#define CLICMDTBL &newscmd
#endif

#endif

#endif

#endif
