API Documentation

Here's an example of validating a tape

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include "NxCoreAPI.h"
#include "NxCoreAPI_Wrapper_C++.h"

NxCoreClass NxCore;

int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMessage)
{
    switch (pNxCoreMessage->MessageType)
    {
        case NxMSG_STATUS:
        {
            switch (pNxCoreSys->Status)
            {
                case NxCORESTATUS_ERROR:
                {
                    printf("Tape error: %02d:%02d:%02d.%03d\n",
                        (int) pNxCoreSys->nxTime.Hour,
                        (int) pNxCoreSys->nxTime.Minute,
                        (int) pNxCoreSys->nxTime.Second,
                        (int) pNxCoreSys->nxTime.Millisecond);
                    return NxCALLBACKRETURN_STOP;
                }

                // WAITFORCOREACCESS is not necessarally an error.
                // It is generated when: 
                //
                // 1) You are running from the current days tape
                // (IE not from a tape file) and signifies NxCoreAccess 
                // program is not running or is in a transitional state
                // from one day to the next. In this case it is safe to continue.
                // 
                // 2) The tape file is incomplete. In this case the application
                // should stop.
                //
                // For this example we will let the program continue.
                //
                case NxCORESTATUS_WAITFORCOREACCESS:
                {
                    printf("Wait For Access: %02d:%02d:%02d.%03d\n",
                        (int) pNxCoreSys->nxTime.Hour,
                        (int) pNxCoreSys->nxTime.Minute,
                        (int) pNxCoreSys->nxTime.Second,
                        (int) pNxCoreSys->nxTime.Millisecond);
                }
            }
            break;
        }
    }

    return NxCALLBACKRETURN_CONTINUE;
}

int main(int argc, char** argv)
{
    if (argc == 1)
    {
        fprintf(stderr, "Usage: %s Tape\n", argv[0]);
        return -1;
    }
    if (!NxCore.LoadNxCore("NxCoreAPI64.dll") &&
        !NxCore.LoadNxCore("NxCoreAPI.dll"))
    {
        fprintf(stderr, "Can't find NxCoreAPI.dll\n");
        return -1;
    }
    int rc = NxCore.ProcessTape(argv[1], 0, 0, 0, nxCoreCallback);
    if (rc)
    {
        printf("%s is not valid: %d\n", argv[1], rc);
    }
    else
    {
        printf("%s is valid\n", argv[1]);
    }
    return 0;
}
import net.nanex.NxCoreClass;
class ValidateTape extends NxCoreClass{

    @Override
    public int OnNxCoreCallback(NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) {
        switch (nxCoreMsg.MessageType)
        {
            case defines.NxMSG_STATUS:
                switch (nxCoreSys.Status)
                {
                    case defines.NxCORESTATUS_ERROR:
                        System.out.println(
                        String.format("Tape error: %02d:%02d:%02d0%3d",
                            nxCoreSys.nxTime.Hour,
                            nxCoreSys.nxTime.Minute,
                            nxCoreSys.nxTime.Second,
                            nxCoreSys.nxTime.Millisecond));
                        return defines.NxCALLBACKRETURN_STOP;

                    // WAITFORCOREACCESS is not necessarally an error.
                    // It is generated when: 
                    //
                    // 1) You are running from the current days tape
                    // (IE not from a tape file) and signifies NxCoreAccess 
                    // program is not running or is in a transitional state
                    // from one day to the next. In this case it is safe to continue.
                    // 
                    // 2) The tape file is incomplete. In this case the application
                    // should stop.
                    //
                    // For this example we will let the program continue.
                    //
                    case defines.NxCORESTATUS_WAITFORCOREACCESS:
                        System.out.println(
                        String.format("Wait For Access: %.2d:%.2d:%.2d.%3d",
                            nxCoreSys.nxTime.Hour,
                            nxCoreSys.nxTime.Minute,
                            nxCoreSys.nxTime.Second,
                            nxCoreSys.nxTime.Millisecond));
                        break;
                }
                break;
        }
        return defines.NxCALLBACKRETURN_CONTINUE;
    }

    public static void main(String args[]) {
        ValidateTape nxCore = new ValidateTape();
        if (args.length == 0) {
            System.out.println("specify tape name");
            return;
        }
        if (nxCore.LoadNxCore("NxCoreAPI64.dll") == 0){
            System.out.println("loading library failed");
            return;
        }
        int rc = nxCore.ProcessTape(args[0], 0, 0, 0);
        if (rc != 0)
            System.out.println(String.format("%s is not valid: %d\n", args[0], rc));
        else
            System.out.println(String.format("%s is valid\n", args[0]));
    }
}
import NxCore

tapePath = ""

def OnNxCoreCallback(NxCoreSys, NxCoreMsg):
    if NxCoreMsg.MessageType == NxCore.NxMSG_STATUS:
        if NxCoreSys.Status == NxCore.NxCORESTATUS_ERROR:
            print("Tape error: {:02d}:{:02d}:{:02d}.{:02d}".format(
                NxCoreSys.nxTime.Hour,
                NxCoreSys.nxTime.Minute,
                NxCoreSys.nxTime.Second,
                NxCoreSys.nxTime.Millisecond))
            return NxCore.NxCALLBACKRETURN_STOP
        #WAITFORCOREACCESS is not necessarally an error.
        #It is generated when: 
        #
        #1) You are running from the current days tape
        #(IE not from a tape file) and signifies NxCoreAccess 
        #program is not running or is in a transitional state
        #from one day to the next. In this case it is safe to continue.
        #
        #2) The tape file is incomplete. In this case the application
        #should stop.
        #
        #For this example we will let the program continue.
        elif NxCoreSys.Status == NxCore.NxCORESTATUS_WAITFORCOREACCESS:
            print("Wait For Access: {:02d}:{:02d}:{:02d}.{:03d}".format(
                NxCoreSys.nxTime.Hour,
                NxCoreSys.nxTime.Minute,
                NxCoreSys.nxTime.Second,
                NxCoreSys.nxTime.Millisecond))
    return NxCore.NxCALLBACKRETURN_CONTINUE

if NxCore.LoadNxCore("NxCoreAPI64.dll"):
    rc = NxCore.ProcessTape(tapePath, 0, 0, 0, OnNxCoreCallback)
    if rc:
        print("{} is not valid: {}\n".format(tapePath, rc));
    else:
        print("{} is valid\n".format(tapePath));
else:
    print("loading library failed")