assorted-commits Mailing List for Assorted projects (Page 18)
Brought to you by:
yangzhang
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(9) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(86) |
Feb
(265) |
Mar
(96) |
Apr
(47) |
May
(136) |
Jun
(28) |
Jul
(57) |
Aug
(42) |
Sep
(20) |
Oct
(67) |
Nov
(37) |
Dec
(34) |
2009 |
Jan
(39) |
Feb
(85) |
Mar
(96) |
Apr
(24) |
May
(82) |
Jun
(13) |
Jul
(10) |
Aug
(8) |
Sep
(2) |
Oct
(20) |
Nov
(31) |
Dec
(17) |
2010 |
Jan
(16) |
Feb
(11) |
Mar
(17) |
Apr
(53) |
May
(31) |
Jun
(13) |
Jul
(3) |
Aug
(6) |
Sep
(11) |
Oct
(4) |
Nov
(17) |
Dec
(17) |
2011 |
Jan
(3) |
Feb
(19) |
Mar
(5) |
Apr
(17) |
May
(3) |
Jun
(4) |
Jul
(14) |
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
(3) |
Dec
(2) |
2012 |
Jan
(3) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
(4) |
Aug
(5) |
Sep
(2) |
Oct
(3) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(9) |
Apr
(5) |
May
|
Jun
(2) |
Jul
(1) |
Aug
(10) |
Sep
(1) |
Oct
(2) |
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
(3) |
Mar
(3) |
Apr
(1) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2016 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <yan...@us...> - 2009-10-08 16:37:07
|
Revision: 1477 http://assorted.svn.sourceforge.net/assorted/?rev=1477&view=rev Author: yangzhang Date: 2009-10-08 16:36:53 +0000 (Thu, 08 Oct 2009) Log Message: ----------- added readme Added Paths: ----------- sandbox/trunk/src/win/eventshare/README Added: sandbox/trunk/src/win/eventshare/README =================================================================== --- sandbox/trunk/src/win/eventshare/README (rev 0) +++ sandbox/trunk/src/win/eventshare/README 2009-10-08 16:36:53 UTC (rev 1477) @@ -0,0 +1,2 @@ +This is from an osronline article in 9/2002-10/2002 issue. It no longer works +due to session changes. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-10-08 00:37:20
|
Revision: 1476 http://assorted.svn.sourceforge.net/assorted/?rev=1476&view=rev Author: yangzhang Date: 2009-10-08 00:37:07 +0000 (Thu, 08 Oct 2009) Log Message: ----------- added NT event-sharing example Added Paths: ----------- sandbox/trunk/src/win/ sandbox/trunk/src/win/eventshare/ sandbox/trunk/src/win/eventshare/eventshare/ sandbox/trunk/src/win/eventshare/eventshare/MAKEFILE sandbox/trunk/src/win/eventshare/eventshare/eventshare.c sandbox/trunk/src/win/eventshare/eventshare/sources sandbox/trunk/src/win/eventshare/eventsys/ sandbox/trunk/src/win/eventshare/eventsys/MAKEFILE sandbox/trunk/src/win/eventshare/eventsys/SOURCES sandbox/trunk/src/win/eventshare/eventsys/eventsys.c sandbox/trunk/src/win/eventshare/inc/ sandbox/trunk/src/win/eventshare/inc/eventioctl.h Added: sandbox/trunk/src/win/eventshare/eventshare/MAKEFILE =================================================================== --- sandbox/trunk/src/win/eventshare/eventshare/MAKEFILE (rev 0) +++ sandbox/trunk/src/win/eventshare/eventshare/MAKEFILE 2009-10-08 00:37:07 UTC (rev 1476) @@ -0,0 +1,6 @@ +# +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the components of NT OS/2 +# +!INCLUDE $(NTMAKEENV)\makefile.def Added: sandbox/trunk/src/win/eventshare/eventshare/eventshare.c =================================================================== --- sandbox/trunk/src/win/eventshare/eventshare/eventshare.c (rev 0) +++ sandbox/trunk/src/win/eventshare/eventshare/eventshare.c 2009-10-08 00:37:07 UTC (rev 1476) @@ -0,0 +1,141 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright 1995 - 2002 OSR Open Systems Resources, Inc. +// All Rights Reserved +// +// This sofware is supplied for instructional purposes only. +// +// OSR Open Systems Resources, Inc. (OSR) expressly disclaims any warranty +// for this software. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, +// THE IMPLIED WARRANTIES OF MECHANTABILITY OR FITNESS FOR A PARTICULAR +// PURPOSE. THE ENTIRE RISK ARISING FROM THE USE OF THIS SOFTWARE REMAINS +// WITH YOU. OSR's entire liability and your exclusive remedy shall not +// exceed the price paid for this material. In no event shall OSR or its +// suppliers be liable for any damages whatsoever (including, without +// limitation, damages for loss of business profit, business interruption, +// loss of business information, or any other pecuniary loss) arising out +// of the use or inability to use this software, even if OSR has been +// advised of the possibility of such damages. Because some states/ +// jurisdictions do not allow the exclusion or limitation of liability for +// consequential or incidental damages, the above limitation may not apply +// to you. +// +// OSR Open Systems Resources, Inc. +// 105 Route 101A Suite 19 +// Amherst, NH 03031 (603) 595-6500 FAX: (603) 595-6503 +// email bugs to: bu...@os... +// +// +// MODULE: +// +// EventShare.C -- Event Share example user mode component +// +// ABSTRACT: +// +// This is a console application that simply creates a named event, +// sends an IOCTL to the event share driver to open a handle +// to the event, and waits for the driver to signal the event +// +// AUTHOR(S): +// +// OSR Open Systems Resources, Inc. +// +// REVISION: +// +// +/////////////////////////////////////////////////////////////////////////////// +#include <windows.h> +#include <winioctl.h> +#include "..\inc\eventioctl.h" +#include <stdio.h> + +int __cdecl main(void) +{ + DWORD bytesReturned; + DWORD WaitStatus; + + HANDLE DeviceDriver; + HANDLE SharedEvent; + + // + // Open up a handle to the device driver + // + DeviceDriver = CreateFile( + "\\\\.\\EventShare", // lpFileName + GENERIC_READ | GENERIC_WRITE, // dwDesiredAccess + FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode + NULL, // lpSecurityAttributes + OPEN_EXISTING, // dwCreationDistribution + 0, // dwFlagsAndAttributes + NULL // hTemplateFile + ); + + if (DeviceDriver == INVALID_HANDLE_VALUE) { + + printf("Unable to open handle to the device driver\n"); + return 1; + + } + + // + // Create named event that will be shared between the driver and + // application. Note that this event is actually created under + // \BaseNamedObjects\ by the object manager so we will need to add + // that to the event name when we try and open this event from kernel mode + // + SharedEvent = CreateEvent(NULL, TRUE, FALSE, "SharedEvent"); + + if (SharedEvent == NULL) { + + printf("Cannot create named event!\n"); + return 1; + + } + + // + // Send an IOCTL to the driver to signal that the named event + // has been created and that it can now open a handle to it + // + if (!DeviceIoControl(DeviceDriver, + IOCTL_OPEN_EVENT, + NULL, 0, + NULL, 0, + &bytesReturned, + NULL)) { + + printf("The driver failed to open the named event!\n"); + return 1; + + } + + // + // Now we can just sit back and wait for the driver to signal our event. + // It should really happen well before 5 seconds... + // + WaitStatus = WaitForSingleObject(SharedEvent, 5000); + + if (WaitStatus != WAIT_OBJECT_0) { + + printf("Driver failed to signal event! WaitForSingleObject returned 0x%8.8x\n", + WaitStatus); + + } else { + + // + // Voila! We've successfully awoken a user mode application by signalling + // an event in kernel mode! + // + printf("The driver has successfully signaled our named event!\n"); + + } + + // + // Clean up any and all resources allocated + // + CloseHandle(SharedEvent); + CloseHandle(DeviceDriver); + + return 0; + +} Added: sandbox/trunk/src/win/eventshare/eventshare/sources =================================================================== --- sandbox/trunk/src/win/eventshare/eventshare/sources (rev 0) +++ sandbox/trunk/src/win/eventshare/eventshare/sources 2009-10-08 00:37:07 UTC (rev 1476) @@ -0,0 +1,17 @@ +TARGETNAME=eventshare +TARGETTYPE=PROGRAM + +USE_MSVCRT=1 + +MSC_WARNING_LEVEL=/W4 /WX + +_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) + +INCLUDES=..\eventsys + + + +SOURCES=eventshare.c + +UMTYPE=console +UMBASE=0x400000 Added: sandbox/trunk/src/win/eventshare/eventsys/MAKEFILE =================================================================== --- sandbox/trunk/src/win/eventshare/eventsys/MAKEFILE (rev 0) +++ sandbox/trunk/src/win/eventshare/eventsys/MAKEFILE 2009-10-08 00:37:07 UTC (rev 1476) @@ -0,0 +1,6 @@ +# +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the components of NT OS/2 +# +!INCLUDE $(NTMAKEENV)\makefile.def Added: sandbox/trunk/src/win/eventshare/eventsys/SOURCES =================================================================== --- sandbox/trunk/src/win/eventshare/eventsys/SOURCES (rev 0) +++ sandbox/trunk/src/win/eventshare/eventsys/SOURCES 2009-10-08 00:37:07 UTC (rev 1476) @@ -0,0 +1,10 @@ +MAJORCOMP=ntos +MINORCOMP=osr + +TARGETNAME=eventsys +TARGETPATH=obj +TARGETTYPE=DRIVER + +INCLUDES=$(BASEDIR)\inc;..\inc + +SOURCES= eventsys.c \ Added: sandbox/trunk/src/win/eventshare/eventsys/eventsys.c =================================================================== --- sandbox/trunk/src/win/eventshare/eventsys/eventsys.c (rev 0) +++ sandbox/trunk/src/win/eventshare/eventsys/eventsys.c 2009-10-08 00:37:07 UTC (rev 1476) @@ -0,0 +1,553 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright 1995 - 2003 OSR Open Systems Resources, Inc. +// All Rights Reserved +// +// This sofware is supplied for instructional purposes only. +// +// OSR Open Systems Resources, Inc. (OSR) expressly disclaims any warranty +// for this software. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, +// THE IMPLIED WARRANTIES OF MECHANTABILITY OR FITNESS FOR A PARTICULAR +// PURPOSE. THE ENTIRE RISK ARISING FROM THE USE OF THIS SOFTWARE REMAINS +// WITH YOU. OSR's entire liability and your exclusive remedy shall not +// exceed the price paid for this material. In no event shall OSR or its +// suppliers be liable for any damages whatsoever (including, without +// limitation, damages for loss of business profit, business interruption, +// loss of business information, or any other pecuniary loss) arising out +// of the use or inability to use this software, even if OSR has been +// advised of the possibility of such damages. Because some states/ +// jurisdictions do not allow the exclusion or limitation of liability for +// consequential or incidental damages, the above limitation may not apply +// to you. +// +// OSR Open Systems Resources, Inc. +// 105 Route 101A Suite 19 +// Amherst, NH 03031 (603) 595-6500 FAX: (603) 595-6503 +// email bugs to: bu...@os... +// +// +// MODULE: +// +// EventShare.C -- Event Share example kernel mode component +// +// ABSTRACT: +// +// This is a legacy device driver that simply gets a handle to and +// sets a named event that is created by a user mode application +// +// AUTHOR(S): +// +// OSR Open Systems Resources, Inc. +// +// REVISION: +// +// +/////////////////////////////////////////////////////////////////////////////// +#include <ntddk.h> +#include <eventioctl.h> + +// +// Global Variables +// + +// +// Our Device Object +// +PDEVICE_OBJECT DeviceObject = NULL; + + +// +// Handle to the shared event +// +HANDLE SharedEventHandle = NULL; + +// +// The actual shared event object +// +PKEVENT SharedEvent = NULL; + + +/////////////////////////////////////////////////////////////////////////////// +// +// EventSysTimerCallback +// +// This is the callback routine in which we'll actually signal the event +// +// +// INPUTS: +// +// DeviceObject - Address of the DEVICE_OBJECT for our device. +// +// Context - Not used +// +// OUTPUTS: +// +// None. +// +// RETURNS: +// +// None +// +// IRQL: +// +// This routine is called at IRQL DISPATCH_LEVEL. +// +// NOTES: +// +/////////////////////////////////////////////////////////////////////////////// +VOID +EventSysTimerCallback ( + IN PDEVICE_OBJECT DeviceObject, + IN PVOID Context + ) + +{ +#if DBG + DbgPrint("EventSysTimerCallback: Entered...\n"); +#endif + + + // + // Set the event so that the user mode application's wait will + // be satisfied. Note that the third parameter, Wait, must be + // set to FALSE since we're running at DISPATCH_LEVEL + // + KeSetEvent(SharedEvent, 0, FALSE); + + +#if DBG + DbgPrint("EventSysTimerCallback: Exited...\n"); +#endif +} + +/////////////////////////////////////////////////////////////////////////////// +// +// EventSysCreateClose +// +// This is the dispatch entry point for processing both IRP_MJ_CREATE +// and IRP_MJ_CLOSE functions. Since this is a simple device driver, +// there's really nothing to do here by complete the requests with success. +// +// +// INPUTS: +// +// DeviceObject - Address of the DEVICE_OBJECT for our device. +// +// Irp - Address of the IRP representing the IRP_MJ_CREATE or IRP_MJ_CLOSE +// call. +// +// OUTPUTS: +// +// None. +// +// RETURNS: +// +// STATUS_SUCCESS. We never fail this function. +// +// IRQL: +// +// This routine is called at IRQL PASSIVE_LEVEL. +// +// NOTES: +// +/////////////////////////////////////////////////////////////////////////////// +NTSTATUS EventSysCreateClose(PDEVICE_OBJECT DeviceObject, PIRP Irp) +{ + PIO_STACK_LOCATION ioStack = IoGetCurrentIrpStackLocation(Irp); + +#if DBG + DbgPrint("EventSysCreateClose: Entered\n"); +#endif + + // + // Nothing much to do.... + // + Irp->IoStatus.Status = STATUS_SUCCESS; + + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + +#if DBG + DbgPrint("EventSysCreateClose: Exited...\n"); +#endif + + return(STATUS_SUCCESS); +} + + +/////////////////////////////////////////////////////////////////////////////// +// +// EventSysDeviceControl +// +// This is the dispatch entry point for processing IRP_MJ_DEVICE_CONTROL +// Irps. +// +// +// INPUTS: +// +// DeviceObject - Address of the DEVICE_OBJECT for our device. +// +// Irp - Address of the IRP representing the IRP_MJ_DEVICE_CONTROL call. +// +// OUTPUTS: +// +// None. +// +// RETURNS: +// +// STATUS_SUCCESS if success, otherwise an appropriate status is returned. +// +// IRQL: +// +// This routine is called at IRQL_PASSIVE_LEVEL. +// +// NOTES: +// +// +/////////////////////////////////////////////////////////////////////////////// +NTSTATUS EventSysDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) +{ + ULONG operation; + PIO_STACK_LOCATION ioStack = IoGetCurrentIrpStackLocation(Irp); + NTSTATUS Status; + KIRQL Irql; + UNICODE_STRING EventName; + HANDLE UserHandle; + +#if DBG + DbgPrint("EventSysDeviceControl: Entered...\n"); +#endif + + operation = ioStack->Parameters.DeviceIoControl.IoControlCode; + + // + // Set the status field to zero for completion + // + Irp->IoStatus.Information = 0; + + switch (operation) { + + // + // IOCTL to open the handle the CORRECT way + // + case IOCTL_OPEN_EVENT: + +#if DBG + DbgPrint("EventSysDeviceControl: Received IOCTL_OPEN_EVENT\n"); +#endif + + // + // When you create a named event in user mode \BaseNamedObjects\ is + // prepended to the name specified in the call to CreateEvent + // + RtlInitUnicodeString(&EventName, L"\\BaseNamedObjects\\SharedEvent"); + + // + // Get a pointer to a KEVENT object that is associated with this + // named event + // + SharedEvent = IoCreateNotificationEvent(&EventName, &SharedEventHandle); + + if (SharedEvent != NULL) { + + // + // Take a reference out on the object so that + // it does not go away if the application + // goes away unexpectedly + // + ObReferenceObject(SharedEvent); + + + Status = STATUS_SUCCESS; + + // + // Start the timer that signals the event + // + IoStartTimer(DeviceObject); + + } else { + + Status = STATUS_UNSUCCESSFUL; + + } + + break; + + // + // IOCTL to open the handle the undesirable way + // + case IOCTL_EVENT_HANDLE: + +#if DBG + DbgPrint("EventSysDeviceControl: Received IOCTL_EVENT_HANDLE\n"); +#endif + + // + // Get the user's handle + // + UserHandle = *(HANDLE *)Irp->AssociatedIrp.SystemBuffer; + + // + // Passing *ExEventObjectType validates that this is indeed and event + // handle + // + // Passing UserMode performs all necessary access checks to make sure + // the calling application has appropriate security access to the handle + // + Status = ObReferenceObjectByHandle( + UserHandle, + EVENT_ALL_ACCESS, + *ExEventObjectType, + UserMode, + &SharedEvent, + NULL + ); + + if (NT_SUCCESS(Status)) { + + // + // Start the timer that signals the event + // + IoStartTimer(DeviceObject); + + } + + break; + + + default: + + // + // This is the case for a bogus request code. + // + Status = STATUS_INVALID_PARAMETER; + +#if DBG + DbgPrint("EventSysDeviceControl: Invalid IOCTL code 0x%0x\n", operation); +#endif + + break; + + } + + // + // Complete the I/O Request + // + Irp->IoStatus.Status = Status; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + +#if DBG + DbgPrint("EventSysDeviceControl: Exited...\n"); +#endif + + return(Status); +} + + +/////////////////////////////////////////////////////////////////////////////// +// +// EventSysUnload +// +// This is the dispatch entry point for processing the unloading of the driver +// +// +// INPUTS: +// +// DriverObject - Address of the DRIVER_OBJECT for our device. +// +// +// OUTPUTS: +// +// None. +// +// RETURNS: +// +// None. +// +// IRQL: +// +// This routine is called at IRQL_PASSIVE_LEVEL. +// +// NOTES: +// +// +/////////////////////////////////////////////////////////////////////////////// +VOID EventSysUnload( IN PDRIVER_OBJECT DriverObject ) +{ + UNICODE_STRING DeviceLinkName; + +#if DBG + DbgPrint(("EventSysDriverUnload: Entered...\n")); +#endif + + if (SharedEventHandle != NULL) { + + // + // Close our handle + // + ZwClose(SharedEventHandle); + + } + + if (SharedEvent != NULL) { + + // + // Release our reference. + // + ObDereferenceObject(SharedEvent); + + } + + RtlInitUnicodeString(&DeviceLinkName, L"\\DosDevices\\EventShare"); + + // + // Delete the symbolic link for our device + // + IoDeleteSymbolicLink(&DeviceLinkName); + + // + // Stop our timer before we delete our device object + // + IoStopTimer(DriverObject->DeviceObject); + + // + // Delete the device object + // + IoDeleteDevice(DriverObject->DeviceObject); + +#if DBG + DbgPrint(("EventSysDriverUnload: Deleted devices\n")); +#endif + +} + + + +/////////////////////////////////////////////////////////////////////////////// +// +// DriverEntry +// +// This routine is called by NT when the driver is first loaded. It is the +// responsibility of this routine to create whatever +// device objects it needs. +// +// INPUTS: +// +// DriverObj - Address of the DRIVER_OBJECT created by NT for this driver. +// +// RegistryPath - UNICODE_STRING which represents this drivers KEY in the +// Registry. +// +// OUTPUTS: +// +// None. +// +// RETURNS: +// +// STATUS_SUCCESS. Otherwise an error indicating why the driver could not +// load. +// +// IRQL: +// +// This routine is called at IRQL_PASSIVE_LEVEL. +// +// NOTES: +// +// +/////////////////////////////////////////////////////////////////////////////// +NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath ) +{ + NTSTATUS Status; + UNICODE_STRING DeviceName; + UNICODE_STRING DeviceLinkName; + +#if DBG + DbgPrint ("EventSysDriverEntry: Entered...\n"); +#endif + + RtlInitUnicodeString(&DeviceName, L"\\Device\\EventShare"); + + // + // Set up the device used for GUI communications + // + Status = IoCreateDevice ( + DriverObject, + 0, + &DeviceName, + FILE_DEVICE_EVENTSYS, + 0, + TRUE, + &DeviceObject + ); + + if (NT_SUCCESS(Status)) { + + RtlInitUnicodeString (&DeviceLinkName, + L"\\DosDevices\\EventShare"); + + // + // Create a symbolic link that a user mode application can specify + // in a call to CreateFile to retrieve a handle to our device + // + Status = IoCreateSymbolicLink ( + &DeviceLinkName, + &DeviceName + ); + + if (!NT_SUCCESS(Status)) { + + // + // If we can't create a symbolic link there's not much we can do... + // +#if DBG + DbgPrint ("EventSysDriverEntry: IoCreateSymbolicLink failed! -- 0x%8.8x\n", + Status); +#endif + + return Status; + + } + + // + // Create dispatch points for all routines that must be handled + // + DriverObject->MajorFunction[IRP_MJ_CREATE] = + DriverObject->MajorFunction[IRP_MJ_CLOSE] = EventSysCreateClose; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = EventSysDeviceControl; + DriverObject->DriverUnload = EventSysUnload; + + } + + if (!NT_SUCCESS(Status)) { + + // + // Something went seriously wrong so just get outta here... + // +#if DBG + DbgPrint("EventSysDriverEntry: Failed to create our device! -- 0x%8.8x\n", Status); +#endif + + return Status; + + } + + // + // Initialize our timer that will signal the event. We'll wait to start it + // until we've received an IOCTL from the user mode application letting + // us know that the event has been created. + // + IoInitializeTimer(DeviceObject, EventSysTimerCallback, NULL); + + // + // We're Done! Our device has successfully loaded + // +#if DBG + DbgPrint ("EventSysDriverEntry: Exited...\n"); +#endif + + return Status; +} + Added: sandbox/trunk/src/win/eventshare/inc/eventioctl.h =================================================================== --- sandbox/trunk/src/win/eventshare/inc/eventioctl.h (rev 0) +++ sandbox/trunk/src/win/eventshare/inc/eventioctl.h 2009-10-08 00:37:07 UTC (rev 1476) @@ -0,0 +1,12 @@ +// +// The following value is arbitrarily chosen from the space defined by Microsoft +// as being "for non-Microsoft use" +// +#define FILE_DEVICE_EVENTSYS 0x00008310 + + +// +// Device control codes - values between 2048 and 4095 arbitrarily chosen +// +#define IOCTL_OPEN_EVENT CTL_CODE(FILE_DEVICE_EVENTSYS, 2049UL, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_EVENT_HANDLE CTL_CODE(FILE_DEVICE_EVENTSYS, 2050UL, METHOD_BUFFERED, FILE_ANY_ACCESS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-10-06 03:11:15
|
Revision: 1475 http://assorted.svn.sourceforge.net/assorted/?rev=1475&view=rev Author: yangzhang Date: 2009-10-06 03:11:04 +0000 (Tue, 06 Oct 2009) Log Message: ----------- added arraycopy Added Paths: ----------- sandbox/trunk/src/c/arraycopy.c Added: sandbox/trunk/src/c/arraycopy.c =================================================================== --- sandbox/trunk/src/c/arraycopy.c (rev 0) +++ sandbox/trunk/src/c/arraycopy.c 2009-10-06 03:11:04 UTC (rev 1475) @@ -0,0 +1,17 @@ +struct s { char buf[9]; }; + +int main() +{ + // This won't compile: + // char src[9] = "hello"; + // char dst[9]; + // dst = src; + + int i; + struct s src = { "hello" }, dst; + src = dst; // This works! + for (i = 0; i < 9; i++) + if (src.buf[i] != dst.buf[i]) + return 1; + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-09-21 06:04:54
|
Revision: 1474 http://assorted.svn.sourceforge.net/assorted/?rev=1474&view=rev Author: yangzhang Date: 2009-09-21 06:04:40 +0000 (Mon, 21 Sep 2009) Log Message: ----------- imported nio server example from sron Modified Paths: -------------- sandbox/trunk/src/java/footprint/go.bash Added Paths: ----------- sandbox/trunk/src/java/MinaUdpExample2.java sandbox/trunk/src/java/nio-server-example/ sandbox/trunk/src/java/nio-server-example/ChangeRequest.java sandbox/trunk/src/java/nio-server-example/EchoWorker.java sandbox/trunk/src/java/nio-server-example/Makefile sandbox/trunk/src/java/nio-server-example/NioServer.java sandbox/trunk/src/java/nio-server-example/README sandbox/trunk/src/java/nio-server-example/ServerDataEvent.java Added: sandbox/trunk/src/java/MinaUdpExample2.java =================================================================== --- sandbox/trunk/src/java/MinaUdpExample2.java (rev 0) +++ sandbox/trunk/src/java/MinaUdpExample2.java 2009-09-21 06:04:40 UTC (rev 1474) @@ -0,0 +1,52 @@ + + +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import org.apache.mina.common.IoHandlerAdapter; +import org.apache.mina.common.IoSession; +import org.apache.mina.common.ThreadModel; +import org.apache.mina.transport.socket.nio.DatagramAcceptor; +import sun.nio.ch.DatagramSocketAdaptor; + +public class Test { + + public static void main(String[] args) throws Exception { + InetAddress addr = InetAddress.getLocalHost(); + ScheduledExecutorService executor = Executors + .newSingleThreadScheduledExecutor(); + executor.schedule(new Runnable() { + public void run() { + System.out.println("hello world"); + } + }, 10, TimeUnit.MILLISECONDS); + DatagramAcceptor a = new DatagramAcceptor(executor); + a.getDefaultConfig().setThreadModel(ThreadModel.MANUAL); + for (int i = 0; i < 2; i++) { + a.bind(new InetSocketAddress(addr, 10000 + i), + new IoHandlerAdapter() { + public void messageReceived(IoSession session, + Object obj) throws Exception { + System.out.println("received " + obj + " on " + + session.getLocalAddress() + " in thread " + + Thread.currentThread().getName()); + } + }); + } + System.out.println("hello"); + while (true) { + Thread.sleep(1000); + byte[] buf = new byte[2]; + DatagramSocket s = new DatagramSocket(); + s.send(new DatagramPacket(buf, buf.length, addr, 10000)); + s.send(new DatagramPacket(buf, buf.length, addr, 10001)); + } + } +} Modified: sandbox/trunk/src/java/footprint/go.bash =================================================================== --- sandbox/trunk/src/java/footprint/go.bash 2009-09-21 05:39:24 UTC (rev 1473) +++ sandbox/trunk/src/java/footprint/go.bash 2009-09-21 06:04:40 UTC (rev 1474) @@ -1,12 +1,11 @@ #!/usr/bin/env bash javac Main.java -java -server Main & -#java Main & +java Main & pid=$! for i in 1 2; do sleep 1 - ps -o rss= $pid + ps -o vsz= -o rss= $pid done wait @@ -15,8 +14,8 @@ pid=$! for i in 1 2 ; do sleep 1 - ps -o rss= $pid + ps -o vsz= -o rss= $pid done wait -# Results: Java takes ~12.3MB, Mono takes ~5.1MB +# Results: Java takes ~12.3MB RSS/860MN VSZ, Mono takes ~5.1MB RSS/43MB VSZ Added: sandbox/trunk/src/java/nio-server-example/ChangeRequest.java =================================================================== --- sandbox/trunk/src/java/nio-server-example/ChangeRequest.java (rev 0) +++ sandbox/trunk/src/java/nio-server-example/ChangeRequest.java 2009-09-21 06:04:40 UTC (rev 1474) @@ -0,0 +1,16 @@ +import java.nio.channels.SocketChannel; + +public class ChangeRequest { + public static final int REGISTER = 1; + public static final int CHANGEOPS = 2; + + public SocketChannel socket; + public int type; + public int ops; + + public ChangeRequest(SocketChannel socket, int type, int ops) { + this.socket = socket; + this.type = type; + this.ops = ops; + } +} \ No newline at end of file Added: sandbox/trunk/src/java/nio-server-example/EchoWorker.java =================================================================== --- sandbox/trunk/src/java/nio-server-example/EchoWorker.java (rev 0) +++ sandbox/trunk/src/java/nio-server-example/EchoWorker.java 2009-09-21 06:04:40 UTC (rev 1474) @@ -0,0 +1,36 @@ +import java.nio.channels.SocketChannel; +import java.util.LinkedList; +import java.util.List; + +public class EchoWorker implements Runnable { + private List queue = new LinkedList(); + + public void processData(NioServer server, SocketChannel socket, byte[] data, int count) { + byte[] dataCopy = new byte[count]; + System.arraycopy(data, 0, dataCopy, 0, count); + synchronized(queue) { + queue.add(new ServerDataEvent(server, socket, dataCopy)); + queue.notify(); + } + } + + public void run() { + ServerDataEvent dataEvent; + + while(true) { + // Wait for data to become available + synchronized(queue) { + while(queue.isEmpty()) { + try { + queue.wait(); + } catch (InterruptedException e) { + } + } + dataEvent = (ServerDataEvent) queue.remove(0); + } + + // Return to sender + dataEvent.server.send(dataEvent.socket, dataEvent.data); + } + } +} \ No newline at end of file Added: sandbox/trunk/src/java/nio-server-example/Makefile =================================================================== --- sandbox/trunk/src/java/nio-server-example/Makefile (rev 0) +++ sandbox/trunk/src/java/nio-server-example/Makefile 2009-09-21 06:04:40 UTC (rev 1474) @@ -0,0 +1,4 @@ +all: NioServer.class + +NioServer.class: NioServer.java + javac $< Added: sandbox/trunk/src/java/nio-server-example/NioServer.java =================================================================== --- sandbox/trunk/src/java/nio-server-example/NioServer.java (rev 0) +++ sandbox/trunk/src/java/nio-server-example/NioServer.java 2009-09-21 06:04:40 UTC (rev 1474) @@ -0,0 +1,205 @@ +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; +import java.nio.channels.spi.SelectorProvider; +import java.util.*; + +public class NioServer implements Runnable { + // The host:port combination to listen on + private InetAddress hostAddress; + private int port; + + // The channel on which we'll accept connections + private ServerSocketChannel serverChannel; + + // The selector we'll be monitoring + private Selector selector; + + // The buffer into which we'll read data when it's available + private ByteBuffer readBuffer = ByteBuffer.allocate(8192); + + private EchoWorker worker; + + // A list of PendingChange instances + private List pendingChanges = new LinkedList(); + + // Maps a SocketChannel to a list of ByteBuffer instances + private Map pendingData = new HashMap(); + + public NioServer(InetAddress hostAddress, int port, EchoWorker worker) throws IOException { + this.hostAddress = hostAddress; + this.port = port; + this.selector = this.initSelector(); + this.worker = worker; + } + + public void send(SocketChannel socket, byte[] data) { + synchronized (this.pendingChanges) { + // Indicate we want the interest ops set changed + this.pendingChanges.add(new ChangeRequest(socket, ChangeRequest.CHANGEOPS, SelectionKey.OP_WRITE)); + + // And queue the data we want written + synchronized (this.pendingData) { + List queue = (List) this.pendingData.get(socket); + if (queue == null) { + queue = new ArrayList(); + this.pendingData.put(socket, queue); + } + queue.add(ByteBuffer.wrap(data)); + } + } + + // Finally, wake up our selecting thread so it can make the required changes + this.selector.wakeup(); + } + + public void run() { + while (true) { + try { + // Process any pending changes + synchronized (this.pendingChanges) { + Iterator changes = this.pendingChanges.iterator(); + while (changes.hasNext()) { + ChangeRequest change = (ChangeRequest) changes.next(); + switch (change.type) { + case ChangeRequest.CHANGEOPS: + SelectionKey key = change.socket.keyFor(this.selector); + key.interestOps(change.ops); + } + } + this.pendingChanges.clear(); + } + + // Wait for an event one of the registered channels + this.selector.select(); + + // Iterate over the set of keys for which events are available + Iterator selectedKeys = this.selector.selectedKeys().iterator(); + while (selectedKeys.hasNext()) { + SelectionKey key = (SelectionKey) selectedKeys.next(); + selectedKeys.remove(); + + if (!key.isValid()) { + continue; + } + + // Check what event is available and deal with it + if (key.isAcceptable()) { + this.accept(key); + } else if (key.isReadable()) { + this.read(key); + } else if (key.isWritable()) { + this.write(key); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private void accept(SelectionKey key) throws IOException { + // For an accept to be pending the channel must be a server socket channel. + ServerSocketChannel serverSocketChannel = (ServerSocketChannel) key.channel(); + + // Accept the connection and make it non-blocking + SocketChannel socketChannel = serverSocketChannel.accept(); + Socket socket = socketChannel.socket(); + socketChannel.configureBlocking(false); + + // Register the new SocketChannel with our Selector, indicating + // we'd like to be notified when there's data waiting to be read + socketChannel.register(this.selector, SelectionKey.OP_READ); + } + + private void read(SelectionKey key) throws IOException { + SocketChannel socketChannel = (SocketChannel) key.channel(); + + // Clear out our read buffer so it's ready for new data + this.readBuffer.clear(); + + // Attempt to read off the channel + int numRead; + try { + numRead = socketChannel.read(this.readBuffer); + } catch (IOException e) { + // The remote forcibly closed the connection, cancel + // the selection key and close the channel. + key.cancel(); + socketChannel.close(); + return; + } + + if (numRead == -1) { + // Remote entity shut the socket down cleanly. Do the + // same from our end and cancel the channel. + key.channel().close(); + key.cancel(); + return; + } + + // Hand the data off to our worker thread + this.worker.processData(this, socketChannel, this.readBuffer.array(), numRead); + } + + private void write(SelectionKey key) throws IOException { + SocketChannel socketChannel = (SocketChannel) key.channel(); + + synchronized (this.pendingData) { + List queue = (List) this.pendingData.get(socketChannel); + + // Write until there's not more data ... + while (!queue.isEmpty()) { + ByteBuffer buf = (ByteBuffer) queue.get(0); + socketChannel.write(buf); + if (buf.remaining() > 0) { + // ... or the socket's buffer fills up + break; + } + queue.remove(0); + } + + if (queue.isEmpty()) { + // We wrote away all data, so we're no longer interested + // in writing on this socket. Switch back to waiting for + // data. + key.interestOps(SelectionKey.OP_READ); + } + } + } + + private Selector initSelector() throws IOException { + // Create a new selector + Selector socketSelector = SelectorProvider.provider().openSelector(); + + // Create a new non-blocking server socket channel + this.serverChannel = ServerSocketChannel.open(); + serverChannel.configureBlocking(false); + + // Bind the server socket to the specified address and port + InetSocketAddress isa = new InetSocketAddress(this.hostAddress, this.port); + serverChannel.socket().bind(isa); + + // Register the server socket channel, indicating an interest in + // accepting new connections + serverChannel.register(socketSelector, SelectionKey.OP_ACCEPT); + + return socketSelector; + } + + public static void main(String[] args) { + try { + EchoWorker worker = new EchoWorker(); + new Thread(worker).start(); + new Thread(new NioServer(null, 9090, worker)).start(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file Added: sandbox/trunk/src/java/nio-server-example/README =================================================================== --- sandbox/trunk/src/java/nio-server-example/README (rev 0) +++ sandbox/trunk/src/java/nio-server-example/README 2009-09-21 06:04:40 UTC (rev 1474) @@ -0,0 +1 @@ +From http://www.javafaq.nu/java-example-code-926.html Added: sandbox/trunk/src/java/nio-server-example/ServerDataEvent.java =================================================================== --- sandbox/trunk/src/java/nio-server-example/ServerDataEvent.java (rev 0) +++ sandbox/trunk/src/java/nio-server-example/ServerDataEvent.java 2009-09-21 06:04:40 UTC (rev 1474) @@ -0,0 +1,13 @@ +import java.nio.channels.SocketChannel; + +class ServerDataEvent { + public NioServer server; + public SocketChannel socket; + public byte[] data; + + public ServerDataEvent(NioServer server, SocketChannel socket, byte[] data) { + this.server = server; + this.socket = socket; + this.data = data; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-09-21 05:39:34
|
Revision: 1473 http://assorted.svn.sourceforge.net/assorted/?rev=1473&view=rev Author: yangzhang Date: 2009-09-21 05:39:24 +0000 (Mon, 21 Sep 2009) Log Message: ----------- added demo of ipconfig-like util Added Paths: ----------- sandbox/trunk/src/java/Ipconfig.java Added: sandbox/trunk/src/java/Ipconfig.java =================================================================== --- sandbox/trunk/src/java/Ipconfig.java (rev 0) +++ sandbox/trunk/src/java/Ipconfig.java 2009-09-21 05:39:24 UTC (rev 1473) @@ -0,0 +1,37 @@ +import java.net.*; +import java.util.*; +/** + * <p>Lists the IP interfaces defined on the system using the Java NetworkInterface.</p> + * <p>ale...@pa...</p> + * <p>Copyright (c) 2003 Alexis Grandemange</p> + * <pre>This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; version 2.1 of the + * License. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * A copy of the GNU Lesser General Public License lesser.txt should be + * included in the distribution.</pre> + * @author Alexis Grandemange + * @version 0, 0, 1 + */ +public class Ipconfig { + Ipconfig() throws Exception { + Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); + while(en.hasMoreElements()) { + NetworkInterface ni = en.nextElement(); + Enumeration<InetAddress> en2 = ni.getInetAddresses(); + while(en2.hasMoreElements()) { + InetAddress ia = en2.nextElement(); + System.out.println("Interface name:" + ni.getName() + + " display name:" + ni.getDisplayName() + " " + + ia.getHostAddress()); + } + } + } + public static void main(String[] args) throws Exception { + new Ipconfig(); + } +} Property changes on: sandbox/trunk/src/java/Ipconfig.java ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-08-30 18:44:29
|
Revision: 1472 http://assorted.svn.sourceforge.net/assorted/?rev=1472&view=rev Author: yangzhang Date: 2009-08-30 18:44:16 +0000 (Sun, 30 Aug 2009) Log Message: ----------- added msf-parser Added Paths: ----------- sandbox/trunk/src/one-off-scripts/msf-parser/ sandbox/trunk/src/one-off-scripts/msf-parser/Makefile sandbox/trunk/src/one-off-scripts/msf-parser/MorkParser.cpp sandbox/trunk/src/one-off-scripts/msf-parser/MorkParser.h sandbox/trunk/src/one-off-scripts/msf-parser/MorkParserDemo.cpp sandbox/trunk/src/one-off-scripts/msf-parser/README sandbox/trunk/src/one-off-scripts/msf-parser/msfparser.cpp Added: sandbox/trunk/src/one-off-scripts/msf-parser/Makefile =================================================================== --- sandbox/trunk/src/one-off-scripts/msf-parser/Makefile (rev 0) +++ sandbox/trunk/src/one-off-scripts/msf-parser/Makefile 2009-08-30 18:44:16 UTC (rev 1472) @@ -0,0 +1,5 @@ +all: MorkParserDemo msfparser +MorkParserDemo: MorkParserDemo.o MorkParser.o +msfparser: msfparser.o MorkParser.o +CC = g++ +CXXFLAGS = -std=gnu++0x Added: sandbox/trunk/src/one-off-scripts/msf-parser/MorkParser.cpp =================================================================== --- sandbox/trunk/src/one-off-scripts/msf-parser/MorkParser.cpp (rev 0) +++ sandbox/trunk/src/one-off-scripts/msf-parser/MorkParser.cpp 2009-08-30 18:44:16 UTC (rev 1472) @@ -0,0 +1,741 @@ +//////////////////////////////////////////////////////////////////// +/// +/// MorkParser.cpp - Mozilla Mork Format Parser/Reader +/// +/// Copyright (C) 2007 ScalingWeb.com +/// All rights reserved. +/// +/// Authors: Yuriy Soroka <ys...@sc...> +/////////////////////////////////////////////////////////////////// + + + +#include "MorkParser.h" +#include <stdlib.h> +#include <sstream> +#include <string> +#include <stdexcept> +#include <fstream> +#include <iostream> +#include <cstring> + +std::string g_Empty = ""; + +inline std::string stringify(double x) +{ + std::ostringstream o; + o << x; + return o.str(); +} + +// ============================================================= +// MorkParser::MorkParser + +MorkParser::MorkParser( int DefaultScope ) +{ + initVars(); + defaultScope_ = DefaultScope; +} + +// ============================================================= +// MorkParser::open + +bool MorkParser::open( const string &path ) +{ + initVars(); + std::string line; + std::ifstream infile(path.c_str(), std::ios_base::in); + if(!infile.is_open()) + { + error_ = FailedToOpen; + return false; + } + + while (getline(infile, line, '\n')) + { + morkData_.append(line); + morkData_.append("\n"); + } + +/* + // Check magic header + QByteArray MagicHeader = MorkFile.readLine(); + + if ( !MagicHeader.contains( MorkMagicHeader ) ) + { + error_ = UnsupportedVersion; + return false; + } +*/ + + // Parse mork + return parse(); +} + +// ============================================================= +// MorkParser::error + +inline MorkErrors MorkParser::error() +{ + return error_; +} + +// ============================================================= +// MorkParser::initVars + +void MorkParser::initVars() +{ + error_ = NoError; + morkPos_ = 0; + nowParsing_ = NPValues; + currentCells_ = 0; + nextAddValueId_ = 0x7fffffff; +} + +// ============================================================= +// MorkParser::parse + +bool MorkParser::parse() +{ + bool Result = true; + char cur = 0; + + // Run over mork chars and parse each term + cur = nextChar(); + + int i = 0; + + while ( Result && cur ) + { + if ( !isWhiteSpace( cur ) ) + { + i++; + // Figure out what a term + switch ( cur ) + { + case '<': + // Dict + Result = parseDict(); + break; + case '/': + // Comment + Result = parseComment(); + break; + case '{': + Result = parseTable(); + // Table + break; + case '[': + Result = parseRow( 0, 0 ); + // Row + break; + case '@': + Result = parseGroup(); + // Group + break; + default: + error_ = DefectedFormat; + Result = false; + break; + } + } + + // Get next char + cur = nextChar(); + } + + return Result; +} + +// ============================================================= +// MorkParser::isWhiteSpace + +bool MorkParser::isWhiteSpace( char c ) +{ + switch ( c ) + { + case ' ': + case '\t': + case '\r': + case '\n': + case '\f': + return true; + default: + return false; + } +} + +// ============================================================= +// MorkParser::nextChar + +inline char MorkParser::nextChar() +{ + char cur = 0; + + + if ( morkPos_ < morkData_.length() ) + { + cur = morkData_[ morkPos_ ]; + morkPos_++; + } + + if ( !cur ) + { + cur = 0; + } + + return cur; +} + +// ============================================================= +// MorkParser::parseDict + +bool MorkParser::parseDict() +{ + char cur = nextChar(); + bool Result = true; + nowParsing_ = NPValues; + + while ( Result && cur != '>' && cur ) + { + if ( !isWhiteSpace( cur ) ) + { + switch ( cur ) + { + case '<': + { + + if ( morkData_.substr( morkPos_ - 1, strlen( MorkDictColumnMeta ) ) == MorkDictColumnMeta ) + { + nowParsing_ = NPColumns; + morkPos_ += strlen( MorkDictColumnMeta ) - 1; + } + + + break; + } + case '(': + Result = parseCell(); + break; + case '/': + Result = parseComment(); + break; + + } + } + + cur = nextChar(); + } + + return Result; +} + +// ============================================================= +// MorkParser::parseComment + +inline bool MorkParser::parseComment() +{ + char cur = nextChar(); + if ( '/' != cur ) return false; + + while ( cur != '\r' && cur != '\n' && cur ) + { + cur = nextChar(); + } + + return true; +} + +// ============================================================= +// MorkParser::parseCell + +bool MorkParser::parseCell() +{ + bool Result = true; + bool bColumnOid = false; + bool bValueOid = false; + bool bColumn = true; + int Corners = 0; + + // Column = Value + std::string Column; + std::string Text; + Column.reserve( 4 ); + Text.reserve( 32 ); + + char cur = nextChar(); + + // Process cell start with column (bColumn == true) + while ( Result && cur != ')' && cur ) + { + switch ( cur ) + { + case '^': + // Oids + Corners++; + if ( 1 == Corners ) + { + bColumnOid = true; + } + else if ( 2 == Corners ) + { + bColumn = false; + bValueOid = true; + } + else + { + Text += cur; + } + + break; + case '=': + // From column to value + if ( bColumn ) + { + bColumn = false; + } + else + { + Text += cur; + } + break; + case '\\': + { + // Get next two chars + char NextChar= nextChar(); + if ( '\r' != NextChar && '\n' != NextChar ) + { + Text += NextChar; + } + else nextChar(); + } + break; + case '$': + { + // Get next two chars + std::string HexChar; + HexChar += nextChar(); + HexChar += nextChar(); + + int x = strtoul(HexChar.c_str(), 0, 16); + Text += stringify(x); + //Text += ( char ) string( HexChar.c_str() ).toInt( 0, 16 ); + } + break; + default: + // Just a char + if ( bColumn ) + { + Column += cur; + } + else + { + Text += cur; + } + break; + } + + cur = nextChar(); + } + + // Apply column and text + //int ColumnId = string( Column.c_str() ).toInt( 0, 16 ); + int ColumnId = strtoul(Column.c_str(), 0, 16); + + if ( NPRows != nowParsing_ ) + { + // Dicts + if ( "" != Text ) + { + if ( nowParsing_ == NPColumns ) + { + columns_[ ColumnId ] = Text; + } + else + { + values_[ ColumnId ] = Text; + } + } + } + else + { + if ( "" != Text ) + { + // Rows + //int ValueId = string( Text.c_str() ).toInt( 0, 16 ); + int ValueId = strtoul(Text.c_str(), 0, 16); + + if ( bValueOid ) + { + ( *currentCells_ )[ ColumnId ] = ValueId; + } + else + { + nextAddValueId_--; + values_[ nextAddValueId_ ] = Text; + ( *currentCells_ )[ ColumnId ] = nextAddValueId_; + } + } + } + + return Result; +} + +// ============================================================= +// MorkParser::parseTable + +bool MorkParser::parseTable() +{ + bool Result = true; + std::string TextId; + int Id = 0, Scope = 0; + + char cur = nextChar(); + + // Get id + while ( cur != '{' && cur != '[' && cur != '}' && cur ) + { + if ( !isWhiteSpace( cur ) ) + { + TextId += cur; + } + + cur = nextChar(); + } + + parseScopeId( TextId, &Id, &Scope ); + + // Parse the table + while ( Result && cur != '}' && cur ) + { + if ( !isWhiteSpace( cur ) ) + { + switch ( cur ) + { + case '{': + Result = parseMeta( '}' ); + break; + case '[': + Result = parseRow( Id, Scope ); + break; + case '-': + case '+': + break; + default: + { + std::string JustId; + while ( !isWhiteSpace( cur ) && cur ) + { + JustId += cur; + cur = nextChar(); + + if ( cur == '}' ) + { + return Result; + } + } + + int JustIdNum = 0, JustScopeNum = 0; + parseScopeId( JustId, &JustIdNum, &JustScopeNum ); + + setCurrentRow( Scope, Id, JustScopeNum, JustIdNum ); + } + break; + } + } + + cur = nextChar(); + } + + return Result; +} + +// ============================================================= +// MorkParser::parseScopeId + +void MorkParser::parseScopeId( const std::string &TextId, int *Id, int *Scope ) +{ + int Pos = 0; + + if ( ( Pos = TextId.find( ':' ) ) >= 0 ) + { + std::string tId = TextId.substr( 0, Pos ); + std::string tSc = TextId.substr( Pos + 1, TextId.length() - Pos ); + + if ( tSc.length() > 1 && '^' == tSc[ 0 ] ) + { + // Delete '^' + tSc.erase( 0, 1 ); + } + + //*Id = string( tId.c_str() ).toInt( 0, 16 ); + *Id = strtoul(tId.c_str(), 0, 16); + + //*Scope = string( tSc.c_str() ).toInt( 0, 16 ); + *Scope = strtoul(tSc.c_str(), 0, 16); + } + else + { + //*Id = string( TextId.c_str() ).toInt( 0, 16 ); + //*Id = string( TextId.c_str() ).toInt( 0, 16 ); + *Id = strtoul(TextId.c_str(), 0, 16); + } +} + +// ============================================================= +// MorkParser::setCurrentRow + +inline void MorkParser::setCurrentRow( int TableScope, int TableId, int RowScope, int RowId ) +{ + if ( !RowScope ) + { + RowScope = defaultScope_; + } + + if ( !TableScope ) + { + TableScope = defaultScope_; + } + + currentCells_ = &( mork_[ abs( TableScope ) ][ abs( TableId ) ][ abs( RowScope ) ][ abs( RowId ) ] ); +} + +// ============================================================= +// MorkParser::parseRow + +bool MorkParser::parseRow( int TableId, int TableScope ) +{ + bool Result = true; + std::string TextId; + int Id = 0, Scope = 0; + nowParsing_ = NPRows; + + char cur = nextChar(); + + // Get id + while ( cur != '(' && cur != ']' && cur != '[' && cur ) + { + if ( !isWhiteSpace( cur ) ) + { + TextId += cur; + } + + cur = nextChar(); + } + + parseScopeId( TextId, &Id, &Scope ); + setCurrentRow( TableScope, TableId, Scope, Id ); + + // Parse the row + while ( Result && cur != ']' && cur ) + { + if ( !isWhiteSpace( cur ) ) + { + switch ( cur ) + { + case '(': + Result = parseCell(); + break; + case '[': + Result = parseMeta( ']' ); + break; + default: + Result = false; + break; + } + } + + cur = nextChar(); + } + + return Result; +} + +// ============================================================= +// MorkParser::parseGroup + +bool MorkParser::parseGroup() +{ + return parseMeta( '@' ); +} + +// ============================================================= +// MorkParser::parseMeta + +bool MorkParser::parseMeta( char c ) +{ + char cur = nextChar(); + + while ( cur != c && cur ) + { + cur = nextChar(); + } + + return true; +} + +// ============================================================= +// MorkParser::getTables + +MorkTableMap *MorkParser::getTables( int TableScope ) +{ + TableScopeMap::iterator iter; + iter = mork_.find( TableScope ); + + if ( iter == mork_.end() ) + { + return 0; + } + + //return &iter.value(); + return &iter->second; +} + +// ============================================================= +// MorkParser::getRows + +MorkRowMap *MorkParser::getRows( int RowScope, RowScopeMap *table ) +{ + RowScopeMap::iterator iter; + iter = table->find( RowScope ); + + if ( iter == table->end() ) + { + return 0; + } + + //return &iter.value(); + return &iter->second; +} + +// ============================================================= +// MorkParser::getValue + +std::string &MorkParser::getValue( int oid ) +{ + MorkDict::iterator foundIter = values_.find( oid ); + + if ( values_.end() == foundIter ) + { + return g_Empty; + } + + //return *foundIter; + return foundIter->second; +} + +// ============================================================= +// MorkParser::getColumn + +std::string &MorkParser::getColumn( int oid ) +{ + MorkDict::iterator foundIter = columns_.find( oid ); + + if ( columns_.end() == foundIter ) + { + return g_Empty; + } + + //return *foundIter; + return foundIter->second; +} + + +#ifndef QT_NO_DEBUG + +// ============================================================= +// MorkParser::debugWrite + +void MorkParser::debugWrite( const string & )//path ) +{ + //QFile outfile( path ); + //outfile.open( QIODevice::WriteOnly ); + //QTextStream output( &outfile ); + + //output.setCodec( "utf-8" ); + + //output << "Column Dict:\r\n"; + //output << "=============================================\r\n\r\n"; + + //// columns dict + //for ( MorkDict::iterator iter = columns_.begin(); + // iter != columns_.end(); iter++ ) + //{ + // output << string::number( iter.key(), 16 ).toUpper() + // << " : " + // << iter->second.c_str() + // << "\r\n"; + //} + + //// values dict + //output << "\r\nValues Dict:\r\n"; + //output << "=============================================\r\n\r\n"; + + //for ( MorkDict::iterator iter = values_.begin(); + // iter != values_.end(); iter++ ) + //{ + // output << string::number( iter->first, 16 ).toUpper() + // << " : " + // << string::fromUtf8( iter->second.c_str() ) + // << "\r\n"; + //} + + //output << "\r\nData:\r\n"; + //output << "=============================================\r\n\r\n"; + + //// Mork data + //for ( TableScopeMap::iterator iter = mork_.begin(); + // iter != mork_.end(); iter++ ) + //{ + // output << "\r\n Scope:" << string::number( iter->first, 16 ).toUpper() << "\r\n"; + + // for ( MorkTableMap::iterator TableIter = iter->second.begin(); + // TableIter != iter->second.end(); TableIter++ ) + // { + // output << "\t Table:" + // << ( ( int ) TableIter->first < 0 ? "-" : " " ) + // << string::number( abs( TableIter->first ), 16 ).toUpper() << "\r\n"; + + // for ( RowScopeMap::iterator RowScopeIter = TableIter->second.begin(); + // RowScopeIter != TableIter->second.end(); RowScopeIter++ ) + // { + // output << "\t\t RowScope:" << string::number( RowScopeIter->first, 16 ).toUpper() << "\r\n"; + + // for ( MorkRowMap::iterator RowIter = RowScopeIter->second.begin(); + // RowIter != RowScopeIter->second.end(); RowIter++ ) + // { + // output << "\t\t\t Row Id:" + // << ( ( int ) RowIter->first < 0 ? "-" : " ") + // << string::number( abs( RowIter->first ), 16 ).toUpper() << "\r\n"; + // output << "\t\t\t\t Cells:\r\n"; + + // for ( MorkCells::iterator CellsIter = RowIter->second.begin(); + // CellsIter != RowIter->second.end(); CellsIter++ ) + // { + // // Write ids + // output << "\t\t\t\t\t" + // << string::number( CellsIter.key(), 16 ).toUpper() + // << " : " + // << string::number( *CellsIter, 16 ).toUpper() + // << " => "; + + // MorkDict::iterator FoundIter = values_.find( *CellsIter ); + + // if ( FoundIter != values_.end() ) + // { + // // Write string values + // output << columns_[ CellsIter.key() ].c_str() + // << " : " + // << string::fromUtf8( FoundIter->second.c_str() ) + // << "\r\n"; + // } + // } + // } + // } + // } + //} + + //output.flush(); +} + +#endif // QT_NO_DEBUG Added: sandbox/trunk/src/one-off-scripts/msf-parser/MorkParser.h =================================================================== --- sandbox/trunk/src/one-off-scripts/msf-parser/MorkParser.h (rev 0) +++ sandbox/trunk/src/one-off-scripts/msf-parser/MorkParser.h 2009-08-30 18:44:16 UTC (rev 1472) @@ -0,0 +1,148 @@ +//////////////////////////////////////////////////////////////////// +/// +/// MorkParser.h - Mozilla Mork Format Parser/Reader +/// +/// Copyright (C) 2007 ScalingWeb.com +/// All rights reserved. +/// +/// Authors: Yuriy Soroka <ys...@sc...> +/// +/////////////////////////////////////////////////////////////////// + + +#ifndef __MorkParser_h__ +#define __MorkParser_h__ + +#pragma warning(disable : 4786 4503) + +#include <string> +#include <map> +using namespace std; + +// Types + +typedef map< int, std::string > MorkDict; +typedef map< int, int > MorkCells; // ColumnId : ValueId +typedef map< int, MorkCells > MorkRowMap; // Row id +typedef map< int, MorkRowMap > RowScopeMap; // Row scope +typedef map< int, RowScopeMap > MorkTableMap; // Table id +typedef map< int, MorkTableMap > TableScopeMap; // Table Scope + +// Mork header of supported format version +const char MorkMagicHeader[] = "// <!-- <mdb:mork:z v=\"1.4\"/> -->"; + +const char MorkDictColumnMeta[] = "<(a=c)>"; + +// Error codes +enum MorkErrors +{ + NoError = 0, + FailedToOpen, + UnsupportedVersion, + DefectedFormat +}; + +// Mork term types +enum MorkTerm +{ + NoneTerm = 0, + DictTerm, + GroupTerm, + TableTerm, + RowTerm, + CellTerm, + CommentTerm, + LiteralTerm +}; + + +/// Class MorkParser + +class MorkParser +{ +public: + + MorkParser( int defaultScope = 0x80 ); + + /// + /// Open and parse mork file + + bool open( const string &path ); + + /// + /// Return error status + + MorkErrors error(); + + /// + /// Returns all tables of specified scope + + MorkTableMap *getTables( int tableScope ); + + /// + /// Rerturns all rows under specified scope + + MorkRowMap *getRows( int rowScope, RowScopeMap *table ); + + /// + /// Return value of specified value oid + + std::string &getValue( int oid ); + + /// + /// Return value of specified column oid + + std::string &getColumn( int oid ); + +#ifndef QT_NO_DEBUG + void debugWrite( const string &path ); +#endif // QT_NO_DEBUG + + +protected: // Members + + void initVars(); + + bool isWhiteSpace( char c ); + char nextChar(); + + void parseScopeId( const std::string &TextId, int *Id, int *Scope ); + void setCurrentRow( int TableScope, int TableId, int RowScope, int RowId ); + + // Parse methods + bool parse(); + bool parseDict(); + bool parseComment(); + bool parseCell(); + bool parseTable(); + bool parseMeta( char c ); + bool parseRow( int TableId, int TableScope ); + bool parseGroup(); + +protected: // Data + + // Columns in mork means value names + MorkDict columns_; + MorkDict values_; + + // All mork file data + TableScopeMap mork_; + MorkCells *currentCells_; + + // Error status of last operation + MorkErrors error_; + + // All Mork data + std::string morkData_; + + int morkPos_; + int nextAddValueId_; + int defaultScope_; + + // Indicates intity is being parsed + enum { NPColumns, NPValues, NPRows } nowParsing_; + +}; + +#endif // __MorkParser_h__ + Added: sandbox/trunk/src/one-off-scripts/msf-parser/MorkParserDemo.cpp =================================================================== --- sandbox/trunk/src/one-off-scripts/msf-parser/MorkParserDemo.cpp (rev 0) +++ sandbox/trunk/src/one-off-scripts/msf-parser/MorkParserDemo.cpp 2009-08-30 18:44:16 UTC (rev 1472) @@ -0,0 +1,276 @@ +//////////////////////////////////////////////////////////////////// +/// +/// Copyright (C) 2008 Scalingweb.com +/// All rights reserved. +/// +/// Author: Yuriy Soroka <ys...@sc...> +/// +//////////////////////////////////////////////////////////////////// + +#include "MorkParser.h" +#include <iostream> + +// Address book params + +const char constFirstName[] = "FirstName"; +const char constLastName[] = "LastName"; +const char constNickName[] = "NickName"; +const char constPrimaryEmail[] = "PrimaryEmail"; +const char constHomePhone[] = "HomePhone"; +const char constFaxNumber[] = "FaxNumber"; +const char constCellularNumber[]= "CellularNumber"; +const char constWorkPhone[] = "WorkPhone"; +const char constHomeAddress[] = "HomeAddress"; +const char constHomeAddress2[] = "HomeAddress2"; +const char constHomeCity[] = "HomeCity"; +const char constHomeState[] = "HomeState"; +const char constHomeZipCode[] = "HomeZipCode"; +const char constHomeCountry[] = "HomeCountry"; +const char constWorkAddress[] = "WorkAddress"; +const char constWorkAddress2[] = "WorkAddress2"; +const char constWorkCity[] = "WorkCity"; +const char constWorkState[] = "WorkState"; +const char constWorkZipCode[] = "WorkZipCode"; +const char constWorkCountry[] = "WorkCountry"; +const char constJobTitle[] = "JobTitle"; +const char constDepartment[] = "Department"; +const char constCompany[] = "Company"; +const char constWebPage1[] = "WebPage1"; +const char constWebPage2[] = "WebPage2"; +const char constNotes[] = "Notes"; + +class AddressBookEntry +{ + public: + + /// Entry ID + std::string id; + + /// Name + std::string first_name; + std::string last_name; + std::string nick_name; + + /// Telephones/Faxes + std::string home_tel; + std::string mobile_tel; + std::string work_tel; + std::string fax; + + /// Addresses + std::string address_work; + std::string address_home; + + /// Web Page + std::string web_page; + + /// Email + std::string email; + + /// Notes + std::string notes; +}; + +typedef std::map< int, AddressBookEntry > AbeMap; +typedef std::map< std::string, std::string > RawAbeMap; + +AbeMap abes_; + + +void fromRawAbe( RawAbeMap &rawAbe, std::string &retText, const char *paramTitle ) +{ + RawAbeMap::iterator iter; + iter = rawAbe.find( paramTitle ); + + if ( iter != rawAbe.end() ) + { + retText = std::string( iter->second.c_str() ); + } +} + +inline void appendAddress( std::string &text, const std::string &add ) +{ + if ( !add.empty() ) + { + text += add; + text += ", "; + } +} + +void addEntry( RawAbeMap &rawAbe, AddressBookEntry &abe ) +{ + fromRawAbe( rawAbe, abe.first_name, constFirstName ); + fromRawAbe( rawAbe, abe.last_name, constLastName ); + fromRawAbe( rawAbe, abe.nick_name, constNickName ); + fromRawAbe( rawAbe, abe.email, constPrimaryEmail ); + + fromRawAbe( rawAbe, abe.fax, constFaxNumber ); + fromRawAbe( rawAbe, abe.mobile_tel, constCellularNumber ); + fromRawAbe( rawAbe, abe.home_tel, constHomePhone ); + fromRawAbe( rawAbe, abe.work_tel, constWorkPhone ); + fromRawAbe( rawAbe, abe.notes, constNotes ); + + fromRawAbe( rawAbe, abe.web_page, constWebPage1 ); + + // Build addresses + std::string HomeAddress; + fromRawAbe( rawAbe, HomeAddress, constHomeAddress ); + std::string HomeAddress2; + fromRawAbe( rawAbe, HomeAddress2, constHomeAddress2 ); + std::string HomeCity; + fromRawAbe( rawAbe, HomeCity, constHomeCity ); + std::string HomeState; + fromRawAbe( rawAbe, HomeState, constHomeState ); + std::string HomeZipCode; + fromRawAbe( rawAbe, HomeZipCode, constHomeZipCode ); + std::string HomeCountry; + fromRawAbe( rawAbe, HomeCountry, constHomeCountry ); + + std::string WorkAddress; + fromRawAbe( rawAbe, WorkAddress, constWorkAddress ); + std::string WorkAddress2; + fromRawAbe( rawAbe, WorkAddress2, constWorkAddress2 ); + std::string WorkCity; + fromRawAbe( rawAbe, WorkCity, constWorkCity ); + std::string WorkState; + fromRawAbe( rawAbe, WorkState, constWorkState ); + std::string WorkZipCode; + fromRawAbe( rawAbe, WorkZipCode, constWorkZipCode ); + std::string WorkCountry; + fromRawAbe( rawAbe, WorkCountry, constWorkCountry ); + std::string JobTitle; + fromRawAbe( rawAbe, JobTitle, constJobTitle ); + std::string Department; + fromRawAbe( rawAbe, Department, constDepartment ); + std::string Company; + fromRawAbe( rawAbe, Company, constCompany ); + + std::string address; + + appendAddress( address, HomeAddress ); + if ( !address.empty() ) address += "\r\n"; + appendAddress( address, HomeAddress2 ); + if ( !HomeAddress2.empty() ) address += "\r\n"; + appendAddress( address, HomeCity ); + appendAddress( address, HomeState ); + appendAddress( address, HomeZipCode ); + if ( !HomeCity.empty() || !HomeState.empty() || !HomeZipCode.empty() ) address += "\r\n"; + appendAddress( address, HomeCountry ); + + abe.address_home = address; + + address.clear(); + + appendAddress( address, JobTitle ); + appendAddress( address, Department ); + if ( !address.empty() ) address += "\r\n"; + appendAddress( address, Company ); + if ( !Company.empty() ) address += "\r\n"; + appendAddress( address, WorkAddress ); + if ( !WorkAddress.empty() ) address += "\r\n"; + appendAddress( address, WorkAddress2 ); + if ( !WorkAddress2.empty() ) address += "\r\n"; + appendAddress( address, WorkCity ); + appendAddress( address, WorkState ); + appendAddress( address, WorkZipCode ); + if ( !WorkCity.empty() || !WorkState.empty() || !WorkZipCode.empty() ) address += "\r\n"; + appendAddress( address, WorkCountry ); + if ( !WorkCountry.empty() ) address += "\r\n"; + + abe.address_work = address; +} + + + +/// +/// Opens address book +/// @param path - path to the address book file +/// @return - true if success, otherwise false +/// +bool openAddressBook( const std::string& path ) +{ + abes_.clear(); + MorkParser mork; + + // Open and parse mork file + if ( !mork.open( path ) ) + { + return false; + } + + const int defaultScope = 0x80; + + MorkTableMap *Tables = 0; + MorkRowMap *Rows = 0; + MorkTableMap::iterator tableIter; + MorkRowMap::iterator rowIter; + + Tables = mork.getTables( defaultScope ); + + if ( Tables ) + { + // Iterate all tables + for ( tableIter = Tables->begin(); tableIter != Tables->end(); tableIter++ ) + { + if ( 0 == tableIter->first ) continue; + + // Get rows + Rows = mork.getRows( defaultScope, &tableIter->second ); + + if ( Rows ) + { + // Iterate all rows + for ( rowIter = Rows->begin(); rowIter != Rows->end(); rowIter++ ) + { + if ( 0 == rowIter->first ) continue; + + RawAbeMap ram; + AddressBookEntry abe; + std::string column; + std::string value; + + char buffer[20]; + snprintf(buffer, sizeof buffer, "%d", rowIter->first); + //itoa( rowIter->first, buffer, 10 ); + + abe.id = std::string( buffer ); + + // Get cells + for ( MorkCells::iterator cellsIter = rowIter->second.begin(); + cellsIter != rowIter->second.end(); cellsIter++ ) + { + column = mork.getColumn( cellsIter->first ); + value = mork.getValue( cellsIter->second ); + + ram[ column ] = value; + } + + AbeMap::iterator abeIter; + + abes_[ rowIter->first ] = abe; + abeIter = abes_.find( rowIter->first ); + + addEntry( ram, abeIter->second ); + } + } + } + } + + return true; +} + +int main( int argc, char ** argv ) +{ + //openAddressBook( "D:\\Development\\OpenSource\\MorkParser-STL1.0\\abook.mab" ); + openAddressBook( "/home/yang/.mozilla-thunderbird/r9d4e7vh.default/ImapMail/imap.gmail.com/y_...@mi... (old).msf" ); + + AbeMap::iterator iter; + + for ( iter = abes_.begin(); iter != abes_.end(); iter++ ) + { + std::cout << "Entry -----------" << std::endl; + std::cout << "Email Address: " << iter->second.email << std::endl; + std::cout << "Name: " << iter->second.first_name << " " << iter->second.last_name << std::endl << std::endl; + } + return 0; +} Added: sandbox/trunk/src/one-off-scripts/msf-parser/README =================================================================== --- sandbox/trunk/src/one-off-scripts/msf-parser/README (rev 0) +++ sandbox/trunk/src/one-off-scripts/msf-parser/README 2009-08-30 18:44:16 UTC (rev 1472) @@ -0,0 +1,17 @@ +msfparser is a simple program that dumps all the emails in a .msf index file. +You should compact the .msf first if you want to ignore deleted files (I don't +know how to distinguish deleted items from undeleted items). + +I originally wrote this to determine the difference between two .msf files. +This was while importing email to Gmail from my Thunderbird local folder, and +noticing that there were fewer messages copied into Gmail than there were in +the source folder. It turned out that duplicates in the Thunderbird local +folder were getting de-duped when copied to Gmail. Those duplicates only +appeared in earlier email, 2006 and before, perhaps due to bugs in earlier +versions of Thunderbird. + +This uses a slightly modified version of the MorkParser library from +<http://www.scalingweb.com/mork_parser.php>. However, this library has a few +bugs, particularly with escaped characters (characters can be escaped with `\` +or with `$`). A good resource on parsing can be found at +<https://wiki.mozilla.org/Mork>. Added: sandbox/trunk/src/one-off-scripts/msf-parser/msfparser.cpp =================================================================== --- sandbox/trunk/src/one-off-scripts/msf-parser/msfparser.cpp (rev 0) +++ sandbox/trunk/src/one-off-scripts/msf-parser/msfparser.cpp 2009-08-30 18:44:16 UTC (rev 1472) @@ -0,0 +1,71 @@ +#include "MorkParser.h" +#include <algorithm> +#include <cstdlib> +#include <iostream> +#include <set> +#include <sstream> +#include <string> +#include <tuple> +#include <vector> +using namespace std; +bool debug = false; +string escape(string &s) { + stringstream t; + for (int i = 0; i < s.size(); i++) { + t << (int) s[i] << " "; + } + return s + " (" + t.str() + ")"; +} +int main(int argc, char **argv) { + MorkParser mork; + if (argc != 2) throw exception(); + if (!mork.open(string(argv[1]))) + throw exception(); + int defaultScope = 0x80; + int count = 0; + MorkTableMap *table = mork.getTables(defaultScope); + set<string> cols; + typedef map<string, string> msg_t; + typedef vector<tuple<uint64_t, msg_t> > msgvec; + msgvec msgs; + for (MorkTableMap::iterator tit = table->begin(); tit != table->end(); ++tit) { + if (tit->first != 0) { + MorkRowMap *row = mork.getRows(defaultScope, &tit->second); + if (row) { + for (MorkRowMap::iterator rit = row->begin(); rit != row->end(); ++rit) { + if (rit->first != 0) { + msg_t msg; + for (MorkCells::iterator cit = rit->second.begin(); cit != rit->second.end(); ++cit) { + cols.insert(mork.getColumn(cit->first)); + msg[mork.getColumn(cit->first)] = mork.getValue(cit->second); + } + if (msg.size() > 0) { + msgs.push_back(make_tuple(strtoul(msg["date"].c_str(), NULL, 16), msg)); + ++count; + } + } + } + } + } + } + cout << "count: " << count << endl; + if (debug) { + cout << "columns:" << endl; + for (set<string>::iterator it = cols.begin(); it != cols.end(); ++it) { + cout << " " << *it << endl; + } + } + sort(msgs.begin(), msgs.end()); + for (msgvec::iterator it = msgs.begin(); it != msgs.end(); ++it) { + uint64_t date = get<0>(*it); + msg_t &msg = get<1>(*it); + bool has_subj = msg.find("subject") != msg.end(); + cout << date << " " << (has_subj ? escape(msg.find("subject")->second) : string("")) << endl; + if (debug || date == 0 || msg["subject"].find("Shneiderman") != string::npos) { + for (msg_t::iterator mit = msg.begin(); mit != msg.end(); ++mit) { + cout << " " << mit->first << ": " << mit->second << endl; + } + } + } + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-08-22 00:36:40
|
Revision: 1471 http://assorted.svn.sourceforge.net/assorted/?rev=1471&view=rev Author: yangzhang Date: 2009-08-22 00:36:33 +0000 (Sat, 22 Aug 2009) Log Message: ----------- added some yahoo hosts Modified Paths: -------------- configs/trunk/src/ssh/config Modified: configs/trunk/src/ssh/config =================================================================== --- configs/trunk/src/ssh/config 2009-08-22 00:36:28 UTC (rev 1470) +++ configs/trunk/src/ssh/config 2009-08-22 00:36:33 UTC (rev 1471) @@ -21,6 +21,57 @@ Host gq4 HostName sherpa4.yrl.gq1.yahoo.com +Host gq5 + HostName sherpa6.yrl.gq1.yahoo.com + +Host gq6 + HostName sherpa7.yrl.gq1.yahoo.com + +Host gq7 + HostName sherpa8.yrl.gq1.yahoo.com + +Host gq8 + HostName sherpa9.yrl.gq1.yahoo.com + +Host gq9 + HostName sherpa10.yrl.gq1.yahoo.com + +Host gq10 + HostName sherpa11.yrl.gq1.yahoo.com + +Host in1 + HostName sherpa1.yrl.in2.yahoo.com + +Host in2 + HostName sherpa2.yrl.in2.yahoo.com + +Host in3 + HostName sherpa3.yrl.in2.yahoo.com + +Host in4 + HostName sherpa4.yrl.in2.yahoo.com + +Host in5 + HostName sherpa5.yrl.in2.yahoo.com + +Host in6 + HostName sherpa6.yrl.in2.yahoo.com + +Host in7 + HostName sherpa7.yrl.in2.yahoo.com + +Host in8 + HostName sherpa8.yrl.in2.yahoo.com + +Host in9 + HostName sherpa9.yrl.in2.yahoo.com + +Host in10 + HostName sherpa10.yrl.in2.yahoo.com + +Host in11 + HostName sherpa11.yrl.in2.yahoo.com + Host sg1 HostName sherpa1.yrl.sg1.yahoo.com @@ -34,7 +85,7 @@ HostName sherpa4.yrl.sg1.yahoo.com Host re1 - HostName sherpa2.corp.re1.yahoo.com + HostName sherpa3.corp.re1.yahoo.com Host re2 HostName sherpa4.corp.re1.yahoo.com @@ -45,6 +96,18 @@ Host re4 HostName sherpa11.corp.re1.yahoo.com +Host re5 + HostName sherpa6.corp.re1.yahoo.com + +Host re6 + HostName sherpa7.corp.re1.yahoo.com + +Host re7 + HostName sherpa8.corp.re1.yahoo.com + +Host re8 + HostName sherpa9.corp.re1.yahoo.com + Host ir1 HostName sherpa2.corp.ird.yahoo.com @@ -57,6 +120,42 @@ Host ir4 HostName sherpa11.corp.ird.yahoo.com +Host ir5 + HostName sherpa6.corp.ird.yahoo.com + +Host ir6 + HostName sherpa7.corp.ird.yahoo.com + +Host ir7 + HostName sherpa8.corp.ird.yahoo.com + +Host ir8 + HostName sherpa9.corp.ird.yahoo.com + +Host sp1 + HostName peanuts16.research.corp.sp1.yahoo.com + +Host sp2 + HostName peanuts17.research.corp.sp1.yahoo.com + +Host sp3 + HostName peanuts21.research.corp.sp1.yahoo.com + +Host sp4 + HostName peanuts22.research.corp.sp1.yahoo.com + +Host sp5 + HostName peanuts23.research.corp.sp1.yahoo.com + +Host sp6 + HostName peanuts24.research.corp.sp1.yahoo.com + +Host sp7 + HostName peanuts25.research.corp.sp1.yahoo.com + +Host sp8 + HostName peanuts26.research.corp.sp1.yahoo.com + # # CSAIL PMG # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-08-22 00:36:38
|
Revision: 1470 http://assorted.svn.sourceforge.net/assorted/?rev=1470&view=rev Author: yangzhang Date: 2009-08-22 00:36:28 +0000 (Sat, 22 Aug 2009) Log Message: ----------- vim: matching pairs Modified Paths: -------------- configs/trunk/src/vim/plugin/_yang.vim Modified: configs/trunk/src/vim/plugin/_yang.vim =================================================================== --- configs/trunk/src/vim/plugin/_yang.vim 2009-08-22 00:35:57 UTC (rev 1469) +++ configs/trunk/src/vim/plugin/_yang.vim 2009-08-22 00:36:28 UTC (rev 1470) @@ -16,6 +16,19 @@ nnoremap <silent> \cw :call CenterWordInSpace()<CR> +" From +" http://concisionandconcinnity.blogspot.com/2009/07/vim-part-ii-matching-pairs.html +vnoremap ( <ESC>`>a)<ESC>`<i(<ESC> +vnoremap ) <ESC>`>a)<ESC>`<i(<ESC> +vnoremap { <ESC>`>a}<ESC>`<i{<ESC> +vnoremap } <ESC>`>a}<ESC>`<i{<ESC> +vnoremap " <ESC>`>a"<ESC>`<i"<ESC> +vnoremap ' <ESC>`>a'<ESC>`<i'<ESC> +vnoremap ` <ESC>`>a`<ESC>`<i`<ESC> +vnoremap [ <ESC>`>a]<ESC>`<i[<ESC> +vnoremap ] <ESC>`>a]<ESC>`<i[<ESC> + + nnoremap <silent> \va :call AlignWordWithWordInPreviousLine()<CR> nnoremap <m-b> :silent call ToggleBrowser()<CR> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-08-22 00:36:14
|
Revision: 1469 http://assorted.svn.sourceforge.net/assorted/?rev=1469&view=rev Author: yangzhang Date: 2009-08-22 00:35:57 +0000 (Sat, 22 Aug 2009) Log Message: ----------- pythonpath python version tweaks; added stoast; cleaner keychain/interactive setup Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2009-08-22 00:34:59 UTC (rev 1468) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2009-08-22 00:35:57 UTC (rev 1469) @@ -118,11 +118,12 @@ prepend_std INFOPATH info # TODO fix this to not use an explicit ruby version prepend_std RUBYLIB /var/lib/gems/1.8/lib -# i think: # - LD_LIBRARY_PATH is for dynamic shared libs # - LIBRARY_PATH is for gcc (static linking) prepend_std LD_LIBRARY_PATH lib /usr/local/lib prepend_std LIBRARY_PATH lib +# This is for pkg-config +prepend_std PKG_CONFIG_PATH lib/pkgconfig # Don't use CPATH for general system headers, since that gets treated as -I # instead of -isystem. prepend_var CPATH $HOME/.local/pkg/cpp-commons/include:/opt/cpp-commons/include @@ -149,7 +150,11 @@ export PYTHONSTARTUP="$HOME/.pythonrc.py" pythonpath_prepend= -for ver in 2.5 ; do # 2.4 ; do # 2.3 2.4 2.5 '' ; do +ver=${PYTHONVERSION} +if [[ ! "$ver" ]] && type python >& /dev/null +then ver="$( python -c 'import sys; print ".".join(map(str,sys.version_info[0:2]))' )" +fi +for ver in $ver ; do pythonpath_prepend="$USER_PREFIX/lib/python$ver/site-packages:$pythonpath_prepend" pythonpath_prepend="$USER_TOAST_PREFIX/lib/python$ver/site-packages:$pythonpath_prepend" pythonpath_prepend="/usr/local/lib/python$ver/site-packages:$pythonpath_prepend" @@ -697,6 +702,10 @@ "$@" } +stoast() { + sudo su - -c "toast $(quote "$@")" +} + #function set_title() { # if [ $# -eq 0 ] ; then # eval set -- "$PWD" @@ -737,15 +746,20 @@ # -t 1 checks if fd 1 (stdout) is a terminal; if so then we're running # interactively. +if [[ -t 1 ]] +then keychain_flags= +else keychain_flags=--noask +fi + +if have keychain +then eval `keychain --eval --nogui $keychain_flags id_dsa 2> /dev/null` +fi + +# TODO note that bash_completion usually does a ton of stuff (and in +# particular it re/undefines `have`), so it's best to move this near the +# top +# Note that this tends to be the most expensive part of my startup. if [[ -t 1 ]] ; then - if have keychain - then eval `keychain --eval --nogui id_dsa 2> /dev/null` - fi - - # TODO note that bash_completion usually does a ton of stuff (and in - # particular it re/undefines `have`), so it's best to move this near the - # top - # Note that this tends to be the most expensive part of my startup. if [[ -f /etc/bash_completion && -z "$BASH_COMPLETION" ]] then . /etc/bash_completion fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-08-22 00:35:07
|
Revision: 1468 http://assorted.svn.sourceforge.net/assorted/?rev=1468&view=rev Author: yangzhang Date: 2009-08-22 00:34:59 +0000 (Sat, 22 Aug 2009) Log Message: ----------- realpath -> readlink -f; added maybe-add-ssh, install-and-setup-exes, setup-exes Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2009-08-13 00:53:35 UTC (rev 1467) +++ shell-tools/trunk/src/bash-commons/common.bash 2009-08-22 00:34:59 UTC (rev 1468) @@ -243,7 +243,7 @@ # TODO is this necessary in light of advanced var expansions? is_declared() { - declare -p "$1" &> /dev/null + declare -p "$1" >& /dev/null } # checks if a service is running; if not, start it! @@ -382,7 +382,7 @@ local dir=. while true ; do if "$@" "$dir" ; then break ; fi - if [[ "$( realpath "$dir" )" == / ]] ; then return 1 ; fi + if [[ "$( readlink -f "$dir" )" == / ]] ; then return 1 ; fi dir="$dir/.." done echo "$dir" @@ -481,7 +481,7 @@ op-tree-files() { local src="$1" dst="$2" find "$src" -not -type d -printf '%P\0' | - xargs -0 -I_ "$@" "$( realpath "$src" )/_" "$dst/_" + xargs -0 -I_ "$@" "$( readlink -f "$src" )/_" "$dst/_" } # Make a deep copy of a directory. @@ -559,6 +559,39 @@ done } +# Add keys if not already added. +maybe-ssh-add() { + if ( ssh-add -l && ! ssh-add -l | fgrep $1 ) >& /dev/null + then ssh-add ~/.ssh/$1 + fi +} + +# Useful for installing packages that come in a tree that runs out-of-the-box, +# like Firefox, Thunderbird, Eclipse, Netbeans, JProfiler. First argument is +# the package directory to install (it's installed using mv), and the second +# argument is the place to install to (defaults to ~/.local/pkg/<package +# directory basename>). +install-and-setup-exes() { + local dir="$1" base="$(basename "$1")" + local dst="${2:-~/.local/pkg/$base}/" + mkdir -p "$dst/bin/" + mv "$dir" "$dst" + setup-exes "$dst/$base/bin/" "$dst/bin/" +} + +# Create shell script wrappers in the dst directory for any executables in the +# src directory. +setup-exes() { + local src="$1" dst="$2" + for i in "$src/"* ; do + if [[ -x "$i" ]] ; then + echo -e "#!/usr/bin/env bash\nexec $(quote "$(readlink -f "$i")") \"\$@\"" \ + > "$dst/$(basename "$i")" + chmod +x "$dst/$(basename "$i")" + fi + done +} + #if ! is_declared indent ; then # noindent #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-08-13 00:53:54
|
Revision: 1467 http://assorted.svn.sourceforge.net/assorted/?rev=1467&view=rev Author: yangzhang Date: 2009-08-13 00:53:35 +0000 (Thu, 13 Aug 2009) Log Message: ----------- added peakmem Modified Paths: -------------- shell-tools/trunk/README Added Paths: ----------- shell-tools/trunk/src/peakmem.bash Modified: shell-tools/trunk/README =================================================================== --- shell-tools/trunk/README 2009-08-12 22:27:41 UTC (rev 1466) +++ shell-tools/trunk/README 2009-08-13 00:53:35 UTC (rev 1467) @@ -108,6 +108,8 @@ (sequentially), but also be able to enter a [Pexpect] common password (useful when keys aren't set up. + +`peakmem` Run a process and get its peak memory usage. bash -------------------------------------------------------------------------------- [HSH]: http://software.complete.org/hsh/ Added: shell-tools/trunk/src/peakmem.bash =================================================================== --- shell-tools/trunk/src/peakmem.bash (rev 0) +++ shell-tools/trunk/src/peakmem.bash 2009-08-13 00:53:35 UTC (rev 1467) @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +"$@" & # Run the given command line in the background. +pid=$! peak=0 +while true; do + sleep 1 + sample="$(ps -o rss= $pid 2> /dev/null)" || break + let peak='sample > peak ? sample : peak' +done +echo "Peak: $peak" 1>&2 Property changes on: shell-tools/trunk/src/peakmem.bash ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-08-12 22:27:54
|
Revision: 1466 http://assorted.svn.sourceforge.net/assorted/?rev=1466&view=rev Author: yangzhang Date: 2009-08-12 22:27:41 +0000 (Wed, 12 Aug 2009) Log Message: ----------- added demo comparing Mono and Hotspot footprints Added Paths: ----------- sandbox/trunk/src/java/footprint/ sandbox/trunk/src/java/footprint/DotNetMain.cs sandbox/trunk/src/java/footprint/Main.java sandbox/trunk/src/java/footprint/go.bash Added: sandbox/trunk/src/java/footprint/DotNetMain.cs =================================================================== --- sandbox/trunk/src/java/footprint/DotNetMain.cs (rev 0) +++ sandbox/trunk/src/java/footprint/DotNetMain.cs 2009-08-12 22:27:41 UTC (rev 1466) @@ -0,0 +1,11 @@ +using System; +using System.Threading; + +class DotNetMain { + public static void Main(string[] args) { + for (int i = 0; i < 3; i++) { + Console.WriteLine("Hello, .NET"); + Thread.Sleep(1000); + } + } +} Added: sandbox/trunk/src/java/footprint/Main.java =================================================================== --- sandbox/trunk/src/java/footprint/Main.java (rev 0) +++ sandbox/trunk/src/java/footprint/Main.java 2009-08-12 22:27:41 UTC (rev 1466) @@ -0,0 +1,8 @@ +public class Main { + public static void main(String[] args) throws Exception { + for (int i = 0; i < 3; i++) { + System.out.println("Hello, Java"); + Thread.sleep(1000); + } + } +} Added: sandbox/trunk/src/java/footprint/go.bash =================================================================== --- sandbox/trunk/src/java/footprint/go.bash (rev 0) +++ sandbox/trunk/src/java/footprint/go.bash 2009-08-12 22:27:41 UTC (rev 1466) @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +javac Main.java +java -server Main & +#java Main & +pid=$! +for i in 1 2; do + sleep 1 + ps -o rss= $pid +done +wait + +csc DotNetMain.cs +./DotNetMain.exe & +pid=$! +for i in 1 2 ; do + sleep 1 + ps -o rss= $pid +done +wait + +# Results: Java takes ~12.3MB, Mono takes ~5.1MB Property changes on: sandbox/trunk/src/java/footprint/go.bash ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-08-10 16:43:36
|
Revision: 1465 http://assorted.svn.sourceforge.net/assorted/?rev=1465&view=rev Author: yangzhang Date: 2009-08-10 16:43:13 +0000 (Mon, 10 Aug 2009) Log Message: ----------- exploration of libc stream buffering Added Paths: ----------- sandbox/trunk/src/nix/buffer/ sandbox/trunk/src/nix/buffer/gen.c sandbox/trunk/src/nix/buffer/go.bash Added: sandbox/trunk/src/nix/buffer/gen.c =================================================================== --- sandbox/trunk/src/nix/buffer/gen.c (rev 0) +++ sandbox/trunk/src/nix/buffer/gen.c 2009-08-10 16:43:13 UTC (rev 1465) @@ -0,0 +1,49 @@ +#include <unistd.h> +#include <stdio.h> + +int main() { + int i; + + // This writes directly to the file without buffering, even if stdout is + // connected to a pipe or file. + + for (i = 0; i < 3; ++i) { + write(STDOUT_FILENO, "a\n", 2); + write(STDERR_FILENO, "b\n", 2); + usleep(300000); + } + + write(STDOUT_FILENO, "===\n", 4); + + // stdout is line-buffered by default, whereas stderr is unbuffered, so the + // b's will show up before the a's. + + for (i = 0; i < 3; ++i) { + fwrite("a\n", 1, 2, stdout); + fwrite("b\n", 1, 2, stderr); + usleep(300000); + } + fflush(stdout); + fflush(stderr); + + write(STDOUT_FILENO, "===\n", 4); + + // We can change stdout's buffering mode. Below we show that just changing + // the mode doesn't actually flush what's already buffered. But afterward, + // the first flush will flush everything, and we're once again interleaving + // a's and b's. + + for (i = 0; i < 3; ++i) { + fwrite("a\n", 1, 2, stdout); + fwrite("b\n", 1, 2, stderr); + usleep(300000); + } + setbuf(stdout, NULL); + for (i = 0; i < 3; ++i) { + fwrite("a\n", 1, 2, stdout); + fwrite("b\n", 1, 2, stderr); + usleep(300000); + } + + return 0; +} Added: sandbox/trunk/src/nix/buffer/go.bash =================================================================== --- sandbox/trunk/src/nix/buffer/go.bash (rev 0) +++ sandbox/trunk/src/nix/buffer/go.bash 2009-08-10 16:43:13 UTC (rev 1465) @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +gcc -o gen gen.c + +# +# These buffer. +# + +./gen 2>&1 | tee /dev/null +expect_unbuffer ./gen 2>&1 | tee /dev/null + +# +# These don't buffer. +# + +ssh localhost "$(readlink -f "$(dirname "$0")/gen")" 2>&1 | tee /dev/null +ssh localhost "expect_unbuffer $(readlink -f "$(dirname "$0")/gen")" 2>&1 | tee /dev/null +expect_unbuffer ssh localhost "$(readlink -f "$(dirname "$0")/gen")" 2>&1 | tee /dev/null Property changes on: sandbox/trunk/src/nix/buffer/go.bash ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-23 08:59:20
|
Revision: 1464 http://assorted.svn.sourceforge.net/assorted/?rev=1464&view=rev Author: yangzhang Date: 2009-07-23 08:59:14 +0000 (Thu, 23 Jul 2009) Log Message: ----------- organized ssh config a bit; add yahoo hosts Modified Paths: -------------- configs/trunk/src/ssh/config Modified: configs/trunk/src/ssh/config =================================================================== --- configs/trunk/src/ssh/config 2009-07-22 20:42:15 UTC (rev 1463) +++ configs/trunk/src/ssh/config 2009-07-23 08:59:14 UTC (rev 1464) @@ -5,10 +5,62 @@ # StrictHostKeyChecking no -Host nr - HostName nr.ath.cx - User yang +# +# Yahoo +# +Host gq1 + HostName sherpa1.yrl.gq1.yahoo.com + +Host gq2 + HostName sherpa2.yrl.gq1.yahoo.com + +Host gq3 + HostName sherpa3.yrl.gq1.yahoo.com + +Host gq4 + HostName sherpa4.yrl.gq1.yahoo.com + +Host sg1 + HostName sherpa1.yrl.sg1.yahoo.com + +Host sg2 + HostName sherpa2.yrl.sg1.yahoo.com + +Host sg3 + HostName sherpa3.yrl.sg1.yahoo.com + +Host sg4 + HostName sherpa4.yrl.sg1.yahoo.com + +Host re1 + HostName sherpa2.corp.re1.yahoo.com + +Host re2 + HostName sherpa4.corp.re1.yahoo.com + +Host re3 + HostName sherpa10.corp.re1.yahoo.com + +Host re4 + HostName sherpa11.corp.re1.yahoo.com + +Host ir1 + HostName sherpa2.corp.ird.yahoo.com + +Host ir2 + HostName sherpa4.corp.ird.yahoo.com + +Host ir3 + HostName sherpa10.corp.ird.yahoo.com + +Host ir4 + HostName sherpa11.corp.ird.yahoo.com + +# +# CSAIL PMG +# + Host farm1 HostName farm1.csail.mit.edu User yang @@ -69,14 +121,31 @@ HostName farm15.csail.mit.edu User yang +# +# Vertica/H-Store +# + Host hz HostName hzproject.com User yzhang +# +# Misc +# + Host icfp HostName 128.30.79.174 User knoppix +Host hadoop + HostName localhost + Port 54022 + HostKeyAlias 10.1.131.188 + +# +# XVM +# + Host rem HostName remote.mit.edu User root @@ -89,6 +158,15 @@ HostName sx-blade-2.mit.edu User root +# +# CSAIL +# + +Host hv + HostName harvard.csail.mit.edu + User yang + ForwardX11 yes + Host blokus HostName blokus.csail.mit.edu User y_z @@ -109,18 +187,13 @@ HostName caneland.csail.mit.edu User y_z -Host hadoop - HostName localhost - Port 54022 - HostKeyAlias 10.1.131.188 - Host pdos HostName pdos.csail.mit.edu User yang -Host sn - HostName sn002.datapository.net - User yang +# +# Cartel +# Host cd3 HostName cartel-dev3.csail.mit.edu @@ -131,18 +204,43 @@ User root Host golf - HostName golf + HostName golf.csail.mit.edu User root +# +# CMU +# + +Host sn + HostName sn002.datapository.net + User yang + +# +# MIT +# + Host ath HostName athena.dialup.mit.edu User y_z +# +# Personal +# + Host zs HostName zs.ath.cx User yang ForwardX11 yes +# yangrzhangr +Host nr + HostName nr.ath.cx + User yang + +# +# People +# + # Rohan K Host kr HostName krang.eecs.harvard.edu @@ -153,6 +251,15 @@ HostName livermore.csail.mit.edu User yang +# Jacob Scott +Host on + HostName orange-ninja.mit.edu + User yang + +# +# Sourceforge +# + Host pubmgr-cvs HostName pubmgr.cvs.sourceforge.net User yangzhang @@ -161,34 +268,32 @@ HostName web.sourceforge.net User yangzhang,assorted +# +# CSAIL DB group +# + Host db HostName db.csail.mit.edu User yang +# +# CSAIL NMS +# + Host nms HostName nms.csail.mit.edu User yang -Host hv - HostName harvard.csail.mit.edu - User yang - ForwardX11 yes - Host cs HostName login.csail.mit.edu User yang ForwardX11 yes -# Jacob Scott -Host on - HostName orange-ninja.mit.edu - User yang - Host lin HostName linerva.mit.edu User y_z ForwardX11 yes - GSSAPIDelegateCredentials yes + #GSSAPIDelegateCredentials yes Host athcs HostName athena.csail.mit.edu This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-22 20:42:21
|
Revision: 1463 http://assorted.svn.sourceforge.net/assorted/?rev=1463&view=rev Author: yangzhang Date: 2009-07-22 20:42:15 +0000 (Wed, 22 Jul 2009) Log Message: ----------- more work on nettytest; close to working Modified Paths: -------------- sandbox/trunk/src/java/nettytest/pom.xml Added Paths: ----------- sandbox/trunk/src/java/nettytest/src/main/java/nettytest/ sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Client.java sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Common.java sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Server.java sandbox/trunk/src/java/nettytest/src/test/java/nettytest/ sandbox/trunk/src/java/nettytest/src/test/java/nettytest/TestSystem.java sandbox/trunk/src/java/nettytest/src/test/resources/nettytest/ sandbox/trunk/src/java/nettytest/src/test/resources/nettytest/p12.pass sandbox/trunk/src/java/nettytest/src/test/resources/nettytest/server.p12 Removed Paths: ------------- sandbox/trunk/src/java/nettytest/src/main/java/Client.java sandbox/trunk/src/java/nettytest/src/main/java/Common.java sandbox/trunk/src/java/nettytest/src/main/java/Server.java Modified: sandbox/trunk/src/java/nettytest/pom.xml =================================================================== --- sandbox/trunk/src/java/nettytest/pom.xml 2009-07-22 02:16:59 UTC (rev 1462) +++ sandbox/trunk/src/java/nettytest/pom.xml 2009-07-22 20:42:15 UTC (rev 1463) @@ -12,9 +12,15 @@ </repositories> <dependencies> <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.6</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.jboss.netty</groupId> <artifactId>netty</artifactId> - <version>3.1.0.BETA3</version> + <version>3.1.0.CR1</version> </dependency> </dependencies> <build> @@ -26,6 +32,15 @@ <target>6</target> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <version>2.6</version> + <configuration> + <downloadSources>true</downloadSources> + <addVersionToProjectName>true</addVersionToProjectName> + </configuration> + </plugin> </plugins> </build> </project> Deleted: sandbox/trunk/src/java/nettytest/src/main/java/Client.java =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/Client.java 2009-07-22 02:16:59 UTC (rev 1462) +++ sandbox/trunk/src/java/nettytest/src/main/java/Client.java 2009-07-22 20:42:15 UTC (rev 1463) @@ -1,62 +0,0 @@ -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.util.concurrent.Callable; -import java.util.concurrent.Executors; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; - -import org.jboss.netty.bootstrap.ClientBootstrap; -import org.jboss.netty.channel.ChannelFuture; -import org.jboss.netty.channel.ChannelFutureListener; -import org.jboss.netty.channel.ChannelPipeline; -import org.jboss.netty.channel.ChannelPipelineCoverage; -import org.jboss.netty.channel.ChannelPipelineFactory; -import org.jboss.netty.channel.Channels; -import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; -import org.jboss.netty.handler.ssl.SslHandler; - -public class Client extends Common implements Callable<Void> { - - public SSLEngine getSslEngine() throws Exception { - SSLContext ctx = SSLContext.getInstance("TLS"); - ctx.init(null, getTrustManagers(), null); - SSLEngine engine = ctx.createSSLEngine(); - engine.setUseClientMode(true); - return engine; - } - - public static void main(String[] args) throws Exception { - Client client = new Client(); - client.call(); - } - - public Void call() throws Exception { - @ChannelPipelineCoverage("all") - class Cpf implements ChannelPipelineFactory { - public ChannelPipeline getPipeline() throws Exception { - ChannelPipeline pipeline = Channels.pipeline(); - pipeline.addLast("ssl", new SslHandler(getSslEngine())); - return pipeline; - } - } - ChannelPipelineFactory pipelineFactory = new Cpf(); - - ClientBootstrap bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors - .newCachedThreadPool())); - bootstrap.setPipelineFactory(pipelineFactory); - bootstrap.setOption("tcpNoDelay", true); - bootstrap.setOption("keepAlive", true); - - ChannelFuture future = bootstrap.connect(new InetSocketAddress(InetAddress.getLocalHost(), 9876)); - future.addListener(new ChannelFutureListener() { - @Override - public void operationComplete(ChannelFuture arg0) throws Exception { - System.out.println(arg0.isSuccess() ? "success" : "failure"); - } - }); - - return null; - } - -} Deleted: sandbox/trunk/src/java/nettytest/src/main/java/Common.java =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/Common.java 2009-07-22 02:16:59 UTC (rev 1462) +++ sandbox/trunk/src/java/nettytest/src/main/java/Common.java 2009-07-22 20:42:15 UTC (rev 1463) @@ -1,30 +0,0 @@ -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -public class Common { - - protected TrustManager[] getTrustManagers() { - return new TrustManager[] { new X509TrustManager() { - // Always trust, even if invalid. - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { - // Always trust. - } - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { - // Always trust. - } - } }; - } - -} Deleted: sandbox/trunk/src/java/nettytest/src/main/java/Server.java =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/Server.java 2009-07-22 02:16:59 UTC (rev 1462) +++ sandbox/trunk/src/java/nettytest/src/main/java/Server.java 2009-07-22 20:42:15 UTC (rev 1463) @@ -1,113 +0,0 @@ -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.net.InetSocketAddress; -import java.security.KeyStore; -import java.util.concurrent.Executors; - -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; - -import org.jboss.netty.bootstrap.ServerBootstrap; -import org.jboss.netty.channel.ChannelHandlerContext; -import org.jboss.netty.channel.ChannelPipeline; -import org.jboss.netty.channel.ChannelPipelineCoverage; -import org.jboss.netty.channel.ChannelPipelineFactory; -import org.jboss.netty.channel.ChannelStateEvent; -import org.jboss.netty.channel.Channels; -import org.jboss.netty.channel.MessageEvent; -import org.jboss.netty.channel.SimpleChannelHandler; -import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; -import org.jboss.netty.handler.ssl.SslHandler; - -public class Server extends Common { - - String passPath; - String certPath; - - public Server(String passPath, String certPath) { - this.passPath = passPath; - this.certPath = certPath; - } - - public SSLEngine getSslEngine() throws Exception { - // Read the password. - InputStreamReader passf = new InputStreamReader(new FileInputStream(passPath)); - char[] pass; - try { - StringBuffer sb = new StringBuffer(); - char[] chunk = new char[4096]; - while (true) { - int nread = passf.read(chunk, 0, chunk.length); - if (nread < 0) break; - sb.append(chunk, 0, nread); - } - String s = sb.toString(); - if (s.charAt(s.length() - 1) == '\n') - s = s.substring(0, s.length() - 1); - pass = s.toCharArray(); - } finally { - passf.close(); - } - - // Load our Java key store. - KeyStore ks = KeyStore.getInstance("pkcs12"); - ks.load(new FileInputStream(certPath), pass); - - // Like ssh-agent. - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(ks, pass); - - // Create the SSL context. - SSLContext ctx = SSLContext.getInstance("TLS"); - ctx.init(kmf.getKeyManagers(), getTrustManagers(), null); - - SSLEngine engine = ctx.createSSLEngine(); - engine.setUseClientMode(true); - return engine; - } - - public static void main(String[] args) throws Exception { - Server server = new Server(args[0], args[1]); - server.call(); - } - - @ChannelPipelineCoverage("all") - class Cpf implements ChannelPipelineFactory { - public ChannelPipeline getPipeline() throws Exception { - ChannelPipeline pipeline = Channels.pipeline(); - pipeline.addLast("ssl", new SslHandler(getSslEngine())); - pipeline.addLast("hdl", new SimpleChannelHandler() { - - @Override - public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { - System.out.println("received"); - } - - @Override - public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { - System.out.println("connected"); - } - }); - return pipeline; - } - } - - public Void call() throws Exception { - ChannelPipelineFactory pipelineFactory = new Cpf(); - - ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors - .newCachedThreadPool(), Executors.newCachedThreadPool())); - bootstrap.setPipelineFactory(pipelineFactory); - bootstrap.setOption("child.tcpNoDelay", true); - bootstrap.setOption("child.keepAlive", true); - bootstrap.setOption("reuseAddress", true); - - bootstrap.bind(new InetSocketAddress(9876)); - - return null; - } - -} - -// vim: et sw=4 ts=4 Copied: sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Client.java (from rev 1460, sandbox/trunk/src/java/nettytest/src/main/java/Client.java) =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Client.java (rev 0) +++ sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Client.java 2009-07-22 20:42:15 UTC (rev 1463) @@ -0,0 +1,111 @@ +package nettytest; + +import java.net.InetSocketAddress; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; + +import org.jboss.netty.bootstrap.ClientBootstrap; +import org.jboss.netty.channel.ChannelFactory; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.channel.ChannelPipelineCoverage; +import org.jboss.netty.channel.ChannelPipelineFactory; +import org.jboss.netty.channel.ChannelStateEvent; +import org.jboss.netty.channel.Channels; +import org.jboss.netty.channel.MessageEvent; +import org.jboss.netty.channel.SimpleChannelHandler; +import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; +import org.jboss.netty.handler.codec.string.StringDecoder; +import org.jboss.netty.handler.codec.string.StringEncoder; +import org.jboss.netty.handler.ssl.SslHandler; + +public class Client extends Common implements Callable<Void> { + + final String host; + final int port; + final ExecutorService bossExecutor, workExecutor; + + public Client(String host, int port, ExecutorService bossExecutor, ExecutorService workExecutor) { + this.host = host; + this.port = port; + this.bossExecutor = bossExecutor; + this.workExecutor = workExecutor; + } + + public SSLEngine getSslEngine() throws Exception { + SSLContext ctx = SSLContext.getInstance("TLS"); + ctx.init(null, getTrustManagers(), null); + SSLEngine engine = ctx.createSSLEngine(); + engine.setUseClientMode(true); + return engine; + } + + public static void main(String[] args) throws Exception { + Client client = new Client(args[0], Integer.parseInt(args[1]), Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); + client.call(); + } + + public Void call() throws Exception { + System.out.println("starting client"); + + ChannelFactory factory = new NioClientSocketChannelFactory(bossExecutor, workExecutor); + final LinkedBlockingQueue<Boolean> onDisconnect = new LinkedBlockingQueue<Boolean>(); + + @ChannelPipelineCoverage("all") + class Cpf implements ChannelPipelineFactory { + public ChannelPipeline getPipeline() throws Exception { + ChannelPipeline pipeline = Channels.pipeline(); + pipeline.addLast("ssl", new SslHandler(getSslEngine())); + pipeline.addLast("decoder", new StringDecoder()); + pipeline.addLast("encoder", new StringEncoder()); + pipeline.addLast("hdl", new SimpleChannelHandler() { + + @Override + public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { + System.out.println("connected"); + ctx.getPipeline().get(SslHandler.class).handshake(e.getChannel()); + } + + @Override + public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { + System.out.println("received: " + e.getMessage()); + e.getChannel().close(); + } + + @Override + public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { + onDisconnect.add(true); + } + }); + return pipeline; + } + } + ChannelPipelineFactory pipelineFactory = new Cpf(); + + ClientBootstrap bootstrap = new ClientBootstrap(factory); + bootstrap.setPipelineFactory(pipelineFactory); + bootstrap.setOption("tcpNoDelay", true); + bootstrap.setOption("keepAlive", true); + + System.out.println("connecting"); + ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port)) + .awaitUninterruptibly(); + if (future.isSuccess()) { + System.out.println("connected"); + onDisconnect.take(); + future.getChannel().close().awaitUninterruptibly(); + } else { + future.getCause().printStackTrace(); + } + factory.releaseExternalResources(); + + return null; + } + +} Copied: sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Common.java (from rev 1460, sandbox/trunk/src/java/nettytest/src/main/java/Common.java) =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Common.java (rev 0) +++ sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Common.java 2009-07-22 20:42:15 UTC (rev 1463) @@ -0,0 +1,31 @@ +package nettytest; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +public class Common { + + protected TrustManager[] getTrustManagers() { + return new TrustManager[] { new X509TrustManager() { + // Always trust, even if invalid. + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + // Always trust. + } + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + // Always trust. + } + } }; + } + +} Copied: sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Server.java (from rev 1462, sandbox/trunk/src/java/nettytest/src/main/java/Server.java) =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Server.java (rev 0) +++ sandbox/trunk/src/java/nettytest/src/main/java/nettytest/Server.java 2009-07-22 20:42:15 UTC (rev 1463) @@ -0,0 +1,154 @@ +package nettytest; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.InetSocketAddress; +import java.security.KeyStore; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; + +import org.jboss.netty.bootstrap.ServerBootstrap; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelFactory; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.ChannelFutureListener; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.channel.ChannelPipelineCoverage; +import org.jboss.netty.channel.ChannelPipelineFactory; +import org.jboss.netty.channel.ChannelStateEvent; +import org.jboss.netty.channel.Channels; +import org.jboss.netty.channel.MessageEvent; +import org.jboss.netty.channel.SimpleChannelHandler; +import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; +import org.jboss.netty.handler.codec.string.StringDecoder; +import org.jboss.netty.handler.codec.string.StringEncoder; +import org.jboss.netty.handler.ssl.SslHandler; + +public class Server extends Common implements Callable<Void> { + + final InputStream passStream, certStream; + final Runnable onListen; + final ExecutorService bossExecutor, workExecutor; + + public Server(InputStream passStream, InputStream certStream, Runnable onListen, ExecutorService bossExecutor, + ExecutorService workExecutor) { + this.passStream = passStream; + this.certStream = certStream; + this.onListen = onListen; + this.bossExecutor = bossExecutor; + this.workExecutor = workExecutor; + } + + public SSLEngine getSslEngine() throws Exception { + // Read the password. + InputStreamReader passf = new InputStreamReader(passStream); + char[] pass; + StringBuffer sb = new StringBuffer(); + char[] chunk = new char[4096]; + while (true) { + int nread = passf.read(chunk, 0, chunk.length); + if (nread < 0) + break; + sb.append(chunk, 0, nread); + } + String s = sb.toString(); + if (s.charAt(s.length() - 1) == '\n') + s = s.substring(0, s.length() - 1); + pass = s.toCharArray(); + + // Load our Java key store. + KeyStore ks = KeyStore.getInstance("pkcs12"); + ks.load(certStream, pass); + + // Like ssh-agent. + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(ks, pass); + + // Create the SSL context. + SSLContext ctx = SSLContext.getInstance("TLS"); + ctx.init(kmf.getKeyManagers(), getTrustManagers(), null); + + SSLEngine engine = ctx.createSSLEngine(); + engine.setUseClientMode(false); + return engine; + } + + public static void main(String[] args) throws Exception { + Server server = new Server(new FileInputStream(args[0]), new FileInputStream(args[1]), null, Executors + .newCachedThreadPool(), Executors.newCachedThreadPool()); + server.call(); + } + + public Void call() throws Exception { + final ChannelFactory factory = new NioServerSocketChannelFactory(bossExecutor, workExecutor); + + final LinkedBlockingQueue<Boolean> onDisconnect = new LinkedBlockingQueue<Boolean>(); + + @ChannelPipelineCoverage("all") + class Cpf implements ChannelPipelineFactory { + public ChannelPipeline getPipeline() throws Exception { + ChannelPipeline pipeline = Channels.pipeline(); + pipeline.addLast("ssl", new SslHandler(getSslEngine())); + pipeline.addLast("decoder", new StringDecoder()); + pipeline.addLast("encoder", new StringEncoder()); + pipeline.addLast("hdl", new SimpleChannelHandler() { + @Override + public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { + onDisconnect.add(true); + } + + @Override + public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { + System.out.println("received: " + e.getMessage()); + } + + @Override + public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { + System.out.println("got connection"); + ctx.getPipeline().get(SslHandler.class).handshake(e.getChannel()).addListener(new ChannelFutureListener() { + @Override + public void operationComplete(ChannelFuture future) throws Exception { + if (future.isSuccess()) { + System.out.println("handshake succeeded"); + future.getChannel().write("hello\n"); + } else { + System.out.println("handshake failed"); + future.getChannel().close(); + } + } + }); + } + }); + return pipeline; + } + } + ChannelPipelineFactory pipelineFactory = new Cpf(); + + ServerBootstrap bootstrap = new ServerBootstrap(factory); + bootstrap.setPipelineFactory(pipelineFactory); + bootstrap.setOption("child.tcpNoDelay", true); + bootstrap.setOption("child.keepAlive", true); + bootstrap.setOption("reuseAddress", true); + + Channel channel = bootstrap.bind(new InetSocketAddress(9876)); + System.out.println("listening"); + if (onListen != null) + onListen.run(); + onDisconnect.take(); + channel.close().awaitUninterruptibly(); + factory.releaseExternalResources(); + + return null; + } + +} + +// vim: et sw=4 ts=4 Added: sandbox/trunk/src/java/nettytest/src/test/java/nettytest/TestSystem.java =================================================================== --- sandbox/trunk/src/java/nettytest/src/test/java/nettytest/TestSystem.java (rev 0) +++ sandbox/trunk/src/java/nettytest/src/test/java/nettytest/TestSystem.java 2009-07-22 20:42:15 UTC (rev 1463) @@ -0,0 +1,38 @@ +package nettytest; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; + +import junit.framework.TestCase; + +import org.junit.Test; + +public class TestSystem extends TestCase { + + @Test + public void testSystem() throws Exception { + final LinkedBlockingQueue<Boolean> queue = new LinkedBlockingQueue<Boolean>(); + ExecutorService clientExecutor = Executors.newCachedThreadPool(), mainExecutor = Executors + .newCachedThreadPool(), serverExecutor = Executors.newCachedThreadPool(); + mainExecutor.submit(new Server(getClass().getResourceAsStream("p12.pass"), getClass().getResourceAsStream( + "server.p12"), new Runnable() { + + @Override + public void run() { + System.out.println("listening"); + queue.add(true); + } + + }, serverExecutor, serverExecutor)); + queue.take(); + mainExecutor.submit(new Client("localhost", 9876, clientExecutor, clientExecutor)); + clientExecutor.awaitTermination(5, TimeUnit.DAYS); + serverExecutor.awaitTermination(5, TimeUnit.DAYS); + mainExecutor.shutdown(); +// mainExecutor.awaitTermination(5, TimeUnit.DAYS); +// clientExecutor.awaitTermination(5, TimeUnit.DAYS); + } + +} Added: sandbox/trunk/src/java/nettytest/src/test/resources/nettytest/p12.pass =================================================================== --- sandbox/trunk/src/java/nettytest/src/test/resources/nettytest/p12.pass (rev 0) +++ sandbox/trunk/src/java/nettytest/src/test/resources/nettytest/p12.pass 2009-07-22 20:42:15 UTC (rev 1463) @@ -0,0 +1 @@ +eUySvp2phM2Wk Added: sandbox/trunk/src/java/nettytest/src/test/resources/nettytest/server.p12 =================================================================== (Binary files differ) Property changes on: sandbox/trunk/src/java/nettytest/src/test/resources/nettytest/server.p12 ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-22 02:17:04
|
Revision: 1462 http://assorted.svn.sourceforge.net/assorted/?rev=1462&view=rev Author: yangzhang Date: 2009-07-22 02:16:59 +0000 (Wed, 22 Jul 2009) Log Message: ----------- load passphrase and certs from files; added dummy cert resources for unit tests Modified Paths: -------------- sandbox/trunk/src/java/nettytest/pom.xml sandbox/trunk/src/java/nettytest/src/main/java/Server.java Added Paths: ----------- sandbox/trunk/src/java/nettytest/src/test/resources/server.p12 sandbox/trunk/src/java/nettytest/src/test/resources/server.pass Modified: sandbox/trunk/src/java/nettytest/pom.xml =================================================================== --- sandbox/trunk/src/java/nettytest/pom.xml 2009-07-22 01:44:24 UTC (rev 1461) +++ sandbox/trunk/src/java/nettytest/pom.xml 2009-07-22 02:16:59 UTC (rev 1462) @@ -4,17 +4,28 @@ <artifactId>nettytest</artifactId> <version>0.0.1-SNAPSHOT</version> <repositories> - <repository> - <id>JBOSS</id> - <name>JBoss Repository</name> - <url>http://repository.jboss.org/maven2/</url> - </repository> + <repository> + <id>JBOSS</id> + <name>JBoss Repository</name> + <url>http://repository.jboss.org/maven2/</url> + </repository> </repositories> <dependencies> - <dependency> - <groupId>org.jboss.netty</groupId> - <artifactId>netty</artifactId> - <version>3.1.0.BETA3</version> - </dependency> + <dependency> + <groupId>org.jboss.netty</groupId> + <artifactId>netty</artifactId> + <version>3.1.0.BETA3</version> + </dependency> </dependencies> -</project> \ No newline at end of file + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>6</source> + <target>6</target> + </configuration> + </plugin> + </plugins> + </build> +</project> Modified: sandbox/trunk/src/java/nettytest/src/main/java/Server.java =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/Server.java 2009-07-22 01:44:24 UTC (rev 1461) +++ sandbox/trunk/src/java/nettytest/src/main/java/Server.java 2009-07-22 02:16:59 UTC (rev 1462) @@ -1,4 +1,5 @@ import java.io.FileInputStream; +import java.io.InputStreamReader; import java.net.InetSocketAddress; import java.security.KeyStore; import java.util.concurrent.Executors; @@ -21,17 +22,41 @@ public class Server extends Common { - String pass = "eUySvp2phM2Wk"; - String certPath = "C:/temp/server.p12"; + String passPath; + String certPath; + public Server(String passPath, String certPath) { + this.passPath = passPath; + this.certPath = certPath; + } + public SSLEngine getSslEngine() throws Exception { + // Read the password. + InputStreamReader passf = new InputStreamReader(new FileInputStream(passPath)); + char[] pass; + try { + StringBuffer sb = new StringBuffer(); + char[] chunk = new char[4096]; + while (true) { + int nread = passf.read(chunk, 0, chunk.length); + if (nread < 0) break; + sb.append(chunk, 0, nread); + } + String s = sb.toString(); + if (s.charAt(s.length() - 1) == '\n') + s = s.substring(0, s.length() - 1); + pass = s.toCharArray(); + } finally { + passf.close(); + } + // Load our Java key store. KeyStore ks = KeyStore.getInstance("pkcs12"); - ks.load(new FileInputStream(certPath), pass.toCharArray()); + ks.load(new FileInputStream(certPath), pass); // Like ssh-agent. KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(ks, pass.toCharArray()); + kmf.init(ks, pass); // Create the SSL context. SSLContext ctx = SSLContext.getInstance("TLS"); @@ -43,7 +68,7 @@ } public static void main(String[] args) throws Exception { - Server server = new Server(); + Server server = new Server(args[0], args[1]); server.call(); } @@ -84,3 +109,5 @@ } } + +// vim: et sw=4 ts=4 Added: sandbox/trunk/src/java/nettytest/src/test/resources/server.p12 =================================================================== (Binary files differ) Property changes on: sandbox/trunk/src/java/nettytest/src/test/resources/server.p12 ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: sandbox/trunk/src/java/nettytest/src/test/resources/server.pass =================================================================== --- sandbox/trunk/src/java/nettytest/src/test/resources/server.pass (rev 0) +++ sandbox/trunk/src/java/nettytest/src/test/resources/server.pass 2009-07-22 02:16:59 UTC (rev 1462) @@ -0,0 +1 @@ +IQgmo1UTNAJnk This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-22 01:44:34
|
Revision: 1461 http://assorted.svn.sourceforge.net/assorted/?rev=1461&view=rev Author: yangzhang Date: 2009-07-22 01:44:24 +0000 (Wed, 22 Jul 2009) Log Message: ----------- added jboss repos Modified Paths: -------------- sandbox/trunk/src/java/nettytest/pom.xml Modified: sandbox/trunk/src/java/nettytest/pom.xml =================================================================== --- sandbox/trunk/src/java/nettytest/pom.xml 2009-07-22 00:04:09 UTC (rev 1460) +++ sandbox/trunk/src/java/nettytest/pom.xml 2009-07-22 01:44:24 UTC (rev 1461) @@ -3,6 +3,13 @@ <groupId>net.sourceforge.assorted</groupId> <artifactId>nettytest</artifactId> <version>0.0.1-SNAPSHOT</version> + <repositories> + <repository> + <id>JBOSS</id> + <name>JBoss Repository</name> + <url>http://repository.jboss.org/maven2/</url> + </repository> + </repositories> <dependencies> <dependency> <groupId>org.jboss.netty</groupId> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-22 00:04:18
|
Revision: 1460 http://assorted.svn.sourceforge.net/assorted/?rev=1460&view=rev Author: yangzhang Date: 2009-07-22 00:04:09 +0000 (Wed, 22 Jul 2009) Log Message: ----------- simple netty SSL test Added Paths: ----------- sandbox/trunk/src/java/nettytest/.classpath sandbox/trunk/src/java/nettytest/.project sandbox/trunk/src/java/nettytest/.settings/ sandbox/trunk/src/java/nettytest/.settings/org.eclipse.jdt.core.prefs sandbox/trunk/src/java/nettytest/.settings/org.maven.ide.eclipse.prefs sandbox/trunk/src/java/nettytest/pom.xml sandbox/trunk/src/java/nettytest/src/ sandbox/trunk/src/java/nettytest/src/main/ sandbox/trunk/src/java/nettytest/src/main/java/ sandbox/trunk/src/java/nettytest/src/main/java/Client.java sandbox/trunk/src/java/nettytest/src/main/java/Common.java sandbox/trunk/src/java/nettytest/src/main/java/Server.java sandbox/trunk/src/java/nettytest/src/main/resources/ sandbox/trunk/src/java/nettytest/src/test/ sandbox/trunk/src/java/nettytest/src/test/java/ sandbox/trunk/src/java/nettytest/src/test/resources/ sandbox/trunk/src/java/nettytest/target/ Added: sandbox/trunk/src/java/nettytest/.classpath =================================================================== --- sandbox/trunk/src/java/nettytest/.classpath (rev 0) +++ sandbox/trunk/src/java/nettytest/.classpath 2009-07-22 00:04:09 UTC (rev 1460) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" output="target/classes" path="src/main/java"/> + <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> + <classpathentry kind="src" output="target/test-classes" path="src/test/java"/> + <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> Added: sandbox/trunk/src/java/nettytest/.project =================================================================== --- sandbox/trunk/src/java/nettytest/.project (rev 0) +++ sandbox/trunk/src/java/nettytest/.project 2009-07-22 00:04:09 UTC (rev 1460) @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>nettytest</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.maven.ide.eclipse.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.maven.ide.eclipse.maven2Nature</nature> + </natures> +</projectDescription> Added: sandbox/trunk/src/java/nettytest/.settings/org.eclipse.jdt.core.prefs =================================================================== --- sandbox/trunk/src/java/nettytest/.settings/org.eclipse.jdt.core.prefs (rev 0) +++ sandbox/trunk/src/java/nettytest/.settings/org.eclipse.jdt.core.prefs 2009-07-22 00:04:09 UTC (rev 1460) @@ -0,0 +1,12 @@ +#Mon Jul 20 18:35:13 PDT 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 Added: sandbox/trunk/src/java/nettytest/.settings/org.maven.ide.eclipse.prefs =================================================================== --- sandbox/trunk/src/java/nettytest/.settings/org.maven.ide.eclipse.prefs (rev 0) +++ sandbox/trunk/src/java/nettytest/.settings/org.maven.ide.eclipse.prefs 2009-07-22 00:04:09 UTC (rev 1460) @@ -0,0 +1,9 @@ +#Mon Jul 20 18:26:37 PDT 2009 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 Added: sandbox/trunk/src/java/nettytest/pom.xml =================================================================== --- sandbox/trunk/src/java/nettytest/pom.xml (rev 0) +++ sandbox/trunk/src/java/nettytest/pom.xml 2009-07-22 00:04:09 UTC (rev 1460) @@ -0,0 +1,13 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>net.sourceforge.assorted</groupId> + <artifactId>nettytest</artifactId> + <version>0.0.1-SNAPSHOT</version> + <dependencies> + <dependency> + <groupId>org.jboss.netty</groupId> + <artifactId>netty</artifactId> + <version>3.1.0.BETA3</version> + </dependency> + </dependencies> +</project> \ No newline at end of file Added: sandbox/trunk/src/java/nettytest/src/main/java/Client.java =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/Client.java (rev 0) +++ sandbox/trunk/src/java/nettytest/src/main/java/Client.java 2009-07-22 00:04:09 UTC (rev 1460) @@ -0,0 +1,62 @@ +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.util.concurrent.Callable; +import java.util.concurrent.Executors; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; + +import org.jboss.netty.bootstrap.ClientBootstrap; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.ChannelFutureListener; +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.channel.ChannelPipelineCoverage; +import org.jboss.netty.channel.ChannelPipelineFactory; +import org.jboss.netty.channel.Channels; +import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; +import org.jboss.netty.handler.ssl.SslHandler; + +public class Client extends Common implements Callable<Void> { + + public SSLEngine getSslEngine() throws Exception { + SSLContext ctx = SSLContext.getInstance("TLS"); + ctx.init(null, getTrustManagers(), null); + SSLEngine engine = ctx.createSSLEngine(); + engine.setUseClientMode(true); + return engine; + } + + public static void main(String[] args) throws Exception { + Client client = new Client(); + client.call(); + } + + public Void call() throws Exception { + @ChannelPipelineCoverage("all") + class Cpf implements ChannelPipelineFactory { + public ChannelPipeline getPipeline() throws Exception { + ChannelPipeline pipeline = Channels.pipeline(); + pipeline.addLast("ssl", new SslHandler(getSslEngine())); + return pipeline; + } + } + ChannelPipelineFactory pipelineFactory = new Cpf(); + + ClientBootstrap bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors + .newCachedThreadPool())); + bootstrap.setPipelineFactory(pipelineFactory); + bootstrap.setOption("tcpNoDelay", true); + bootstrap.setOption("keepAlive", true); + + ChannelFuture future = bootstrap.connect(new InetSocketAddress(InetAddress.getLocalHost(), 9876)); + future.addListener(new ChannelFutureListener() { + @Override + public void operationComplete(ChannelFuture arg0) throws Exception { + System.out.println(arg0.isSuccess() ? "success" : "failure"); + } + }); + + return null; + } + +} Added: sandbox/trunk/src/java/nettytest/src/main/java/Common.java =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/Common.java (rev 0) +++ sandbox/trunk/src/java/nettytest/src/main/java/Common.java 2009-07-22 00:04:09 UTC (rev 1460) @@ -0,0 +1,30 @@ +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +public class Common { + + protected TrustManager[] getTrustManagers() { + return new TrustManager[] { new X509TrustManager() { + // Always trust, even if invalid. + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + // Always trust. + } + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + // Always trust. + } + } }; + } + +} Added: sandbox/trunk/src/java/nettytest/src/main/java/Server.java =================================================================== --- sandbox/trunk/src/java/nettytest/src/main/java/Server.java (rev 0) +++ sandbox/trunk/src/java/nettytest/src/main/java/Server.java 2009-07-22 00:04:09 UTC (rev 1460) @@ -0,0 +1,86 @@ +import java.io.FileInputStream; +import java.net.InetSocketAddress; +import java.security.KeyStore; +import java.util.concurrent.Executors; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; + +import org.jboss.netty.bootstrap.ServerBootstrap; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.channel.ChannelPipelineCoverage; +import org.jboss.netty.channel.ChannelPipelineFactory; +import org.jboss.netty.channel.ChannelStateEvent; +import org.jboss.netty.channel.Channels; +import org.jboss.netty.channel.MessageEvent; +import org.jboss.netty.channel.SimpleChannelHandler; +import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; +import org.jboss.netty.handler.ssl.SslHandler; + +public class Server extends Common { + + String pass = "eUySvp2phM2Wk"; + String certPath = "C:/temp/server.p12"; + + public SSLEngine getSslEngine() throws Exception { + // Load our Java key store. + KeyStore ks = KeyStore.getInstance("pkcs12"); + ks.load(new FileInputStream(certPath), pass.toCharArray()); + + // Like ssh-agent. + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(ks, pass.toCharArray()); + + // Create the SSL context. + SSLContext ctx = SSLContext.getInstance("TLS"); + ctx.init(kmf.getKeyManagers(), getTrustManagers(), null); + + SSLEngine engine = ctx.createSSLEngine(); + engine.setUseClientMode(true); + return engine; + } + + public static void main(String[] args) throws Exception { + Server server = new Server(); + server.call(); + } + + @ChannelPipelineCoverage("all") + class Cpf implements ChannelPipelineFactory { + public ChannelPipeline getPipeline() throws Exception { + ChannelPipeline pipeline = Channels.pipeline(); + pipeline.addLast("ssl", new SslHandler(getSslEngine())); + pipeline.addLast("hdl", new SimpleChannelHandler() { + + @Override + public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { + System.out.println("received"); + } + + @Override + public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { + System.out.println("connected"); + } + }); + return pipeline; + } + } + + public Void call() throws Exception { + ChannelPipelineFactory pipelineFactory = new Cpf(); + + ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors + .newCachedThreadPool(), Executors.newCachedThreadPool())); + bootstrap.setPipelineFactory(pipelineFactory); + bootstrap.setOption("child.tcpNoDelay", true); + bootstrap.setOption("child.keepAlive", true); + bootstrap.setOption("reuseAddress", true); + + bootstrap.bind(new InetSocketAddress(9876)); + + return null; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-22 00:03:16
|
Revision: 1459 http://assorted.svn.sourceforge.net/assorted/?rev=1459&view=rev Author: yangzhang Date: 2009-07-22 00:03:08 +0000 (Wed, 22 Jul 2009) Log Message: ----------- Initial import. Added Paths: ----------- sandbox/trunk/src/java/nettytest/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-20 22:32:03
|
Revision: 1458 http://assorted.svn.sourceforge.net/assorted/?rev=1458&view=rev Author: yangzhang Date: 2009-07-20 22:31:41 +0000 (Mon, 20 Jul 2009) Log Message: ----------- fixed the bug (cannot use empty passphrase for p12); enhanced with custom password input files Modified Paths: -------------- sandbox/trunk/src/java/ssl/go.bash Modified: sandbox/trunk/src/java/ssl/go.bash =================================================================== --- sandbox/trunk/src/java/ssl/go.bash 2009-07-20 00:29:54 UTC (rev 1457) +++ sandbox/trunk/src/java/ssl/go.bash 2009-07-20 22:31:41 UTC (rev 1458) @@ -2,6 +2,11 @@ set -o errexit -o nounset +if [[ ! -f ca.pass || ! -f server.pass || ! -f p12.pass ]] ; then + echo 'Supply ca.pass, server.pass, p12.pass (careful with permissions)' 1>&2 + exit 1 +fi + cat > ssl.cfg << EOF [ req ] prompt = no @@ -11,62 +16,58 @@ EOF # CA -openssl genrsa -des3 -out ca.key -passout pass:capass 4096 -openssl req -new -x509 -days 365 -key ca.key -out ca.crt -passin pass:capass -config ca.cfg +openssl genrsa -des3 -out ca.key -passout file:ca.pass 4096 +openssl req -new -x509 -days 365 -key ca.key -out ca.crt -passin file:ca.pass -config ca.cfg # cert -openssl genrsa -des3 -out server.key -passout pass:serverpass 4096 -openssl req -new -key server.key -out server.csr -passin pass:serverpass -config server.cfg +openssl genrsa -des3 -out server.key -passout file:server.pass 4096 +openssl req -new -key server.key -out server.csr -passin file:server.pass -config server.cfg # sign -openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -passin pass:capass +openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -passin file:ca.pass # convert to pkcs12; cannot use empty password, or subsequent java load fails -openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12 -passin pass:serverpass -passout pass:p12pass +openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12 -passin file:server.pass -passout file:p12.pass # try to use from java -cat > SslTest.java << EOF +cat > SslTest.java << "EOF" import java.io.*; import java.security.*; import javax.net.ssl.*; public class SslTest { public static void main(String[] args) throws Exception { - FileInputStream fis = new FileInputStream(args[0]); - KeyStore ks = KeyStore.getInstance("pkcs12"); - ks.load(fis, "p12pass".toCharArray()); + // Read the password. + InputStreamReader passf = new InputStreamReader(new FileInputStream(args[0])); + char[] pass; + try { + StringBuffer sb = new StringBuffer(); + char[] chunk = new char[4096]; + while (true) { + int nread = passf.read(chunk, 0, chunk.length); + if (nread < 0) break; + sb.append(chunk, 0, nread); + } + String s = sb.toString(); + if (s.charAt(s.length() - 1) == '\n') + s = s.substring(0, s.length() - 1); + pass = s.toCharArray(); + } finally { + passf.close(); + } + // Read the pkcs12 keystore. + FileInputStream ksf = new FileInputStream(args[1]); + KeyStore ks; + try { + ks = KeyStore.getInstance("pkcs12"); + ks.load(ksf, pass); + } finally { + ksf.close(); + } + + // Load the keys. KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(ks, "p12pass".toCharArray()); + kmf.init(ks, pass); } } EOF javac SslTest.java -java SslTest server.p12 - -###### -# Output: -# -# Generating RSA private key, 4096 bit long modulus -# ..++ -# ..................................++ -# e is 65537 (0x10001) -# Generating RSA private key, 4096 bit long modulus -# .++ -# ...................................................................++ -# e is 65537 (0x10001) -# Signature ok -# subject=/C=US -# Getting CA Private Key -# Exception in thread "main" java.security.UnrecoverableKeyException: Get Key failed: Given final block not properly padded -# at sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:288) -# at java.security.KeyStore.getKey(KeyStore.java:779) -# at sun.security.ssl.SunX509KeyManagerImpl.<init>(SunX509KeyManagerImpl.java:131) -# at sun.security.ssl.KeyManagerFactoryImpl$SunX509.engineInit(KeyManagerFactoryImpl.java:68) -# at javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:256) -# at SslTest.main(SslTest.java:9) -# Caused by: javax.crypto.BadPaddingException: Given final block not properly padded -# at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811) -# at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676) -# at com.sun.crypto.provider.PKCS12PBECipherCore.implDoFinal(PKCS12PBECipherCore.java:345) -# at com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede.engineDoFinal(PKCS12PBECipherCore.java:378) -# at javax.crypto.Cipher.doFinal(Cipher.java:1813) -# at sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:270) -# ... 5 more +java SslTest p12.pass server.p12 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-20 01:50:25
|
Revision: 1456 http://assorted.svn.sourceforge.net/assorted/?rev=1456&view=rev Author: yangzhang Date: 2009-07-20 00:25:59 +0000 (Mon, 20 Jul 2009) Log Message: ----------- added ssl fail demo Added Paths: ----------- sandbox/trunk/src/java/ssl/ sandbox/trunk/src/java/ssl/go.bash Added: sandbox/trunk/src/java/ssl/go.bash =================================================================== --- sandbox/trunk/src/java/ssl/go.bash (rev 0) +++ sandbox/trunk/src/java/ssl/go.bash 2009-07-20 00:25:59 UTC (rev 1456) @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset + +cat > ssl.cfg << EOF +[ req ] +prompt = no +distinguished_name = req_distinguished_name +[ req_distinguished_name ] +C = US +EOF + +# CA +openssl genrsa -des3 -out ca.key -passout pass:capass 4096 +openssl req -new -x509 -days 365 -key ca.key -out ca.crt -passin pass:capass -config ca.cfg + +# cert +openssl genrsa -des3 -out server.key -passout pass:serverpass 4096 +openssl req -new -key server.key -out server.csr -passin pass:serverpass -config server.cfg + +# sign +openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -passin pass:capass + +# convert to pkcs12 +openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12 -passin pass:serverpass -passout pass: + +# try to use from java +cat > SslTest.java << EOF +import java.io.*; import java.security.*; import javax.net.ssl.*; +public class SslTest { + public static void main(String[] args) throws Exception { + FileInputStream fis = new FileInputStream(args[0]); + KeyStore ks = KeyStore.getInstance("pkcs12"); + ks.load(fis, null); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(ks, "serverpass".toCharArray()); + } +} +EOF +javac SslTest.java +java SslTest server.p12 + +###### +# Output: +# +# Generating RSA private key, 4096 bit long modulus +# ..++ +# ..................................++ +# e is 65537 (0x10001) +# Generating RSA private key, 4096 bit long modulus +# .++ +# ...................................................................++ +# e is 65537 (0x10001) +# Signature ok +# subject=/C=US +# Getting CA Private Key +# Exception in thread "main" java.security.UnrecoverableKeyException: Get Key failed: Given final block not properly padded +# at sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:288) +# at java.security.KeyStore.getKey(KeyStore.java:779) +# at sun.security.ssl.SunX509KeyManagerImpl.<init>(SunX509KeyManagerImpl.java:131) +# at sun.security.ssl.KeyManagerFactoryImpl$SunX509.engineInit(KeyManagerFactoryImpl.java:68) +# at javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:256) +# at SslTest.main(SslTest.java:9) +# Caused by: javax.crypto.BadPaddingException: Given final block not properly padded +# at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811) +# at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676) +# at com.sun.crypto.provider.PKCS12PBECipherCore.implDoFinal(PKCS12PBECipherCore.java:345) +# at com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede.engineDoFinal(PKCS12PBECipherCore.java:378) +# at javax.crypto.Cipher.doFinal(Cipher.java:1813) +# at sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:270) +# ... 5 more Property changes on: sandbox/trunk/src/java/ssl/go.bash ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-20 01:50:24
|
Revision: 1457 http://assorted.svn.sourceforge.net/assorted/?rev=1457&view=rev Author: yangzhang Date: 2009-07-20 00:29:54 +0000 (Mon, 20 Jul 2009) Log Message: ----------- fixed the fail Modified Paths: -------------- sandbox/trunk/src/java/ssl/go.bash Modified: sandbox/trunk/src/java/ssl/go.bash =================================================================== --- sandbox/trunk/src/java/ssl/go.bash 2009-07-20 00:25:59 UTC (rev 1456) +++ sandbox/trunk/src/java/ssl/go.bash 2009-07-20 00:29:54 UTC (rev 1457) @@ -21,8 +21,8 @@ # sign openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -passin pass:capass -# convert to pkcs12 -openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12 -passin pass:serverpass -passout pass: +# convert to pkcs12; cannot use empty password, or subsequent java load fails +openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12 -passin pass:serverpass -passout pass:p12pass # try to use from java cat > SslTest.java << EOF @@ -31,10 +31,10 @@ public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream(args[0]); KeyStore ks = KeyStore.getInstance("pkcs12"); - ks.load(fis, null); + ks.load(fis, "p12pass".toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(ks, "serverpass".toCharArray()); + kmf.init(ks, "p12pass".toCharArray()); } } EOF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-07-13 06:27:28
|
Revision: 1455 http://assorted.svn.sourceforge.net/assorted/?rev=1455&view=rev Author: yangzhang Date: 2009-07-13 06:27:22 +0000 (Mon, 13 Jul 2009) Log Message: ----------- added some old microbenchmarks Added Paths: ----------- sandbox/trunk/src/scala/bench/ sandbox/trunk/src/scala/bench/StreamBench.scala sandbox/trunk/src/scala/bench/StreamRecursion.scala sandbox/trunk/src/scala/bench/TextPerf.scala Added: sandbox/trunk/src/scala/bench/StreamBench.scala =================================================================== --- sandbox/trunk/src/scala/bench/StreamBench.scala (rev 0) +++ sandbox/trunk/src/scala/bench/StreamBench.scala 2009-07-13 06:27:22 UTC (rev 1455) @@ -0,0 +1,161 @@ +package scalatest; + +object StreamBench { + + def time[a](label: String)(f: => a) = { + val start = System.currentTimeMillis + val result = try { f } finally { + val end = System.currentTimeMillis + println("time for " + label + ": " + (end - start) + "ms") + } + result + } + + def main(args: Array[String]) { + randomAccess + } + + def multitime(label: String)(f: => Any) { + time(label)(f) + time(label)(f) + time(label)(f) + } + + def randomAccess { + val (step,stop) = (100000,900000) + + // stack overflow + /* + val xs = List range (0, stop); + multitime("random access into list") { + xs(stop-1) + } + */ + + multitime("random access into stream") { + Stream range (0, stop) apply (stop-1) + } + + val s = Stream range (0, stop) + s(stop-1) + multitime("random access into cached stream") { + s(stop-1) + } + } + + def cons { + val (step,stop) = (100000,900000) + + // Array.apply calls Stream.length, causing a stack overflow + /* + multitime("array via stream") { + def r(i: Int): Stream[Int] = + if (i == stop) Stream empty + else Stream cons (i, r(i+1)) + Array(r(0):_*) + } + */ + + multitime("iterating into array") { + val a = new Array[Int](stop) + Iterator range (0, stop) copyToArray (a,0) + a + } + + multitime("iterating into boxed array") { + val a = new Array[Integer](stop) + Iterator range (0, stop) map (x => new Integer(x)) copyToArray (a,0) + a + } + + multitime("iterating into arraybuffer") { + val a = new scala.collection.mutable.ArrayBuffer[Int] + Iterator range (0, stop) copyToBuffer a + a + } + + // resizeablearray starts at 16 and doubles + multitime("iterating into arraybuffer with capacity") { + val a = new scala.collection.mutable.ArrayBuffer[Int] { + ensureSize(stop+10) + } + Iterator range (0, stop) copyToBuffer a + a + } + + multitime("iterating into listbuffer") { + val a = new scala.collection.mutable.ListBuffer[Int] + Iterator range (0, stop) copyToBuffer a + a + } + } + + def streams { + val (step,stop) = (100000,900000) + + time("for-loop") { + var i = 0 + while (i < stop) { + if ( i % step == 0 ) println(i) + i += 1 + } + } + + time("traversing Iterator") { + def f { + for ( i <- Iterator from 0 ) { + if ( i % step == 0 ) { + if ( i > stop ) return + println(i) + } + } + } + f + } + + def traverseStream(s: Stream[Int]) { + val i = s.head + if ( i % step == 0 ) { + if ( i > stop ) return + println( i ) + } + traverseStream( s.tail ) + } + + time ( "traversing Stream" ) { + traverseStream( Stream from 0 ) + } + + // explicitly putting this in a separate method allows s to be GCed + def g { + val s = Stream from 0 + time ( "caching Stream" ) { + traverseStream( s ) + } + + time ( "traversing cached Stream" ) { + traverseStream( s ) + } + } + g + g // goes much faster the second time + + time ( "Stream.foreach" ) { + def f { + Stream from 0 foreach { i => + if ( i % step == 0 ) { + if ( i > stop ) return + println( i ) + } + } + } + f + } + } + + def mkStream(iter: Iterator[Int]): Stream[Int] = { + if (!iter.hasNext) Stream empty + else Stream cons (iter.next, mkStream(iter)) + } + +} Added: sandbox/trunk/src/scala/bench/StreamRecursion.scala =================================================================== --- sandbox/trunk/src/scala/bench/StreamRecursion.scala (rev 0) +++ sandbox/trunk/src/scala/bench/StreamRecursion.scala 2009-07-13 06:27:22 UTC (rev 1455) @@ -0,0 +1,19 @@ +package scalatest; + +import commons.Collections._ + +object StreamRecursion { + + def main(args: Array[String]) { + val s = Stream range (0, 100000) + def f(s: Stream[Int]): Stream[Int] = + Stream cons ( + s.head, + f(Stream fromIterator (s drop 1 elements)) + ) + f(s) foreach ( x => + if (x % 10000 == 0) println(x) + ) + } + +} Added: sandbox/trunk/src/scala/bench/TextPerf.scala =================================================================== --- sandbox/trunk/src/scala/bench/TextPerf.scala (rev 0) +++ sandbox/trunk/src/scala/bench/TextPerf.scala 2009-07-13 06:27:22 UTC (rev 1455) @@ -0,0 +1,90 @@ +package scalatest; + +object TextPerf { + def time[a](label: String)(f: => a) = { + val start = System.currentTimeMillis + val result = try { f } finally { + val end = System.currentTimeMillis + println("time for " + label + ": " + (end - start) + "ms") + } + result + } + def multitime(label: String)(f: => Any) { + time(label)(f) + time(label)(f) + time(label)(f) + } + def main(args: Array[String]) { + val count = 100000 + println("abc" replaceAll ("b","")) + multitime("replaceAll (inline)") { + 0 until count foreach { x => + "abc" replaceAll ("b","") + } + } + multitime("replaceAll (named function)") { + def f = "abc" replaceAll ("b","") + 0 until count foreach { x => + f + } + } + multitime("replaceAll (parameterized function)") { + def f(s:String) = s replaceAll ("b","") + 0 until count foreach { x => + f("abc") + } + } + + def f(s:String) = s filter (_!='b') mkString "" + println(f("abc")) + multitime("filter") { + 0 until count foreach { x => f("abc") } + } + + val p = java.util.regex.Pattern compile "b" + def g(s:String) = { + p matcher s replaceAll "" + } + println(g("abc")) + multitime("compiled") { + 0 until count foreach { x => g("abc") } + } + + def h(s:Array[Char]) = { + val t = new Array[Char](3) + var i, j = 0 + while (i < s.length) { + if (s(i) != 'b') { + t(j) = s(i) + j += 1 + } + i += 1 + } + t + } + def i(ss:String) = { + val s = ss.toCharArray + val t = new Array[Char](s.length) + var i, j = 0 + while (i < s.length) { + if (s(i) != 'b') { + t(j) = s(i) + j += 1 + } + i += 1 + } + new String(t, 0, j) + } + val s = "abc" toArray; + println(new String(h("abc" toCharArray))) + multitime("array") { + 0 until count foreach { x => h(s) } + } + multitime("array conversion + array") { + 0 until count foreach { x => h("abc" toCharArray) } + } + multitime("array conversion + array + string conversion") { + 0 until count foreach { x => i("abc") } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-06-19 09:53:38
|
Revision: 1454 http://assorted.svn.sourceforge.net/assorted/?rev=1454&view=rev Author: yangzhang Date: 2009-06-19 09:53:33 +0000 (Fri, 19 Jun 2009) Log Message: ----------- added findreps script Added Paths: ----------- sandbox/trunk/src/one-off-scripts/find-reps/ sandbox/trunk/src/one-off-scripts/find-reps/Makefile sandbox/trunk/src/one-off-scripts/find-reps/findreps.cc Added: sandbox/trunk/src/one-off-scripts/find-reps/Makefile =================================================================== --- sandbox/trunk/src/one-off-scripts/find-reps/Makefile (rev 0) +++ sandbox/trunk/src/one-off-scripts/find-reps/Makefile 2009-06-19 09:53:33 UTC (rev 1454) @@ -0,0 +1,2 @@ +CXXFLAGS = -Wall +all: findreps Added: sandbox/trunk/src/one-off-scripts/find-reps/findreps.cc =================================================================== --- sandbox/trunk/src/one-off-scripts/find-reps/findreps.cc (rev 0) +++ sandbox/trunk/src/one-off-scripts/find-reps/findreps.cc 2009-06-19 09:53:33 UTC (rev 1454) @@ -0,0 +1,26 @@ +#include <cstdio> +#include <unistd.h> +using namespace std; +enum { size = 4096 }; +int main() { + char buf[size]; + int counter = 0, charno = 0; + bool started = false; + while (true) { + ssize_t r = read(0, buf, size); + if (r < 0) { perror("read"); break; } + if (r == 0) { break; } + for (int i = 0; i < size; ++i, ++charno) { + if (buf[i] == 'a') { + ++counter; + started = true; + } else { + if (started && counter > 1024) + printf("charno %d counter %d\n", charno, counter); + counter = 0; + started = false; + } + } + } + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2009-06-07 18:26:38
|
Revision: 1453 http://assorted.svn.sourceforge.net/assorted/?rev=1453&view=rev Author: yangzhang Date: 2009-06-07 18:26:16 +0000 (Sun, 07 Jun 2009) Log Message: ----------- tagged v0.2 release Added Paths: ----------- mailing-list-filter/tags/0.2/ mailing-list-filter/tags/0.2/README mailing-list-filter/tags/0.2/publish.bash mailing-list-filter/tags/0.2/setup.py Removed Paths: ------------- mailing-list-filter/tags/0.2/README mailing-list-filter/tags/0.2/publish.bash mailing-list-filter/tags/0.2/setup.py Property changes on: mailing-list-filter/tags/0.2 ___________________________________________________________________ Added: svn:mergeinfo + Deleted: mailing-list-filter/tags/0.2/README =================================================================== --- mailing-list-filter/trunk/README 2009-06-03 17:52:11 UTC (rev 1451) +++ mailing-list-filter/tags/0.2/README 2009-06-07 18:26:16 UTC (rev 1453) @@ -1,62 +0,0 @@ -Overview --------- - -I have a Gmail account that I use for subscribing to and posting to mailing -lists. When dealing with high-volume mailing lists, I am typically only -interested in those threads that I participated in. This is a simple filter -for starring and marking unread any messages belonging to such threads. - -This is accomplished by looking at the set of messages that were either sent -from me or explicitly addressed to me. From this "root set" of messages, we -can use the `Message-ID`, `References`, and `In-Reply-To` headers to determine -threads, and thus the other messages that we care about. - -I have found this to be more accurate than my two original approaches. I used -to have Gmail filters that starred/marked unread any messages containing my -name anywhere in the message. This worked OK since my name is not too common, -but it produced some false positives (not that bad, just unstar messages) and -some false negatives (much harder to detect). - -A second approach is to tag all subjects with some signature string. This -usually is fine, but it doesn't work when you did not start the thread (and -thus determine the subject). You can try to change the subject line, but this -is (1) poor netiquette, (2) unreliable because your reply may not register in -other mail clients as being part of the same thread (and thus other -participants may miss your reply), and (3) unreliable because replies might not -directly referencing your post (either intentionally or unintentionally). It -also fails when others change the subject. Finally, this approach is -unsatisfactory because it pollutes subject lines, and it essentially replicates -exactly what Message-ID was intended for. - -This script is not intended to be a replacement for the Gmail filters. I still -keep those active so that I can get immediate first-pass filtering. I execute -this script on a daily basis to perform second-pass filtering/unfiltering to -catch those false negatives that may have been missed. - -Setup ------ - -Requirements: - -- [argparse](http://argparse.python-hosting.com/) 0.8.0 -- [Python Commons](http://assorted.sf.net/python-commons/) 0.6 - -Install the program using the standard `setup.py` program. - -Todo ----- - -- Currently, we assume that the server specification points to a mailbox - containing all messages (both sent and received), and a message is determined - to have been sent by you by looking at the From: header field. This works - well with Gmail. An alternative strategy is to look through two folders, one - that's the Inbox and one that's the Sent mailbox, and treat all messages in - Sent as having been sent by you. This is presumably how most other IMAP - servers work. - -- Implement incremental maintenance of local cache. - -- Accept custom operations for filtered/unfiltered messages - (trashing/untrashing, labeling/unlabeling, etc.). - -- Refactor the message fetching/management part out into its own library. Copied: mailing-list-filter/tags/0.2/README (from rev 1452, mailing-list-filter/trunk/README) =================================================================== --- mailing-list-filter/tags/0.2/README (rev 0) +++ mailing-list-filter/tags/0.2/README 2009-06-07 18:26:16 UTC (rev 1453) @@ -0,0 +1,72 @@ +Overview +-------- + +I have a Gmail account that I use for subscribing to and posting to mailing +lists. When dealing with high-volume mailing lists, I am typically only +interested in those threads that I participated in. This is a simple filter +for starring and marking unread any messages belonging to such threads. + +This is accomplished by looking at the set of messages that were either sent +from me or explicitly addressed to me. From this "root set" of messages, we +can use the `Message-ID`, `References`, and `In-Reply-To` headers to determine +threads, and thus the other messages that we care about. + +I have found this to be more accurate than my two original approaches. I used +to have Gmail filters that starred/marked unread any messages containing my +name anywhere in the message. This worked OK since my name is not too common, +but it produced some false positives (not that bad, just unstar messages) and +some false negatives (much harder to detect). + +A second approach is to tag all subjects with some signature string. This +usually is fine, but it doesn't work when you did not start the thread (and +thus determine the subject). You can try to change the subject line, but this +is (1) poor netiquette, (2) unreliable because your reply may not register in +other mail clients as being part of the same thread (and thus other +participants may miss your reply), and (3) unreliable because replies might not +directly referencing your post (either intentionally or unintentionally). It +also fails when others change the subject. Finally, this approach is +unsatisfactory because it pollutes subject lines, and it essentially replicates +exactly what Message-ID was intended for. + +This script is not intended to be a replacement for the Gmail filters. I still +keep those active so that I can get immediate first-pass filtering. I execute +this script on a daily basis to perform second-pass filtering/unfiltering to +catch those false negatives that may have been missed. + +Setup +----- + +Requirements: + +- [argparse](http://argparse.python-hosting.com/) 0.8.0 +- [Python Commons](http://assorted.sf.net/python-commons/) 0.6 + +Install the program using the standard `setup.py` program. + +Todo +---- + +- Currently, we assume that the server specification points to a mailbox + containing all messages (both sent and received), and a message is determined + to have been sent by you by looking at the From: header field. This works + well with Gmail. An alternative strategy is to look through two folders, one + that's the Inbox and one that's the Sent mailbox, and treat all messages in + Sent as having been sent by you. This is presumably how most other IMAP + servers work. + +- Accept custom operations for filtered/unfiltered messages + (trashing/untrashing, labeling/unlabeling, etc.). + +- Refactor the message fetching/management part out into its own library. + +Changes +------- + +v0.2 + +- Added disk-based operation to remove memory capacity limit. +- Added incremental updates to local cache. + +v0.1 + +- Initial release: fully in-memory operation and no incremental updates. Deleted: mailing-list-filter/tags/0.2/publish.bash =================================================================== --- mailing-list-filter/trunk/publish.bash 2009-06-03 17:52:11 UTC (rev 1451) +++ mailing-list-filter/tags/0.2/publish.bash 2009-06-07 18:26:16 UTC (rev 1453) @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -fullname='Mailing List Filter' -version=0.1 -license=gpl -websrcs=( README ) -rels=( pypi: ) -. assorted.bash "$@" Copied: mailing-list-filter/tags/0.2/publish.bash (from rev 1452, mailing-list-filter/trunk/publish.bash) =================================================================== --- mailing-list-filter/tags/0.2/publish.bash (rev 0) +++ mailing-list-filter/tags/0.2/publish.bash 2009-06-07 18:26:16 UTC (rev 1453) @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +fullname='Mailing List Filter' +version=0.2 +license=gpl3 +websrcs=( README ) +rels=( pypi: ) +. assorted.bash "$@" Deleted: mailing-list-filter/tags/0.2/setup.py =================================================================== --- mailing-list-filter/trunk/setup.py 2009-06-03 17:52:11 UTC (rev 1451) +++ mailing-list-filter/tags/0.2/setup.py 2009-06-07 18:26:16 UTC (rev 1453) @@ -1,28 +0,0 @@ -#!/usr/bin/env python - -from commons.setup import run_setup - -pkg_info_text = """ -Metadata-Version: 1.1 -Name: mailing-list-filter -Version: 0.1 -Author: Yang Zhang -Author-email: yaaang NOSPAM at REMOVECAPS gmail -Home-page: http://assorted.sourceforge.net/mailing-list-filter/ -Download-url: http://pypi.python.org/pypi/mailing-list-filter/ -Summary: Mailing List Filter -License: Python Software Foundation License -Description: Filter mailing list email for relevant threads only. -Keywords: mailing,list,email,filter,IMAP,Gmail -Platform: any -Provides: commons -Classifier: Development Status :: 4 - Beta -Classifier: Environment :: No Input/Output (Daemon) -Classifier: Intended Audience :: End Users/Desktop -Classifier: License :: OSI Approved :: Python Software Foundation License -Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Python -Classifier: Topic :: Communications :: Email -""" - -run_setup(pkg_info_text, scripts = ['src/mlf.py']) Copied: mailing-list-filter/tags/0.2/setup.py (from rev 1452, mailing-list-filter/trunk/setup.py) =================================================================== --- mailing-list-filter/tags/0.2/setup.py (rev 0) +++ mailing-list-filter/tags/0.2/setup.py 2009-06-07 18:26:16 UTC (rev 1453) @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +from commons.setup import run_setup + +pkg_info_text = """ +Metadata-Version: 1.1 +Name: mailing-list-filter +Version: 0.2 +Author: Yang Zhang +Author-email: yaaang NOSPAM at REMOVECAPS gmail +Home-page: http://assorted.sourceforge.net/mailing-list-filter/ +Download-url: http://pypi.python.org/pypi/mailing-list-filter/ +Summary: Mailing List Filter +License: Python Software Foundation License +Description: Filter mailing list email for relevant threads only. +Keywords: mailing,list,email,filter,IMAP,Gmail +Platform: any +Provides: commons +Classifier: Development Status :: 4 - Beta +Classifier: Environment :: No Input/Output (Daemon) +Classifier: Intended Audience :: End Users/Desktop +Classifier: License :: OSI Approved :: Python Software Foundation License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Topic :: Communications :: Email +""" + +run_setup(pkg_info_text, scripts = ['src/mlf.py']) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |