]> git.tuebingen.mpg.de Git - osl.git/blobdiff - osl.c
Always compile with -fvisibility=hidden.
[osl.git] / osl.c
diff --git a/osl.c b/osl.c
index ded1e5327cd8bb175d629cf89820eeccb06b01ab..3ec2f549e2d3ed916d1c300455f81519dc6f9544 100644 (file)
--- a/osl.c
+++ b/osl.c
@@ -176,16 +176,13 @@ static ssize_t write_all(int fd, const void *buf, size_t size)
  * \param buf The buffer to write to the file.
  * \param size The size of \a buf.
  *
- * \return Positive on success, negative on errors. Possible errors include:
- * any errors from para_open() or para_write().
- *
- * \sa para_open(), para_write().
+ * \return Standard.
  */
-int para_write_file(const char *filename, const void *buf, size_t size)
+static int write_file(const char *filename, const void *buf, size_t size)
 {
        int ret, fd;
 
-       ret = para_open(filename, O_WRONLY | O_CREAT | O_EXCL, 0644);
+       ret = osl_open(filename, O_WRONLY | O_CREAT | O_EXCL, 0644);
        if (ret < 0)
                return ret;
        fd = ret;
@@ -204,7 +201,7 @@ static int append_file(const char *filename, char *header, size_t header_size,
        int ret, fd;
 
 //     DEBUG_LOG("appending %zu  + %zu bytes\n", header_size, data_size);
-       ret = para_open(filename, O_WRONLY | O_CREAT | O_APPEND, 0644);
+       ret = osl_open(filename, O_WRONLY | O_CREAT | O_APPEND, 0644);
        if (ret < 0)
                return ret;
        fd = ret;
@@ -230,71 +227,6 @@ out:
        return ret;
 }
 
-/**
- * Traverse the given directory recursively.
- *
- * \param dirname The directory to traverse.
- * \param func The function to call for each entry.
- * \param private_data Pointer to an arbitrary data structure.
- *
- * For each regular file under \a dirname, the supplied function \a func is
- * called.  The full path of the regular file and the \a private_data pointer
- * are passed to \a func. Directories for which the calling process has no
- * permissions to change to are silently ignored.
- *
- * \return Standard.
- */
-int for_each_file_in_dir(const char *dirname,
-               int (*func)(const char *, void *), void *private_data)
-{
-       DIR *dir;
-       struct dirent *entry;
-       int cwd_fd, ret2, ret = para_opendir(dirname, &dir, &cwd_fd);
-
-       if (ret < 0)
-               return ret == -ERRNO_TO_ERROR(EACCES)? 1 : ret;
-       /* scan cwd recursively */
-       while ((entry = readdir(dir))) {
-               mode_t m;
-               char *tmp;
-               struct stat s;
-
-               if (!strcmp(entry->d_name, "."))
-                       continue;
-               if (!strcmp(entry->d_name, ".."))
-                       continue;
-               if (lstat(entry->d_name, &s) == -1)
-                       continue;
-               m = s.st_mode;
-               if (!S_ISREG(m) && !S_ISDIR(m))
-                       continue;
-               tmp = make_message("%s/%s", dirname, entry->d_name);
-               ret = -ERRNO_TO_ERROR(ENOMEM);
-               if (!tmp)
-                       goto out;
-               if (!S_ISDIR(m)) {
-                       ret = func(tmp, private_data);
-                       free(tmp);
-                       if (ret < 0)
-                               goto out;
-                       continue;
-               }
-               /* directory */
-               ret = for_each_file_in_dir(tmp, func, private_data);
-               free(tmp);
-               if (ret < 0)
-                       goto out;
-       }
-       ret = 1;
-out:
-       closedir(dir);
-       ret2 = para_fchdir(cwd_fd);
-       if (ret2 < 0 && ret >= 0)
-               ret = ret2;
-       close(cwd_fd);
-       return ret;
-}
-
 static int verify_name(const char *name)
 {
        if (!name)
@@ -714,7 +646,7 @@ static int create_table_index(struct osl_table *t)
        assert(offset = size);
        filename = index_filename(t->desc);
        if (filename)
-               ret = para_write_file(filename, buf, size);
+               ret = write_file(filename, buf, size);
        else
                ret = -ERRNO_TO_ERROR(ENOMEM);
        free(buf);
@@ -729,7 +661,7 @@ static int create_table_index(struct osl_table *t)
  *
  * \return Standard.
  */
-int osl_create_table(const struct osl_table_description *desc)
+__export int osl_create_table(const struct osl_table_description *desc)
 {
        const struct osl_column_description *cd;
        char *table_dir = NULL, *filename;
@@ -761,7 +693,7 @@ int osl_create_table(const struct osl_table_description *desc)
                        goto out;
                INFO_LOG("filename: %s\n", filename);
                if (cd->storage_type == OSL_MAPPED_STORAGE) {
-                       ret = para_open(filename, O_RDWR | O_CREAT | O_EXCL,
+                       ret = osl_open(filename, O_RDWR | O_CREAT | O_EXCL,
                                0644);
                        free(filename);
                        if (ret < 0)
@@ -1180,7 +1112,7 @@ void clear_rbtrees(struct osl_table *t)
  *
  * \sa osl_open_table(), unmap_table().
  */
-int osl_close_table(struct osl_table *t, enum osl_close_flags flags)
+__export int osl_close_table(struct osl_table *t, enum osl_close_flags flags)
 {
        int ret;
 
@@ -1291,7 +1223,7 @@ int init_rbtrees(struct osl_table *t)
  *
  * \return Standard.
  */
-int osl_open_table(const struct osl_table_description *table_desc,
+__export int osl_open_table(const struct osl_table_description *table_desc,
                struct osl_table **result)
 {
        int i, ret;
@@ -1368,7 +1300,7 @@ static int write_disk_storage_file(const struct osl_table *t, unsigned col_num,
        filename = disk_storage_path(t, col_num, ds_name);
        if (!filename)
                return -ERRNO_TO_ERROR(ENOMEM);
-       ret = para_write_file(filename, obj->data, obj->size);
+       ret = write_file(filename, obj->data, obj->size);
        free(filename);
        return ret;
 }
@@ -1497,7 +1429,7 @@ static int delete_disk_storage_file(const struct osl_table *t, unsigned col_num,
  *
  * \sa struct osl_table_description, osl_compare_func, osl_add_row().
  */
-int osl_add_and_get_row(struct osl_table *t, struct osl_object *objects,
+__export int osl_add_and_get_row(struct osl_table *t, struct osl_object *objects,
                struct osl_row **row)
 {
        int i, ret;
@@ -1649,7 +1581,7 @@ out:
  *
  * This is equivalent to osl_add_and_get_row(t, objects, NULL).
  */
-int osl_add_row(struct osl_table *t, struct osl_object *objects)
+__export int osl_add_row(struct osl_table *t, struct osl_object *objects)
 {
        return osl_add_and_get_row(t, objects, NULL);
 }
@@ -1671,7 +1603,7 @@ int osl_add_row(struct osl_table *t, struct osl_object *objects)
  *
  * \sa osl_storage_type, osl_open_disk_object().
  */
-int osl_get_object(const struct osl_table *t, const struct osl_row *r,
+__export int osl_get_object(const struct osl_table *t, const struct osl_row *r,
        unsigned col_num, struct osl_object *object)
 {
        const struct osl_column_description *cd;
@@ -1718,7 +1650,7 @@ static int mark_mapped_object_invalid(const struct osl_table *t,
  * \return Positive on success, negative on errors. Possible errors include:
  * \p E_BAD_TABLE, errors returned by osl_get_object().
  */
-int osl_del_row(struct osl_table *t, struct osl_row *row)
+__export int osl_del_row(struct osl_table *t, struct osl_row *row)
 {
        struct osl_row *r = row;
        int i, ret;
@@ -1792,7 +1724,7 @@ static int check_rbtree_col(const struct osl_table *t, unsigned col_num,
  *
  * \sa osl_storage_flags
  */
-int osl_get_row(const struct osl_table *t, unsigned col_num,
+__export int osl_get_row(const struct osl_table *t, unsigned col_num,
                const struct osl_object *obj, struct osl_row **result)
 {
        int ret;
@@ -1870,7 +1802,7 @@ static int rbtree_loop_reverse(struct osl_column *col,  void *private_data,
  *
  * \sa osl_storage_flags, osl_rbtree_loop_reverse(), osl_compare_func.
  */
-int osl_rbtree_loop(const struct osl_table *t, unsigned col_num,
+__export int osl_rbtree_loop(const struct osl_table *t, unsigned col_num,
        void *private_data, osl_rbtree_loop_func *func)
 {
        struct osl_column *col;
@@ -1896,7 +1828,7 @@ int osl_rbtree_loop(const struct osl_table *t, unsigned col_num,
  *
  * \sa osl_rbtree_loop().
  */
-int osl_rbtree_loop_reverse(const struct osl_table *t, unsigned col_num,
+__export int osl_rbtree_loop_reverse(const struct osl_table *t, unsigned col_num,
        void *private_data, osl_rbtree_loop_func *func)
 {
        struct osl_column *col;
@@ -1969,7 +1901,7 @@ out:
  *
  * \return Standard
  */
-int osl_update_object(struct osl_table *t, const struct osl_row *r,
+__export int osl_update_object(struct osl_table *t, const struct osl_row *r,
                unsigned col_num, struct osl_object *obj)
 {
        struct osl_column *col;
@@ -2070,7 +2002,7 @@ int osl_update_object(struct osl_table *t, const struct osl_row *r,
  *
  * \sa osl_get_object(), osl_storage_type, osl_close_disk_object().
  */
-int osl_open_disk_object(const struct osl_table *t, const struct osl_row *r,
+__export int osl_open_disk_object(const struct osl_table *t, const struct osl_row *r,
                unsigned col_num, struct osl_object *obj)
 {
        const struct osl_column_description *cd;
@@ -2105,7 +2037,7 @@ int osl_open_disk_object(const struct osl_table *t, const struct osl_row *r,
  *
  * \sa para_munmap().
  */
-int osl_close_disk_object(struct osl_object *obj)
+__export int osl_close_disk_object(struct osl_object *obj)
 {
        return para_munmap(obj->data, obj->size);
 }
@@ -2120,7 +2052,7 @@ int osl_close_disk_object(struct osl_object *obj)
  *
  * \return Positive on success, \p -E_BAD_TABLE if \a t is \p NULL.
  */
-int osl_get_num_rows(const struct osl_table *t, unsigned *num_rows)
+__export int osl_get_num_rows(const struct osl_table *t, unsigned *num_rows)
 {
        if (!t)
                return -E_BAD_TABLE;
@@ -2145,7 +2077,7 @@ int osl_get_num_rows(const struct osl_table *t, unsigned *num_rows)
  *
  * \sa osl_get_nth_row().
  */
-int osl_get_rank(const struct osl_table *t, struct osl_row *r,
+__export int osl_get_rank(const struct osl_table *t, struct osl_row *r,
                unsigned col_num, unsigned *rank)
 {
        struct osl_object obj;
@@ -2187,7 +2119,7 @@ int osl_get_rank(const struct osl_table *t, struct osl_row *r,
  * \sa osl_storage_flags, osl_compare_func, osl_get_row(),
  * osl_rbtree_last_row(), osl_rbtree_first_row(), osl_get_rank().
  */
-int osl_get_nth_row(const struct osl_table *t, unsigned col_num,
+__export int osl_get_nth_row(const struct osl_table *t, unsigned col_num,
                unsigned n, struct osl_row **result)
 {
        struct osl_column *col;
@@ -2228,7 +2160,7 @@ int osl_get_nth_row(const struct osl_table *t, unsigned col_num,
  *
  * \sa osl_get_nth_row(), osl_rbtree_last_row().
  */
-int osl_rbtree_first_row(const struct osl_table *t, unsigned col_num,
+__export int osl_rbtree_first_row(const struct osl_table *t, unsigned col_num,
                struct osl_row **result)
 {
        return osl_get_nth_row(t, col_num, 1, result);
@@ -2249,7 +2181,7 @@ int osl_rbtree_first_row(const struct osl_table *t, unsigned col_num,
  *
  * \sa osl_get_nth_row(), osl_rbtree_first_row().
  */
-int osl_rbtree_last_row(const struct osl_table *t, unsigned col_num,
+__export int osl_rbtree_last_row(const struct osl_table *t, unsigned col_num,
                struct osl_row **result)
 {
        unsigned num_rows;