Commit 2739870a authored by Philipp Huebner's avatar Philipp Huebner

Imported Upstream version 0.2015.09.25

parent b6916c6c
sudo: false
language: erlang
install:
- rebar get-deps
otp_release:
- 17.1
- 17.5
- 18.0
# P1 YAML
# P1 YAML [![Build Status](https://travis-ci.org/processone/p1_yaml.svg?branch=master)](https://travis-ci.org/processone/p1_yaml)
P1 YAML is an Erlang wrapper for [libyaml](http://pyyaml.org/wiki/LibYAML) "C" library.
## Installation
> $ ./configure
> $ make
$ ./configure
$ make
## Example usage
......
/*
* ejabberd, Copyright (C) 2002-2015 ProcessOne
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
*/
#include <yaml.h>
#include <erl_nif.h>
#include <stdlib.h>
......
This diff is collapsed.
......@@ -28,15 +28,11 @@ AC_ERLANG_NEED_ERLC
# AC_ERLANG_SUBST_ROOT_DIR
# AC_ERLANG_SUBST_LIB_DIR
AC_CHECK_LIB(yaml, yaml_parser_initialize, [YAML_LIB=yes], [], [])
AC_CHECK_HEADER(yaml.h, [YAML_HEADER=yes], [], [])
AC_CHECK_HEADERS([yaml.h], [], [
AC_MSG_ERROR([libyaml header file yaml.h was not found])])
if test "x$YAML_LIB" = "x"; then
AC_MSG_ERROR([libyaml library was not found])
fi
if test "x$YAML_HEADER" = "x"; then
AC_MSG_ERROR([libyaml header file "yaml.h" was not found])
fi
AC_SEARCH_LIBS([yaml_parser_initialize], [yaml], [], [
AC_MSG_ERROR([libyaml library was not found])])
AC_CONFIG_FILES([vars.config])
AC_OUTPUT
File deleted
Cfg = case file:consult("vars.config") of
{ok, Terms} ->
Terms;
_Err ->
[]
end ++ [{cflags, "-g -O2 -Wall"}, {ldflags, "-lyaml"}],
{cflags, CfgCFlags} = lists:keyfind(cflags, 1, Cfg),
{ldflags, CfgLDFlags} = lists:keyfind(ldflags, 1, Cfg),
Config = [
{erl_opts, [debug_info]},
{port_env, [{"CFLAGS", "$CFLAGS " ++ CfgCFlags},
{"LDFLAGS", "$LDFLAGS " ++ CfgLDFlags}]},
{port_specs, [{"priv/lib/p1_yaml.so", ["c_src/p1_yaml.c"]}]}
].
%% Local Variables:
%% mode: erlang
%% End:
%% vim: set filetype=erlang tabstop=8:
%%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <>
%%% @copyright (C) 2013, Evgeniy Khramtsov
%%% @doc
%%%----------------------------------------------------------------------
%%% File : p1_yaml.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose : YAML parser
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%% @end
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <>
%%%-------------------------------------------------------------------
%%%
%%% p1_yaml, Copyright (C) 2002-2015 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% 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
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%%
%%%----------------------------------------------------------------------
-module(p1_yaml).
%% API
......@@ -121,9 +139,15 @@ encode_pair({K, V}, N) ->
%%% Internal functions
%%%===================================================================
get_so_path() ->
EbinDir = filename:dirname(code:which(?MODULE)),
AppDir = filename:dirname(EbinDir),
filename:join([AppDir, "priv", "lib"]).
PrivDir = case code:priv_dir(p1_yaml) of
{error, _} ->
EbinDir = filename:dirname(code:which(?MODULE)),
AppDir = filename:dirname(EbinDir),
filename:join([AppDir, "priv"]);
V ->
V
end,
filename:join([PrivDir, "lib"]).
make_flags([{plain_as_atom, true}|Opts]) ->
?PLAIN_AS_ATOM bor make_flags(Opts);
......@@ -151,7 +175,7 @@ indent(N) ->
-include_lib("eunit/include/eunit.hrl").
load_nif_test() ->
?assertEqual(ok, load_nif(filename:join(["..", "priv", "lib"]))).
?assertEqual(ok, load_nif()).
decode_test1_test() ->
FileName = filename:join(["..", "test", "test1.yml"]),
......
%%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <>
%%% @copyright (C) 2013, Evgeniy Khramtsov
%%% @doc
%%%----------------------------------------------------------------------
%%% File : p1_yaml_app.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose : YAML parser application
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%% @end
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <>
%%%-------------------------------------------------------------------
%%%
%%% p1_yaml, Copyright (C) 2002-2015 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% 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
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%%
%%%----------------------------------------------------------------------
-module(p1_yaml_app).
-behaviour(application).
......
%%%----------------------------------------------------------------------
%%% File : p1_yaml_sup.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose : YAML parser supervisor
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% p1_yaml, Copyright (C) 2002-2015 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% 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
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%%
%%%----------------------------------------------------------------------
-module(p1_yaml_sup).
......
{erl_opts, [debug_info]}.
{port_env, [{"CFLAGS", "$CFLAGS -g -O2 -Wall"},
{"LDFLAGS", "$LDFLAGS -lyaml"}]}.
{port_specs, [{"priv/lib/p1_yaml.so", ["c_src/p1_yaml.c"]}]}.
{cflags, "@CFLAGS@"}.
{ldflags, "@LDFLAGS@ @LIBS@"}.
%% Local Variables:
%% mode: erlang
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment