libnw hacks

This page contains links to some of my libnw hacks. It is autogenerated from the comments (if any) at the head of each file.

AUTHORS(updated Sun Jan 22 20:35:02 2006)


COPYING(updated Wed Aug 8 11:50:46 2007)


ChangeLog(updated Sun Jan 22 20:35:02 2006)


FILE_FORMAT_v1.txt(updated Sun Jan 14 20:58:52 2007)


FILE_FORMAT_v2.txt(updated Mon May 7 20:18:35 2007)


INSTALL(updated Wed Aug 8 11:50:46 2007)


Makefile.am(updated Wed Dec 12 23:38:11 2007)


Makefile.in(updated Wed Dec 12 23:38:11 2007)
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.


NEWS(updated Sun Jan 22 20:35:02 2006)


README(updated Sun Jan 14 20:58:52 2007)


README.ORIG(updated Sun Jan 14 20:58:52 2007)


aclocal.m4(updated Wed Dec 12 23:38:11 2007)
# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
# serial 48 AC_PROG_LIBTOOL
# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
# -----------------------------------------------------------
# If this macro is not defined by Autoconf, define it here.


common.c(updated Wed Dec 27 18:54:40 2006)
/* this file originally came from the mpg123 plugin, although I've
carved it up quite a bit. It's under GPL. */
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "mple.h"
#include "common.h"
#define MAX_SKIP_LENGTH (256 * 1024)
#define MPG_MD_STEREO 0
#define MPG_MD_JOINT_STEREO 1
#define MPG_MD_DUAL_CHANNEL 2
#define MPG_MD_MONO 3
#define ID3_GET_SIZE28(a, b, c, d) \


common.h(updated Tue Dec 12 00:03:39 2006)
/* private header file to attach common.c to mple.c */
/*
* MP3 file stuff
* This is largely to work around the huge number of globals present
* in the mpg123 code
*/
#define MAXFRAMESIZE 1792


config.h.in(updated Wed Dec 12 23:38:11 2007)
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `dbus-1' library (-ldbus-1). */
#undef HAVE_LIBDBUS_1
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t


configure(updated Wed Dec 12 23:38:11 2007)
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for libnw 0.1.
#
# Report bugs to <waider@waider.ie>.
#
# Copyright (C) 2003 Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
# Be Bourne compatible


configure.ac(updated Wed Dec 12 23:38:11 2007)
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.


libnw-test.c(updated Sun Oct 14 21:25:36 2007)
/* test rig for libNW functions */
/* caution: will delete the contents of whatever you tell it is the
test device */
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <glib.h>
#include <unistd.h>
#include <libnw.h>
/* need this for frobbing the test file */
#include <common.h>
#define TEST_DEVICE "/var/tmp/NW-S23"
#define TEST_FILE "test.mp3"
/*
* The original MP3 code pads out short reads with zeros, which is
* fine and sensible for streaming but makes no sense, really, for
* file reads. This switches it on and off and adjusts the expected
* test results accordingly.
*/
#ifdef PAD_SHORT_READ
#define TEST_FILE_SIZE 703040
#define TEST_FILE_MS 43521
#define TEST_FILE_FRAMES 1682
#else
#define TEST_FILE_SIZE 702622
#define TEST_FILE_MS 43495
#define TEST_FILE_FRAMES 1681
#endif


libnw.c(updated Wed Dec 12 23:38:11 2007)
#include <libnw.h>
#include <libnw_internals.h>
#include <glib.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h> /* TEMP */
#include <id3tag.h>
#include "mple.h"
#include "mple_v2.h"
#include "common.h"
/*
* scan for any available devices. currently only scans for v1. The
* MAGIC parameter is a string that HAL identifies the device with,
* e.g. "NETWORK WALKMAN".
*/


libnw.h(updated Sun Oct 14 21:25:36 2007)
#ifndef LIBNW_H
#define LIBNW_H
#include <glib.h>
#include <sys/time.h>
#include <id3tag.h>
#include <stdio.h>
#include <sys/stat.h>
/* predeclare the structs */


libnw_internals.h(updated Sun Oct 14 21:25:36 2007)
#ifndef LIB_NW_INTERNALS_H
#define LIB_NW_INTERNALS_H
#include <libnw.h>


mp3filemanager.c(updated Sun Oct 14 21:25:36 2007)
/*
* This is a Gtk2 replacement for the MP3FileManager program shipped
* with the Sony NW-S23. It currently needs the following things
* fixed (X marks the ones I've fixed):
*
* X dropping folders at specific positions doesn't work; they always
* get appended to the end of the folder list. You can move 'em
* around once they're on the device, though.
* X changes are synced to the device far too often, and the syncing
* is a huge kludge that involves deleting the entire track/folder
* list, syncing that, then rebuilding the new list from
* scratch. Mostly this is because I need to add a few more hooks to
* mple.c
* X doesn't delete mp*.dat files when tracks are deleted from the
* UI. The index entries *are* deleted, so the mpdat files won't
* play, though.
* * Delete All button does nothing
* * You can't select more than one thing at a time from the
* list. This is a serious pain if you're trying to make bulk
* changes, such as moving a half-dozen tracks. This can't be fixed
* without subclassing, see below.
* * Delete All and Delete both have confirm dialogs in the Windows
* version.
* * The file transfer stuff needs a little fixing - the main window
* should be disabled; this is done with - I think - an
* application-modal window on Windows. A better idea would be to
* thread the transfer process so you could keep adding files while
* the current transfer is in progress.
* * You can't drop a deep directory structure on it and expect it to
* do something useful. Windows will collapse a Band/Album/Mp3.mp3
* filename into Folder "Band Album", Track Mp3.mp3
* X Files should be listed by the mp3 filename, not the mp3 title.
* * The windows version doesn't use a progress bar for
* transfers. While I like the progress bar, it does mean that the
* status bar is only half as wide as it should be.
* * It would be nice if I could handle any URI that drag-and-drop
* throws me; at the very least, dragging a URL from firefox into
* the gadget would be cool.
* * Context menu is broken
* * Context menu should allow you to edit the metadata of a file
* X The device path is hardcoded.
* * Mount/Unmount device would be neat
* * dropping is still not quite right
* - dropping a file at the end of the device
* - dropping a file onto a folder prepends instead of appends
*
* And internally;
* * the code is full of memory leaks. I did a dry-run with valgrind,
* but there's so much noise from Gtk and X that I gave up.
* * Globals. I hate globals. I hate hate hate hate them.
* * Might be smart to isolate the unix-specific stuff if I'm going to
* try building this on Windows at some point. There are probably
* glib functions to help me.
*
* The code is, in general, pretty horrible, in part because I'm
* trying to force the default GtkTree stuff to do things it's not
* really meant to do. At some point I need to learn how to subclass
* the GtkTreeStore so I can add on the bits I need, such as better
* drag/drop, edit on button-click rather than button-press, etc.
*
* The other reason the code is horrible is that I've not done any
* serious Gtk work before, and it's not exactly intuitive. I keep
* finding useful glib functions after I've spent half an hour writing
* equivalent code, too. Henry Spencer would be proud...
*/
/*


mple.c(updated Sun Oct 14 21:25:36 2007)
/*
* Interfacing library for Sony's obfuscated MP3 file format as used
* on their network walkman devices
*
* Waider, March 2005
*/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <wchar.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <malloc.h>
#include <time.h>
#include <glib.h>
/* mp3 internals handling */
#include <id3tag.h>
/* hardware abstraction layer, for obtaining the serial off the device */
#ifdef HAL_VERSION
#include <libhal.h>
#if HAL_VERSION == 4
#define libhal_get_all_devices(x,y,z) hal_get_all_devices(x,y)
#define libhal_device_property_exists(w,x,y,z) \
hal_device_property_exists(w,x,y)
#define libhal_device_get_property_string(w,x,y,z) \
hal_device_get_property_string(w,x,y)
#define libhal_device_get_property_bool(w,x,y,z) \
hal_device_get_property_bool(w,x,y)
#define libhal_free_string(x) hal_free_string(x)
#define libhal_free_string_array(x) hal_free_string_array(x)
#endif
#endif
#include "libnw.h"
#include "mple.h"
#include "config.h"
#include "common.h"
#include "util.h"
/******************************************************************************
* DEVICE MANIPULATION
*****************************************************************************/
/* this is, obviously, undocumented */


mple.h(updated Thu Apr 5 21:38:00 2007)
#ifndef MPLE_H
#define MPLE_H
#include <glib.h>
/* I hate include files that aren't self-contained */
#include <time.h>
#include <id3tag.h>
#include <stdio.h>
#include <sys/stat.h>
#include <libnw.h>
#include <libnw_internals.h>
#define DEFAULT_PB_TEMPLATE "%s/esys/pblist%d.dat"
#define DEFAULT_MP_TEMPLATE "%s/esys/nw-mp3/mp%04x.dat"
#define DEFAULT_MASTER_PBLIST 1
#define MAX_TRACKS 40000 /* according to the manual */
/* On-disk data structures and magic */
#define PBLIST_MAGIC "\x00\x03\xce\xa0"
#define MPDAT_MAGIC "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
/* This is used to find likely devices in HAL */
#define HAL_MAGIC "NETWORK WALKMAN"
/* Header structure from pblist file [incomplete] */


mple_v2.c(updated Sun Oct 14 21:25:36 2007)
#include <glib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <id3tag.h>
#include <malloc.h>
#include <assert.h>
#include <sys/types.h>
#include "libnw.h"
#include "mple_v2.h"
#include "common.h"
#include "util.h"
/* functions for dealing with common file structures */


mple_v2.h(updated Mon May 7 20:18:35 2007)
#ifndef MPLE_V2_H
#define MPLE_V2_H
#include <glib.h>
#include <libnw.h>
#include <libnw_internals.h>


nw-cp.c(updated Sat Aug 11 18:47:33 2007)
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <libnw.h>
#include <string.h>
#include <errno.h>
#include <iconv.h>
/*
* convert a UTF16BE string to UTF8 and print it. Because iconv messes
* with the i/o pointers, we need to keep two copies of each.
*/


nw-dump.c(updated Tue Apr 10 22:46:27 2007)
/*
* Dump the contents of the player. Takes a single parameter: the
* mount-point of the player.
*/
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <ctype.h>
#include <errno.h>
#include <glib.h>
#include <iconv.h>
#include <time.h>
#include <libnw.h>


nw-load.c(updated Wed Dec 12 23:38:11 2007)
/* load files onto the Network Walkman */
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <glib.h>
#include <unistd.h>
#include "libnw.h"


nw-rm.c(updated Thu Apr 5 21:38:00 2007)
/* load files onto the Network Walkman */
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <glib.h>
#include <libnw.h>


util.c(updated Mon May 7 20:18:35 2007)
/*
* utility functions
*/
#include <id3tag.h>
#include "util.h"
#include "config.h"
/*
* effectively mkdir -p
* create directory PATH, including any required parent directories,
* using MODE as the file mode for each newly created directory.
*/


util.h(updated Sat Apr 14 14:20:31 2007)
#ifndef UTIL_H
#define UTIL_H
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <glib.h>



Waider Ugh. Did I write that?