Skip to content

Commit

Permalink
Merge pull request #1 from BHare1985/zproject-skeletons
Browse files Browse the repository at this point in the history
Regenerate .c and .h
  • Loading branch information
BHare1985 authored Apr 5, 2024
2 parents cc8adfe + 9911fab commit c03394f
Show file tree
Hide file tree
Showing 12 changed files with 292 additions and 135 deletions.
16 changes: 8 additions & 8 deletions include/filemq.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/* =========================================================================
filemq - An updated attempt at FileMQ.
filemq - A FileMQ server and client
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
file, You can obtain one at http://mozilla.org/MPL/2.0/.
=========================================================================
*/

#ifndef __FILEMQ_H_INCLUDED__
#define __FILEMQ_H_INCLUDED__
#ifndef FILEMQ_H_H_INCLUDED
#define FILEMQ_H_H_INCLUDED

// Include the project library file
#include "filemq_library.h"
Expand Down
28 changes: 14 additions & 14 deletions include/fmq_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
* The XML model used for this code generation: fmq_client.xml, or
* The code generation script that built this file: zproto_client_c
************************************************************************
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
file, You can obtain one at http://mozilla.org/MPL/2.0/.
=========================================================================
*/

Expand Down Expand Up @@ -64,25 +64,25 @@ FILEMQ_EXPORT zsock_t *
FILEMQ_EXPORT bool
fmq_client_connected (fmq_client_t *self);

// Connect to server endpoint, with specified timeout in msecs (zero means wait
// forever). Connect succeeds if connection is successful.
// Connect to server endpoint, with specified timeout in msecs (zero means wait
// forever). Connect succeeds if connection is successful.
// Returns >= 0 if successful, -1 if interrupted.
FILEMQ_EXPORT uint8_t
FILEMQ_EXPORT uint8_t
fmq_client_connect (fmq_client_t *self, const char *endpoint, uint32_t timeout);

// Subscribe to a directory on the server, directory specified by path.
// Subscribe to a directory on the server, directory specified by path.
// Returns >= 0 if successful, -1 if interrupted.
FILEMQ_EXPORT uint8_t
FILEMQ_EXPORT uint8_t
fmq_client_subscribe (fmq_client_t *self, const char *path);

// Tell the api where to store files. This should be done before subscribing to
// anything.
// Tell the api where to store files. This should be done before subscribing to
// anything.
// Returns >= 0 if successful, -1 if interrupted.
FILEMQ_EXPORT uint8_t
FILEMQ_EXPORT uint8_t
fmq_client_set_inbox (fmq_client_t *self, const char *path);

// Return last received status
FILEMQ_EXPORT uint8_t
FILEMQ_EXPORT uint8_t
fmq_client_status (fmq_client_t *self);

// Return last received reason
Expand Down
14 changes: 7 additions & 7 deletions include/fmq_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
* The XML model used for this code generation: fmq_msg.xml, or
* The code generation script that built this file: zproto_codec_c
************************************************************************
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
file, You can obtain one at http://mozilla.org/MPL/2.0/.
=========================================================================
*/

Expand Down Expand Up @@ -95,11 +95,11 @@ typedef struct _fmq_msg_t fmq_msg_t;
#endif

// @interface
// Create a new empty fmq_msg
fmq_msg_t *
// Create a new empty fmq_msg
fmq_msg_new (void);

// Destroy a fmq_msg instance
// Destroy the fmq_msg
void
fmq_msg_destroy (fmq_msg_t **self_p);

Expand Down
14 changes: 8 additions & 6 deletions include/fmq_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
* The XML model used for this code generation: fmq_server.xml, or
* The code generation script that built this file: zproto_server_c
************************************************************************
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
file, You can obtain one at http://mozilla.org/MPL/2.0/.
=========================================================================
*/

Expand Down Expand Up @@ -45,7 +45,7 @@ extern "C" {
// zstr_send (fmq_server, "VERBOSE");
//
// Bind fmq_server to specified endpoint. TCP endpoints may specify
// the port number as "*" to aquire an ephemeral port:
// the port number as "*" to acquire an ephemeral port:
//
// zstr_sendx (fmq_server, "BIND", endpoint, NULL);
//
Expand Down Expand Up @@ -80,12 +80,14 @@ extern "C" {
//
// This is the fmq_server constructor as a zactor_fn:
//

FILEMQ_EXPORT void
fmq_server (zsock_t *pipe, void *args);

// Self test of this class
FILEMQ_EXPORT void
fmq_server_test (bool verbose);

// @end

#ifdef __cplusplus
Expand Down
55 changes: 50 additions & 5 deletions src/filemq_client.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,51 @@
/* =========================================================================
filemq_client - Very simple client
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
=========================================================================
*/

/*
@header
filemq_client - Very simple client
@discuss
@end
*/

#include "filemq_classes.h"

int main (int argc, char *argv [])
{
fmq_client_t *client;
int rc;
zsock_t *msgpipe;
zpoller_t *poller;
bool verbose = false;
int argn;
for (argn = 1; argn < argc; argn++) {
if (streq (argv [argn], "--help")
|| streq (argv [argn], "-h")) {
puts ("filemq_client inbox-dir [options] ...");
puts (" --verbose / -v verbose test output");
puts (" --help / -h this information");
return 0;
}
else
if (streq (argv [argn], "--verbose")
|| streq (argv [argn], "-v"))
verbose = true;
else {
printf ("Unknown option: %s\n", argv [argn]);
return 1;
}
}

fmq_client_t *client;
int rc;
zsock_t *msgpipe;
zpoller_t *poller;

if (argc < 2) {
puts ("usage: filemq_client inbox-dir");
Expand All @@ -16,7 +55,11 @@ int main (int argc, char *argv [])
// Create the client
client = fmq_client_new ();
assert (client);
fmq_client_verbose = 1;

if (verbose){
zsys_info ("filemq_client - Very simple client");
fmq_client_verbose = 1;
}

rc = fmq_client_connect (client, "tcp://localhost:5670", 1000);
assert (rc == 0);
Expand Down Expand Up @@ -51,9 +94,11 @@ int main (int argc, char *argv [])
break;
}
}

puts ("interrupted");

zpoller_destroy (&poller);
fmq_client_destroy (&client);

return 0;
}
51 changes: 46 additions & 5 deletions src/filemq_server.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,64 @@
/* =========================================================================
filemq_server - Very simple server
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
=========================================================================
*/

/*
@header
filemq_server - Very simple server
@discuss
@end
*/

#include "filemq_classes.h"

int main (int argc, char *argv [])
{
zactor_t *server;
if (argc < 2) {
puts ("usage: filemq_server publish-from");
return 0;
bool verbose = false;
int argn;
for (argn = 1; argn < argc; argn++) {
if (streq (argv [argn], "--help")
|| streq (argv [argn], "-h")) {
puts ("filemq_server publish-from [options] ...");
puts (" --verbose / -v verbose test output");
puts (" --help / -h this information");
return 0;
}
else
if (streq (argv [argn], "--verbose")
|| streq (argv [argn], "-v"))
verbose = true;
else {
printf ("Unknown option: %s\n", argv [argn]);
return 1;
}
}

zactor_t *server;
server = zactor_new (fmq_server, "filemq_server");

//zstr_send (server, "VERBOSE");
if (verbose){
zsys_info ("filemq_server - Very simple server");
zstr_send (server, "VERBOSE");
}

zstr_sendx (server, "PUBLISH", argv [1], "/", NULL);
zstr_sendx (server, "BIND", "tcp://*:5670", NULL);

while (!zsys_interrupted)
zclock_sleep (1000);

puts ("interrupted");

zactor_destroy (&server);

return 0;
}
31 changes: 21 additions & 10 deletions src/fmq_client.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
/* =========================================================================
fmq_client - FILEMQ Client
fmq_client - FileMQ Client
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of FileMQ, a C implemenation of the protocol:
https://github.com/danriegsecker/filemq2.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
file, You can obtain one at http://mozilla.org/MPL/2.0/.
=========================================================================
*/

/*
@header
Description of class for man page.
fmq_client - FileMQ Client
@discuss
Detailed discussion of the class, if any.
@end
*/

// TODO: Change these to match your project's needs
#include "filemq_classes.h"

// Forward reference to method arguments structure
Expand Down Expand Up @@ -478,7 +476,20 @@ async_server_not_present (client_t *self)


// ---------------------------------------------------------------------------
// Selftest
// Self test of this class

// If your selftest reads SCMed fixture data, please keep it in
// src/selftest-ro; if your test creates filesystem objects, please
// do so under src/selftest-rw.
// The following pattern is suggested for C selftest code:
// char *filename = NULL;
// filename = zsys_sprintf ("%s/%s", SELFTEST_DIR_RO, "mytemplate.file");
// assert (filename);
// ... use the "filename" for I/O ...
// zstr_free (&filename);
// This way the same "filename" variable can be reused for many subtests.
#define SELFTEST_DIR_RO "src/selftest-ro"
#define SELFTEST_DIR_RW "src/selftest-rw"

void
fmq_client_test (bool verbose)
Expand Down
Loading

0 comments on commit c03394f

Please sign in to comment.