home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Languages / python / PyObjC-0.47-MIHS / pyobjc-0.47-src / Demo / ObjC / StructUser / StructUser.m < prev    next >
Encoding:
Text File  |  1996-11-13  |  1.6 KB  |  81 lines

  1. /* Copyright (c) 1996 by Lele Gaifax.  All Rights Reserved
  2.  *
  3.  * This file is part of the PyObjC package.
  4.  *
  5.  * $RCSfile: StructUser.m,v $
  6.  * $Revision: 1.1.1.2 $
  7.  * $Date: 1996/11/14 01:49:56 $
  8.  *
  9.  * Created Mon Sep  9 18:24:56 1996.
  10.  */
  11.  
  12. #include "StructUser.h"
  13. #include <stdio.h>
  14.  
  15. #define CLASS_VERSION 0
  16.  
  17. @implementation StructUser
  18.  
  19. + (void) initialize
  20. {
  21.   if (self == [StructUser class])
  22.     {
  23.       [StructUser setVersion:CLASS_VERSION];
  24.     }
  25. }
  26.  
  27. + me
  28. {
  29.   struct passwd me = { "lele",
  30.                "whoknows",
  31.                100, 100, 0,
  32.                "no comment required",
  33.                "gecos field",
  34.                "/tmp",
  35.                "pysh" };
  36.   
  37.   return [[self alloc] initWithPasswd:me];
  38. }
  39.  
  40. - initWithUserId:(int) uid
  41. {
  42.   struct passwd *entry = getpwuid (uid);
  43.  
  44.   if (entry)
  45.     return [self initWithPasswd:*entry];
  46.   else
  47.     return nil;
  48. }
  49.  
  50. - initWithPasswd:(struct passwd) aPwdEntry
  51. {
  52.   [super init];
  53.   pwdEntry = aPwdEntry;
  54.   return self;
  55. }
  56.  
  57. - (void) show
  58. {
  59.   printf ("pw_name->'%s'\n", pwdEntry.pw_name);
  60.   printf ("    pw_passwd->'%s'\n", pwdEntry.pw_passwd);
  61.   printf ("    pw_uid->'%d'\n", pwdEntry.pw_uid);
  62.   printf ("    pw_gid->'%d'\n", pwdEntry.pw_gid);
  63.   printf ("    pw_quota->'%d'\n", pwdEntry.pw_quota);
  64.   printf ("    pw_comment->'%s'\n", pwdEntry.pw_comment);
  65.   printf ("    pw_gecos->'%s'\n", pwdEntry.pw_gecos);
  66.   printf ("    pw_dir->'%s'\n", pwdEntry.pw_dir);
  67.   printf ("    pw_shell->'%s'\n", pwdEntry.pw_shell);
  68. }
  69.  
  70. - (struct passwd) pwdEntry
  71. {
  72.   return pwdEntry;
  73. }
  74.  
  75. - (double) multiplyUserIdBy:(float) f
  76. {
  77.   return pwdEntry.pw_uid * f;
  78. }
  79.  
  80. @end /* StructUser class implementation */
  81.