Language-Haskell

 view release on metacpan or  search on metacpan

hugs98-Nov2003/fptools/libraries/unix/System/Posix/User.hsc  view on Meta::CPAN

   userShell     :: String
 }

getUserEntryForID :: UserID -> IO UserEntry
#ifdef HAVE_GETPWUID_R
getUserEntryForID uid = do
  allocaBytes (#const sizeof(struct passwd)) $ \ppw ->
    allocaBytes pwBufSize $ \pbuf ->
      alloca $ \ pppw -> do
        throwErrorIfNonZero_ "getUserEntryForID" $
	     c_getpwuid_r uid ppw pbuf (fromIntegral pwBufSize) pppw
	unpackUserEntry ppw

foreign import ccall unsafe "getpwuid_r"
  c_getpwuid_r :: CUid -> Ptr CPasswd -> 
			CString -> CSize -> Ptr (Ptr CPasswd) -> IO CInt
#else
getUserEntryForID = error "System.Posix.User.getUserEntryForID: not supported"
#endif

getUserEntryForName :: String -> IO UserEntry
#if HAVE_GETPWNAM_R
getUserEntryForName name = do
  allocaBytes (#const sizeof(struct passwd)) $ \ppw ->
    allocaBytes pwBufSize $ \pbuf ->

hugs98-Nov2003/fptools/libraries/unix/System/Posix/User_hsc_make.c  view on Meta::CPAN

    fputs ("getUserEntryForID uid = do\n"
           "  allocaBytes (", stdout);
#line 203 "User.hsc"
    hsc_const (sizeof(struct passwd));
    fputs (") $ \\ppw ->\n"
           "", stdout);
    hsc_line (204, "User.hsc");
    fputs ("    allocaBytes pwBufSize $ \\pbuf ->\n"
           "      alloca $ \\ pppw -> do\n"
           "        throwErrorIfNonZero_ \"getUserEntryForID\" $\n"
           "\t     c_getpwuid_r uid ppw pbuf (fromIntegral pwBufSize) pppw\n"
           "\tunpackUserEntry ppw\n"
           "\n"
           "foreign import ccall unsafe \"getpwuid_r\"\n"
           "  c_getpwuid_r :: CUid -> Ptr CPasswd -> \n"
           "\t\t\tCString -> CSize -> Ptr (Ptr CPasswd) -> IO CInt\n"
           "", stdout);
#line 213 "User.hsc"
#else 
    fputs ("\n"
           "", stdout);
    hsc_line (214, "User.hsc");
    fputs ("getUserEntryForID = error \"System.Posix.User.getUserEntryForID: not supported\"\n"
           "", stdout);
#line 215 "User.hsc"



( run in 0.355 second using v1.01-cache-2.11-cpan-8d75d55dd25 )