mirror of
https://abf.rosa.ru/djam/cups-pdf.git
synced 2025-02-23 17:32:48 +00:00
64 lines
1.6 KiB
Diff
64 lines
1.6 KiB
Diff
--- src/cups-pdf.c.orig 2007-05-04 13:48:54.000000000 +0200
|
|
+++ src/cups-pdf.c 2007-09-15 11:59:41.000000000 +0200
|
|
@@ -287,6 +287,45 @@
|
|
return 0;
|
|
}
|
|
|
|
+static char *getdesktopdir(struct passwd *passwd) {
|
|
+ static char bufret[BUFSIZE];
|
|
+ char *need, *ret, buftmp[BUFSIZE];
|
|
+ FILE *fic;
|
|
+
|
|
+ // Default (if not found) = $HOME
|
|
+ ret=passwd->pw_dir;
|
|
+
|
|
+ snprintf(buftmp, BUFSIZE, "%s/.config/user-dirs.dirs", passwd->pw_dir);
|
|
+ fic = fopen(buftmp, "r");
|
|
+ if (fic) {
|
|
+ while (fgets(buftmp, BUFSIZE, fic)) {
|
|
+ need=strstr(buftmp, "XDG_DESKTOP_DIR=");
|
|
+ if (need) {
|
|
+ need+=16;
|
|
+ // Remove opening quote
|
|
+ if ((*need)=='"') need++;
|
|
+ if (memcmp(need, "$HOME", 5)) {
|
|
+ strncpy(bufret, need, BUFSIZE);
|
|
+ }
|
|
+ else {
|
|
+ snprintf(bufret, BUFSIZE, "%s%s", passwd->pw_dir, need+5);
|
|
+ }
|
|
+ // Remove closing quote
|
|
+ need=strrchr(bufret, '"');
|
|
+ if (need) *need=0;
|
|
+ // Return internal buffer
|
|
+ ret = bufret;
|
|
+
|
|
+ log_event(CPDEBUG, "XDG_DESKTOP_DIR:", ret);
|
|
+ }
|
|
+ }
|
|
+ fclose(fic);
|
|
+ }
|
|
+ else
|
|
+ log_event(CPERROR, "Can't read", buftmp);
|
|
+ return ret;
|
|
+}
|
|
+
|
|
static char *preparedirname(struct passwd *passwd, char *uname) {
|
|
int size;
|
|
char bufin[BUFSIZE], bufout[BUFSIZE], *needle, *cptr;
|
|
@@ -297,6 +336,15 @@
|
|
|
|
strncpy(bufin, conf.out, BUFSIZE);
|
|
do {
|
|
+ needle=strstr(bufin, "${DESKTOP}");
|
|
+ if (needle == NULL)
|
|
+ break;
|
|
+ needle[0]='\0';
|
|
+ cptr=needle+10;
|
|
+ snprintf(bufout, BUFSIZE, "%s%s%s", bufin, getdesktopdir(passwd), cptr);
|
|
+ strncpy(bufin, bufout, BUFSIZE);
|
|
+ } while (needle != NULL);
|
|
+ do {
|
|
needle=strstr(bufin, "${HOME}");
|
|
if (needle == NULL)
|
|
break;
|