<commit_before>/* Copyright (c) 2001, Stanford University
 * All rights reserved.
 *
 * See the file LICENSE.txt for information on redistributing this software.
 */

#ifndef CR_NET_H
#define CR_NET_H

#ifdef WINDOWS
#define WIN32_LEAN_AND_MEAN
#pragma warning( push, 3 ) /* shut up about warnings in YOUR OWN HEADER FILES!!! */
#include <winsock2.h>
#endif

#include <stdio.h>

#include "cr_protocol.h"

typedef struct CRConnection CRConnection;

typedef enum {
	CR_NO_CONNECTION,
	CR_TCPIP,
	CR_DROP_PACKETS,
	CR_FILE_TRACE,
	CR_GM,
	CR_MULTI_PACKET
} CRConnectionType;

#if defined(WINDOWS)
typedef SOCKET CRSocket;
#else
typedef int    CRSocket;
#endif

int crGetHostname( char *buf, unsigned int len );
int crGetPID(void);

void crNetDefaultRecv( CRConnection *conn, void *buf, unsigned int len );

typedef void (*CRVoidFunc)( void );
typedef int (*CRNetReceiveFunc)( CRConnection *conn, void *buf, unsigned int len );
typedef int (*CRNetConnectFunc)( CRConnection *conn );
typedef void (*CRNetCloseFunc)( unsigned int sender_id );

void crNetInit( CRNetReceiveFunc recvFunc, CRNetCloseFunc closeFunc );
void *crNetAlloc( CRConnection *conn );
void crNetSend( CRConnection *conn, void **bufp, void *start, unsigned int len );
void crNetSendExact( CRConnection *conn, void *start, unsigned int len );
void crNetSingleRecv( CRConnection *conn, void *buf, unsigned int len );
unsigned int  crNetGetMessage( CRConnection *conn, CRMessage **message );
void crNetReadline( CRConnection *conn, void *buf );
int  crNetRecv( void );
void crNetFree( CRConnection *conn, void *buf );
void crNetAccept( CRConnection *conn, unsigned short port );
int crNetConnect( CRConnection *conn );
void crNetDisconnect( CRConnection *conn );
void crCloseSocket( CRSocket sock );

typedef struct __messageList {
	CRMessage *mesg;
	unsigned int len;
	struct __messageList *next;
} CRMessageList;

typedef struct CRMultiBuffer {
	unsigned int  len;
	unsigned int  max;
	void         *buf;
} CRMultiBuffer;

struct CRConnection {
	CRConnectionType type;
	unsigned int id; // from the mothership

	CRMessageList *messageList, *messageTail;

	CRMultiBuffer multi;

	unsigned int mtu;

	int broker;

	int endianness, swap;

	char *hostname;
	int port;

	void *(*Alloc)( CRConnection *conn );
	void  (*Send)( CRConnection *conn, void **buf, void *start, unsigned int len );
	void  (*SendExact)( CRConnection *conn, void *start, unsigned int len );
	void  (*Recv)( CRConnection *conn, void *buf, unsigned int len );
	void  (*Free)( CRConnection *conn, void *buf );
	void  (*InstantReclaim)( CRConnection *conn, CRMessage *mess );
	void  (*HandleNewMessage)( CRConnection *conn, CRMessage *mess, unsigned int len );
	void  (*Accept)( CRConnection *conn, unsigned short port );
	int  (*Connect)( CRConnection *conn );
	void  (*Disconnect)( CRConnection *conn );

	unsigned int sizeof_buffer_header;

	/* logging */
	int total_bytes;

	/* credits for flow control */
	int send_credits;
	int recv_credits;

	/* TCP/IP */
	CRSocket tcp_socket;
	int index;

	/* FILE Tracing */
	char *filename;
	FILE *fp;

	/* Myrinet GM */
	unsigned int gm_node_id;
	unsigned int gm_port_num;
};

CRConnection *crNetConnectToServer( char *server, unsigned short default_port, int mtu, int broker );
CRConnection *crNetAcceptClient( char *protocol, unsigned short port, unsigned int mtu, int broker );


#endif /* CR_NET_H */
<commit_msg>Changed a C++ comment to a C-style comment.<commit_after>/* Copyright (c) 2001, Stanford University
 * All rights reserved.
 *
 * See the file LICENSE.txt for information on redistributing this software.
 */

#ifndef CR_NET_H
#define CR_NET_H

#ifdef WINDOWS
#define WIN32_LEAN_AND_MEAN
#pragma warning( push, 3 ) /* shut up about warnings in YOUR OWN HEADER FILES!!! */
#include <winsock2.h>
#endif

#include <stdio.h>

#include "cr_protocol.h"

typedef struct CRConnection CRConnection;

typedef enum {
	CR_NO_CONNECTION,
	CR_TCPIP,
	CR_DROP_PACKETS,
	CR_FILE_TRACE,
	CR_GM,
	CR_MULTI_PACKET
} CRConnectionType;

#if defined(WINDOWS)
typedef SOCKET CRSocket;
#else
typedef int    CRSocket;
#endif

int crGetHostname( char *buf, unsigned int len );
int crGetPID(void);

void crNetDefaultRecv( CRConnection *conn, void *buf, unsigned int len );

typedef void (*CRVoidFunc)( void );
typedef int (*CRNetReceiveFunc)( CRConnection *conn, void *buf, unsigned int len );
typedef int (*CRNetConnectFunc)( CRConnection *conn );
typedef void (*CRNetCloseFunc)( unsigned int sender_id );

void crNetInit( CRNetReceiveFunc recvFunc, CRNetCloseFunc closeFunc );
void *crNetAlloc( CRConnection *conn );
void crNetSend( CRConnection *conn, void **bufp, void *start, unsigned int len );
void crNetSendExact( CRConnection *conn, void *start, unsigned int len );
void crNetSingleRecv( CRConnection *conn, void *buf, unsigned int len );
unsigned int  crNetGetMessage( CRConnection *conn, CRMessage **message );
void crNetReadline( CRConnection *conn, void *buf );
int  crNetRecv( void );
void crNetFree( CRConnection *conn, void *buf );
void crNetAccept( CRConnection *conn, unsigned short port );
int crNetConnect( CRConnection *conn );
void crNetDisconnect( CRConnection *conn );
void crCloseSocket( CRSocket sock );

typedef struct __messageList {
	CRMessage *mesg;
	unsigned int len;
	struct __messageList *next;
} CRMessageList;

typedef struct CRMultiBuffer {
	unsigned int  len;
	unsigned int  max;
	void         *buf;
} CRMultiBuffer;

struct CRConnection {
	CRConnectionType type;
	unsigned int id; /* from the mothership */

	CRMessageList *messageList, *messageTail;

	CRMultiBuffer multi;

	unsigned int mtu;

	int broker;

	int endianness, swap;

	char *hostname;
	int port;

	void *(*Alloc)( CRConnection *conn );
	void  (*Send)( CRConnection *conn, void **buf, void *start, unsigned int len );
	void  (*SendExact)( CRConnection *conn, void *start, unsigned int len );
	void  (*Recv)( CRConnection *conn, void *buf, unsigned int len );
	void  (*Free)( CRConnection *conn, void *buf );
	void  (*InstantReclaim)( CRConnection *conn, CRMessage *mess );
	void  (*HandleNewMessage)( CRConnection *conn, CRMessage *mess, unsigned int len );
	void  (*Accept)( CRConnection *conn, unsigned short port );
	int  (*Connect)( CRConnection *conn );
	void  (*Disconnect)( CRConnection *conn );

	unsigned int sizeof_buffer_header;

	/* logging */
	int total_bytes;

	/* credits for flow control */
	int send_credits;
	int recv_credits;

	/* TCP/IP */
	CRSocket tcp_socket;
	int index;

	/* FILE Tracing */
	char *filename;
	FILE *fp;

	/* Myrinet GM */
	unsigned int gm_node_id;
	unsigned int gm_port_num;
};

CRConnection *crNetConnectToServer( char *server, unsigned short default_port, int mtu, int broker );
CRConnection *crNetAcceptClient( char *protocol, unsigned short port, unsigned int mtu, int broker );


#endif /* CR_NET_H */

{'fraction_non_alphanumeric': 0.10486121310030841, 'fraction_numerical': 0.002349831105889264, 'mean_word_length': 5.031886625332152, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3049252', 'n_tokens_mistral': 2240, 'n_tokens_neox': 2145, 'n_words': 749}