#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include "zlib.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <string.h>
#include <netdb.h>
#include <iostream>
Go to the source code of this file.
|
void | getCompressedBuffer (const char *fname, Bytef **buffPtr, unsigned long &zippedSize) |
|
int | main (int argc, char **argv) |
|
void getCompressedBuffer |
( |
const char * |
fname, |
|
|
Bytef ** |
buffPtr, |
|
|
unsigned long & |
zippedSize |
|
) |
| |
Definition at line 20 of file cmsShowSendReport.cc.
References dtNoiseDBValidation_cfg::cerr, cmsRelvalreport::exit, NULL, and query::result.
Referenced by main().
22 FILE* pFile = fopen (
fname ,
"r" );
26 fseek (pFile , 0 , SEEK_END);
27 unsigned int lSize = ftell (pFile);
31 void* buffer = malloc (
sizeof(Bytef)*(lSize));
33 size_t result = fread (buffer, 1, lSize ,pFile);
42 unsigned int deflatedSize = compressBound(lSize) + 4;
43 Bytef * deflatedBuff = (Bytef*) malloc (
sizeof(Bytef)*(deflatedSize));
44 *((
unsigned int*)deflatedBuff) = htonl(lSize);
47 *buffPtr = deflatedBuff;
50 zippedSize = deflatedSize;
51 compress(deflatedBuff+4, &zippedSize, (
const Bytef *)buffer, lSize);
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 63 of file cmsShowSendReport.cc.
References dtNoiseDBValidation_cfg::cerr, cmsRelvalreport::exit, getCompressedBuffer(), h, and sd.
67 std::cerr <<
"Uasage: sendCrashReport <fileName>" << std::endl;
exit(1);
71 int sd = socket(AF_INET,SOCK_DGRAM, 0);
72 if (sd < 0) {
return 1; }
75 struct sockaddr_in cliAddr;
76 cliAddr.sin_family = AF_INET;
77 cliAddr.sin_addr.s_addr = htonl(INADDR_ANY);
78 cliAddr.sin_port = htons(0);
80 int rc = bind(sd, (
struct sockaddr *) &cliAddr,
sizeof(cliAddr));
82 std::cerr <<
"Can't bind port %d " << rc << std::endl;
exit(1);
86 struct hostent*
h = gethostbyname(
"xrootd.t2.ucsd.edu");
91 struct sockaddr_in remoteServAddr;
92 remoteServAddr.sin_family = h->h_addrtype;
93 memcpy((
char *) &remoteServAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
94 remoteServAddr.sin_port = htons(9699);
97 unsigned long buffSize;
100 sendto(sd, buff, buffSize, 0,
101 (
struct sockaddr *) &remoteServAddr,
102 sizeof(remoteServAddr));
void getCompressedBuffer(const char *fname, Bytef **buffPtr, unsigned long &zippedSize)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.