diff --git a/examples/mms_utility/mms_utility.c b/examples/mms_utility/mms_utility.c index 24c909c9..3cedd8ab 100644 --- a/examples/mms_utility/mms_utility.c +++ b/examples/mms_utility/mms_utility.c @@ -129,7 +129,8 @@ int main(int argc, char** argv) int c; - while ((c = getopt(argc, argv, "mifdh:p:l:t:a:r:g:j:x:v:c:y:z:")) != -1) { + while ((c = getopt(argc, argv, "mifdh:p:l:t:a:r:g:j:x:v:c:y:z:")) != -1) + { switch (c) { case 'm': printRawMmsMessages = 1; @@ -212,7 +213,8 @@ int main(int argc, char** argv) if (printRawMmsMessages) MmsConnection_setRawMessageHandler(con, (MmsRawMessageHandler) printRawMmsMessage, NULL); - if (!MmsConnection_connect(con, &error, hostname, tcpPort)) { + if (!MmsConnection_connect(con, &error, hostname, tcpPort)) + { printf("MMS connect failed!\n"); if (error != MMS_ERROR_NONE) @@ -223,14 +225,16 @@ int main(int argc, char** argv) else printf("MMS connected.\n"); - if (identifyDevice) { + if (identifyDevice) + { MmsServerIdentity* identity = MmsConnection_identify(con, &error); if (error != MMS_ERROR_NONE) returnCode = error; - if (identity != NULL) { + if (identity != NULL) + { printf("\nServer identity:\n----------------\n"); printf(" vendor:\t%s\n", identity->vendorName); printf(" model:\t%s\n", identity->modelName); @@ -240,32 +244,37 @@ int main(int argc, char** argv) printf("Reading server identity failed!\n"); } - if (readDeviceList) { + if (readDeviceList) + { printf("\nDomains present on server:\n--------------------------\n"); LinkedList nameList = MmsConnection_getDomainNames(con, &error); if (error != MMS_ERROR_NONE) returnCode = error; - if (nameList) { + if (nameList) + { LinkedList_printStringList(nameList); LinkedList_destroy(nameList); } } - if (getDeviceDirectory) { + if (getDeviceDirectory) + { LinkedList variableList = MmsConnection_getDomainVariableNames(con, &error, domainName); if (error != MMS_ERROR_NONE) returnCode = error; - if (variableList) { + if (variableList) + { LinkedList element = LinkedList_getNext(variableList); printf("\nMMS domain variables for domain %s\n", domainName); - while (element != NULL) { + while (element != NULL) + { char* name = (char*) element->data; printf(" %s\n", name); @@ -284,8 +293,8 @@ int main(int argc, char** argv) if (error != MMS_ERROR_NONE) returnCode = error; - if (variableList) { - + if (variableList) + { LinkedList element = variableList; printf("\nMMS journals for domain %s\n", domainName); @@ -301,18 +310,17 @@ int main(int argc, char** argv) else { printf("\nFailed to read domain journals (error=%d)\n", error); } - } - if (readJournal) { - + if (readJournal) + { printf(" read journal %s...\n", journalName); char* logDomain = journalName; char* logName = strchr(journalName, '/'); - if (logName != NULL) { - + if (logName != NULL) + { logName[0] = 0; logName++; @@ -335,11 +343,12 @@ int main(int argc, char** argv) MmsValue_delete(startTime); MmsValue_delete(endTime); - if (journalEntries != NULL) { - + if (journalEntries != NULL) + { bool readNext; - do { + do + { readNext = false; LinkedList lastEntry = LinkedList_getLastElement(journalEntries); @@ -353,7 +362,8 @@ int main(int argc, char** argv) LinkedList_destroyDeep(journalEntries, (LinkedListValueDeleteFunction) MmsJournalEntry_destroy); - if (moreFollows) { + if (moreFollows) + { char buf[100]; MmsValue_printToBuffer(nextEntryId, buf, 100); @@ -374,12 +384,14 @@ int main(int argc, char** argv) printf(" Invalid log name!\n"); } - if (readVariable) { - if (readWriteHasDomain) { - + if (readVariable) + { + if (readWriteHasDomain) + { MmsValue* result; - if (componentName == NULL) { + if (componentName == NULL) + { if (arrayIndex == -1) { result = MmsConnection_readVariable(con, &error, domainName, variableName); } @@ -396,15 +408,18 @@ int main(int argc, char** argv) } } - if (error != MMS_ERROR_NONE) { + if (error != MMS_ERROR_NONE) + { printf("Reading variable failed: (ERROR %i)\n", error); returnCode = error; } - else { + else + { printf("Read SUCCESS\n"); - if (result != NULL) { + if (result != NULL) + { char outbuf[1024]; MmsValue_printToBuffer(result, outbuf, 1024); @@ -416,22 +431,27 @@ int main(int argc, char** argv) else printf("result: NULL\n"); } - } else + { printf("Reading VMD scope variable not yet supported!\n"); + } } - if (readVariableList) { - if (readWriteHasDomain) { + if (readVariableList) + { + if (readWriteHasDomain) + { MmsValue* variables = MmsConnection_readNamedVariableListValues(con, &error, domainName, variableName, true); - if (error != MMS_ERROR_NONE) { + if (error != MMS_ERROR_NONE) + { printf("Reading variable failed: (ERROR %i)\n", error); returnCode = error; } - else { + else + { printf("Read SUCCESS\n"); } } @@ -439,24 +459,28 @@ int main(int argc, char** argv) printf("Reading VMD scope variable list not yet supported!\n"); } - if (readDataSetDirectory) { - if (readWriteHasDomain) { - + if (readDataSetDirectory) + { + if (readWriteHasDomain) + { bool deletable = false; LinkedList varListDir = MmsConnection_readNamedVariableListDirectory(con, &error, domainName, variableName, &deletable); - if (error != MMS_ERROR_NONE) { + if (error != MMS_ERROR_NONE) + { printf("Reading variable list directory failed: (ERROR %i)\n", error); returnCode = error; } - else { + else + { LinkedList varListElem = LinkedList_getNext(varListDir); int listIdx = 0; - while (varListElem) { + while (varListElem) + { MmsVariableAccessSpecification* varAccessSpec = (MmsVariableAccessSpecification*)LinkedList_getData(varListElem); if (varAccessSpec->arrayIndex) @@ -476,14 +500,15 @@ int main(int argc, char** argv) printf("Reading VMD scope variable list not yet supported!\n"); } - if (showFileList) { + if (showFileList) + { char lastName[300]; lastName[0] = 0; char* continueAfter = NULL; - while (MmsConnection_getFileDirectory(con, &error, "", continueAfter, mmsFileDirectoryHandler, lastName)) { - + while (MmsConnection_getFileDirectory(con, &error, "", continueAfter, mmsFileDirectoryHandler, lastName)) + { if (error != MMS_ERROR_NONE) returnCode = error; @@ -491,21 +516,25 @@ int main(int argc, char** argv) } } - if (getFileAttributes) { + if (getFileAttributes) + { MmsConnection_getFileDirectory(con, &error, filename, NULL, mmsGetFileAttributeHandler, NULL); if (error != MMS_ERROR_NONE) returnCode = error; } - if (deleteFile) { + if (deleteFile) + { MmsConnection_fileDelete(con, &error, filename); - if (error != MMS_ERROR_NONE) { + if (error != MMS_ERROR_NONE) + { printf("Delete file failed: (ERROR %i)\n", error); returnCode = error; } - else { + else + { printf("File deleted\n"); } } @@ -521,4 +550,3 @@ exit: return returnCode; } - diff --git a/examples/rsv_publisher_example/r_sv_publisher_example.c b/examples/rsv_publisher_example/r_sv_publisher_example.c index e4dad561..30c74dd7 100644 --- a/examples/rsv_publisher_example/r_sv_publisher_example.c +++ b/examples/rsv_publisher_example/r_sv_publisher_example.c @@ -21,8 +21,8 @@ main(int argc, char** argv) { RSession rSession = RSession_create(); - if (rSession) { - + if (rSession) + { /* Call RSession_setLocalAddress to use a particular interface to send the R-GOOSE messages */ //RSession_setLocalAddress(rSession, "169.254.110.126", -1); RSession_setRemoteAddress(rSession, "230.0.10.10", 102); @@ -32,8 +32,8 @@ main(int argc, char** argv) uint32_t activeKeyId = 1; uint64_t nextKeyChangeTime = Hal_getTimeInMs() + 5000; - if (svPublisher) { - + if (svPublisher) + { signal(SIGINT, sigint_handler); char* key1 = "0123456789ABCDEF"; @@ -63,7 +63,8 @@ main(int argc, char** argv) RSession_start(rSession); - while (running) { + while (running) + { Timestamp ts; Timestamp_clearFlags(&ts); Timestamp_setTimeInMilliseconds(&ts, Hal_getTimeInMs()); @@ -84,7 +85,8 @@ main(int argc, char** argv) SVPublisher_publish(svPublisher); - if (Hal_getTimeInMs() >= nextKeyChangeTime) { + if (Hal_getTimeInMs() >= nextKeyChangeTime) + { /* change key */ if (activeKeyId == 1) @@ -101,14 +103,15 @@ main(int argc, char** argv) SVPublisher_destroy(svPublisher); } - else { + else + { printf("Failed to create SV publisher\n"); } RSession_destroy(rSession); } - else { + else + { printf("Failed to create remote session instance\n"); } - }