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

#if defined (_WIN32)
   #include <winsock2.h>
   #include <ws2tcpip.h>
#endif

#if defined (__unix__) || defined (__linux__)
   #include <unistd.h>
   #include <sys/types.h>
   #include <sys/socket.h>
   #include <arpa/inet.h>
   #include <netinet/in.h>
   #include <netdb.h>
#endif

#include "statsd.h"

//Define the private functions
static const char *networkToPresentation(int af, const void *src, char *dst, size_t size);
static int sendToServer(Statsd* stats, const char* bucket, StatsType type, int delta, double sampleRate);
static int buildStatString(char* stat, const char* nameSpace, const char* bucket, StatsType type, int delta, double sampleRate);

#if defined(_WIN32)
static const char *networkToPresentation(int af, const void *src, char *dst, size_t size){
   return InetNtop(af, src, dst, size);
}
#else
static const char *networkToPresentation(int af, const void *src, char *dst, size_t size){
   return inet_ntop(af, src, dst, size);
}
#endif

/**
   This is a helper function that will do the dirty work of sending
   the stats to the statsd server. 

   @param[in] stats - The stats client object
   @param[in] bucket - The optional bucket name, if this is null then
      the defualt bucket name is used from the stats object.
   @param[in] type - The type of stat being sent
   @param[in] delta - The value to send
   @param[in] sampleRate - The sample rate of this stat. If the value is
      less then or equal to 0, or greater then or equal to 1, it is ignored.

   @return STATSD_SUCCESS on success, STATSD_BAD_STATS_TYPE if the type is 
      not recognized. STATSD_UDP_SEND if the sendto() failed.<commit_msg>Made only 1 networkToPresentation function that works in both Windows and Unix.<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#if defined (_WIN32)
   #include <windows.h>
   #include <winsock2.h>
   #include <winsock.h>
   #include <ws2tcpip.h>
#endif

#if defined (__unix__) || defined (__linux__)
   #include <unistd.h>
   #include <sys/types.h>
   #include <sys/socket.h>
   #include <arpa/inet.h>
   #include <netinet/in.h>
   #include <netdb.h>
#endif

#include "statsd.h"

//Define the private functions
static const char *networkToPresentation(int af, const void *src, char *dst, size_t size);
static int sendToServer(Statsd* stats, const char* bucket, StatsType type, int delta, double sampleRate);
static int buildStatString(char* stat, const char* nameSpace, const char* bucket, StatsType type, int delta, double sampleRate);

static const char *networkToPresentation(int af, const void *src, char *dst, size_t size){
   return inet_ntop(af, src, dst, size);
}

/**
   This is a helper function that will do the dirty work of sending
   the stats to the statsd server. 

   @param[in] stats - The stats client object
   @param[in] bucket - The optional bucket name, if this is null then
      the defualt bucket name is used from the stats object.
   @param[in] type - The type of stat being sent
   @param[in] delta - The value to send
   @param[in] sampleRate - The sample rate of this stat. If the value is
      less then or equal to 0, or greater then or equal to 1, it is ignored.

   @return STATSD_SUCCESS on success, STATSD_BAD_STATS_TYPE if the type is 
      not recognized. STATSD_UDP_SEND if the sendto() failed.
{'fraction_non_alphanumeric': 0.09900410076157, 'fraction_numerical': 0.004393673110720563, 'mean_word_length': 3.9636627906976742, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '3237956', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1092, 'n_words': 439}