Home > Back-end >  What a great god can help me this code under analysis
What a great god can help me this code under analysis

Time:10-08

/* *
* * * Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by
* * * The Board of Trustees of The University of Illinois.
* * * All rights reserved.
* */


# ifdef WIN32
# # ifndef NO_SOCKET
# define NO_SOCKET
# endif
# endif

# # ifndef NO_SOCKET

//to track the usage, define the target host and port in the compile line, e.g. :
//- DTBSOFT_TRACK_HOST=\ "127.0.0.1 " - DTBSOFT_TRACK_PORT=3141
//# define TBSOFT_TRACK_HOST "127.0.0.1
"//# define TBSOFT_TRACK_PORT 3141

# # ifndef TBSOFT_TRACK_MAXLEN
1024/* # define TBSOFT_TRACK_MAXLEN maximum message length */
# endif

# include & lt; Stdio. H>
# include & lt; Stdlib. H>
# include & lt; String. H>
# include & lt; Sys/types. H>
# include & lt; Unistd. H>
# include & lt; ARPA/inet. H>
# include & lt; An FCNTL. H>
# include & lt; Sys/socket. H>
# include & lt; Netinet/in. H>
# include & lt; The PWD. H>

# endif

# include "InfoStream. H"
# include "memusage. H"

# include "Lattice h"
# include "ComputeMsmMsa. H"//men for MsmMsaData definition
# include main. Decl. "h"
# include "is the main. H"

# # ifndef NO_SOCKET

Int send_dgram (const char * host_addr, int port, const char * buf, int buflen) {
Struct sockaddr_in addr.
Int sockfd;

# # ifndef NOHOSTNAME
If ((sockfd=socket (AF_INET, SOCK_DGRAM, 0)) & lt; 0 {
return -1;
}

Memset (& amp; Addr, 0, sizeof (addr));
Addr. Sin_family=AF_INET;
Addr. Sin_port=htons (port);
Addr. Sin_addr. S_addr=inet_addr (host_addr);

Sendto (sockfd, buf, buflen, 0, (struct sockaddr *) & amp; Addr, sizeof (addr));

Close (sockfd);
# endif

return 0;
}


Int tbsoft_sendusage (const char * program,
Const char * versionnum,
Const char * platform,
Const char * numcpus,
Const char * miscinfo) {

# # ifndef NOHOSTNAME
# ifdef TBSOFT_TRACK_HOST
Iout & lt; <"Sending the usage information to" & lt; <":" & lt; # endif

Char sendbuf [TBSOFT_TRACK_MAXLEN];
Char host [128].
Struct passwd * pw.
Char user [128].

Memset (sendbuf, 0, sizeof (sendbuf));

Gethostname (host, 128); The host [127]=0;
Pw=getpwuid (getuid ());
If (pw & amp; & Pw - & gt; Pw_name) {
Strncpy (user, pw - & gt; Pw_name, 127); The user [127]=0;
} else {
Sprintf (user, "% d", getuid ());
}

Sprintf (sendbuf, 1% s % s "% s % s % s % s % s",
Program, versionnum, platform, numcpus miscinfo, host, user);
Iout & lt; # ifdef TBSOFT_TRACK_HOST
Send_dgram (TBSOFT_TRACK_HOST TBSOFT_TRACK_PORT, sendbuf, strlen (sendbuf));
# endif

# endif
return 0;
}

# endif

Extern const char * namd_build_date;
Extern const char * namd_build_user;
Extern const char * namd_build_machine;

The class main: public Chare
{
Public:
The main (CkArgMsg *)
{

//print banner
Iout & lt; <
"\ n"# ifdef MEM_OPT_VERSION
"\ n" "\ n"# endif
# if 0
"\ n" "\ n"# endif
# ifdef SCYLD_NOTICE

"\ n"" "\ n"
  • Related