Dendro  5.01
Dendro in Greek language means tree. The Dendro library is a large scale (262K cores on ORNL's Titan) distributed memory adaptive octree framework. The main goal of Dendro is to perform large scale multiphysics simulations efficeiently in mordern supercomputers. Dendro consists of efficient parallel data structures and algorithms to perform variational ( finite element) methods and finite difference mthods on 2:1 balanced arbitary adaptive octrees which enables the users to perform simulations raning from black holes (binary black hole mergers) to blood flow in human body, where applications ranging from relativity, astrophysics to biomedical engineering.
cencode.h
1 /*
2 cencode.h - c header for a base64 encoding algorithm
3 
4 This is part of the libb64 project, and has been placed in the public domain.
5 For details, see http://sourceforge.net/projects/libb64
6 */
7 
8 #ifndef BASE64_CENCODE_H
9 #define BASE64_CENCODE_H
10 
11 typedef enum
12 {
13  step_A, step_B, step_C
14 } base64_encodestep;
15 
16 typedef struct
17 {
18  base64_encodestep step;
19  char result;
20  int stepcount;
22 
23 inline void base64_init_encodestate(base64_encodestate* state_in);
24 
25 inline char base64_encode_value(char value_in);
26 
27 inline int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in);
28 
29 inline int base64_encode_blockend(char* code_out, base64_encodestate* state_in);
30 
31 
32 /*
33 cencoder.c - c source to a base64 encoding algorithm implementation
34 
35 This is part of the libb64 project, and has been placed in the public domain.
36 For details, see http://sourceforge.net/projects/libb64
37 */
38 
39 const int CHARS_PER_LINE = 72;
40 
41 inline void base64_init_encodestate(base64_encodestate* state_in)
42 {
43  state_in->step = step_A;
44  state_in->result = 0;
45  state_in->stepcount = 0;
46 }
47 
48 inline char base64_encode_value(char value_in)
49 {
50  static const char* encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
51  if (value_in > 63) return '=';
52  return encoding[(int)value_in];
53 }
54 
55 inline int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in)
56 {
57  const char* plainchar = plaintext_in;
58  const char* const plaintextend = plaintext_in + length_in;
59  char* codechar = code_out;
60  char result;
61  char fragment;
62 
63  result = state_in->result;
64 
65  switch (state_in->step)
66  {
67  while (1)
68  {
69  case step_A:
70  if (plainchar == plaintextend)
71  {
72  state_in->result = result;
73  state_in->step = step_A;
74  return codechar - code_out;
75  }
76  fragment = *plainchar++;
77  result = (fragment & 0x0fc) >> 2;
78  *codechar++ = base64_encode_value(result);
79  result = (fragment & 0x003) << 4;
80  case step_B:
81  if (plainchar == plaintextend)
82  {
83  state_in->result = result;
84  state_in->step = step_B;
85  return codechar - code_out;
86  }
87  fragment = *plainchar++;
88  result |= (fragment & 0x0f0) >> 4;
89  *codechar++ = base64_encode_value(result);
90  result = (fragment & 0x00f) << 2;
91  case step_C:
92  if (plainchar == plaintextend)
93  {
94  state_in->result = result;
95  state_in->step = step_C;
96  return codechar - code_out;
97  }
98  fragment = *plainchar++;
99  result |= (fragment & 0x0c0) >> 6;
100  *codechar++ = base64_encode_value(result);
101  result = (fragment & 0x03f) >> 0;
102  *codechar++ = base64_encode_value(result);
103 
104  ++(state_in->stepcount);
105 #ifdef DENDRO_VTK_WRAP_COORDS
106  if (state_in->stepcount == CHARS_PER_LINE/4)
107  {
108  *codechar++ = '\n';
109  state_in->stepcount = 0;
110  }
111 #endif
112  }
113  }
114  /* control should not reach here */
115  return codechar - code_out;
116 }
117 
118 inline int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
119 {
120  char* codechar = code_out;
121 
122  switch (state_in->step)
123  {
124  case step_B:
125  *codechar++ = base64_encode_value(state_in->result);
126  *codechar++ = '=';
127  *codechar++ = '=';
128  break;
129  case step_C:
130  *codechar++ = base64_encode_value(state_in->result);
131  *codechar++ = '=';
132  break;
133  case step_A:
134  break;
135  }
136 
137 #ifdef DENDRO_VTK_WRAP_COORDS
138  *codechar++ = '\n';
139 #endif
140 
141  return codechar - code_out;
142 }
143 
144 
145 
146 #endif /* BASE64_CENCODE_H */
Definition: cencode.h:16