<commit_before>
#include <unistd.h>
#include <limits.h>
#include "cgi/cgi.h"
#include "cgi/cgiwrap.h"
#include "util/neo_err.h"

int main (int argc, char **argv, char **envp)
{
  NEOERR *err;
  CGI *cgi;
  char *cs_file;
  char hdf_file[_POSIX_PATH_MAX];

  cgi_debug_init (argc,argv);
  cgiwrap_init_std (argc, argv, envp);

  err = cgi_init(&cgi, NULL);
  if (err != STATUS_OK)
  {
    cgi_neo_error(cgi, err);
    nerr_log_error(err);
    return -1;
  }

  cs_file = hdf_get_value (cgi->hdf, "CGI.PathTranslated", NULL);
  if (cs_file == NULL)
  {
    cgi_error (cgi, "No PATH_TRANSLATED var");
    return -1;
  }
  snprintf (hdf_file, sizeof(hdf_file), "%s.hdf", cs_file);
  err = hdf_read_file (cgi->hdf, hdf_file);
  if (err != STATUS_OK)
  {
    cgi_neo_error(cgi, err);
    nerr_log_error(err);
    return -1;
  }
  err = cgi_display (cgi, cs_file);
  if (err != STATUS_OK)
  {
    cgi_neo_error(cgi, err);
    nerr_log_error(err);
    return -1;
  }
  return 0;
}<commit_msg>add the files path to the load path add debugging output check for various HDF files<commit_after>
#include <unistd.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "cgi/cgi.h"
#include "cgi/cgiwrap.h"
#include "util/neo_err.h"

int main (int argc, char **argv, char **envp)
{
  NEOERR *err;
  CGI *cgi;
  char *cs_file;
  char hdf_file[_POSIX_PATH_MAX];
  char *p;
  int x;

  cgi_debug_init (argc,argv);
  cgiwrap_init_std (argc, argv, envp);

  err = cgi_init(&cgi, NULL);
  if (err != STATUS_OK)
  {
    cgi_neo_error(cgi, err);
    nerr_log_error(err);
    return -1;
  }

  cs_file = hdf_get_value (cgi->hdf, "CGI.PathTranslated", NULL);
  if (cs_file == NULL)
  {
    cgi_error (cgi, "No PATH_TRANSLATED var");
    return -1;
  }
  p = strrchr (cs_file, '/');
  if (p)
  {
    *p = '\0';
    err = hdf_set_value (cgi->hdf, "hdf.loadpaths.0", cs_file);
    *p = '/';
    if (err)
    {
      cgi_neo_error(cgi, err);
      nerr_log_error(err);
      return -1;
    }
  }
  snprintf (hdf_file, sizeof(hdf_file), "%s.hdf", cs_file);
  err = hdf_read_file (cgi->hdf, hdf_file);
  if (err && !nerr_handle(&err, NERR_NOT_FOUND))
  {
    cgi_neo_error(cgi, err);
    nerr_log_error(err);
    return -1;
  }
  p = strrchr (cs_file, '.');
  if (p)
  {
    *p = '\0';
    snprintf (hdf_file, sizeof(hdf_file), "%s.hdf", cs_file);
    *p = '.';
    err = hdf_read_file (cgi->hdf, hdf_file);
    if (err && !nerr_handle(&err, NERR_NOT_FOUND))
    {
      cgi_neo_error(cgi, err);
      nerr_log_error(err);
      return -1;
    }
  }
  err = cgi_display (cgi, cs_file);
  if (err != STATUS_OK)
  {
    cgi_neo_error(cgi, err);
    nerr_log_error(err);
    return -1;
  }
  if (hdf_get_int_value (cgi->hdf, "Query.debug", 0))
  {
    cgiwrap_writef("<hr>");
    x = 0;
    while (1)
    {
      char *k, *v;
      err = cgiwrap_iterenv (x, &k, &v);
      if (err != STATUS_OK)
      {
	nerr_log_error(err);
	break;
      }
      if (k == NULL) break;
      cgiwrap_writef("%s = %s<br>", k, v);
      free(k);  
      free(v);
      x++;
    }
    cgiwrap_writef("<pre>");
    hdf_dump(cgi->hdf, NULL);
  }
  return 0;
}
{'fraction_non_alphanumeric': 0.16852500796431985, 'fraction_numerical': 0.005734310289901242, 'mean_word_length': 2.900621118012422, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '4063127', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1380, 'n_words': 289}