Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,23 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
/* Fit a call sign on a four-character cargo tag. Default CMOC runtime. */
|
||||
#include <cmoc.h>
|
||||
|
||||
static int setTag(char *tag, size_t capacity, const char *name)
|
||||
{
|
||||
size_t length = strlen(name);
|
||||
if (length >= capacity)
|
||||
return 0; /* Leave the previous tag intact. */
|
||||
memcpy(tag, name, length + 1); /* Copy the terminating zero as well. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char tag[5] = "";
|
||||
if (!setTag(tag, sizeof(tag), "MARS"))
|
||||
return 1;
|
||||
printf("TAG: %s, LETTERS: %u\n", tag, (unsigned) strlen(tag));
|
||||
if (!setTag(tag, sizeof(tag), "EARTH") && strcmp(tag, "MARS") == 0)
|
||||
printf("EARTH TOO LONG. KEPT %s\n", tag);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user