2 #include <stdio.h> /* for FILE etc */
4 #include <unistd.h> /* for unlink */
5 #include <stdlib.h> /* for free */
6 #include <sys/stat.h> /* for stat */
9 #include "pnd_container.h"
11 #include "pnd_discovery.h"
12 #include "pnd_pndfiles.h"
14 #include "pnd_desktop.h"
15 #include "pnd_logger.h"
17 unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t *p ) {
18 char filename [ FILENAME_MAX ];
23 // http://standards.freedesktop.org/desktop-entry-spec
27 if ( ! p -> unique_id ) {
28 pnd_log ( PND_LOG_DEFAULT, "Can't emit dotdesktop for %s, missing unique-id\n", targetpath );
33 pnd_log ( PND_LOG_DEFAULT, "Can't emit dotdesktop for %s, missing exec\n", targetpath );
38 pnd_log ( PND_LOG_DEFAULT, "Can't emit dotdesktop for %s, missing target path\n", targetpath );
43 pnd_log ( PND_LOG_DEFAULT, "Can't emit dotdesktop for %s, missing pnd_run.sh\n", targetpath );
49 sprintf ( filename, "%s/%s#%u.desktop", targetpath, p -> unique_id, p -> subapp_number );
53 //printf ( "EMIT DOTDESKTOP '%s'\n", filename );
55 f = fopen ( filename, "w" );
61 fprintf ( f, "%s\n", PND_DOTDESKTOP_HEADER );
63 if ( p -> title_en ) {
64 snprintf ( buffer, 1020, "Name=%s\n", p -> title_en );
65 fprintf ( f, "%s", buffer );
68 fprintf ( f, "Type=Application\n" );
69 fprintf ( f, "Version=1.0\n" );
72 snprintf ( buffer, 1020, "Icon=%s\n", p -> icon );
73 fprintf ( f, "%s", buffer );
76 if ( p -> unique_id ) {
77 fprintf ( f, "X-Pandora-UID=%s\n", p -> unique_id );
81 if ( p -> desc_en && p -> desc_en [ 0 ] ) {
82 snprintf ( buffer, 1020, "Comment=%s\n", p -> desc_en ); // no [en] needed I suppose, yet
83 fprintf ( f, "%s", buffer );
87 if ( p -> preview_pic1 ) {
88 fprintf ( f, "X-Pandora-Preview-Pic-1=%s\n", p -> preview_pic1 );
91 if ( p -> clockspeed ) {
92 fprintf ( f, "X-Pandora-Clockspeed=%s\n", p -> clockspeed );
95 if ( p -> startdir ) {
96 fprintf ( f, "X-Pandora-Startdir=%s\n", p -> startdir );
99 if ( p -> main_category ) {
100 fprintf ( f, "X-Pandora-MainCategory=%s\n", p -> main_category );
102 if ( p -> main_category1 ) {
103 fprintf ( f, "X-Pandora-MainCategory1=%s\n", p -> main_category1 );
105 if ( p -> main_category2 ) {
106 fprintf ( f, "X-Pandora-MainCategory2=%s\n", p -> main_category2 );
109 if ( p -> alt_category ) {
110 fprintf ( f, "X-Pandora-AltCategory=%s\n", p -> alt_category );
112 if ( p -> alt_category1 ) {
113 fprintf ( f, "X-Pandora-AltCategory1=%s\n", p -> alt_category1 );
115 if ( p -> alt_category2 ) {
116 fprintf ( f, "X-Pandora-AltCategory2=%s\n", p -> alt_category2 );
119 #if 0 // we let pnd_run.sh command line handle this instead of in .desktop
120 if ( p -> startdir ) {
121 snprintf ( buffer, 1020, "Path=%s\n", p -> startdir );
122 fprintf ( f, "%s", buffer );
124 fprintf ( f, "Path=%s\n", PND_DEFAULT_WORKDIR );
131 if ( p -> option_no_x11 ) {
132 nohup = "/usr/bin/nohup ";
138 if ( p -> object_type == pnd_object_type_directory ) {
139 snprintf ( buffer, 1020, "Exec=%s%s -p \"%s\" -e \"%s\" -b \"%s\"",
140 nohup, pndrun, p -> object_path, p -> exec,
141 p -> appdata_dirname ? p -> appdata_dirname : p -> unique_id );
142 } else if ( p -> object_type == pnd_object_type_pnd ) {
143 snprintf ( buffer, 1020, "Exec=%s%s -p \"%s/%s\" -e \"%s\" -b \"%s\"",
144 nohup, pndrun, p -> object_path, p -> object_filename, p -> exec,
145 p -> appdata_dirname ? p -> appdata_dirname : p -> unique_id );
149 if ( p -> startdir ) {
150 strncat ( buffer, " -s ", 1020 );
151 strncat ( buffer, p -> startdir, 1020 );
155 if ( p -> execargs ) {
156 char argbuf [ 1024 ];
157 snprintf ( argbuf, 1000, " -a \"%s\"", p -> execargs );
158 strncat ( buffer, argbuf, 1020 );
162 if ( p -> clockspeed && atoi ( p -> clockspeed ) != 0 ) {
163 strncat ( buffer, " -c ", 1020 );
164 strncat ( buffer, p -> clockspeed, 1020 );
168 if ( pnd_pxml_get_x11 ( p -> option_no_x11 ) == pnd_pxml_x11_stop ) {
169 strncat ( buffer, " -x ", 1020 );
173 strncat ( buffer, "\n", 1020 );
176 fprintf ( f, "%s", buffer );
181 char cats [ 512 ] = "";
187 // "Application" used to be in the standard and is commonly supported still
188 // Utility and Network should ensure the app is visible 'somewhere' :/
189 char *defaults = PND_DOTDESKTOP_DEFAULT_CATEGORY;
191 // determine searchpath (for conf, not for apps)
192 confpath = pnd_conf_query_searchpath();
194 // inhale the conf file
195 c = pnd_conf_fetch_by_id ( pnd_conf_categories, confpath );
197 // if we can find a default category set, pull it in; otherwise assume
199 if ( pnd_conf_get_as_char ( c, "default" ) ) {
200 defaults = pnd_conf_get_as_char ( c, "default" );
203 // ditch the confpath
209 n = pnd_map_dotdesktop_categories ( c, cats, 511, p );
212 fprintf ( f, "Categories=%s\n", cats );
214 fprintf ( f, "Categories=%s\n", defaults );
218 fprintf ( f, "Categories=%s\n", defaults );
223 fprintf ( f, "%s\n", PND_DOTDESKTOP_SOURCE ); // should we need to know 'who' created the file during trimming
230 unsigned char pnd_emit_dotinfo ( char *targetpath, char *pndrun, pnd_disco_t *p ) {
231 char filename [ FILENAME_MAX ];
232 char buffer [ 1024 ];
234 char *viewer, *searchpath;
235 pnd_conf_handle desktoph;
238 // http://standards.freedesktop.org/desktop-entry-spec
244 searchpath = pnd_conf_query_searchpath();
246 desktoph = pnd_conf_fetch_by_id ( pnd_conf_desktop, searchpath );
252 viewer = pnd_conf_get_as_char ( desktoph, "info.viewer" );
255 return ( 0 ); // no way to view the file
259 if ( ! p -> unique_id ) {
260 pnd_log ( PND_LOG_DEFAULT, "Can't emit dotdesktop for %s, missing unique-id\n", targetpath );
264 if ( ! p -> info_filename ) {
265 pnd_log ( PND_LOG_DEFAULT, "Can't emit dotdesktop for %s, missing info_filename\n", targetpath );
269 if ( ! p -> info_name ) {
270 pnd_log ( PND_LOG_DEFAULT, "Can't emit dotdesktop for %s, missing info_name\n", targetpath );
274 if ( ! targetpath ) {
275 pnd_log ( PND_LOG_DEFAULT, "Can't emit dotdesktop for %s, missing target path\n", targetpath );
280 pnd_log ( PND_LOG_DEFAULT, "Can't emit dotdesktop for %s, missing pnd_run.sh\n", targetpath );
286 sprintf ( filename, "%s/%s#%uinfo.desktop", targetpath, p -> unique_id, p -> subapp_number );
290 f = fopen ( filename, "w" );
296 fprintf ( f, "%s\n", PND_DOTDESKTOP_HEADER );
298 if ( p -> info_name ) {
299 snprintf ( buffer, 1020, "Name=%s\n", p -> info_name );
300 fprintf ( f, "%s", buffer );
303 fprintf ( f, "Type=Application\n" );
304 fprintf ( f, "Version=1.0\n" );
308 snprintf ( buffer, 1020, "Icon=%s\n", p -> icon );
309 fprintf ( f, "%s", buffer );
313 if ( p -> unique_id ) {
314 fprintf ( f, "X-Pandora-UID=%s\n", p -> unique_id );
317 if ( p -> title_en && p -> title_en [ 0 ] ) {
318 snprintf ( buffer, 1020, "Comment=Automatic menu info entry for %s\n", p -> title_en );
319 fprintf ( f, "%s", buffer );
322 #if 0 // we let pnd_run.sh command line handle this instead of in .desktop
323 if ( p -> startdir ) {
324 snprintf ( buffer, 1020, "Path=%s\n", p -> startdir );
325 fprintf ( f, "%s", buffer );
327 fprintf ( f, "Path=%s\n", PND_DEFAULT_WORKDIR );
334 char *viewerargs = pnd_conf_get_as_char ( desktoph, "info.viewer_args" );
335 if ( viewerargs && viewerargs [ 0 ] ) {
336 snprintf ( pargs, 1001, "%s %s",
337 pnd_conf_get_as_char ( desktoph, "info.viewer_args" ), p -> info_filename );
340 // WARNING: This might not be quite right; if no viewer-args, shouldn't we still append the info-filename? likewise,
341 // even if we do have view-args, shouldn't we check if filename is present?
344 char pndfile [ 1024 ];
345 if ( p -> object_type == pnd_object_type_directory ) {
346 // for PXML-app-dir, pnd_run.sh doesn't want the PXML.xml.. it just wants the dir-name
347 strncpy ( pndfile, p -> object_path, 1000 );
348 } else if ( p -> object_type == pnd_object_type_pnd ) {
349 // pnd_run.sh wants the full path and filename for the .pnd file
350 snprintf ( pndfile, 1020, "%s/%s", p -> object_path, p -> object_filename );
353 pnd_apps_exec_info_t info;
354 info.viewer = viewer;
357 if ( ! pnd_apps_exec_disco ( pndrun, p, PND_EXEC_OPTION_NORUN | PND_EXEC_OPTION_INFO, &info ) ) {
361 fprintf ( f, "Exec=%s\n", pnd_apps_exec_runline() );
363 if ( pnd_conf_get_as_char ( desktoph, "info.category" ) ) {
364 fprintf ( f, "Categories=%s\n", pnd_conf_get_as_char ( desktoph, "info.category" ) );
366 fprintf ( f, "Categories=Documentation\n" );
369 fprintf ( f, "%s\n", PND_DOTDESKTOP_SOURCE ); // should we need to know 'who' created the file during trimming
376 unsigned char pnd_emit_icon ( char *targetpath, pnd_disco_t *p ) {
377 //#define BITLEN (8*1024)
378 #define BITLEN (64*1024)
379 char buffer [ FILENAME_MAX ]; // target filename
380 char from [ FILENAME_MAX ]; // source filename
381 unsigned char bits [ BITLEN ];
385 // prelim .. if a pnd file, and no offset found, discovery code didn't locate icon.. so bail.
386 if ( ( p -> object_type == pnd_object_type_pnd ) &&
387 ( ! p -> pnd_icon_pos ) )
389 return ( 0 ); // discover code didn't find it, so FAIL
392 // determine filename for target
393 sprintf ( buffer, "%s/%s.png", targetpath, p -> unique_id /*, p -> subapp_number*/ ); // target
395 /* first.. open the source file, by type of application:
396 * are we looking through a pnd file or a dir?
398 if ( p -> object_type == pnd_object_type_directory ) {
399 sprintf ( from, "%s/%s", p -> object_path, p -> icon );
400 } else if ( p -> object_type == pnd_object_type_pnd ) {
401 sprintf ( from, "%s/%s", p -> object_path, p -> object_filename );
404 pnd = fopen ( from, "rb" );
407 pnd_log ( PND_LOG_DEFAULT, " Emit icon, couldn't open source\n" );
413 target = fopen ( buffer, "wb" );
417 pnd_log ( PND_LOG_DEFAULT, " Emit icon, couldn't open target\n" );
421 fseek ( pnd, 0, SEEK_END );
423 //fseek ( pnd, 0, SEEK_SET );
425 fseek ( pnd, p -> pnd_icon_pos, SEEK_SET );
427 len -= p -> pnd_icon_pos;
429 pnd_log ( PND_LOG_DEFAULT, " Emit icon, length: %u\n", len );
433 if ( len > (BITLEN) ) {
439 if ( fread ( bits, bitlen, 1, pnd ) != 1 ) {
443 pnd_log ( PND_LOG_DEFAULT, " Emit icon, bad read\n" );
450 char bigbuffer [ 200 * 1024 ] = "\0";
452 pnd_log ( PND_LOG_DEFAULT, " Read hexdump\n" );
453 while ( i < bitlen ) {
454 sprintf ( b, "%x,", bits [ i ] );
455 strcat ( bigbuffer, b );
458 pnd_log ( PND_LOG_DEFAULT, bigbuffer );
462 if ( fwrite ( bits, bitlen, 1, target ) != 1 ) {
466 pnd_log ( PND_LOG_DEFAULT, " Emit icon, bad write\n" );
471 //pnd_log ( PND_LOG_DEFAULT, " Emit icon, next block, length: %u\n", len );
477 //pnd_log ( PND_LOG_DEFAULT, " Emit icon, done.\n" );
482 #if 1 // we switched direction to freedesktop standard categories
483 // if no categories herein, return 0; otherwise, if some category-like-text, return 1
484 int pnd_map_dotdesktop_categories ( pnd_conf_handle c, char *target_buffer, unsigned short int len, pnd_disco_t *d ) {
488 // clear target so we can easily append
489 memset ( target_buffer, '\0', len );
491 // for each main-cat and sub-cat, including alternates, just append them all together
492 // we'll try mapping them, since the categories file is there, but we'll default to
493 // copying over; this lets the conf file do merging or renaming of cagtegories, which
494 // could still be useful, but we can leave the conf file empty to effect a pure
495 // trusted-PXML-copying
497 // it would be sort of cumbersome to copy all the freedesktop.org defined categories (as
498 // there are hundreds), and would also mean new ones and peoples custom ones would
501 /* attempt primary category chain
503 #define MAPCAT(field) \
504 if ( ( t = d -> field ) ) { \
505 match = pnd_map_dotdesktop_category ( c, t ); \
506 strncat ( target_buffer, match ? match : t, len ); \
507 strncat ( target_buffer, ";", len ); \
510 MAPCAT(main_category);
511 MAPCAT(main_category1);
512 MAPCAT(main_category2);
513 MAPCAT(alt_category);
514 MAPCAT(alt_category1);
515 MAPCAT(alt_category2);
517 if ( target_buffer [ 0 ] ) {
518 return ( 1 ); // I guess its 'good'?
522 if ( ( t = d -> main_category ) ) {
523 match = pnd_map_dotdesktop_category ( c, t );
524 strncat ( target_buffer, match ? match : t, len );
525 strncat ( target_buffer, ";", len );
533 #if 0 // we switched direction
534 //int pnd_map_dotdesktop_categories ( pnd_conf_handle c, char *target_buffer, unsigned short int len, pnd_pxml_handle h ) {
535 int pnd_map_dotdesktop_categories ( pnd_conf_handle c, char *target_buffer, unsigned short int len, pnd_disco_t *d ) {
536 unsigned short int n = 0; // no. matches
540 // clear target so we can easily append
541 memset ( target_buffer, '\0', len );
543 /* attempt primary category chain
547 if ( ( t = d -> main_category ) ) {
548 match = pnd_map_dotdesktop_category ( c, t );
552 ( t = d -> main_category1 ) )
554 match = pnd_map_dotdesktop_category ( c, t );
558 ( t = d -> main_category2 ) )
560 match = pnd_map_dotdesktop_category ( c, t );
564 strncat ( target_buffer, match, len );
565 len -= strlen ( target_buffer );
569 /* attempt secondary category chain
573 if ( ( t = d -> alt_category ) ) {
574 match = pnd_map_dotdesktop_category ( c, t );
578 ( t = d -> alt_category1 ) )
580 match = pnd_map_dotdesktop_category ( c, t );
584 ( t = d -> alt_category2 ) )
586 match = pnd_map_dotdesktop_category ( c, t );
590 if ( target_buffer [ 0 ] != '\0' && len > 0 ) {
591 strcat ( target_buffer, ";" );
594 strncat ( target_buffer, match, len );
595 len -= strlen ( target_buffer );
599 #if 0 // doh, originally I was using pxml-t till I realized I pre-boned myself on that one
602 if ( ( t = pnd_pxml_get_main_category ( h ) ) ) {
603 match = pnd_map_dotdesktop_category ( c, t );
607 ( t = pnd_pxml_get_subcategory1 ( h ) ) )
609 match = pnd_map_dotdesktop_category ( c, t );
613 ( t = pnd_pxml_get_subcategory2 ( h ) ) )
615 match = pnd_map_dotdesktop_category ( c, t );
619 strncat ( target_buffer, match, len );
620 len -= strlen ( target_buffer );
624 /* attempt secondary category chain
628 if ( ( t = pnd_pxml_get_altcategory ( h ) ) ) {
629 match = pnd_map_dotdesktop_category ( c, t );
633 ( t = pnd_pxml_get_altsubcategory1 ( h ) ) )
635 match = pnd_map_dotdesktop_category ( c, t );
639 ( t = pnd_pxml_get_altsubcategory2 ( h ) ) )
641 match = pnd_map_dotdesktop_category ( c, t );
645 if ( target_buffer [ 0 ] != '\0' && len > 0 ) {
646 strcat ( target_buffer, ";" );
649 strncat ( target_buffer, match, len );
650 len -= strlen ( target_buffer );
656 strcat ( target_buffer, ";" );
663 // given category 'foo', look it up in the provided config map. return the char* reference, or NULL
664 char *pnd_map_dotdesktop_category ( pnd_conf_handle c, char *single_category ) {
668 key = malloc ( strlen ( single_category ) + 4 + 1 );
670 sprintf ( key, "map.%s", single_category );
672 ret = pnd_conf_get_as_char ( c, key );
679 unsigned char *pnd_emit_icon_to_buffer ( pnd_disco_t *p, unsigned int *r_buflen ) {
680 // this is shamefully mostly a copy of emit_icon() above; really, need to refactor that to use this routine
681 // with a fwrite at the end...
682 char from [ FILENAME_MAX ]; // source filename
683 char bits [ 8 * 1024 ];
686 unsigned char *target = NULL, *targiter = NULL;
688 // prelim .. if a pnd file, and no offset found, discovery code didn't locate icon.. so bail.
689 if ( ( p -> object_type == pnd_object_type_pnd ) &&
690 ( ! p -> pnd_icon_pos ) )
692 return ( NULL ); // discover code didn't find it, so FAIL
695 /* first.. open the source file, by type of application:
696 * are we looking through a pnd file or a dir?
698 if ( p -> object_type == pnd_object_type_directory ) {
699 sprintf ( from, "%s/%s", p -> object_path, p -> icon );
700 } else if ( p -> object_type == pnd_object_type_pnd ) {
701 sprintf ( from, "%s/%s", p -> object_path, p -> object_filename );
704 pnd = fopen ( from, "r" );
710 // determine length of file, then adjust by icon position to find begin of icon
713 fseek ( pnd, 0, SEEK_END );
715 //fseek ( pnd, 0, SEEK_SET );
717 fseek ( pnd, p -> pnd_icon_pos, SEEK_SET );
719 len -= p -> pnd_icon_pos;
721 // create target buffer
722 target = malloc ( len );
735 // copy over icon to target
738 if ( len > (8*1024) ) {
744 if ( fread ( bits, bitlen, 1, pnd ) != 1 ) {
750 memmove ( targiter, bits, bitlen );
761 // parse_dotdesktop() can be used to read a libpnd generated .desktop and return a limited
762 // but useful disco-t structure back; possibly useful for scanning .desktops rather than
763 // scanning pnd-files?
764 pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath, unsigned int flags ) {
766 // will verify the .desktop has the libpnd-marking on it (X-Pandora-Source): PND_DOTDESKTOP_SOURCE
768 // attempt to extract..
769 // - unique-id (from filename or field)
770 // - subapp number (from filename)
771 // - exec required info
774 // - comment (desc-en)
777 // - appdata name (or unique-id if not present)
783 char pndpath [ 1024 ];
784 bzero ( pndpath, 1024 );
786 // filter on filename?
787 if ( flags & PND_DOTDESKTOP_LIBPND_ONLY ) {
788 // too bad we didn't put some libpnd token at the front of the filename or something
789 // hell, we should cleanse unique-id to ensure its not full of special chars like '*' and '..'.. eep!
790 if ( strrchr ( ddpath, '#' ) == NULL ) { // but if requiring libpnd, we can at least check for #subapp-number
795 if ( strstr ( ddpath, ".desktop" ) == NULL ) {
799 if ( strstr ( ddpath, "info.desktop" ) != NULL ) {
803 // determine file length
806 if ( stat ( ddpath, &statbuf) < 0 ) {
807 return ( NULL ); // couldn't open
812 unsigned char libpnd_origin = 0;
815 pnd_disco_t *p = malloc ( sizeof(pnd_disco_t) );
819 bzero ( p, sizeof(pnd_disco_t) );
822 FILE *f = fopen ( ddpath, "r" );
825 return ( NULL ); // not up or shut up!
828 while ( fgets ( dd, 1024, f ) ) {
829 char *nl = strchr ( dd, '\n' );
837 if ( strncmp ( dd, "Name=", 5 ) == 0 ) {
838 p -> title_en = strdup ( dd + 5 );
839 } else if ( strncmp ( dd, "Name[en]=", 9 ) == 0 ) {
840 p -> title_en = strdup ( dd + 9 );
841 } else if ( strncmp ( dd, "Icon=", 5 ) == 0 ) {
842 p -> icon = strdup ( dd + 5 );
843 } else if ( strcmp ( dd, PND_DOTDESKTOP_SOURCE ) == 0 ) {
845 } else if ( strncmp ( dd, "X-Pandora-UID=", 14 ) == 0 ) {
846 p -> unique_id = strdup ( dd + 14 );
847 } else if ( strncmp ( dd, "X-Pandora-Preview-Pic-1=", 24 ) == 0 ) {
848 p -> preview_pic1 = strdup ( dd + 24 );
849 } else if ( strncmp ( dd, "X-Pandora-Clockspeed=", 21 ) == 0 ) {
850 p -> clockspeed = strdup ( dd + 21 );
851 } else if ( strncmp ( dd, "X-Pandora-Startdir=", 19 ) == 0 ) {
852 p -> startdir = strdup ( dd + 19 );
854 } else if ( strncmp ( dd, "X-Pandora-MainCategory=", 23 ) == 0 ) {
855 p -> main_category = strdup ( dd + 23 );
856 } else if ( strncmp ( dd, "X-Pandora-MainCategory1=", 24 ) == 0 ) {
857 p -> main_category1 = strdup ( dd + 24 );
858 } else if ( strncmp ( dd, "X-Pandora-MainCategory2=", 24 ) == 0 ) {
859 p -> main_category2 = strdup ( dd + 24 );
861 } else if ( strncmp ( dd, "X-Pandora-AltCategory=", 22 ) == 0 ) {
862 p -> alt_category = strdup ( dd + 22 );
863 } else if ( strncmp ( dd, "X-Pandora-AltCategory1=", 23 ) == 0 ) {
864 p -> alt_category1 = strdup ( dd + 23 );
865 } else if ( strncmp ( dd, "X-Pandora-AltCategory2=", 23 ) == 0 ) {
866 p -> alt_category2 = strdup ( dd + 23 );
868 } else if ( strncmp ( dd, "Comment=", 8 ) == 0 ) {
869 p -> desc_en = strdup ( dd + 8 );
870 } else if ( strncmp ( dd, "Comment[en]=", 12 ) == 0 ) {
871 p -> desc_en = strdup ( dd + 12 );
872 } else if ( strncmp ( dd, "Exec=", 5 ) == 0 ) {
874 char *e = strstr ( dd, " -e " );
877 // probably libpnd app
882 char *space = strchr ( e, ' ' );
883 p -> exec = strndup ( e, space - e - 1 );
886 char *b = strstr ( dd, " -b " );
889 char *space = strchr ( b, '\0' );
890 p -> appdata_dirname = strndup ( b, space - b - 1 );
893 char *p = strstr ( dd, " -p " );
896 char *space = strchr ( p, ' ' );
897 strncpy ( pndpath, p, space - p - 1 );
901 // probably not libpnd app
902 p -> exec = strdup ( dd + 5 );
905 #if 0 // ignore; using X- categories now
906 } else if ( strncmp ( dd, "Categories=", 11 ) == 0 ) {
907 // HACK; only honours first category
908 char *semi = strchr ( dd, ';' );
910 p -> main_category = strndup ( dd + 11, semi - dd + 11 );
912 p -> main_category = strdup ( dd + 11 );
914 semi = strchr ( p -> main_category, ';' );
930 if ( ! libpnd_origin ) {
933 if ( flags & PND_DOTDESKTOP_LIBPND_ONLY ) {
934 pnd_disco_destroy ( p );
940 p -> object_flags |= PND_DISCO_CUSTOM1; // so caller can do something if it wishes
944 if ( ( ! p -> title_en ) ||
948 pnd_disco_destroy ( p );
953 if ( ! p -> unique_id ) {
954 if ( flags & PND_DOTDESKTOP_LIBPND_ONLY ) {
955 pnd_disco_destroy ( p );
960 snprintf ( hack, 100, "inode-%lu", statbuf.st_ino );
961 p -> unique_id = strdup ( hack );
966 p -> object_type = pnd_object_type_pnd;
969 if ( pndpath [ 0 ] ) {
975 char *slash = strrchr ( source, '/' );
977 p -> object_path = strndup ( source, slash - source );
978 p -> object_filename = strdup ( slash + 1 );
980 p -> object_path = "./";
981 p -> object_filename = strdup ( source );