Flexibility and adaptability requirements of future electric power grids for integrating distributed energy resources (DERs) call for the development of wide-area monitoring, protection and control (WAMPAC) applications, utilizing synchrophasor measurements provided by the phasor measurement units (PMUs).IEEE C37.118 is the most utilized protocol for real-time exchange of synchronized phasor measurement data. In order to fulfill some gaps not addressed in IEEE C37.118, and also to harmonize with the IEC 61850 power utility automation standard, the IEC 61850-90-5 technical report has been developed. IEC TR 61850-90-5 introduces a mechanism for transfer of digital states and time synchronized phasor measurement data over wide-area networks between PMUs, phasor data concentrators (PDCs) and WAMPAC applications in the context of IEC 61850.This work interprets the IEEE C37.118.2 and IEC 61850-90-5 Routed-Sampled Value and Routed-GOOSE protocols and describes the design and implementation of a library named Khorjin with the functionality of (1) an IEEE C37.118.2 to IEC 61850-90-5 gateway and protocol converter and (2) an IEC 61850-90-5 subscriber and traffic parser.The main contribution of this work is the development of Khorjin library using only standard C libraries (i.e. independent from any operating system). This is allowing the use of the library in different platforms.The design requirements and functionality of the Khorjin library has been tested in the KTH SmarTS Lab real-time hardware-in-the-loop (HIL) simulation environment to assess its conformance to the functional requirements of IEEE C37.118.2 and IEC 61850-90-5 standards.