summaryrefslogtreecommitdiff
path: root/tests/server/util.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-04-14 11:19:12 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-04-14 13:04:10 +0200
commit5e855bbd18f84a02c951be7cac6188276818cdac (patch)
treecc0f2ce746ad8bcd3c0b95dac31eaa9606a0333a /tests/server/util.c
parent675f5fb66fd30ff2ea0bfdf455430fe1f76e42a6 (diff)
downloadcurl-5e855bbd18f84a02c951be7cac6188276818cdac.tar.gz
tests: add the mqtt test server mqttd
Diffstat (limited to 'tests/server/util.c')
-rw-r--r--tests/server/util.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/server/util.c b/tests/server/util.c
index 65d491c0b..169ca5bcb 100644
--- a/tests/server/util.c
+++ b/tests/server/util.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -284,6 +284,20 @@ int write_pidfile(const char *filename)
return 1; /* success */
}
+/* store the used port number in a file */
+int write_portfile(const char *filename, int port)
+{
+ FILE *portfile = fopen(filename, "wb");
+ if(!portfile) {
+ logmsg("Couldn't write port file: %s %s", filename, strerror(errno));
+ return 0; /* fail */
+ }
+ fprintf(portfile, "%d\n", port);
+ fclose(portfile);
+ logmsg("Wrote port %d to %s", port, filename);
+ return 1; /* success */
+}
+
void set_advisor_read_lock(const char *filename)
{
FILE *lockfile;