<commit_before>/*
 *	Copyright (C) 2006-2008 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; version 2.1 only. with the special
 * exception on linking described in file LICENSE.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * Inotify Ocaml binding - C glue
 */

#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/inotify.h>
#include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/custom.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include <caml/callback.h>

static int inotify_flag_table[] = {
        IN_ACCESS, IN_ATTRIB, IN_CLOSE_WRITE, IN_CLOSE_NOWRITE,
        IN_CREATE, IN_DELETE, IN_DELETE_SELF, IN_MODIFY,
        IN_MOVE_SELF, IN_MOVED_FROM, IN_MOVED_TO, IN_OPEN,
        IN_DONT_FOLLOW, IN_MASK_ADD, IN_ONESHOT, IN_ONLYDIR,
        IN_EXCL_UNLINK, IN_MOVE, IN_CLOSE, IN_ALL_EVENTS, 0
};

static int inotify_return_table[] = {
        IN_ACCESS, IN_ATTRIB, IN_CLOSE_WRITE, IN_CLOSE_NOWRITE,
        IN_CREATE, IN_DELETE, IN_DELETE_SELF, IN_MODIFY,
        IN_MOVE_SELF, IN_MOVED_FROM, IN_MOVED_TO, IN_OPEN,
        IN_IGNORED, IN_ISDIR, IN_Q_OVERFLOW, IN_UNMOUNT, 0
};

static void raise_inotify_error(char const *msg)
{
        static const value *inotify_err = NULL;
        value args[2];<commit_msg>IN_EXCL_UNLINK is still not supported everywhere<commit_after>/*
 *	Copyright (C) 2006-2008 <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; version 2.1 only. with the special
 * exception on linking described in file LICENSE.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * Inotify Ocaml binding - C glue
 */

#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/inotify.h>
#include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/custom.h>
#include <caml/fail.h>
#include <caml/signals.h>
#include <caml/callback.h>

#ifndef IN_EXCL_UNLINK
#define IN_EXCL_UNLINK 0  /* If not supported, just ignore */
#endif

static int inotify_flag_table[] = {
        IN_ACCESS, IN_ATTRIB, IN_CLOSE_WRITE, IN_CLOSE_NOWRITE,
        IN_CREATE, IN_DELETE, IN_DELETE_SELF, IN_MODIFY,
        IN_MOVE_SELF, IN_MOVED_FROM, IN_MOVED_TO, IN_OPEN,
        IN_DONT_FOLLOW, IN_MASK_ADD, IN_ONESHOT, IN_ONLYDIR,
        IN_EXCL_UNLINK, IN_MOVE, IN_CLOSE, IN_ALL_EVENTS, 0
};

static int inotify_return_table[] = {
        IN_ACCESS, IN_ATTRIB, IN_CLOSE_WRITE, IN_CLOSE_NOWRITE,
        IN_CREATE, IN_DELETE, IN_DELETE_SELF, IN_MODIFY,
        IN_MOVE_SELF, IN_MOVED_FROM, IN_MOVED_TO, IN_OPEN,
        IN_IGNORED, IN_ISDIR, IN_Q_OVERFLOW, IN_UNMOUNT, 0
};

static void raise_inotify_error(char const *msg)
{
        static const value *inotify_err = NULL;
        value args[2];
{'fraction_non_alphanumeric': 0.0928246013667426, 'fraction_numerical': 0.0076879271070615035, 'mean_word_length': 4.06926406926407, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2538288', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1249, 'n_words': 363}