Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>class zintvector</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
class zIntVector

Usage

    #include <intvec.hpp>
    zIntVector ...;

Description

    // There are two constructors, a default constructor which just
    // establishes an object for which the install function can be
    // called later.  The second constructor takes arguments specifying
    // the required vector, a pointer to the user handler function, and
    // the stack size to be reserved for the interrupt handler.  This
    // latter is defaulted to 256 bytes, which will be adequate for
    // many purposes.  The effect of this second constructor is to install
    // the supplied handler immediately.

        zIntVector();
        zIntVector(unsigned v, ihandler fp, unsigned s = 256);

    // The install function is used with a zIntVector object which has
    // not already intercepted a vector.  Its arguments are similar to
    // those of the second constructor.

        int install(unsigned v, ihandler fp, unsigned s = 256);

    // Functions suspend and reinstate put the vector and interrupt
    // handler back as they were before the zIntVector object took
    // control, and establish control again respectively.

        int suspend();
        int reinstate();

    // The newhandler function allows the interrupt handler associated
    // with a zIntVector object to be changed on the fly.

        int newhandler(ihandler fp, unsigned s = 256);

    // Finally there are a group of reporting functions. operator()
    // reports which vector the zIntVector object is tied to,
    // state returns the state of the object as a bit pattern made up
    // from the elements of enum iv_flags, and error, as usual, reports
    // the state of the error flag and resets it.

        unsigned operator()() const { return vector; }
        int state() const { return _state; }
        int error() { int e = err; err = 0; return e; }
        ~zIntVector() { suspend(); }

Example 

    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream.hpp>
    #include <intvec.hpp>

    volatile int got_ctrl_c = 0;

    //. In this case it is the minimally simple handler.  We just note
    //. that the keyboard interrupt ocurred.
    extern "C" {
    int ctrl_c_handler(struct INT_DATA *)
    {
        ++got_ctrl_c;   // just note that one occurred
        return 1;       // do not chain old handler
    }
    }

    main()
    {

    //. Declare a zIntVector on vector 0x23, to use the handler defined
    //. above, with immediate installation.

        zIntVector ctrlc(0x23,ctrl_c_handler);
        char buffer[80];

        cout << "Enter a string possibly including .";
        cout.flush();
        gets(buffer);
        cout << "\n" << endl;
        if (got_ctrl_c)
            cout << "There was a .n the text you entered" << endl;
        return EXIT_SUCCESS;
    }

See Also






Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson