Category : C Source Code
Archive   : GHLNKLST.ZIP
Filename : LLSWAP.C

 
Output of file : LLSWAP.C contained in archive : GHLNKLST.ZIP
/*
* L I N K E D L I S T T O O L K I T
*
* Copyright (C) 1990 by Garyl Lee Hester
*
* llswap.c
*
* Atom Swap Routine
*/
#include /* for NULL definition */
#include "ll.h"

/*
* ll_swap - swap next/prev bindings of pAtomOne and pAtomTwo
*/
void ll_swapatom( PATOM pAtomOne, PATOM pAtomTwo, PLLENDS pEnds )
{
PLLBIND pBindOne;
PLLBIND pBindTwo;
PLLBIND pBindOnePrev;

if( pAtomOne && pAtomTwo && pEnds && pAtomOne != pAtomTwo )
{
pBindOne = MAKEPBIND( pAtomOne );
pBindTwo = MAKEPBIND( pAtomTwo );

/*
* see if pAtomOne is directly upstream from pAtomTwo
*/
if( pBindOne->pNext == pBindTwo )
{
ll_unbatom( pAtomOne, pEnds );
ll_insatom( pAtomOne, _LL_AFTER, pAtomTwo, pEnds );
}

/*
* see if pAtomOne is directly downstream from pAtomTwo
*/
else if( pBindOne->pPrev == pBindTwo )
{
ll_unbatom( pAtomTwo, pEnds );
ll_insatom( pAtomTwo, _LL_AFTER, pAtomOne, pEnds );
}

/*
* else the atoms are discreet enough not to pose a problem
*/
else
{
pBindOnePrev = pBindOne->pPrev;

ll_unbatom( pAtomOne, pEnds );
ll_insatom( pAtomOne, _LL_BEFORE, pAtomTwo, pEnds );
ll_unbatom( pAtomTwo, pEnds );

if( pBindOnePrev == NULL )
ll_insatom( pAtomTwo,
_LL_BEFORE,
MAKEPATOM( pEnds->pHead ),
pEnds
);
else
ll_insatom( pAtomTwo,
_LL_AFTER,
MAKEPATOM( pBindOnePrev ),
pEnds
);
}
}
}



  3 Responses to “Category : C Source Code
Archive   : GHLNKLST.ZIP
Filename : LLSWAP.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/