blob: 6a5a0a09b1a19bf97136fe59e396bc7b317074ac [file] [log] [blame]
Zhenkai Zhue25def92012-03-12 16:39:25 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
Chaoyi Bian3e1eb162012-04-03 16:59:32 -070019 * Chaoyi Bian <bcy@pku.edu.cn>
Zhenkai Zhue25def92012-03-12 16:39:25 -070020 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
22
23#ifndef SYNC_APP_SOCKET_C_H
24#define SYNC_APP_SOCKET_C_H
25
Chaoyi Bian9d8768a2012-03-14 17:23:36 -070026#ifdef __cplusplus
Zhenkai Zhue25def92012-03-12 16:39:25 -070027extern "C" {
Chaoyi Bian9d8768a2012-03-14 17:23:36 -070028#endif
Chaoyi Bian2f2d6412012-06-04 16:53:08 -070029
Chaoyi Bian9d8768a2012-03-14 17:23:36 -070030 typedef struct SyncAppSocketStruct SyncAppSocketStruct;
Chaoyi Bian2f2d6412012-06-04 16:53:08 -070031
32 struct MissingDataInfoC
33 {
34 const char *prefix;
35 int session;
36 int low;
37 int high;
38 };
Zhenkai Zhue25def92012-03-12 16:39:25 -070039
Chaoyi Bian2f2d6412012-06-04 16:53:08 -070040 SyncAppSocketStruct *create_sync_app_socket(const char *prefix,
41 void (*updatecallback)(const struct MissingDataInfo*, const int, const SyncAppSocketStruct*),
42 void (*removecallback)(const char *));
Alexander Afanasyev03a58b72012-03-12 18:11:56 -070043 void delete_sync_app_socket(SyncAppSocketStruct **sock);
Chaoyi Bian9d8768a2012-03-14 17:23:36 -070044 int sync_app_socket_publish(SyncAppSocketStruct *sock, const char *prefix, int session, const char *buf, int freshness);
Alexander Afanasyev03a58b72012-03-12 18:11:56 -070045 void sync_app_socket_remove(SyncAppSocketStruct *sock, const char *prefix);
Chaoyi Bian2f2d6412012-06-04 16:53:08 -070046 void sync_app_socket_fetch(SyncAppSocketStruct *sock, const char *prefix, int session, int seq,
47 void (*callback)(const char*, const char*), int retry = 0);
Chaoyi Bian9d8768a2012-03-14 17:23:36 -070048#ifdef __cplusplus
Zhenkai Zhue25def92012-03-12 16:39:25 -070049}
Chaoyi Bian9d8768a2012-03-14 17:23:36 -070050#endif
Zhenkai Zhue25def92012-03-12 16:39:25 -070051
52#endif // SYNC_APP_SOCKET_C_H