Back to index

salome-kernel  6.5.0
Functions
Utils_Identity.cxx File Reference
#include <iostream>
#include "utilities.h"
#include "Utils_Identity.hxx"
#include <string.h>
#include <pwd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <netdb.h>

Go to the source code of this file.

Functions

const char * duplicate (const char *const str)
 This function can be changed by strdup() if strdup() is ANSI.
struct utsname get_uname (void)
const char * get_adip (void)
const char *const get_pwname (void)
std::ostream & operator<< (std::ostream &os, const Identity &monid)

Function Documentation

const char* duplicate ( const char *const  str)

This function can be changed by strdup() if strdup() is ANSI.

It is strongly (and only) used in the Registry environment (RegistryService, RegistryConnexion, Identity, ...)

Definition at line 42 of file duplicate.cxx.

{
        ASSERT(str!=NULL) ;
        const size_t length = strlen( str ) ;
        ASSERT(length>0) ;
        char *new_str = new char[ 1+length ] ;
        ASSERT(new_str) ;
        strcpy( new_str , str ) ;
        return new_str ;
}
const char* get_adip ( void  )

Definition at line 63 of file Utils_Identity.cxx.

{
        struct utsname  hostid;
#if defined(_DEBUG_) || defined(_DEBUG)
        const int retour=uname(&hostid);
        ASSERT(retour>=0);
#else
        uname(&hostid);
#endif

        const hostent* pour_adip=gethostbyname(hostid.nodename);
        ASSERT(pour_adip!=NULL);
        const in_addr ip_addr=*(struct in_addr*)(pour_adip->h_addr) ;
        return duplicate(inet_ntoa(ip_addr));
}

Here is the call graph for this function:

const char* const get_pwname ( void  )

Definition at line 78 of file Utils_Identity.cxx.

{
        struct passwd *papa = getpwuid(getuid());
        return papa->pw_name ;
}
struct utsname get_uname ( void  ) [read]

Definition at line 51 of file Utils_Identity.cxx.

{
        struct utsname          hostid;
#if defined(_DEBUG_) || defined(_DEBUG)
        const int retour=uname(&hostid);
        ASSERT(retour>=0);
#else
        uname(&hostid);
#endif
        return hostid ;
}
std::ostream& operator<< ( std::ostream &  os,
const Identity &  monid 
)

Definition at line 261 of file Utils_Identity.cxx.

{
        ASSERT(monid._name!=NULL) ;
        os << "Identity :" << std::endl ;
        os << '\t' << "Component name : " << monid._name << std::endl ;
        os << '\t' << "Numero de PID :  " << monid._pid << std::endl;
        os << '\t' << "Uid utilisateur  : "   << monid._uid << std::endl;
        os << '\t' << "nom utilisateur  : "   << monid._pwname << std::endl;
#ifndef WIN32
        os << '\t' << "Nom de machine : " << monid._hostid.nodename << std::endl;
#else
        os << '\t' << "Nom de machine : " << monid._hostid << std::endl;
#endif
        os << '\t' << "Adresse IP : " << monid._adip << std::endl;
        os << '\t' << "Heure de lancement : " << monid._cstart ; //ctime(&monid._start) ;
        os << '\t' << "Dans le repertoire : " << monid._dir << std::endl;

        return os ;
}