-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic_example.c
More file actions
26 lines (22 loc) · 954 Bytes
/
basic_example.c
File metadata and controls
26 lines (22 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../src/cvec.h"
int main (){
struct vcLog *vcInfo = init_cvector("MyProcess","basiclog");
// Prepare and send a Message
int size;
int msgLen; //The length of the message we unpacked, we do not need this here.
char sendingMessage[50];
strcpy(sendingMessage, "ExampleMessage");
printf("We are packing this message: %s\n", sendingMessage);
char * resultBuffer = prepare_send(vcInfo, "Sending Message", sendingMessage, 50, &size);
// Unpack the message again
char * receivedMessage = unpack_receive(vcInfo, "Receiving Message", resultBuffer, size, &msgLen);
printf("We received this message: %s\n", receivedMessage);
// Can be called at any point
log_local_event(vcInfo, "Example Complete");
// No further events will be written to log file
disable_logging(vcInfo);
log_local_event(vcInfo, "This will not be logged.");
}