#include <cstdio>
#include <cstdlib>
#include <arpa/inet.h>
#include "zlib.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <cstring>
#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) |
|
◆ BUFLEN
◆ getCompressedBuffer()
void getCompressedBuffer |
( |
const char * |
fname, |
|
|
Bytef ** |
buffPtr, |
|
|
unsigned long & |
zippedSize |
|
) |
| |
Definition at line 20 of file cmsShowSendReport.cc.
References edmScanValgrind::buffer, DMR_cfg::cerr, beamvalidation::exit(), alignmentValidation::fname, free(), malloc(), and mps_fire::result.
Referenced by main().
22 FILE* pFile = fopen (
fname ,
"r" );
26 fseek (pFile , 0 , SEEK_END);
27 unsigned int lSize = ftell (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);
void free(void *ptr) noexcept
void * malloc(size_t size) noexcept
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 63 of file cmsShowSendReport.cc.
References dir2webdir::argc, GCPpyPlots::argv, DMR_cfg::cerr, beamvalidation::exit(), free(), getCompressedBuffer(), and h.
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)
void free(void *ptr) noexcept
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.