ADSM-L

Re: Informix ONBAR logical logs

1999-01-29 09:18:32
Subject: Re: Informix ONBAR logical logs
From: Christoph Martin <martin AT UNI-MAINZ DOT DE>
Date: Fri, 29 Jan 1999 15:18:32 +0100
Paul Zarnowski <vkm AT CORNELLC.CIT.CORNELL DOT EDU> writes:

>
> At 03:31 PM 1/27/99 +0100, you wrote:
> >Triggered from the last message on this topic ( We have the same
> >problems with the logs filling up out ADSM storage ) I finally sat
> >down this night and wrote a small program using the ADSM XOpen API to
> >expire Informix logfiles.
>
>
> >If people are interested, I can share the code with them.
> >
> >Christoph
>
> Yes, I'm interested in this!  I suspect others will be also.
> ..Paul
>

Here it is: Make with 'make expire CCFLAGS=-g LDFLAGS=-lXApi'

-----------------------------------------------------------------------------
#include <stdio.h>
#include <stdio.h>

#include "dsmapitd.h"
#include "custom.h"         /* Definitions for platform specific types */
#include "xapidef.h"        /* XOpen Sample API type definitions       */
#include "xbsa.h"

/*#include "dsmapips.h"
#include "dsmapitd.h"
#include "dapitype.h"*/

void rcXApiOut(BSA_Int16 rc)
{
   printf("(%d) ",rc);
   switch(rc)
   {
      case BSA_RC_OK :
         printf("No error occured.\n");
         break;
      case BSA_RC_ABORT_ACTIVE_NOT_FOUND :
         printf("No active object matched the name that was\n");
         printf("specified for a BSADeactivateObject() call.\n");
         break;
      case BSA_RC_ABORT_SYSTEM_ERROR :
         printf("System detected error, operation aborted.\n");
         break;
      case BSA_RC_AUTHENTICATION_FAILURE :
         printf("There was an authentication failure.\n");
         break;
      case BSA_RC_BAD_CALL_SEQUENCE :
         printf("The sequence of API calls is incorrect.\n");
         break;
      case BSA_RC_BAD_HANDLE :
         printf("The handle used to associate this call with a\n");
         printf("previous BSAInit() call is invalid.\n");
         break;
      case BSA_RC_BUFFER_TOO_SMALL :
         printf("Buffer is too small to hold the object entry to\n");
         printf("be returned.\n");
         break;
      case BSA_RC_DESC_TOO_LONG :
         printf("The description is too long.\n");
         break;
      case BSA_RC_OBJECTSPACE_TOO_LONG :
         printf("The length of the objectspace name is too long.\n");
         break;
      case BSA_RC_INVALID_TOKEN :
         printf("The new token is invalid.\n");
         break;
      case BSA_RC_INVALID_VOTE :
         printf("The value specified for vote is invalid.\n");
         break;
      case BSA_RC_INVALID_KEYWORD :
         printf("An entry in the environment structure is\n");
         printf("invalid.\n");
         break;
      case BSA_RC_MATCH_EXISTS :
         printf("Object matching the specified predicate\n");
         printf("already exists.\n");
         break;
      case BSA_RC_MORE_DATA :
         printf("More data is available. Data can be obtained\n");
         printf("through BSAGetData() or ");
         printf("BSAGetNextQueryObject().\n");
         break;
      case BSA_RC_MORE_RULES :
         printf("Response has more rules. Remainder of the\n");
         printf("rules can obtained through successive ");
         printf("BSAGetNextAccessRule() calls.\n");
         break;
      case BSA_RC_NEWTOKEN_REQD :
         printf("A value must be entered for the new token.\n");
         printf("The old token has expired.\n");
         break;
      case BSA_RC_NO_MATCH :
         printf("No object matched the specified predicate.\n");
         break;
      case BSA_RC_NO_MORE_DATA :
         printf("There is no more data.\n");
         break;
      case BSA_RC_NO_RESOURCES :
         printf("Backup_Services is out of resources.\n");
         break;
      case BSA_RC_NULL_DATABLKPTR :
         printf("A data block pointer is required.\n");
         break;
      case BSA_RC_NULL_OBJNAME :
         printf("An object name is required.\n");
         break;
      case BSA_RC_NULL_POINTER :
         printf("A required pointer parameter is NULL.\n");
         break;
      case BSA_RC_NULL_RULEID :
         printf("Rule id is required.\n");
         break;
      case BSA_RC_OBJECT_NAME_TOO_LONG :
         printf("The object name is too long.\n");
         break;
      case BSA_RC_OBJECT_NOT_EMPTY :
         printf("The object is not empty.\n");
         break;
      case BSA_RC_OBJECT_NOT_FOUND :
         printf("There is no copy of the requested object.\n");
         break;
      case BSA_RC_OBJINFO_TOO_LONG :
         printf("The length of the object dependent\n");
         printf("information is too long.\n");
         break;
      case BSA_RC_OBJNAME_TOO_LONG :
         printf("The length of the object name is too long.\n");
         break;
      case BSA_RC_OPERATION_NOT_AUTHORIZED :
         printf("This session is not authorized to use this API\n");
         printf("call.\n");
         break;
      case BSA_RC_OLDTOKEN_REQD :
         printf("A value must be entered for the old token.\n");
         break;
      case BSA_RC_TOKEN_EXPIRED :
         printf("Security token has expired and must be\n");
         printf("updated.\n");
         break;
      case BSA_RC_TXN_ABORTED :
         printf("The transaction was aborted.\n");
         break;
      case BSA_RC_UNMATCHED_QUOTE :
         printf("An unmatched quote is in the value field of an\n");
         printf("environment variable.\n");
         break;
      case BSA_RC_USER_OWNS_OBJECTS :
         printf("A user cannot be deleted while it owns\n");
         printf("objects.\n");
         break;
      case ADSM_RC_ERROR :
         printf("ADSM error.  See the error log file.\n");
         break;
      case ADSM_RC_INVALID_NODE :
         printf("The BSAObjectOwner does not match the value\n");
         printf("on BSAInit.\n");
         break;
      case ADSM_RC_INVALID_COPYTYPE :
         printf("The value specified for copyType is invalid.\n");
         break;
      case ADSM_RC_INVALID_OBJTYPE :
         printf("The value specified for objectType is invalid.\n");
         break;
      case ADSM_RC_INVALID_STATUS :
         printf("The value specified for objectStatus is invalid.\n");
         break;
      case ADSM_RC_INVALID_ST_VER :
         printf("The value specified for the structure version is invalid.\n");
         break;
      case ADSM_RC_OWNER_TOO_LONG :
         printf("The value specified for the BSAObjectOwner or appObjectOwner 
is too long.\n");
         break;
      case ADSM_RC_PSWD_TOO_LONG :
         printf("The value specified for the securityToken is too long.\n");
         break;
      case ADSM_RC_PSWD_GEN :
         printf("User has Passwordaccess=generate, but appl supplied node or 
owner.\n");
         break;
      default :
         printf("There is no explanation for this error code.\n");
         break;
      } /* switch */

   return;
} /* rcXApiOut() */

int main(int argc,char **argv)
{
  ApiVersion                 apiLibVer;
  char      *envPtr[ADSM_ENV_STRS+1];
  char      envStrs[ADSM_ENV_STRS] [BSA_MAX_DESC];
  BSA_Int16 rc = RC_OK;
  BSA_UInt32 BSAHandle = 0;
  int i;
  dsmApiVersion       apiVer;      /* application's API version */
  ObjectOwner objectOwner;
  SecurityToken token = "";

  ObjectName objectName;

  printf("argc:%d, argv[1]:%s, argv[2]:%s:%s\n", argc,
         argv[1],
         argv[2]);

  if (argc != 3)
    {
      printf("Usage: %s <FileSpace> <Path>\n", argv[0]);
      exit(1);
    }

  memset(&apiLibVer,0x00,sizeof(dsmApiVersion));     /* Zero out block */
  BSAQueryApiVersion(&apiLibVer);        /* Get the end user's version */
  printf("\nAPI Library Version = %d.%d.%d\n\n",apiLibVer.version,
         apiLibVer.release,
         apiLibVer.level);
  /* Compare with the application client's library version */
  if (apiLibVer.version < BSA_API_VERSION)
    {
      /* The ADSM API library is at a lower version than the application.
         If your application depends on new functions in the higher version,
         stop and tell the customer to upgrade its software.
         */
    }
  if (apiLibVer.release < BSA_API_RELEASE)
    {
      /* The ADSM API library is at a lower release than the application.
         If your application depends on new functions in the higher release,
         stop and tell the customer to upgrade its software.
         */
    }
  {  printf("Application Version = %d.%d.%d\n",BSA_API_VERSION,
            BSA_API_RELEASE,
            BSA_API_LEVEL);
  /*  printf("Application version is different than end user's API 
version.\n\n");*/
  };

  apiVer.version = DSM_API_VERSION;     /* Set the application's API    */
  apiVer.release = DSM_API_RELEASE;     /*   version from the constants */
  apiVer.level   = DSM_API_LEVEL;       /*   in dsmapitd.h              */

  strcpy(objectOwner.bsaObjectOwner, "");
  strcpy(objectOwner.appObjectOwner, "");

  for (i=0; i<ADSM_ENV_STRS; i++)
    envPtr[i] = envStrs[i];

  envPtr[ADSM_ENV_STRS] = NULL;

  rc = BSAInit(&BSAHandle,      /* Contains session handle on retrun. */
               &token,        /* password                           */
               &objectOwner,  /* Node name and Owner name           */
               envPtr);         /* Environment variables              */

  if (rc)
    {
      printf("*** BSAInit failed: ");
      rcXApiOut(rc);

      if (rc != BSA_RC_TOKEN_EXPIRED)
        {
          BSATerminate(BSAHandle);       /* clean up memory blocks */
          rc = (RC_SESSION_FAILED);
        }

      return rc;
    }

  if ((rc = BSABeginTxn(BSAHandle)))    /* Objects in this txn.        */

    {
      printf("*** BSABeginTxn(1) failed: \n");
      rcXApiOut(rc);
      rc = (RC_SESSION_FAILED);
    }

  strcpy(objectName.objectSpaceName, argv[1]);
  strcpy(objectName.pathName, argv[2]);

  rc = BSAMarkObjectInactive(BSAHandle,
                             &objectName);

  if (rc != BSA_RC_OK)
    {
      printf("*** BSAMarkObjectInactive failed: ");
      rcXApiOut(rc);
    } /* if */

  rc = BSAEndTxn(BSAHandle,          /* DSM API sess handle         */
                 BSAVote_COMMIT);     /* Commit transaction.         */
  if (rc)
    {
      printf("*** BSAEndTxn failed: ");
      rcXApiOut(rc);
      rc = (RC_SESSION_FAILED);
    } /* if */

  rc = BSATerminate(BSAHandle);

}


--
 ===========================================================================
 ===========================================================================
Christoph Martin, Uni-Mainz, Germany
 Internet-Mail:  Christoph.Martin AT Uni-Mainz DOT DE
--------------export-a-crypto-system-sig -RSA-3-lines-PERL------------------
#!/usr/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
#!/usr/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
#what's this? see http://www.dcs.ex.ac.uk/~aba/rsa/
<Prev in Thread] Current Thread [Next in Thread>