JNIEXPORT void JNICALL Java_org_clearsilver_HDF__1setSymLink( JNIEnv *env, jclass objClass, jint hdf_obj_ptr, jstring j_hdf_name_src, jstring j_hdf_name_dest) { HDF *hdf = (HDF *)hdf_obj_ptr; NEOERR *err; const char *hdf_name_src; const char *hdf_name_dest; if (!j_hdf_name_src) { throwNullPointerException(env, "hdf_name_src argument was null"); return; } hdf_name_src = (*env)->GetStringUTFChars(env, j_hdf_name_src, 0); if (!j_hdf_name_dest) { throwNullPointerException(env, "hdf_name_dest argument was null"); return; } hdf_name_dest = (*env)->GetStringUTFChars(env, j_hdf_name_dest, 0); err = hdf_set_symlink(hdf, hdf_name_src, hdf_name_dest); (*env)->ReleaseStringUTFChars(env, j_hdf_name_src, hdf_name_src); (*env)->ReleaseStringUTFChars(env, j_hdf_name_dest, hdf_name_dest); if (err != STATUS_OK) { // Throw an exception jNeoErr(env, err); } }
static PyObject * p_hdf_set_symlink (PyObject *self, PyObject *args) { HDFObject *ho = (HDFObject *)self; PyObject *rv; char *src; char *dest; NEOERR *err; if (!PyArg_ParseTuple(args, "ss:setSymLink(src, dest)", &src, &dest)) return NULL; err = hdf_set_symlink (ho->data, src, dest); if (err) return p_neo_error(err); rv = Py_None; Py_INCREF(rv); return rv; }
int main(int argc, char *argv[]) { NEOERR *err; HDF *hdf; int x; char name[256]; char value[256]; double tstart = 0; err = hdf_init(&hdf); DIE_NOT_OK(err); err = hdf_set_value (hdf, "Beware", "1"); DIE_NOT_OK(err); err = hdf_set_value (hdf, "Beware.The", "2"); DIE_NOT_OK(err); err = hdf_set_valuef (hdf, "Beware.The.%s=%d", "Ides", 3); DIE_NOT_OK(err); err = hdf_set_value (hdf, "Beware.Off", "4"); DIE_NOT_OK(err); err = hdf_set_value (hdf, "Beware.The.Ides.Of", "5"); DIE_NOT_OK(err); err = hdf_set_value (hdf, "Beware.The.Butter", "6"); DIE_NOT_OK(err); err = hdf_set_attr (hdf, "Beware.The.Butter", "Lang", "en"); DIE_NOT_OK(err); err = hdf_set_attr (hdf, "Beware.The.Butter", "Lang", "1"); DIE_NOT_OK(err); err = hdf_set_attr (hdf, "Beware.The.Butter", "Lang", NULL); DIE_NOT_OK(err); err = hdf_read_file (hdf, "test.hdf"); DIE_NOT_OK(err); hdf_dump(hdf, NULL); x = hdf_get_int_value (hdf, "Beware.The.Ides", 0); if (x != 3) { ne_warn("hdf_get_int_value returned %d, expected 3", x); return -1; } /* test symlinks */ { const char *v; err = hdf_set_value(hdf, "Destination.Foo", "bar"); DIE_NOT_OK(err); err = hdf_set_symlink(hdf, "Symlink.baz", "Destination.Foo"); DIE_NOT_OK(err); v = hdf_get_value(hdf, "Symlink.baz", "notfound"); if (strcmp(v, "bar")) { ne_warn("hdf_get_value through symlink returned %s, expected bar", v); return -1; } err = hdf_set_value(hdf, "Symlink.baz", "newvalue"); DIE_NOT_OK(err); v = hdf_get_value(hdf, "Symlink.baz", "notfound"); if (strcmp(v, "newvalue")) { ne_warn("hdf_get_value through symlink returned %s, expected newvalue", v); return -1; } err = hdf_set_value(hdf, "Symlink.baz.too", "newtoo"); DIE_NOT_OK(err); v = hdf_get_value(hdf, "Symlink.baz.too", "newtoo"); if (strcmp(v, "newtoo")) { ne_warn("hdf_get_value through symlink returned %s, expected newtoo", v); return -1; } v = hdf_get_value(hdf, "Destination.Foo.too", "newtoo"); if (strcmp(v, "newtoo")) { ne_warn("hdf_get_value through symlink returned %s, expected newtoo", v); return -1; } } for (x = 0; x < 10000; x++) { rand_name(name, sizeof(name)); neo_rand_word(value, sizeof(value)); /* ne_warn("Setting %s = %s", name, value); */ err = hdf_set_value (hdf, name, value); DIE_NOT_OK(err); } tstart = ne_timef(); hdf_sort_obj(hdf, sortByName); ne_warn("sort took %5.5fs", ne_timef() - tstart); hdf_dump(hdf, NULL); hdf_destroy(&hdf); return 0; }