<commit_before>/* $Id: main.c,v 1.22 1998/04/21 05:06:22 phelps Exp $ */

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>

#include "Message.h"
#include "Subscription.h"
#ifdef USE_BRIDGE
# include "BridgeConnection.h"
# define CONNECTION BridgeConnection
# define CONNECTION_ALLOC BridgeConnection_alloc
# define CONNECTION_SEND BridgeConnection_send
# define CONNECTION_GETFD BridgeConnection_getFD
# define CONNECTION_READ BridgeConnection_read
# define PORT 8800
#else /* USE_BRIDGE */
# include "ElvinConnection.h"
# define CONNECTION ElvinConnection
# define CONNECTION_ALLOC ElvinConnection_alloc
# define CONNECTION_SEND ElvinConnection_send
# define CONNECTION_GETFD ElvinConnection_getFD
# define CONNECTION_READ ElvinConnection_read
# define PORT 5678
#endif /* USE_BRIDGE */
#include "Control.h"
#include "Tickertape.h"

#ifdef ELVIN_HOSTNAME
#define HOSTNAME ELVIN_HOSTNAME
#else /* ELVIN_HOSTNAME */
#define HOSTNAME "fatcat"
#endif /* ELVIN_HOSTNAME */
#define BUFFERSIZE 8192

/* Notification of something */
static void NotifyAction(Widget widget, XEvent *event, String *params, Cardinal *cparams);

/* Shuts everything down and go away */
static void QuitAction(Widget widget, XEvent *event, String *params, Cardinal *cparams);

/* The ControlPanel popup */
static ControlPanel controlPanel;

/* The tickertape widget */
TickertapeWidget tickertape;

/* The default application actions table */
static XtActionsRec actions[] =
{
    {"notify", NotifyAction},
    {"quit", QuitAction}
};

/* Notification of something */
static void NotifyAction(Widget widget, XEvent *event, String *params, Cardinal *cparams)
{
    /* pass this on to the control panel */
    ControlPanel_handleNotify(controlPanel, widget);
}

/* Callback for when the Window Manager wants to close a window */
static void QuitAction(Widget widget, XEvent *event, String *params, Cardinal *cparams)
{
    /* if main window then quit */
    if (widget == (Widget) tickertape)
    {
	XtDestroyApplicationContext(XtWidgetToApplicationContext(widget));
	exit(0);
    }
    /* otherwise just hide the popup */
    else
    {
	XtPopdown(widget);
    }
}

/* Callback for buttonpress in tickertape window */
static void Click(Widget widget, XtPointer context, XtPointer ignored)
{
    ControlPanel_show(controlPanel);
}

/* Callback for message to send from control panel */
static void sendMessage(Message message, void *context)
{
    CONNECTION connection = (CONNECTION)context;

    CONNECTION_SEND(connection, message);
    Message_free(message);
}

/* Callback for message to show in scroller */
static void receiveMessage(Message message, void *context)
{
    TickertapeWidget tickertape = (TickertapeWidget)context;
    TtAddMessage(tickertape, message);
}


/* Answers the user's group file */
static FILE *getGroupFile()
{
    char buffer[BUFFERSIZE];
    char *dir;

    dir = getenv("TICKERDIR");
    if (dir != NULL)
    {
	sprintf(buffer, "%s/group", dir);
    }
    else
    {
	sprintf(buffer, "%s/.ticker/groups", getenv("HOME"));
    }
#ifdef DEBUG    
    printf("reading group file \"%s\"\n", buffer);
#endif /* DEBUG */
    return fopen(buffer, "r");
}


/* Parse args and go */
int main(int argc, char *argv[])
{
    CONNECTION connection;
    FILE *file;
    List subscriptions;
    Widget top;
    XtAppContext context;
    Atom deleteAtom;
    char *hostname = HOSTNAME;
    int port = PORT;
    int index = 1;

    /* Create the toplevel widget */
    top = XtVaAppInitialize(
	&context, "Tickertape",
	NULL, 0, &argc, argv, NULL,
	XtNtitle, "Tickertape",
	XtNborderWidth, 0,
	NULL);

    /* Add a calback for when it gets destroyed (?) */
    XtAppAddActions(context, actions, XtNumber(actions));<commit_msg>Understands the WM_DELETE_WINDOW message again<commit_after>/* $Id: main.c,v 1.23 1998/05/09 06:20:36 phelps Exp $ */

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>

#include "Message.h"
#include "Subscription.h"
#ifdef USE_BRIDGE
# include "BridgeConnection.h"
# define CONNECTION BridgeConnection
# define CONNECTION_ALLOC BridgeConnection_alloc
# define CONNECTION_SEND BridgeConnection_send
# define CONNECTION_GETFD BridgeConnection_getFD
# define CONNECTION_READ BridgeConnection_read
# define PORT 8800
#else /* USE_BRIDGE */
# include "ElvinConnection.h"
# define CONNECTION ElvinConnection
# define CONNECTION_ALLOC ElvinConnection_alloc
# define CONNECTION_SEND ElvinConnection_send
# define CONNECTION_GETFD ElvinConnection_getFD
# define CONNECTION_READ ElvinConnection_read
# define PORT 5678
#endif /* USE_BRIDGE */
#include "Control.h"
#include "Tickertape.h"

#ifdef ELVIN_HOSTNAME
#define HOSTNAME ELVIN_HOSTNAME
#else /* ELVIN_HOSTNAME */
#define HOSTNAME "fatcat"
#endif /* ELVIN_HOSTNAME */
#define BUFFERSIZE 8192

/* Notification of something */
static void NotifyAction(Widget widget, XEvent *event, String *params, Cardinal *cparams);

/* Shuts everything down and go away */
static void QuitAction(Widget widget, XEvent *event, String *params, Cardinal *cparams);

/* The ControlPanel popup */
static ControlPanel controlPanel;

/* The top-level widget */
Widget top;

/* The tickertape widget */
TickertapeWidget tickertape;

/* The default application actions table */
static XtActionsRec actions[] =
{
    {"notify", NotifyAction},
    {"quit", QuitAction}
};

/* Notification of something */
static void NotifyAction(Widget widget, XEvent *event, String *params, Cardinal *cparams)
{
    /* pass this on to the control panel */
    ControlPanel_handleNotify(controlPanel, widget);
}

/* Callback for when the Window Manager wants to close a window */
static void QuitAction(Widget widget, XEvent *event, String *params, Cardinal *cparams)
{
    /* if main window then quit */
    if (widget == top)
    {
	XtDestroyApplicationContext(XtWidgetToApplicationContext(widget));
	exit(0);
    }
    /* otherwise just hide the popup */
    else
    {
	XtPopdown(widget);
    }
}

/* Callback for buttonpress in tickertape window */
static void Click(Widget widget, XtPointer context, XtPointer ignored)
{
    ControlPanel_show(controlPanel);
}

/* Callback for message to send from control panel */
static void sendMessage(Message message, void *context)
{
    CONNECTION connection = (CONNECTION)context;

    CONNECTION_SEND(connection, message);
    Message_free(message);
}

/* Callback for message to show in scroller */
static void receiveMessage(Message message, void *context)
{
    TickertapeWidget tickertape = (TickertapeWidget)context;
    TtAddMessage(tickertape, message);
}


/* Answers the user's group file */
static FILE *getGroupFile()
{
    char buffer[BUFFERSIZE];
    char *dir;

    dir = getenv("TICKERDIR");
    if (dir != NULL)
    {
	sprintf(buffer, "%s/group", dir);
    }
    else
    {
	sprintf(buffer, "%s/.ticker/groups", getenv("HOME"));
    }
#ifdef DEBUG    
    printf("reading group file \"%s\"\n", buffer);
#endif /* DEBUG */
    return fopen(buffer, "r");
}


/* Parse args and go */
int main(int argc, char *argv[])
{
    CONNECTION connection;
    FILE *file;
    List subscriptions;
    XtAppContext context;
    Atom deleteAtom;
    char *hostname = HOSTNAME;
    int port = PORT;
    int index = 1;

    /* Create the toplevel widget */
    top = XtVaAppInitialize(
	&context, "Tickertape",
	NULL, 0, &argc, argv, NULL,
	XtNtitle, "Tickertape",
	XtNborderWidth, 0,
	NULL);

    /* Add a calback for when it gets destroyed (?) */
    XtAppAddActions(context, actions, XtNumber(actions));
{'fraction_non_alphanumeric': 0.11079136690647481, 'fraction_numerical': 0.010202746893394376, 'mean_word_length': 4.28403593642018, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3757994', 'n_tokens_mistral': 2513, 'n_tokens_neox': 2394, 'n_words': 705}