puts.c
changeset 0 7d3c07f8acfb
child 1 9ccc1574a367
equal deleted inserted replaced
-1:000000000000 0:7d3c07f8acfb
       
     1 #include "dl.h"
       
     2 
       
     3 /* shameless stolen from
       
     4  * http://uberhip.com/people/godber/interception/html/slide_6.html
       
     5  * and of course from the manpage of dlopen(3)
       
     6  */
       
     7 
       
     8 
       
     9 int puts(const char* s)
       
    10 {
       
    11     static int (*orig)(const char*);
       
    12     int rc;
       
    13 
       
    14     if (!orig)
       
    15 	orig = get_original_function("libc.so.6", "puts");
       
    16 
       
    17     (*orig)("<puts>");
       
    18     rc = (*orig)(s);
       
    19     (*orig)("</puts>");
       
    20     return rc;
       
    21 }