Пример #1
0
static NEOERR* hdf_read_file_internal (HDF *hdf, const char *path,
                                       int include_handle)
{
  NEOERR *err;
  int lineno = 0;
  char fpath[PATH_BUF_SIZE];
  char *ibuf = NULL;
  const char *ptr = NULL;
  HDF *top = hdf->top;
  STRING line;

  string_init(&line);

  if (path == NULL)
    return nerr_raise(NERR_ASSERT, "Can't read NULL file");

  if (top->fileload)
  {
    err = top->fileload(top->fileload_ctx, hdf, path, &ibuf);
  }
  else
  {
    if (path[0] != '/')
    {
      err = hdf_search_path (hdf, path, fpath, PATH_BUF_SIZE);
      if (err != STATUS_OK) return nerr_pass(err);
      path = fpath;
    }

    err = ne_load_file (path, &ibuf);
  }
  if (err) return nerr_pass(err);

  ptr = ibuf;
  err = _hdf_read_string(hdf, &ptr, &line, path, &lineno, include_handle);
  free(ibuf);
  string_clear(&line);
  return nerr_pass(err);
}
Пример #2
0
NEOERR* hdf_read_file (HDF *hdf, const char *path)
{
  NEOERR *err;
  int lineno = 0;
  char fpath[_POSIX_PATH_MAX];
  char *ibuf = NULL;
  const char *ptr = NULL;
  HDF *top = hdf->top;
  STRING line;

  string_init(&line);

  if (path == NULL) 
    return nerr_raise(NERR_ASSERT, "Can't read NULL file");

  if (top->fileload)
  {
    err = top->fileload(top->fileload_ctx, hdf, path, &ibuf);
  }
  else
  {
    if (path[0] != '/')
    {
      err = hdf_search_path (hdf, path, fpath);
      if (err != STATUS_OK) return nerr_pass(err);
      path = fpath;
    }

    err = ne_load_file (path, &ibuf);
  }
  if (err) return nerr_pass(err);

  ptr = ibuf;
  err = _hdf_read_string(hdf, &ptr, &line, path, &lineno, INCLUDE_FILE);
  free(ibuf);
  string_clear(&line);
  return nerr_pass(err);
}