20 const char * entryType;
28 nameLength = strlen(con->
appName);
30 memset(item, 0,
sizeof(*item));
32 if (strncmp(line, con->
appName, nameLength))
return;
43 if (*line ==
'\0')
return;
49 if (*line ==
'\0')
return;
52 if (opt[0] ==
'-' && opt[1] ==
'-')
53 item->option.longName = opt + 2;
54 else if (opt[0] ==
'-' && opt[2] ==
'\0')
55 item->option.shortName = opt[1];
62 for (i = 0, j = 0; i < item->argc; i++, j++) {
64 if (!strncmp(item->argv[i],
"--POPTdesc=",
sizeof(
"--POPTdesc=")-1)) {
65 f = item->argv[i] +
sizeof(
"--POPTdesc=");
66 if (f[0] ==
'$' && f[1] ==
'"') f++;
67 item->option.descrip = f;
71 if (!strncmp(item->argv[i],
"--POPTargs=",
sizeof(
"--POPTargs=")-1)) {
72 f = item->argv[i] +
sizeof(
"--POPTargs=");
73 if (f[0] ==
'$' && f[1] ==
'"') f++;
74 item->option.argDescrip = f;
80 item->argv[j] = item->argv[i];
89 if (!strcmp(entryType,
"alias"))
91 else if (!strcmp(entryType,
"exec"))
99 char * file = NULL, * chptr, * end;
105 fd = open(fn, O_RDONLY);
109 fileLength = lseek(fd, 0, SEEK_END);
110 if (fileLength == -1 || lseek(fd, 0, 0) == -1) {
117 file = malloc(fileLength + 1);
118 if (file == NULL || read(fd, (
char *)file, fileLength) != fileLength) {
126 if (close(fd) == -1) {
131 dst = buf = malloc(fileLength + 1);
136 end = (file + fileLength);
138 while (chptr < end) {
144 if (*dst && *dst !=
'#')
173 static const char _popt_sysconfdir[] = POPT_SYSCONFDIR
"/popt";
174 static const char _popt_etc[] =
"/etc/popt";
179 if (con->
appName == NULL)
return 0;
181 if (strcmp(_popt_sysconfdir, _popt_etc)) {
189 if (!stat(
"/etc/popt.d", &s) && S_ISDIR(s.st_mode)) {
192 if (!glob(
"/etc/popt.d/*", 0, NULL, &g)) {
194 for (i=0; i<g.gl_pathc; i++) {
195 char *f=g.gl_pathv[i];
196 if (strstr(f,
".rpmnew") || strstr(f,
".rpmsave"))
199 if (!S_ISREG(s.st_mode) && !S_ISLNK(s.st_mode))
212 if ((home = getenv(
"HOME"))) {
213 fn = malloc(strlen(home) + 20);
216 strcat(fn,
"/.popt");