Mercurial > emacs
comparison src/editfns.c @ 12026:505a894d943e
(syms_of_editfns): user-login-name renamed from user-name.
user-real-login-name renamed from user-real-name.
C names changed to Vuser_real_login_name, Vuser_login_name as well.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 30 May 1995 21:56:32 +0000 |
parents | bb03a720fd58 |
children | a2920d062bb5 |
comparison
equal
deleted
inserted
replaced
12025:e804b43418f6 | 12026:505a894d943e |
---|---|
42 static long difftm (); | 42 static long difftm (); |
43 | 43 |
44 /* Some static data, and a function to initialize it for each run */ | 44 /* Some static data, and a function to initialize it for each run */ |
45 | 45 |
46 Lisp_Object Vsystem_name; | 46 Lisp_Object Vsystem_name; |
47 Lisp_Object Vuser_real_name; /* login name of current user ID */ | 47 Lisp_Object Vuser_real_login_name; /* login name of current user ID */ |
48 Lisp_Object Vuser_full_name; /* full name of current user */ | 48 Lisp_Object Vuser_full_name; /* full name of current user */ |
49 Lisp_Object Vuser_name; /* user name from LOGNAME or USER */ | 49 Lisp_Object Vuser_login_name; /* user name from LOGNAME or USER */ |
50 | 50 |
51 void | 51 void |
52 init_editfns () | 52 init_editfns () |
53 { | 53 { |
54 char *user_name; | 54 char *user_name; |
69 pw = (struct passwd *) getpwuid (getuid ()); | 69 pw = (struct passwd *) getpwuid (getuid ()); |
70 #ifdef MSDOS | 70 #ifdef MSDOS |
71 /* We let the real user name default to "root" because that's quite | 71 /* We let the real user name default to "root" because that's quite |
72 accurate on MSDOG and because it lets Emacs find the init file. | 72 accurate on MSDOG and because it lets Emacs find the init file. |
73 (The DVX libraries override the Djgpp libraries here.) */ | 73 (The DVX libraries override the Djgpp libraries here.) */ |
74 Vuser_real_name = build_string (pw ? pw->pw_name : "root"); | 74 Vuser_real_login_name = build_string (pw ? pw->pw_name : "root"); |
75 #else | 75 #else |
76 Vuser_real_name = build_string (pw ? pw->pw_name : "unknown"); | 76 Vuser_real_login_name = build_string (pw ? pw->pw_name : "unknown"); |
77 #endif | 77 #endif |
78 | 78 |
79 /* Get the effective user name, by consulting environment variables, | 79 /* Get the effective user name, by consulting environment variables, |
80 or the effective uid if those are unset. */ | 80 or the effective uid if those are unset. */ |
81 user_name = (char *) getenv ("LOGNAME"); | 81 user_name = (char *) getenv ("LOGNAME"); |
88 if (!user_name) | 88 if (!user_name) |
89 { | 89 { |
90 pw = (struct passwd *) getpwuid (geteuid ()); | 90 pw = (struct passwd *) getpwuid (geteuid ()); |
91 user_name = (char *) (pw ? pw->pw_name : "unknown"); | 91 user_name = (char *) (pw ? pw->pw_name : "unknown"); |
92 } | 92 } |
93 Vuser_name = build_string (user_name); | 93 Vuser_login_name = build_string (user_name); |
94 | 94 |
95 /* If the user name claimed in the environment vars differs from | 95 /* If the user name claimed in the environment vars differs from |
96 the real uid, use the claimed name to find the full name. */ | 96 the real uid, use the claimed name to find the full name. */ |
97 tem = Fstring_equal (Vuser_name, Vuser_real_name); | 97 tem = Fstring_equal (Vuser_login_name, Vuser_real_login_name); |
98 if (NILP (tem)) | 98 if (NILP (tem)) |
99 pw = (struct passwd *) getpwnam (XSTRING (Vuser_name)->data); | 99 pw = (struct passwd *) getpwnam (XSTRING (Vuser_login_name)->data); |
100 | 100 |
101 p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown"); | 101 p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown"); |
102 q = (unsigned char *) index (p, ','); | 102 q = (unsigned char *) index (p, ','); |
103 Vuser_full_name = make_string (p, q ? q - p : strlen (p)); | 103 Vuser_full_name = make_string (p, q ? q - p : strlen (p)); |
104 | 104 |
106 p = XSTRING (Vuser_full_name)->data; | 106 p = XSTRING (Vuser_full_name)->data; |
107 q = (unsigned char *) index (p, '&'); | 107 q = (unsigned char *) index (p, '&'); |
108 /* Substitute the login name for the &, upcasing the first character. */ | 108 /* Substitute the login name for the &, upcasing the first character. */ |
109 if (q) | 109 if (q) |
110 { | 110 { |
111 r = (unsigned char *) alloca (strlen (p) + XSTRING (Vuser_name)->size + 1); | 111 r = (unsigned char *) alloca (strlen (p) |
112 + XSTRING (Vuser_login_name)->size + 1); | |
112 bcopy (p, r, q - p); | 113 bcopy (p, r, q - p); |
113 r[q - p] = 0; | 114 r[q - p] = 0; |
114 strcat (r, XSTRING (Vuser_name)->data); | 115 strcat (r, XSTRING (Vuser_login_name)->data); |
115 r[q - p] = UPCASE (r[q - p]); | 116 r[q - p] = UPCASE (r[q - p]); |
116 strcat (r, q + 1); | 117 strcat (r, q + 1); |
117 Vuser_full_name = build_string (r); | 118 Vuser_full_name = build_string (r); |
118 } | 119 } |
119 #endif /* AMPERSAND_FULL_NAME */ | 120 #endif /* AMPERSAND_FULL_NAME */ |
514 struct passwd *pw; | 515 struct passwd *pw; |
515 | 516 |
516 /* Set up the user name info if we didn't do it before. | 517 /* Set up the user name info if we didn't do it before. |
517 (That can happen if Emacs is dumpable | 518 (That can happen if Emacs is dumpable |
518 but you decide to run `temacs -l loadup' and not dump. */ | 519 but you decide to run `temacs -l loadup' and not dump. */ |
519 if (INTEGERP (Vuser_name)) | 520 if (INTEGERP (Vuser_login_name)) |
520 init_editfns (); | 521 init_editfns (); |
521 | 522 |
522 if (NILP (uid)) | 523 if (NILP (uid)) |
523 return Vuser_name; | 524 return Vuser_login_name; |
524 | 525 |
525 CHECK_NUMBER (uid, 0); | 526 CHECK_NUMBER (uid, 0); |
526 pw = (struct passwd *) getpwuid (XINT (uid)); | 527 pw = (struct passwd *) getpwuid (XINT (uid)); |
527 return (pw ? build_string (pw->pw_name) : Qnil); | 528 return (pw ? build_string (pw->pw_name) : Qnil); |
528 } | 529 } |
535 () | 536 () |
536 { | 537 { |
537 /* Set up the user name info if we didn't do it before. | 538 /* Set up the user name info if we didn't do it before. |
538 (That can happen if Emacs is dumpable | 539 (That can happen if Emacs is dumpable |
539 but you decide to run `temacs -l loadup' and not dump. */ | 540 but you decide to run `temacs -l loadup' and not dump. */ |
540 if (INTEGERP (Vuser_name)) | 541 if (INTEGERP (Vuser_login_name)) |
541 init_editfns (); | 542 init_editfns (); |
542 return Vuser_real_name; | 543 return Vuser_real_login_name; |
543 } | 544 } |
544 | 545 |
545 DEFUN ("user-uid", Fuser_uid, Suser_uid, 0, 0, 0, | 546 DEFUN ("user-uid", Fuser_uid, Suser_uid, 0, 0, 0, |
546 "Return the effective uid of Emacs, as an integer.") | 547 "Return the effective uid of Emacs, as an integer.") |
547 () | 548 () |
2281 "The name of the machine Emacs is running on."); | 2282 "The name of the machine Emacs is running on."); |
2282 | 2283 |
2283 DEFVAR_LISP ("user-full-name", &Vuser_full_name, | 2284 DEFVAR_LISP ("user-full-name", &Vuser_full_name, |
2284 "The full name of the user logged in."); | 2285 "The full name of the user logged in."); |
2285 | 2286 |
2286 DEFVAR_LISP ("user-name", &Vuser_name, | 2287 DEFVAR_LISP ("user-login-name", &Vuser_login_name, |
2287 "The user's name, taken from environment variables if possible."); | 2288 "The user's name, taken from environment variables if possible."); |
2288 | 2289 |
2289 DEFVAR_LISP ("user-real-name", &Vuser_real_name, | 2290 DEFVAR_LISP ("user-real-login-name", &Vuser_real_login_name, |
2290 "The user's name, based upon the real uid only."); | 2291 "The user's name, based upon the real uid only."); |
2291 | 2292 |
2292 defsubr (&Schar_equal); | 2293 defsubr (&Schar_equal); |
2293 defsubr (&Sgoto_char); | 2294 defsubr (&Sgoto_char); |
2294 defsubr (&Sstring_to_char); | 2295 defsubr (&Sstring_to_char); |