www.sas.com > Service and Support > Technical Support
 
Technical Support SAS - The power to know(tm)
  TS Home | Intro to Services | News and Info | Contact TS | Site Map | FAQ | Feedback


#pragma title P2UPSKCM Compare Functions
#include <stdio.h>
#include <string.h>
#include "p2upnode.h"
#pragma eject
/*--------------------------------------------------------------------+
| Function  : compare_by_ttr                                          |
|                                                                     |
| Purpose   : Compare two struct PDS_MBR variables by ttr             |
|                                                                     |
|   Language: C                                                       |
|                                                                     |
| Parameters:                                                         |
|             a_comp - struct PDS_MB                                  |
|             b_comp - struct PDS_MB                                  |
|                                                                     |
| Returns   :                                                         |
|             0  - ttr's match                                        |
|             1  - a_comp ttr is greater than b_comp ttr              |
|            -1  - a_comp ttr is less than b_comp ttr                 |
|                                                                     |
| Notes     :                                                         |
|                                                                     |
+--------------------------------------------------------------------*/
extern int compare_by_ttr ( PDS_MBR * a_comp, PDS_MBR * b_comp)
{
 int rc;
  rc = memcmp(a_comp->ttr_data.ttrpds,b_comp->ttr_data.ttrpds,3);
  if (rc < 0) rc = -1;
  if (rc > 0) rc =  1;
  return(rc);
}

#pragma eject
/*--------------------------------------------------------------------+
| Function  : compare_by_name                                         |
|                                                                     |
| Purpose   : Compare two struct PDS_MBR variables by member name     |
|                                                                     |
| Language  : C                                                       |
|                                                                     |
| Parameters:                                                         |
|             a_comp - struct PDS_MB                                  |
|             b_comp - struct PDS_MB                                  |
|                                                                     |
| Returns   :                                                         |
|             0 - member names match                                  |
|             1 - a_comp member name is greater than b_comp           |
|                 member name                                         |
|            -1 - a_comp member name is less than b_comp              |
|                 member name                                         |
| Notes     :                                                         |
|                                                                     |
+--------------------------------------------------------------------*/
extern int compare_by_name(PDS_MBR * a_comp, PDS_MBR *  b_comp)
{
 int rc;

 rc = memcmp(a_comp->member,b_comp->member,8);
 if (rc < 0) rc = -1;
 if (rc > 0) rc =  1;

 return(rc);
}


Copyright (c) 2000 SAS Institute Inc. All Rights Reserved.
Terms of Use & Legal Information | Privacy Statement