00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CCN_SyncUtil
00021 #define CCN_SyncUtil
00022
00023 #include "IndexSorter.h"
00024 #include <ccn/ccn.h>
00025
00026 struct SyncLongHashStruct;
00027 struct SyncRootStruct;
00028 struct SyncBaseStruct;
00029
00030
00031 void
00032 SyncNoteErr(const char *msg);
00033
00034 int
00035 SyncSetDecodeErr(struct ccn_buf_decoder *d, int val);
00036
00037 int
00038 SyncCheckDecodeErr(struct ccn_buf_decoder *d);
00039
00040
00041
00042
00043
00044 int64_t
00045 SyncCurrentTime(void);
00046
00047
00048 int64_t
00049 SyncDeltaTime(int64_t mt1, int64_t mt2);
00050
00051
00052
00053 struct ccn_buf_decoder *
00054 SyncInitDecoderFromCharbufRange(struct ccn_buf_decoder *d,
00055 const struct ccn_charbuf *cb,
00056 ssize_t start, ssize_t stop);
00057
00058 struct ccn_buf_decoder *
00059 SyncInitDecoderFromCharbuf(struct ccn_buf_decoder *d,
00060 const struct ccn_charbuf *cb,
00061 ssize_t start);
00062
00063
00064
00065 int
00066 SyncDecodeHexDigit(char c);
00067
00068
00069
00070 int
00071 SyncDecodeUriChar(char c);
00072
00073 char *
00074 SyncHexStr(const unsigned char *cp, size_t sz);
00075
00076
00077
00078
00079
00080 int
00081 SyncNoteFailed(struct SyncRootStruct *root, char *where, char *why, int line);
00082
00083 void
00084 SyncNoteSimple(struct SyncRootStruct *root, char *where, char *s1);
00085
00086 void
00087 SyncNoteSimple2(struct SyncRootStruct *root, char *where, char *s1, char *s2);
00088
00089 void
00090 SyncNoteSimple3(struct SyncRootStruct *root, char *where, char *s1, char *s2, char *s3);
00091
00092 void
00093 SyncNoteUri(struct SyncRootStruct *root, char *where, char *why, struct ccn_charbuf *name);
00094
00095 void
00096 SyncNoteUriBase(struct SyncBaseStruct *base, char *where, char *why, struct ccn_charbuf *name);
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 int
00108 SyncCmpNamesInner(struct ccn_buf_decoder *xx, struct ccn_buf_decoder *yy);
00109
00110
00111
00112
00113
00114
00115 #define SYNC_BAD_CMP (-2)
00116 int
00117 SyncCmpNames(const struct ccn_charbuf *cbx, const struct ccn_charbuf *cby);
00118
00119
00120
00121
00122
00123 int
00124 SyncIsName(const struct ccn_charbuf *cb);
00125
00126
00127
00128
00129 int
00130 SyncComponentCount(const struct ccn_charbuf *name);
00131
00132
00133
00134
00135
00136
00137
00138
00139 int
00140 SyncPatternMatch(const struct ccn_charbuf *pattern,
00141 const struct ccn_charbuf *name,
00142 int start);
00143
00144
00145
00146
00147
00148
00149 int
00150 SyncPrefixMatch(const struct ccn_charbuf *prefix,
00151 const struct ccn_charbuf *name,
00152 int start);
00153
00154
00155
00156
00157
00158 int
00159 SyncComponentMatch(const struct ccn_charbuf *x,
00160 const struct ccn_charbuf *y);
00161
00162
00163
00164
00165
00166
00167 int
00168 SyncGetComponentPtr(const struct ccn_charbuf *src, int comp,
00169 const unsigned char **xp, ssize_t *xs);
00170
00171
00172
00173
00174
00175
00176 int
00177 SyncAppendAllComponents(struct ccn_charbuf *dst,
00178 const struct ccn_charbuf *src);
00179
00180
00181
00182
00183
00184
00185 struct ccn_charbuf *
00186 SyncNameForIndexbuf(const unsigned char *buf, struct ccn_indexbuf *comps);
00187
00188
00189
00190
00191
00192
00193 struct ccn_charbuf *
00194 SyncUriForName(struct ccn_charbuf *name);
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 void
00209 SyncGetHashPtr(const struct ccn_buf_decoder *hd,
00210 const unsigned char **xp, ssize_t *xs);
00211
00212 ssize_t
00213 SyncCmpHashesRaw(const unsigned char *xp, ssize_t xs,
00214 const unsigned char *yp, ssize_t ys);
00215
00216
00217
00218 void
00219 SyncAccumHashRaw(struct SyncLongHashStruct *hp,
00220 const unsigned char *xp, size_t xs);
00221
00222
00223
00224
00225 void
00226 SyncAccumHashInner(struct SyncLongHashStruct *hp,
00227 const struct ccn_buf_decoder *d);
00228
00229
00230
00231
00232 void
00233 SyncAccumHash(struct SyncLongHashStruct *hp, const struct ccn_charbuf *cb);
00234
00235
00236 extern struct ccn_charbuf *
00237 SyncLongHashToBuf(const struct SyncLongHashStruct *hp);
00238
00239
00240
00241 uint32_t
00242 SyncSmallHash(const unsigned char * xp, ssize_t xs);
00243
00244
00245
00246
00247
00248
00249
00250 int
00251 SyncAppendTaggedNumber(struct ccn_charbuf *cb,
00252 enum ccn_dtag dtag,
00253 unsigned val);
00254
00255
00256 int
00257 SyncAppendRandomBytes(struct ccn_charbuf *cb, int n);
00258
00259
00260 int
00261 SyncAppendRandomHash(struct ccn_charbuf *cb, int n);
00262
00263
00264 int
00265 SyncAppendRandomName(struct ccn_charbuf *cb, int nComp, int maxCompLen);
00266
00267
00268
00269
00270
00271 int
00272 SyncAppendElementInner(struct ccn_charbuf *cb, struct ccn_buf_decoder *d);
00273
00274
00275
00276
00277 int
00278 SyncAppendElement(struct ccn_charbuf *dst, const struct ccn_charbuf *src);
00279
00280 struct ccn_charbuf *
00281 SyncExtractName(struct ccn_buf_decoder *d);
00282
00283 struct ccn_charbuf *
00284 SyncCopyName(const struct ccn_charbuf *name);
00285
00286
00287
00288
00289
00290 unsigned
00291 SyncParseUnsigned(struct ccn_buf_decoder *d, enum ccn_dtag dtag);
00292
00293 ssize_t
00294 SyncParseHash(struct ccn_buf_decoder *d);
00295
00296 ssize_t
00297 SyncParseName(struct ccn_buf_decoder *d);
00298
00299
00300
00301
00302
00303 struct SyncNameAccumEntry {
00304 struct ccn_charbuf *name;
00305 intmax_t data;
00306 };
00307
00308 struct SyncNameAccum {
00309 int len;
00310 int lim;
00311 struct SyncNameAccumEntry *ents;
00312 };
00313
00314
00315
00316
00317 struct SyncNameAccum *
00318 SyncAllocNameAccum(int lim);
00319
00320
00321
00322
00323
00324 struct SyncNameAccum *
00325 SyncFreeNameAccum(struct SyncNameAccum *na);
00326
00327
00328
00329
00330
00331 struct SyncNameAccum *
00332 SyncFreeNameAccumAndNames(struct SyncNameAccum *na);
00333
00334
00335
00336
00337
00338 int
00339 SyncNameAccumSorter(IndexSorter_Base base,
00340 IndexSorter_Index x, IndexSorter_Index y);
00341
00342
00343
00344
00345
00346 int
00347 SyncNameAccumAppend(struct SyncNameAccum *na,
00348 struct ccn_charbuf *name,
00349 intmax_t data);
00350
00351
00352
00353
00354
00355
00356
00357 struct ccn_charbuf *
00358 SyncNameAccumCanon(struct SyncNameAccum *na,
00359 const struct ccn_charbuf *name);
00360
00361 struct SyncNodeAccum {
00362 int len;
00363 int lim;
00364 struct SyncNodeComposite **ents;
00365 };
00366
00367 struct SyncNodeAccum *
00368 SyncAllocNodeAccum(int lim);
00369
00370 struct SyncNodeAccum *
00371 SyncFreeNodeAccum(struct SyncNodeAccum *na);
00372
00373 void
00374 SyncAccumNode(struct SyncNodeAccum *na, struct SyncNodeComposite *nc);
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 struct ccn_charbuf *
00386 SyncGenInterest(struct ccn_charbuf *name,
00387 int scope,
00388 int lifetime,
00389 int maxSuffix,
00390 int childPref,
00391 struct SyncNameAccum *excl);
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401 struct ccn_charbuf *
00402 SyncNameForLocalNode(struct SyncRootStruct *root, struct ccn_charbuf *hash);
00403
00404
00405
00406
00407
00408
00409 int
00410 SyncPointerToContent(struct ccn_charbuf *cb, struct ccn_parsed_ContentObject *pco,
00411 const unsigned char **xp, size_t *xs);
00412
00413
00414
00415
00416
00417
00418 struct ccn_charbuf *
00419 SyncSignBuf(struct SyncBaseStruct *base,
00420 struct ccn_charbuf *cb,
00421 struct ccn_charbuf *name,
00422 long fresh, int flags);
00423
00424
00425
00426
00427
00428
00429
00430
00431 int
00432 SyncLocalRepoFetch(struct SyncBaseStruct *base,
00433 struct ccn_charbuf *name,
00434 struct ccn_charbuf *cb,
00435 struct ccn_parsed_ContentObject *pco);
00436
00437
00438
00439
00440
00441
00442 int
00443 SyncLocalRepoStore(struct SyncBaseStruct *base,
00444 struct ccn_charbuf *name,
00445 struct ccn_charbuf *content,
00446 int flags);
00447
00448 #endif
00449