Beispiel #1
0
    int WatchOverRepo(IntPtr h, string p, string t)
    {
        // this is a C# expansion of Egal.WatchOverRepo
        int    res;
        IntPtr prefix = Egal.ccn_charbuf_create();
        IntPtr topo   = Egal.ccn_charbuf_create();

        Egal.ccn_name_init(prefix);
        Egal.ccn_name_init(topo);

        res = Egal.ccn_name_from_uri(prefix, p);
        if (res < 0)
        {
            print("Prefix not right");
            return(res);
        }

        res = Egal.ccn_name_from_uri(topo, t);
        if (res < 0)
        {
            print("Topo not right");
            return(res);
        }

        int timeout = TIMEOUT;

        if (timeout < -1)
        {
            print("Timeout cannot be less than -1");
            return(-1);
        }
        timeout *= 1000;

        IntPtr slice = Egal.ccns_slice_create();

        Egal.ccns_slice_set_topo_prefix(slice, topo, prefix);

        IntPtr ccns = Egal.ccns_open(h, slice, WatchCallback, IntPtr.Zero, IntPtr.Zero);

        // ccns_close(&ccns, NULL, NULL);

        Egal.ccns_slice_destroy(ref slice);

        return(res);
    }
Beispiel #2
0
    int WriteSlice(IntPtr h, System.String p, System.String t)
    {
        // this is a C# expansion of Egal.WriteSlice
        int    res;
        IntPtr prefix = Egal.ccn_charbuf_create();
        IntPtr topo   = Egal.ccn_charbuf_create();

        Egal.ccn_name_init(prefix);
        Egal.ccn_name_init(topo);

        res = Egal.ccn_name_from_uri(prefix, p);
        if (res < 0)
        {
            print("Prefix not right");
            return(res);
        }

        res = Egal.ccn_name_from_uri(topo, t);
        if (res < 0)
        {
            print("Topo not right");
            return(res);
        }

        int timeout = TIMEOUT;

        if (timeout < -1)
        {
            print("Timeout cannot be less than -1");
            return(-1);
        }
        timeout *= 1000;

        IntPtr slice = Egal.ccns_slice_create();

        Egal.ccns_slice_set_topo_prefix(slice, topo, prefix);

        res = Egal.ccns_write_slice(h, slice, prefix);

        Egal.ccns_slice_destroy(ref slice); // after this, slice == 0

        return(res);
    }