<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi, <o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">I think the getlogin function works without a full function declaration since it is a system call that is run by the shell as a privileged call. The manual for getlogin specifies:
<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:.5in">“The name is normally associated with a login shell at the time a session is created, and is inherited by all processes descended from the login shell.”<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:.5in"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">This leads me to believe that the underlying implementation of getlogin is written in the OS itself and C code will only have to declare the function either through unistd.h or writing “char&nbsp; * getlogin(void);”.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">I could be wrong, looking forward to hearing what other people think!<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Best Regards, <o:p></o:p></p>
<p class="MsoNormal">Tim<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">cs631apue-bounces@lists.stevens.edu &lt;cs631apue-bounces@lists.stevens.edu&gt; on behalf of Jan Schaumann &lt;jschauma@stevens.edu&gt;<br>
<b>Date: </b>Wednesday, September 8, 2021 at 12:46 PM<br>
<b>To: </b>cs631apue@lists.stevens.edu &lt;cs631apue@lists.stevens.edu&gt;<br>
<b>Subject: </b>[cs631apue] function forward declarations<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal">Hello,<br>
<br>
In the Week 01 checkpoint, one of you asked:<br>
<br>
---<br>
Why does the program of welcome.c work after we<br>
declare the getlogin function in the front without<br>
providing an 'include' for the header file of unistd.h<br>
as told in the manual page?<br>
<br>
It should not work without implementation of getlogin<br>
function! <br>
---<br>
<br>
Can one of you help answer this question?<br>
<br>
-Jan<br>
_______________________________________________<br>
cs631apue mailing list<br>
cs631apue@lists.stevens.edu<br>
<a href="https://lists.stevens.edu/mailman/listinfo/cs631apue">https://lists.stevens.edu/mailman/listinfo/cs631apue</a><o:p></o:p></p>
</div>
</div>
</body>
</html>