Rev | Line | |
---|
[9] | 1 | /*
|
---|
| 2 | domainname.c
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #include <stdio.h>
|
---|
| 6 | #include <string.h>
|
---|
| 7 | #include <net/netlib.h>
|
---|
| 8 |
|
---|
| 9 | int getdomainname(domain, size)
|
---|
| 10 | char *domain;
|
---|
| 11 | size_t size;
|
---|
| 12 | {
|
---|
| 13 | FILE *domainfile;
|
---|
| 14 | char *line;
|
---|
| 15 |
|
---|
| 16 | domainfile= fopen("/etc/domainname", "r");
|
---|
| 17 | if (!domainfile)
|
---|
| 18 | {
|
---|
| 19 | return -1;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | line= fgets(domain, size, domainfile);
|
---|
| 23 | fclose(domainfile);
|
---|
| 24 | if (!line)
|
---|
| 25 | return -1;
|
---|
| 26 | line= strchr(domain, '\n');
|
---|
| 27 | if (line)
|
---|
| 28 | *line= '\0';
|
---|
| 29 | return 0;
|
---|
| 30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.