unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t *p ) {
char filename [ FILENAME_MAX ];
- char buffer [ 1024 ];
+ char buffer [ 4096 ];
FILE *f;
// specification
}
#endif
+ // association requests
+ if ( p -> associationitem1_filetype ) {
+ fprintf ( f, "MimeType=%s\n", p -> associationitem1_filetype );
+ }
+
if ( p -> exec ) {
char *nohup;
strncat ( buffer, p -> startdir, 1020 );
}
- // args
+ // args (regular args, for pnd_run.sh to handle)
if ( p -> execargs ) {
char argbuf [ 1024 ];
snprintf ( argbuf, 1000, " -a \"%s\"", p -> execargs );
strncat ( buffer, " -x ", 1020 );
}
+ // args (dashdash -- args, that the shell can screw with before pnd_run.sh gets them)
+ if ( p -> exec_dashdash_args ) {
+ char argbuf [ 4096 ];
+ snprintf ( argbuf, 4096, " -- %s", p -> exec_dashdash_args );
+ strncat ( buffer, argbuf, 4096 );
+ }
+
// newline
strncat ( buffer, "\n", 1020 );
// prelim .. if a pnd file, and no offset found, discovery code didn't locate icon.. so bail.
if ( ( p -> object_type == pnd_object_type_pnd ) &&
- ( ! p -> pnd_icon_pos ) )
+ ( ! p -> pnd_icon_pos64 ) )
{
return ( 0 ); // discover code didn't find it, so FAIL
}
return ( 0 );
}
- unsigned int len;
+ off_t len;
target = fopen ( buffer, "wb" );
return ( 0 );
}
- fseek ( pnd, 0, SEEK_END );
- len = ftell ( pnd );
- //fseek ( pnd, 0, SEEK_SET );
+ fseeko ( pnd, 0, SEEK_END );
+ len = ftello ( pnd );
- fseek ( pnd, p -> pnd_icon_pos, SEEK_SET );
+ fseeko ( pnd, p -> pnd_icon_pos64, SEEK_SET );
- len -= p -> pnd_icon_pos;
+ len -= p -> pnd_icon_pos64;
- pnd_log ( PND_LOG_DEFAULT, " Emit icon, length: %u\n", len );
+ if ( len <= 0 ) {
+ fclose ( pnd );
+ return ( 0 );
+ }
+
+ pnd_log ( PND_LOG_DEFAULT, " Emit icon, length: %u\n", (int)len );
while ( len ) {
#define MAPCAT(field) \
if ( ( t = d -> field ) ) { \
match = pnd_map_dotdesktop_category ( c, t ); \
- strncat ( target_buffer, match ? match : t, len ); \
- strncat ( target_buffer, ";", len ); \
+ if ( ( !match ) || ( strcasecmp ( match, "NoCategory" ) ) ) { \
+ strncat ( target_buffer, match ? match : t, len ); \
+ strncat ( target_buffer, ";", len ); \
+ } \
}
MAPCAT(main_category);
// prelim .. if a pnd file, and no offset found, discovery code didn't locate icon.. so bail.
if ( ( p -> object_type == pnd_object_type_pnd ) &&
- ( ! p -> pnd_icon_pos ) )
+ ( ! p -> pnd_icon_pos64 ) )
{
return ( NULL ); // discover code didn't find it, so FAIL
}
}
// determine length of file, then adjust by icon position to find begin of icon
- unsigned int len;
+ off_t len;
+
+ fseeko ( pnd, 0, SEEK_END );
+ len = ftello ( pnd );
- fseek ( pnd, 0, SEEK_END );
- len = ftell ( pnd );
- //fseek ( pnd, 0, SEEK_SET );
+ fseeko ( pnd, p -> pnd_icon_pos64, SEEK_SET );
- fseek ( pnd, p -> pnd_icon_pos, SEEK_SET );
+ len -= p -> pnd_icon_pos64;
- len -= p -> pnd_icon_pos;
+ if ( len <= 0 ) {
+ fclose ( pnd );
+ return ( NULL );
+ }
// create target buffer
target = malloc ( len );
return ( NULL );
} else {
char hack [ 100 ];
- snprintf ( hack, 100, "inode-%lu", statbuf.st_ino );
+ snprintf ( hack, 100, "inode-%lu", (long)statbuf.st_ino );
p -> unique_id = strdup ( hack );
}
}