| <!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->pw_name, <B><FONT COLOR="#BC8F8F">"passwd"</FONT></B>, passwd->pw_passwd, 0); |
| Tcl_SetVar2(interp, passwd->pw_name, <B><FONT COLOR="#BC8F8F">"name"</FONT></B>, passwd->pw_gecos, 0); |
| Tcl_SetVar2(interp, passwd->pw_name, <B><FONT COLOR="#BC8F8F">"home"</FONT></B>, passwd->pw_dir, 0); |
| Tcl_SetVar2(interp, passwd->pw_name, <B><FONT COLOR="#BC8F8F">"shell"</FONT></B>, passwd->pw_shell, 0); |
| Tcl_SetResult(interp, passwd->pw_name, NULL); |
| <B><FONT COLOR="#A020F0">return</FONT></B> TCL_OK; |
| } |
| </pre> |
| |
| |
| </body> |
| </html> |