Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37775628
en ru br
Репозитории ALT
S:3.0.1-alt2
5.1: 2.4.5-alt2
4.1: 2.4.5-alt2
4.0: 2.4.5-alt2
www.altlinux.org/Changes

Другие репозитории
Upstream:2.4.6

Группа :: Издательство
Пакет: cups-pdf

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: cups-pdf-desktop.patch
Скачать


--- 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;
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin