What does RINOK do?

Help
2013-06-28
2013-06-29
  • Jānis Zalāns

    Jānis Zalāns - 2013-06-28

    Hello everyone! This is my first post on this forum after registering at sourceforge in 2008.

    I am writing 7zip archive repair tool in c#. So far i am stuck with end header, but that's not the point here.

    I am browsing c source code of 7zip because 7zipFormat text document doesn't describe a lot of things. So i am wondering, what does RINOK do? On Types.h file at line 52 it is defined as:

    define RINOK(x) { int result = (x); if (result != 0) return result; }

    A lot of functions use it, for example:
    RINOK(inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR));
    RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE));
    RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END));

    All these functions returns SRes that is defined as "typedef int SRes;", so my guess would be that RINOK guarantees that function returns int?

    Thanks for Your time.

     
  • Igor Pavlov

    Igor Pavlov - 2013-06-29

    RINOK means "Return If Not OK".

     
  • Jānis Zalāns

    Jānis Zalāns - 2013-06-29

    So, if there is function:

    int foo () {
    RINOK (something(args));
    do_sth_else;
    return 0;
    }

    and if "something" function doesn't return 0, foo function exits as normal line in code "return something value"? Did i understood it correctly?

    i mean that instead of RINOK i could write:

    int foo () {
    int value = something(args);
    if (value != 0) return value;
    do_sth_else;
    return 0;
    }

    Am i getting it right? Million thanks for Your time.

     

Log in to post a comment.