From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 16-JUN-1992 20:19:40.29
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: Need simple $ SEND program

In article <1992Jun14.071443.5889@socrates.umd.edu>, MIKE@KAVISHAR.UMD.EDU (Michael F. Santangelo) writes:
> Some time ago, someone posted a relatively simple source (was in FORTRAN)
> for a $ SEND command that simply sent a message to a locally logged 
> on user, for example:
> 
>   $ SEND JOHNDOE "Hi there, you must get lots of comments about your username!"
> 
> All it did was front-end the $BRKTHRU (?) system service passing the
> appropriate info from the command line args.  Could someone re-post
> this program?  I know it is probably on some ancient DECUS sig-tape,
> but I don't have access to any and I just want to get this put up
> quick-and-dirty.  Thanks!

Here's another one. It acceps mail distribution list too.

1) $ cc broadcast.c
   $ link broadcast

2) Install with OPER and WORLD privilege

3) $ broadcast :== $device:broadcast.exe

Every non-privileged user can BROADCAST.

4) $ broadcast ?	
   for help information. or print_helptext()


-> BROADCAST.C -------------------------------------------------------------
/*
    Broadcast utility (version 1.0)
    Dick Sloetjes
    12-Dec-1991

    05-feb-1992 Add B(eep) en L(og) switches
*/

#include jpidef
#include dvidef
#include devdef
#include ssdef
#include stdio
#include descrip
#include stdlib
#include ctype
#include brkdef
#include prvdef

#define  MAX_STRING 	256
#define  TRUE           1
#define  FALSE          0

struct  ITEM
{
        short   len;                    /* buffer length */
        short   item_code;              /* information item requested */
        char    *buf;                   /* return buffer */
        int     *rlen;                  /* return length */
};

/*======================================================================*/
/*	PROTO types							*/
/*======================================================================*/

static void		broadcast_list( char message_ptr[],
					char list_ptr[]);
static void		broadcast( char message_buf[],
				   char user_buf[]);
static void		find_first_element( char out_string[],
					    char in_string[]);
static void		get_dispatch_string( char dispatch_str_ptr[]);
static void		enable_oper_priv( void);
static void		print_helptext( void);

/*======================================================================*/
/*      GLOBAL parameters						*/
/*======================================================================*/

static int number_nr = 0;
static int failed_nr = 0;
static int nobroad_nr = 0;
static int enable_logging = FALSE;

/*----------------------------------------------------------------------*/
/* Main()
/*----------------------------------------------------------------------*/
main( argc, argv)
int argc;
char *argv[];
{
    char users[ MAX_STRING ];
    char message[ MAX_STRING ];
    char users_list[ MAX_STRING ];
    char dispatch_str[ MAX_STRING ];
    char message_str[ MAX_STRING ];
    int beep = FALSE;

    if ( argc != 3 && argc != 4 )
    {
	print_helptext();
	return( 1 );
    }
    else if (strncmp( argv[1], "-", 1) == 0 && argc == 4 )
    {
    	if ( strpbrk( argv[1], "l") != NULL )
	    enable_logging = TRUE;

    	if ( strpbrk( argv[1], "b") != NULL )
	    beep = TRUE;

    	strcpy( users, argv[2] );
    	strcpy( message, argv[3] );
    }
    else if ( argc == 3 )
    {
    	strcpy( users, argv[1] );
    	strcpy( message, argv[2] );
    } else
    {
	print_helptext();
	return( 1 );
    }

    enable_oper_priv();

    /*------------------------------------------------------------------*/
    /*	Compose message string
    /*------------------------------------------------------------------*/
    get_dispatch_string( dispatch_str );
    if ( beep )
        sprintf( message_str, "\r\n%s\r\n%s", dispatch_str, message );
    else
        sprintf( message_str, "\r\n%s\r\n%s", dispatch_str, message );


    /*------------------------------------------------------------------*/
    /*	Broadcast to users
    /*------------------------------------------------------------------*/
    if ( strncmp( users, "@", 1) == 0)
    {
	broadcast_list( message_str, &users[1] );
    }
    else if ( strncmp( users, "?", 1) == 0)
    {
	print_helptext();
    }
    else
    {
        find_first_element( users_list, users );
    	broadcast( message_str, users_list );
    }

    /*------------------------------------------------------------------*/
    /*	print statistics
    /*------------------------------------------------------------------*/
    if ( enable_logging )
    {
	if ( number_nr != 0 || nobroad_nr != 0 || failed_nr != 0 )
	{
	    printf("Broadcast statistics\n");
	    if ( number_nr != 0 )
		printf("\t%d terminal(s) have been notified.\n", number_nr );
	    if ( failed_nr != 0 )
		printf("\t%d terminal(s) timed out\n", failed_nr );
	    if ( nobroad_nr != 0 )
		printf("\t%d terminal(s) broadcast disabled\n", nobroad_nr);
	}
	else
	{
	    printf("No broadcast messages sent\n");
	}
    }
    return( 1 );
}

/*======================================================================*/
/*	broadcast_list							*/
/*======================================================================*/
static void			/* Returns: Nothing			*/
broadcast_list( message_ptr, list_ptr )
char message_ptr[];
char list_ptr[];
{
    FILE *list_file_ptr;
    int status;
    char line[ MAX_STRING ];

    list_file_ptr = fopen( list_ptr, "r", "shr=get" );

    if ( list_file_ptr == 0 )
    {
    	printf("File %s not found\n", list_ptr );
    	exit(1);
    }

    status = fgets( line, MAX_STRING, list_file_ptr );
    while ( status != 0 )
    {
	find_first_element( line, line );
        if ( line[0] == '@' )
    		broadcast_list( message_ptr, &line[1] );
	else if ( strlen(line) != 0 ) broadcast( message_ptr, line );
	status = fgets( line, MAX_STRING, list_file_ptr );
    }
    fclose( list_file_ptr );
    return;
}
/*======================================================================*/
/*	broadcast							*/
/*======================================================================*/
static void			/* Returns: Nothing			*/
broadcast(message_buf, user_buf)
char message_buf[];
char user_buf[];
{
    int status;
    struct dsc$descriptor message,user;
    char   user_name[ MAX_STRING ];
    struct
	{ short int condition;
  	  short int number;
	  short int failed;
	  short int nobroad;
	} iosb; 

    message.dsc$w_length   = strlen(message_buf);
    message.dsc$a_pointer  = message_buf;
    message.dsc$b_dtype    = DSC$K_DTYPE_T;
    message.dsc$b_class    = DSC$K_CLASS_S;

    user.dsc$w_length  = strlen(user_buf);
    user.dsc$a_pointer = user_buf;
    user.dsc$b_dtype   = DSC$K_DTYPE_T;
    user.dsc$b_class   = DSC$K_CLASS_S;

    status = sys$brkthruw(0,                       /* efn     */
  			  &message,         	   /* msgbuf  */
  			  &user,	           /* sendto  */
  			  BRK$C_USERNAME,   	   /* sndtyp  */
  			  &iosb,                   /* iosb    */
  			  0,                       /* carcon  */
  			  BRK$M_CLUSTER,           /* flags   */
  			  BRK$C_USER10,            /* reqid   */
  			  5,                       /* timeout */
  			  0,                       /* astadr  */
  			  0);                      /* astprm  */

    if (status != SS$_NORMAL)
    {
	    lib$signal( status );
    }
    if ( enable_logging )
    {
	if ( iosb.number > 0 )
	{
	    printf("Broadcast to %s have been sent\n", user_buf );
	    number_nr = number_nr + iosb.number;
	}

	if ( iosb.failed > 0 )
	{
	    printf("Broadcast to %s have been timed out\n", user_buf );
	    failed_nr = failed_nr + iosb.failed;
	}

	if ( iosb.nobroad > 0 )
	{
	    printf("Broadcast to %s canceled, broadcast disabled\n", user_buf );
	    nobroad_nr = nobroad_nr + iosb.nobroad;
	}

	if ( iosb.condition != SS$_NORMAL )
	{
	    printf("Broadcast to %s failed: reason %d\n",
	    user_buf,
	    iosb.condition );
	}
    }
}

/*======================================================================*/
/*	find_first_element						*/
/*======================================================================*/
static void			/* Returns: Nothing			*/
find_first_element(out_string, in_string )
char out_string[];
char in_string[];
{
    int i,j,len;
    char exclamation_set[] = "!";
    char *c_ptr;

    c_ptr = strpbrk( in_string, exclamation_set);
    if ( c_ptr != 0 ) *c_ptr = '\0';

    len = strlen( in_string );
    i = 0;
    j = 0;
    while ( i != len )
    {
    	if ( isspace( in_string[ i ] ) != 0 )
    	{
    	   i++;
    	}
    	else if ( isalnum( in_string[ i ] ) != 0 )
        {
	   out_string[ j ] = toupper(in_string[ i ]);
           i++;
           j++;
        }
    	else
	{
	   out_string[ j ] = in_string[ i ];
           i++;
           j++;
	}
    }
    out_string[ j ] = '\0';
    return;
}

/*======================================================================*/
/*	get_username							*/
/*======================================================================*/
static void			/* Returns: Nothing			*/
get_dispatch_string( dispatch_str_ptr )
char dispatch_str_ptr[];
{
    char user_name[ 12+1 ];
    short int  user_name_length;
    char terminal_name[ 7+1 ];
    short int  terminal_name_length;
    int  master_pid;
    int  master_pid_len;

    char   	*date_time;
    int     	clock;
    int 	status;

    struct  ITEM
    {
	    short   len;                    /* buffer length */
	    short   item_code;              /* information item requested */
	    char    *buf;                   /* return buffer */
	    int     *rlen;                  /* return length */
    };

    struct
    {
	    struct  ITEM items[2];
	    int     endoflist;
    } jpi_itemlist  =
	{
	12, JPI$_USERNAME, user_name     , &user_name_length    , /* user name  */
	7, JPI$_TERMINAL, terminal_name , &terminal_name_length , /* terminal   */
	0
	};

    time(&clock);
    date_time = ctime(&clock);
    date_time[19] = '\0';

    status = sys$getjpiw(0,0,0,&jpi_itemlist,0,0,0);
    if (status != SS$_NORMAL) lib$signal(status);

    user_name[ user_name_length ] = '\0';
    terminal_name[ terminal_name_length ] = '\0';

    sprintf( dispatch_str_ptr,
             "Broadcast received from user %s at %s %s",
    	     user_name,
    	     terminal_name,
             date_time );

    return;
}

/*======================================================================*/
/*	enable_oper_priv						*/
/*======================================================================*/
static void			/* Returns: Nothing			*/
enable_oper_priv()
{
    unsigned char enbflg = 1;
    unsigned int prvadr = PRV$M_OPER | PRV$M_WORLD;
    int status;

    status = sys$setprv( enbflg, &prvadr, 0 ,0 );
    if (status != SS$_NORMAL &&
        status != SS$_NOTALLPRIV ) lib$signal(status);

    return;
}

/*======================================================================*/
/*	print_helptext							*/
/*======================================================================*/
static void 			/* Returns: Nothing			*/
print_helptext()
{
    printf("Broadcast version 1.2, 6-feb-1992\n");
    printf("Broadcast [-<switches>] <user> \"<message>\" \n");
    printf("Broadcast [-<switches>] @<distribution-list> \"<message>\" \n");
    printf("Switches:\n");
    printf("  - b forces broadcast to beep when users get message\n");
    printf("  - l gives information to which users on LOCAL node broadcast is sent!\n");
    printf("Everything behind \'!\' in distribution list is ignored!\n");
    return;
}

#! rnews 1130
Path: mswe.dnet.ms.philips.nl!hdavids
From: hdavids@mswe.dnet.ms.philips.nl (Henk Davids)
Newsgroups: nlnet.misc
Subject: Veiligheid betaalpassen
Message-ID: <1992Jun15.200322.130965@mswe.dnet.ms.philips.nl>
Date: 15 Jun 92 20:03:22 +0100
Organization: Philips Medical Systems Nederland
Lines: 15

De laatste weken loopt er in het weekblad Vrij Nederland een serie over de
problemen die je als consument kunt hebben met de banken. Daarin is al een
aantal keren melding gemaakt van mensen die hun betaalpas (Euro of Postbank)
zijn kwijtgeraakt door diefstal, waarna er onmiddellijk grote bedragen van
hun rekening werden afgeschreven. In alle gevallen houden de slachtoffers
bij hoog en bij laag vol dat ze hun pin-code nergens hadden opgeschreven.

Weet iemand hoe dat nou precies zit? Zit de pin-code in de informatie op de
magneetstrip van de kaart zelf? Al die betaalautomaten hebben toch een on-line
verbinding met de bankcomputer, en dan zou dat toch niet nodig zijn?
De banken houden het erop dat de klant een stickertje met de pin-code op
de kaart hebben geplakt of zoiets, dus is de schade voor de consument.

						Henk

#! rnews 853
Relay-Version: VMS News - V6.0-3 14/03/90 VAX/VMS V5.4; site mswe.dnet.ms.philips.nl
Path: mswe.dnet.ms.philips.nl!daily-planet.concordia.ca!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!
 snorkelwacker.mit.edu!spool.mu.edu!sol.ctr.columbia.edu!
 zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!SOL1.GPS.CALTECH.EDU!carl
Newsgroups: comp.os.vms
Subject: Re: Postscript converter wanted
Message-ID: <0094E868.2EDF3540.6141@SOL1.GPS.CALTECH.EDU>
From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
Date: 12 Sep 91 17:04:30 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The Internet
Lines: 4

I forgot to mention that if you don't have a symbiont (or print daemon, or
whatever) that ends each job with a control-D, you also have to append a
control-D to the file before sending it to the printer if you use my PostScript
programs to print the file.

