LAMMPS works through a series of user defined fixes. These are objects the user can define by inheretiting from a base class called fix with a pre-definied structure. These are automatically registered with LAMMPS and instantiated (created when LAMMPS runs). The use can then defined a range of "hook"* functions with names like post_setup or pre_force, which can be used to inject code where you want (after the setup or before the force calcultation respectivly) in the overall LAMMPS solver. The addition code is included in LAMMPS by writing user add on packages which can be included when LAMMPS is complied. Provided LAMMPS has been built with the extra package, they can then be used, often by keywords to switch these on from the user input.
For CPL library, the package is USER_CPL and the code inside includes fix_cpl_init, fix_cpl_force and CPLSocketLAMMPS. The socket is the bulk of the code which handles getting information from LAMMPS, fix_cpl_force applies the constraint force and fix_cpl_init is the top level function to handle communication and call the CPLSocketLAMMPS/fix_cpl_force routines.