"Fossies" - the Fresh Open Source Software Archive

Member "linux_logo-6.0/libsysinfo-0.3.0/all/uname.c" (8 May 2020, 841 Bytes) of package /linux/misc/linux_logo-6.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include "sysinfo.h"
    2 
    3 #include <string.h>      /* strncpy */
    4 #include <sys/utsname.h> /* uname   */
    5 
    6 #include "../include/generic.h"
    7 
    8 int uname_get_os_info(struct os_info_type *os_info) {
    9 
   10     struct utsname buf;
   11 
   12     uname(&buf);
   13 
   14     strncpy_truncate(os_info->os_name,buf.sysname,
   15                         SYSINFO_OS_NAME_SIZE);
   16     strncpy_truncate(os_info->os_version,buf.release,
   17                         SYSINFO_OS_VERSION_SIZE);
   18     strncpy_truncate(os_info->os_revision,buf.version,
   19                         SYSINFO_OS_REVISION_SIZE);
   20 /*  os_info->host_name=strdup(buf.nodename); */
   21     return 0;
   22 }
   23 
   24 char *uname_get_host_name(char *hostname,char *domain) {
   25 
   26     struct utsname buf;
   27 
   28     uname(&buf);
   29 
   30     strncpy_truncate(hostname,buf.nodename,SYSINFO_HOSTNAME_SIZE);
   31 /*  strncpy(domain,buf.domainname,64);*/
   32     /* Can't get there from here */
   33     strncpy_truncate(domain,"Unknown",SYSINFO_DOMAIN_SIZE);
   34     return hostname;
   35 }