source: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/legacy/getusershell.c@ 337

Last change on this file since 337 was 337, checked in by coas-nagasima, 6 years ago

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 565 bytes
Line 
1#define _GNU_SOURCE
2#include <stdio.h>
3#include <unistd.h>
4
5static const char defshells[] = "/bin/sh\n/bin/csh\n";
6
7static char *line;
8static size_t linesize;
9static FILE *f;
10
11void endusershell(void)
12{
13 if (f) fclose(f);
14 f = 0;
15}
16
17void setusershell(void)
18{
19 if (!f) f = fopen("/etc/shells", "rbe");
20 if (!f) f = fmemopen((void *)defshells, sizeof defshells - 1, "rb");
21}
22
23char *getusershell(void)
24{
25 ssize_t l;
26 if (!f) setusershell();
27 if (!f) return 0;
28 l = getline(&line, &linesize, f);
29 if (l <= 0) return 0;
30 if (line[l-1]=='\n') line[l-1]=0;
31 return line;
32}
Note: See TracBrowser for help on using the repository browser.