NAMD
Classes | Macros | Functions | Variables
main.C File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <pwd.h>
#include "InfoStream.h"
#include "memusage.h"
#include "Lattice.h"
#include "ComputeMsmMsa.h"
#include "main.decl.h"
#include "main.h"
#include "NamdEventsProfiling.h"
#include "main.def.h"

Go to the source code of this file.

Classes

class  main
 

Macros

#define TBSOFT_TRACK_MAXLEN   1024 /* maximum message length */
 

Functions

void RegisterNamdEventsProfiling ()
 
int send_dgram (const char *host_addr, int port, const char *buf, int buflen)
 
int tbsoft_sendusage (const char *program, const char *versionnum, const char *platform, const char *numcpus, const char *miscinfo)
 

Variables

const char * namd_build_date
 
const char * namd_build_user
 
const char * namd_build_machine
 

Macro Definition Documentation

◆ TBSOFT_TRACK_MAXLEN

#define TBSOFT_TRACK_MAXLEN   1024 /* maximum message length */

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

Definition at line 22 of file main.C.

Referenced by tbsoft_sendusage().

Function Documentation

◆ RegisterNamdEventsProfiling()

void RegisterNamdEventsProfiling ( )

Definition at line 47 of file main.C.

References NamdProfileEvent::EventsCount, NAMD_REGISTER_EVENT, and NamdProfileEventStr.

Referenced by main::main().

47  {
48  // CkPrintf("########### eventCount: %d #########\n", NamdProfileEvent::EventsCount);
49  for (int i = 0; i < NamdProfileEvent::EventsCount; i++) {
50  // CkPrintf("########### name: %s, id: %d ##########\n", NamdProfileEventStr[i], i);
52  }
53 }
char const *const NamdProfileEventStr[]
#define NAMD_REGISTER_EVENT(name, cid)

◆ send_dgram()

int send_dgram ( const char *  host_addr,
int  port,
const char *  buf,
int  buflen 
)

Definition at line 57 of file main.C.

Referenced by tbsoft_sendusage().

57  {
58  struct sockaddr_in addr;
59  int sockfd;
60 
61 #ifndef NOHOSTNAME
62  if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
63  return -1;
64  }
65 
66  memset(&addr, 0, sizeof(addr));
67  addr.sin_family = AF_INET;
68  addr.sin_port = htons(port);
69  addr.sin_addr.s_addr = inet_addr(host_addr);
70 
71  sendto(sockfd, buf, buflen, 0, (struct sockaddr *)&addr, sizeof(addr));
72 
73  close(sockfd);
74 #endif
75 
76  return 0;
77 }

◆ tbsoft_sendusage()

int tbsoft_sendusage ( const char *  program,
const char *  versionnum,
const char *  platform,
const char *  numcpus,
const char *  miscinfo 
)

Definition at line 80 of file main.C.

References endi(), iINFO(), iout, send_dgram(), and TBSOFT_TRACK_MAXLEN.

Referenced by main::main().

84  {
85 
86 #ifndef NOHOSTNAME
87 #ifdef TBSOFT_TRACK_HOST
88  iout << iINFO
89  << "Sending usage information to " << TBSOFT_TRACK_HOST
90  << ":" << TBSOFT_TRACK_PORT << " via UDP. Sent data is:\n";
91 #endif
92 
93  char sendbuf[TBSOFT_TRACK_MAXLEN];
94  char host[128];
95  struct passwd *pw;
96  char user[128];
97 
98  memset(sendbuf, 0, sizeof(sendbuf));
99 
100  gethostname(host, 128); host[127] = 0;
101  pw = getpwuid(getuid());
102  if ( pw && pw->pw_name ) {
103  strncpy(user, pw->pw_name, 127); user[127] = 0;
104  } else {
105  sprintf(user,"%d",getuid());
106  }
107 
108  sprintf(sendbuf, "1 %s %s %s %s %s %s %s",
109  program, versionnum, platform, numcpus, miscinfo, host, user);
110  iout << iINFO << sendbuf << "\n" << endi;
111 #ifdef TBSOFT_TRACK_HOST
112  send_dgram(TBSOFT_TRACK_HOST, TBSOFT_TRACK_PORT, sendbuf, strlen(sendbuf));
113 #endif
114 
115 #endif
116  return 0;
117 }
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
#define TBSOFT_TRACK_MAXLEN
Definition: main.C:22
int send_dgram(const char *host_addr, int port, const char *buf, int buflen)
Definition: main.C:57

Variable Documentation

◆ namd_build_date

const char* namd_build_date

Referenced by main::main().

◆ namd_build_machine

const char* namd_build_machine

Referenced by main::main().

◆ namd_build_user

const char* namd_build_user

Referenced by main::main().