blob: 5dfb0d6f04e953b7e2e5968d50fa975832a57ca6 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>C Tcl Command</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<? prevnext "<h1>Tcl Command in C</h1>" ?>
<pre>
<B><FONT COLOR="#228B22">int</FONT></B>
<B><FONT COLOR="#0000FF">GetPW</FONT></B>(ClientData clientData, Tcl_Interp *interp,
<B><FONT COLOR="#228B22">int</FONT></B> objc, Tcl_Obj *CONST objv[])
{
<B><FONT COLOR="#228B22">struct</FONT></B> passwd *passwd;
passwd = getpwuid(getuid());
Tcl_SetVar2(interp, passwd-&gt;pw_name, <B><FONT COLOR="#BC8F8F">&quot;passwd&quot;</FONT></B>, passwd-&gt;pw_passwd, 0);
Tcl_SetVar2(interp, passwd-&gt;pw_name, <B><FONT COLOR="#BC8F8F">&quot;name&quot;</FONT></B>, passwd-&gt;pw_gecos, 0);
Tcl_SetVar2(interp, passwd-&gt;pw_name, <B><FONT COLOR="#BC8F8F">&quot;home&quot;</FONT></B>, passwd-&gt;pw_dir, 0);
Tcl_SetVar2(interp, passwd-&gt;pw_name, <B><FONT COLOR="#BC8F8F">&quot;shell&quot;</FONT></B>, passwd-&gt;pw_shell, 0);
Tcl_SetResult(interp, passwd-&gt;pw_name, NULL);
<B><FONT COLOR="#A020F0">return</FONT></B> TCL_OK;
}
</pre>
</body>
</html>