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 "main.def.h"

Go to the source code of this file.

Classes

class  main
 

Macros

#define TBSOFT_TRACK_MAXLEN   1024 /* maximum message length */
 

Functions

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

#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

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

Definition at line 48 of file main.C.

Referenced by tbsoft_sendusage().

48  {
49  struct sockaddr_in addr;
50  int sockfd;
51 
52 #ifndef NOHOSTNAME
53  if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
54  return -1;
55  }
56 
57  memset(&addr, 0, sizeof(addr));
58  addr.sin_family = AF_INET;
59  addr.sin_port = htons(port);
60  addr.sin_addr.s_addr = inet_addr(host_addr);
61 
62  sendto(sockfd, buf, buflen, 0, (struct sockaddr *)&addr, sizeof(addr));
63 
64  close(sockfd);
65 #endif
66 
67  return 0;
68 }
int tbsoft_sendusage ( const char *  program,
const char *  versionnum,
const char *  platform,
const char *  numcpus,
const char *  miscinfo 
)

Definition at line 71 of file main.C.

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

Referenced by main::main().

75  {
76 
77 #ifndef NOHOSTNAME
78 #ifdef TBSOFT_TRACK_HOST
79  iout << iINFO
80  << "Sending usage information to " << TBSOFT_TRACK_HOST
81  << ":" << TBSOFT_TRACK_PORT << " via UDP. Sent data is:\n";
82 #endif
83 
84  char sendbuf[TBSOFT_TRACK_MAXLEN];
85  char host[128];
86  struct passwd *pw;
87  char user[128];
88 
89  memset(sendbuf, 0, sizeof(sendbuf));
90 
91  gethostname(host, 128); host[127] = 0;
92  pw = getpwuid(getuid());
93  if ( pw && pw->pw_name ) {
94  strncpy(user, pw->pw_name, 127); user[127] = 0;
95  } else {
96  sprintf(user,"%d",getuid());
97  }
98 
99  sprintf(sendbuf, "1 %s %s %s %s %s %s %s",
100  program, versionnum, platform, numcpus, miscinfo, host, user);
101  iout << iINFO << sendbuf << "\n" << endi;
102 #ifdef TBSOFT_TRACK_HOST
103  send_dgram(TBSOFT_TRACK_HOST, TBSOFT_TRACK_PORT, sendbuf, strlen(sendbuf));
104 #endif
105 
106 #endif
107  return 0;
108 }
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:107
#define iout
Definition: InfoStream.h:87
#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:48
infostream & endi(infostream &s)
Definition: InfoStream.C:38

Variable Documentation

const char* namd_build_date

Referenced by main::main().

const char* namd_build_machine

Referenced by main::main().

const char* namd_build_user

Referenced by main::main().