Changeset 4960:60cdebcb83ef in roaraudio for libroarpulse/util.c


Ignore:
Timestamp:
05/14/11 04:46:29 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

some updates for pulseaudio emulation, converted libroarpulse-simple fully to VS API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarpulse/util.c

    r4896 r4960  
    7272 
    7373/** Return the current username in the specified string buffer. */ 
    74 char *pa_get_user_name(char *s, size_t l); 
     74char *pa_get_user_name(char *s, size_t l) { 
     75 char * user = NULL; 
     76 
     77 if ( s == NULL ) { 
     78  roar_err_set(ROAR_ERROR_FAULT); 
     79  roar_err_to_errno(); 
     80  return NULL; 
     81 } 
     82 
     83 if ( user == NULL ) 
     84  user = getenv("USER"); 
     85 if ( user == NULL ) 
     86  user = getenv("LOGNAME"); 
     87 if ( user == NULL ) 
     88  user = getenv("USERNAME"); 
     89 
     90#ifdef ROAR_HAVE_GETUID 
     91 if ( user == NULL ) 
     92  if ( getuid() == 0 ) 
     93   user = "root"; 
     94#endif 
     95 
     96 if ( user == NULL ) { 
     97  roar_err_set(ROAR_ERROR_NOENT); 
     98  roar_err_to_errno(); 
     99  return NULL; 
     100 } 
     101 
     102 strncpy(s, user, l); 
     103 s[l-1] = 0; 
     104 
     105 return s; 
     106} 
    75107 
    76108/** Return the current hostname in the specified buffer. */ 
    77 char *pa_get_host_name(char *s, size_t l); 
     109char *pa_get_host_name(char *s, size_t l) { 
     110#ifdef ROAR_HAVE_GETHOSTNAME 
     111 if (gethostname(s, l) == -1) 
     112  return NULL; 
     113 
     114 s[l-1] = 0; 
     115 return s; 
     116#else 
     117 roar_err_set(ROAR_ERROR_NOSYS); 
     118 roar_err_to_errno(); 
     119 return NULL; 
     120#endif 
     121} 
    78122 
    79123/** Return the fully qualified domain name in s */ 
Note: See TracChangeset for help on using the changeset viewer.