<commit_before>/*
 * Copyright (c) 2004, 2013 Regents of The University of Michigan.
 * Copyright (c) 1983, 1987 Regents of the University of California.
 * Copyright (c) 1983 <NAME>.
 * All Rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * * Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */


#include <limits.h>
#include <sysexits.h>
#include <time.h>
#include <syslog.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>

#include "simvacation.h"
#include "vdb.h"
#include "vlu.h"

/*
 *  VACATION -- return a message to the sender when on vacation.
 *
 *	This program is invoked as a message receiver.  It returns a
 *	message specified by the user to whomever sent the mail, taking
 *	care not to return a message too often to prevent "I am on
 *	vacation" loops.
 */

int     check_from();
void    myexit( int );
int     nsearch( char *, char * );
int     pexecv( char *path, char ** );
void    readheaders();
yastr   append_header( yastr, char *, int );
int     check_header( char *, const char * );
int     sendmessage( char *, char * );
void    usage( char * );


/* RFC 2822 2.1.1
 *  There are two limits that this standard places on the number of
 *  characters in a line. Each line of characters MUST be no more than
 *  998 characters, and SHOULD be no more than 78 characters, excluding
 *  the CRLF.
 */
#define	MAXLINE	1000
#define PRETTYLINE 80

struct name_list  *names;
struct headers  *h;
static char    from[MAXLINE];

char            *rcpt;
struct vdb      *vdb;
struct vlu      *vlu;

extern int optind, opterr;
extern char *optarg;

int debug;


    int
main( int argc, char **argv )
{
    debug = 0;
    time_t interval;
    int ch, rc;
    char *vacmsg;
    char *progname;
    char *vlu_config = CONFFILE;

    if ( (progname = strrchr( argv[0], '/' )) == NULL )
	progname = strdup( argv[0] );
    else
	progname = strdup( progname + 1 );

    openlog( progname, LOG_PID, LOG_VACATION );
    opterr = 0;
    interval = -1;

    h = malloc( sizeof( struct headers ));
    memset( h, 0, sizeof( struct headers ));

    from[0] = '\0';

    while (( ch = getopt( argc, argv, "c:df:r:" )) != EOF ) {
	switch( (char) ch ) {
        case 'c':
            vlu_config = optarg;
            break;
        case 'd':
            debug = 1;
            break;
	case 'f':
	    strncpy(from, optarg, MAXLINE - 1);
	    from[MAXLINE - 1] = '\0';
	    break;
	case 'r':
	    if ( isdigit( *optarg )) {
		interval = atol( optarg ) * SECSPERDAY;
		if ( interval < 0 )
		    usage( progname );
	    }
	    else
		interval = LONG_MAX;
	    break;

	    case '?':
	    default:
		usage( progname );
	}
    }<commit_msg>Fix braces<commit_after>/*
 * Copyright (c) 2004, 2013 Regents of The University of Michigan.
 * Copyright (c) 1983, 1987 Regents of the University of California.
 * Copyright (c) 1983 <NAME>.
 * All Rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * * Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */


#include <limits.h>
#include <sysexits.h>
#include <time.h>
#include <syslog.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>

#include "simvacation.h"
#include "vdb.h"
#include "vlu.h"

/*
 *  VACATION -- return a message to the sender when on vacation.
 *
 *	This program is invoked as a message receiver.  It returns a
 *	message specified by the user to whomever sent the mail, taking
 *	care not to return a message too often to prevent "I am on
 *	vacation" loops.
 */

int     check_from();
void    myexit( int );
int     nsearch( char *, char * );
int     pexecv( char *path, char ** );
void    readheaders();
yastr   append_header( yastr, char *, int );
int     check_header( char *, const char * );
int     sendmessage( char *, char * );
void    usage( char * );


/* RFC 2822 2.1.1
 *  There are two limits that this standard places on the number of
 *  characters in a line. Each line of characters MUST be no more than
 *  998 characters, and SHOULD be no more than 78 characters, excluding
 *  the CRLF.
 */
#define	MAXLINE	1000
#define PRETTYLINE 80

struct name_list  *names;
struct headers  *h;
static char    from[MAXLINE];

char            *rcpt;
struct vdb      *vdb;
struct vlu      *vlu;

extern int optind, opterr;
extern char *optarg;

int debug;


    int
main( int argc, char **argv )
{
    debug = 0;
    time_t interval;
    int ch, rc;
    char *vacmsg;
    char *progname;
    char *vlu_config = CONFFILE;

    if ( (progname = strrchr( argv[0], '/' )) == NULL )
	progname = strdup( argv[0] );
    else
	progname = strdup( progname + 1 );

    openlog( progname, LOG_PID, LOG_VACATION );
    opterr = 0;
    interval = -1;

    h = malloc( sizeof( struct headers ));
    memset( h, 0, sizeof( struct headers ));

    from[0] = '\0';

    while (( ch = getopt( argc, argv, "c:df:r:" )) != EOF ) {
	switch( (char) ch ) {
        case 'c':
            vlu_config = optarg;
            break;
        case 'd':
            debug = 1;
            break;
	case 'f':
	    strncpy(from, optarg, MAXLINE - 1);
	    from[MAXLINE - 1] = '\0';
	    break;
	case 'r':
	    if ( isdigit( *optarg )) {
		interval = atol( optarg ) * SECSPERDAY;
		if ( interval < 0 ) {
		    usage( progname );
                }
	    } else {
                usage( progname );
            }
	    break;

	    case '?':
	    default:
		usage( progname );
	}
    }
{'fraction_non_alphanumeric': 0.09691897137311985, 'fraction_numerical': 0.012615235322658904, 'mean_word_length': 2.9734939759036143, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5235277', 'n_tokens_mistral': 2716, 'n_tokens_neox': 2438, 'n_words': 1047}