NAMD
Classes | Macros | Functions
MStream.C File Reference
#include <string.h>
#include "Communicate.h"
#include "MStream.h"
#include "converse.h"
#include "Debug.h"

Go to the source code of this file.

Classes

struct  StreamMessage
 

Macros

#define MIN_DEBUG_LEVEL   2
 

Functions

static int checkSum (StreamMessage *msg)
 

Macro Definition Documentation

#define MIN_DEBUG_LEVEL   2

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

Definition at line 12 of file MStream.C.

Function Documentation

static int checkSum ( StreamMessage msg)
static

Definition at line 65 of file MStream.C.

References StreamMessage::checksum, StreamMessage::data, DebugM, StreamMessage::index, StreamMessage::len, NAMD_bug(), and StreamMessage::tag.

66 {
67  int checksum = 0;
68  for ( size_t i=0; i < msg->len; i++ ) {
69  checksum += (unsigned char) msg->data[i];
70  }
71  if ( checksum != msg->checksum ) {
72  DebugM(5,"Error on " << msg->tag << ":" << msg->index <<
73  " of length " << msg->len <<
74  " with checksum " << ((int)checksum) <<
75  " vs " << ((int)(msg->checksum)) <<"\n");
76  NAMD_bug("MStream checksums do not agree!");
77  }
78  return 1;
79 }
unsigned int checksum
Definition: MStream.C:22
#define DebugM(x, y)
Definition: Debug.h:59
void NAMD_bug(const char *err_msg)
Definition: common.C:129
size_t len
Definition: MStream.C:20
char data[1]
Definition: MStream.C:24
unsigned int index
Definition: MStream.C:21