2 This file is part of catta.
4 catta is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 catta is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
12 Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with catta; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 #include <catta/error.h>
28 #include <catta/watch.h>
29 #include <catta/simple-watch.h>
30 #include <catta/malloc.h>
31 #include <catta/alternative.h>
32 #include <catta/timeval.h>
34 #include <catta/core.h>
35 #include <catta/log.h>
36 #include <catta/publish.h>
37 #include <catta/lookup.h>
39 static CattaSEntryGroup *group = NULL;
41 static void server_callback(CattaServer *s, CattaServerState state, CATTA_GCC_UNUSED void* userdata) {
43 catta_log_debug("server state: %i", state);
45 if (state == CATTA_SERVER_RUNNING) {
48 group = catta_s_entry_group_new(s, NULL, NULL);
51 ret = catta_server_add_service(s, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, "foo", "_http._tcp", NULL, NULL, 80, "test1", NULL);
52 assert(ret == CATTA_OK);
54 catta_s_entry_group_commit(group);
58 static void modify_txt_callback(CATTA_GCC_UNUSED CattaTimeout *e, void *userdata) {
60 CattaServer *s = userdata;
62 catta_log_debug("modifying");
64 ret = catta_server_update_service_txt(s, group, CATTA_IF_UNSPEC, CATTA_PROTO_UNSPEC, 0, "foo", "_http._tcp", NULL, "test2", NULL);
65 assert(ret == CATTA_OK);
68 int main(CATTA_GCC_UNUSED int argc, CATTA_GCC_UNUSED char *argv[]) {
69 CattaSimplePoll *simple_poll;
70 const CattaPoll *poll_api;
73 CattaServerConfig config;
75 simple_poll = catta_simple_poll_new();
78 poll_api = catta_simple_poll_get(simple_poll);
81 catta_server_config_init(&config);
82 config.publish_domain = config.publish_workstation = config.use_ipv6 = config.publish_hinfo = 0;
83 server = catta_server_new(poll_api, &config, server_callback, NULL, NULL);
85 catta_server_config_free(&config);
87 poll_api->timeout_new(poll_api, catta_elapse_time(&tv, 1000*10, 0), modify_txt_callback, server);
89 catta_simple_poll_loop(simple_poll);