Browse Source

fl_wrapper: changed tpl_*.c files to be sed friendly while looking as normal C code

karasz/new-early
Alejandro Mery 17 years ago
parent
commit
4b997e6fdb
3 changed files with 31 additions and 28 deletions
  1. +7
    -6
      src/tools-source/fl_wrapper/tpl_exec.c
  2. +13
    -12
      src/tools-source/fl_wrapper/tpl_open.c
  3. +11
    -10
      src/tools-source/fl_wrapper/tpl_rest.c

+ 7
- 6
src/tools-source/fl_wrapper/tpl_exec.c

@ -1,13 +1,14 @@
extern $ret_type $function($p1);
$ret_type (*orig_$function)($p1) = 0;
$ret_type $function($p1)
extern RET_TYPE FUNCTION(P1);
RET_TYPE (*orig_FUNCTION)(P1) = 0;
RET_TYPE FUNCTION(P1)
{
int old_errno=errno;
handle_file_access_after("$function", f, 0);
if (!orig_$function) orig_$function = get_dl_symbol("$function");
handle_file_access_after("FUNCTION", f, 0);
if (!orig_FUNCTION) orig_FUNCTION = get_dl_symbol("FUNCTION");
errno=old_errno;
return orig_$function($p2);
return orig_FUNCTION(P2);
}

+ 13
- 12
src/tools-source/fl_wrapper/tpl_open.c

@ -1,25 +1,26 @@
extern $ret_type $function($p1);
$ret_type (*orig_$function)($p1) = 0;
$ret_type $function($p1)
extern RET_TYPE FUNCTION(P1);
RET_TYPE (*orig_FUNCTION)(P1) = 0;
RET_TYPE FUNCTION(P1)
{
struct status_t status;
int old_errno=errno;
$ret_type rc;
RET_TYPE rc;
mode_t b = 0;
#ifdef FLWRAPPER_BASEDIR
if (a & (O_WRONLY|O_CREAT|O_APPEND))
check_write_access("$function", f);
check_write_access("FUNCTION", f);
#endif
handle_file_access_before("$function", f, &status);
if (!orig_$function) orig_$function = get_dl_symbol("$function");
handle_file_access_before("FUNCTION", f, &status);
if (!orig_FUNCTION) orig_FUNCTION = get_dl_symbol("FUNCTION");
errno=old_errno;
#if DEBUG == 1
fprintf(stderr, "fl_wrapper.so debug [%d]: going to run original $function() at %p (wrapper is at %p).\n",
getpid(), orig_$function, $function);
fprintf(stderr, "fl_wrapper.so debug [%d]: going to run original FUNCTION() at %p (wrapper is at %p).\n",
getpid(), orig_FUNCTION, FUNCTION);
#endif
if (a & O_CREAT) {
@ -29,13 +30,13 @@ $ret_type $function($p1)
b = va_arg(ap, mode_t);
va_end(ap);
rc = orig_$function($p2, b);
rc = orig_FUNCTION(P2, b);
}
else
rc = orig_$function($p2);
rc = orig_FUNCTION(P2);
old_errno=errno;
handle_file_access_after("$function", f, &status);
handle_file_access_after("FUNCTION", f, &status);
errno=old_errno;
return rc;

+ 11
- 10
src/tools-source/fl_wrapper/tpl_rest.c

@ -1,24 +1,25 @@
extern $ret_type $function($p1);
$ret_type (*orig_$function)($p1) = 0;
$ret_type $function($p1)
extern RET_TYPE FUNCTION(P1);
RET_TYPE (*orig_FUNCTION)(P1) = 0;
RET_TYPE FUNCTION(P1)
{
struct status_t status;
int old_errno=errno;
$ret_type rc;
RET_TYPE rc;
handle_file_access_before("$function", f, &status);
if (!orig_$function) orig_$function = get_dl_symbol("$function");
handle_file_access_before("FUNCTION", f, &status);
if (!orig_FUNCTION) orig_FUNCTION = get_dl_symbol("FUNCTION");
errno=old_errno;
#if DEBUG == 1
fprintf(stderr, "fl_wrapper.so debug [%d]: going to run original $function() at %p (wrapper is at %p).\n",
getpid(), orig_$function, $function);
fprintf(stderr, "fl_wrapper.so debug [%d]: going to run original FUNCTION() at %p (wrapper is at %p).\n",
getpid(), orig_FUNCTION, FUNCTION);
#endif
rc = orig_$function($p2);
rc = orig_FUNCTION(P2);
old_errno=errno;
handle_file_access_after("$function", f, &status);
handle_file_access_after("FUNCTION", f, &status);
errno=old_errno;
return rc;

Loading…
Cancel
Save