Changeset 1658

Show
Ignore:
Timestamp:
07/21/08 00:38:19 (2 months ago)
Author:
common
Message:

libemu

  • to simplify profiling, create emu_profile_argument_add_sockaddr_ptr for use in connect&bind hooks
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libemu/trunk/include/emu/environment/emu_profile.h

    r1655 r1658  
    2626 *******************************************************************************/ 
    2727 
     28 
     29#include <netinet/in.h> 
     30#include <arpa/inet.h> 
     31#include <sys/types.h> 
     32#include <sys/socket.h> 
    2833 
    2934#include "emu/emu_list.h" 
     
    154159 
    155160void *emu_profile_function_argument_get(struct emu_profile_function *function, int argc); 
    156 #endif 
     161 
     162void emu_profile_argument_add_sockaddr_ptr(struct emu_profile *profile, const char *name, uint32_t ptr, struct sockaddr sa); 
     163 
     164#endif                                                                                               
     165 
  • libemu/trunk/src/environment/emu_profile.c

    r1655 r1658  
    2929#include <stdlib.h> 
    3030#include <stdio.h> 
    31 #include <netinet/in.h> 
    32 #include <arpa/inet.h> 
    33 #include <sys/types.h> 
    34 #include <sys/socket.h> 
     31 
    3532 
    3633 
    3734#include "emu/environment/emu_profile.h" 
     35 
     36 
     37 
    3838 
    3939/* 
     
    166166 
    167167    struct emu_profile_argument *argument = emu_profile_argument_new(render_string, argtype, argname); 
     168        if (value == NULL) 
     169                value = ""; 
    168170        argument->value.tchar = strdup(value); 
    169171        emu_profile_argument_add(profile, argument); 
     
    203205} 
    204206 
     207void emu_profile_argument_add_sockaddr_ptr(struct emu_profile *profile, const char *name, uint32_t ptr, struct sockaddr sa) 
     208{ 
     209 
     210        if ( sa.sa_family == AF_INET ) 
     211        {                                                                                           
     212                struct sockaddr_in *si = (struct sockaddr_in *)&sa;                                     
     213                emu_profile_argument_add_ptr(profile, "sockaddr_in *", (char*)name, ptr);                
     214                emu_profile_argument_struct_start(profile, "", "");                                     
     215                emu_profile_argument_add_short(profile, "short", "sin_family", si->sin_family);         
     216                emu_profile_argument_add_port(profile, "unsigned short", "sin_port", si->sin_port);     
     217                emu_profile_argument_struct_start(profile, "in_addr", "sin_addr");                      
     218                emu_profile_argument_add_ip(profile, "unsigned long", "s_addr", si->sin_addr.s_addr);   
     219                emu_profile_argument_struct_end(profile);                                               
     220                emu_profile_argument_add_string(profile, "char", "sin_zero", "       ");                
     221                emu_profile_argument_struct_end(profile);                                               
     222 
     223        } 
     224        else 
     225        {                                                                                           
     226                emu_profile_argument_struct_start(profile, "sockaddr *", "name");                       
     227                emu_profile_argument_struct_end(profile);                                               
     228        }                                                                                           
     229 
     230} 
    205231 
    206232struct emu_profile_function *emu_profile_function_new()