//
//  ViewController.m
//  wsq_demo
//
//  Created by Cognaxon on 7/31/20.
//  Copyright © 2020 Cognaxon. All rights reserved.
//


/*
In order to add "WSQ Image Library" to your Xcode project you need to add following script to your project:
Build Phases -> Add New Build Phase -> New Run Script Phase
=======================================
export DYLIB=libWSQ_library64.so
mkdir -p  "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/Frameworks"
cp -f "$SRCROOT/$DYLIB" "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/Frameworks"
/usr/bin/codesign --force --sign - --timestamp=none "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/Frameworks/$DYLIB"
install_name_tool -change $DYLIB @loader_path/../Frameworks/$DYLIB "$TARGET_BUILD_DIR/$TARGET_NAME.app/Contents/MacOS/$PRODUCT_NAME"
=======================================
*/


// Turn Sandboxing ON to avoid runtime errors about missing iCloud support



#import "ViewController.h"


#include <dlfcn.h>


///for streams begin
#ifdef __APPLE__
#include <sys/uio.h>
#else
#include <sys/io.h>
#endif

#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
///for streams end




void *wsq_library_handle;

typedef int (*_ReadImageFromFile)(const char*, int*, int*, unsigned char**);
_ReadImageFromFile ReadImageFromFile = 0;

typedef int (*_SaveImageToFile)(const char*, int, int, int, unsigned char*);
_SaveImageToFile SaveImageToFile = 0;

typedef void (*_WriteWSQ_bitrate)(double);
_WriteWSQ_bitrate WriteWSQ_bitrate = 0;

typedef double (*_ReadWSQ_bitrate)();
_ReadWSQ_bitrate ReadWSQ_bitrate = 0;

typedef void (*_WriteWSQ_ppi)(int);
_WriteWSQ_ppi WriteWSQ_ppi = 0;

typedef int (*_ReadWSQ_ppi)();
_ReadWSQ_ppi ReadWSQ_ppi = 0;

typedef void (*_WriteWSQ_comment)(char*);
_WriteWSQ_comment WriteWSQ_comment = 0;

typedef char* (*_ReadWSQ_comment)();
_ReadWSQ_comment ReadWSQ_comment = 0;

typedef void (*_WriteTIFFcompression)(int);
_WriteTIFFcompression WriteTIFFcompression = 0;

typedef void (*_WriteTIFFpredictor)(int);
_WriteTIFFpredictor WriteTIFFpredictor = 0;

typedef char* (*_GenerateSerialNumber)();
_GenerateSerialNumber GenerateSerialNumber = 0;

typedef int (*_UnlockWSQLibrary)(char* authorizationcode);
_UnlockWSQLibrary UnlockWSQLibrary = 0;


typedef int (*_WSQ_decode_stream)(unsigned char *input_data_stream, const int input_stream_length, unsigned char **output_data_stream, int *width, int *height, int *ppi, char **comment_text);
_WSQ_decode_stream WSQ_decode_stream = 0;


typedef int (*_WSQ_encode_stream)(unsigned char *input_data_stream, const int width, const int height, const double bitrate, const int ppi, char *comment_text, unsigned char **output_data_stream, int *output_stream_length);
_WSQ_encode_stream WSQ_encode_stream = 0;


char* error = (char*) NULL;

NSURL* file_name_nsurl;
NSString* file_name_nsstring;
const char *file_name_char = (char*) NULL;



int width = 0;
int height = 0;
unsigned char* imageData = 0;
unsigned char* imageData_for_saving = 0;
int type = 0;


unsigned char *input_data_stream, *output_data_stream;
unsigned char *input_data_stream2, *output_data_stream2;
int ppi = 0;
double bitrate = 0.75;
char* comment_text;//  = (char*) NULL;
size_t file_size, n, input_stream_length;
FILE *infp, *outfp;
int handle;
int output_stream2_length;
char* save_filename_with_extension;





@implementation ViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    
    saveButton.enabled = NO;
    streamToWSQButton.enabled = NO;
    
    comment_text = (char*) NULL; //need to initialize comment_text in order to avoid crash
    
    
    wsq_library_handle = dlopen("libWSQ_library64.so", RTLD_LAZY);
    if (wsq_library_handle == NULL)
    {printf("libWSQ_library64.so dlopen error!\n");}
   

    if (!GenerateSerialNumber)
    {
        GenerateSerialNumber = (_GenerateSerialNumber)dlsym(wsq_library_handle, "GenerateSerialNumber");
        error = dlerror(); if(error){printf("%s\n", error); return;}
    }
    
    
    if (!UnlockWSQLibrary)
    {
        UnlockWSQLibrary = (_UnlockWSQLibrary)dlsym(wsq_library_handle, "UnlockWSQLibrary");
        error = dlerror(); if(error){printf("%s\n", error); return;}
    }
    
    
    if (!ReadImageFromFile)
    {
        ReadImageFromFile = (_ReadImageFromFile)dlsym(wsq_library_handle, "ReadImageFromFile");
        error = dlerror(); if(error){printf("%s\n", error); return;}
    }
    
    
    if (!SaveImageToFile)
    {
        SaveImageToFile = (_SaveImageToFile)dlsym(wsq_library_handle, "SaveImageToFile");
        error = dlerror(); if(error){printf("%s\n", error); return;}
    }
    

    if (!WSQ_decode_stream)
    {
        WSQ_decode_stream = (_WSQ_decode_stream)dlsym(wsq_library_handle, "WSQ_decode_stream");
        error = dlerror(); if(error){printf("%s\n", error); return;}
    }
    
    if (!WSQ_encode_stream)
    {
        WSQ_encode_stream = (_WSQ_encode_stream)dlsym(wsq_library_handle, "WSQ_encode_stream");
        error = dlerror(); if(error){printf("%s\n", error); return;}
    }
    

    input_data_stream = (unsigned char*)NULL;
    output_data_stream = (unsigned char*)NULL;
    input_data_stream2 = (unsigned char*)NULL;
    output_data_stream2 = (unsigned char*)NULL;
 
    
    //When you're done with the library, dispose of it:
    //dlclose(wsq_library);
    
    
    
}





- (void)setRepresentedObject:(id)representedObject {
    [super setRepresentedObject:representedObject];
    
    // Update the view, if already loaded.
}



- (IBAction)OpenButtonAction:(id)pId;
{
  

    // Create the File Open Dialog class.
    NSOpenPanel* openDlg = [NSOpenPanel openPanel];
    
    // Enable the selection of files in the dialog.
    [openDlg setCanChooseFiles:YES];
    
    // Multiple files not allowed
    [openDlg setAllowsMultipleSelection:NO];
    
    // Can't select a directory
    [openDlg setCanChooseDirectories:NO];
    
    
    NSArray* fileTypes = [NSArray arrayWithObjects:@"wsq", @"bmp", @"tif", @"tiff", @"jpg", @"jpeg", @"png", @"gif", @"tga", @"pcx", @"psd", @"cel", @"iff", nil];
    [openDlg setAllowedFileTypes:fileTypes];
    
    
    // Display the dialog. If the OK button was pressed,
    // process the files.
    if ( [openDlg runModal] == NSModalResponseOK )
    {
        // Get an array containing the full filenames of all
        // files and directories selected.
        NSArray* urls = [openDlg URLs];
        
        // Loop through all the files and process them.
        //for(int i = 0; i < [urls count]; i++ )
        //{
        //    NSURL* url = [urls objectAtIndex:i];
        //    NSLog(@"Url: %@", url);
        //}
        
        
        file_name_nsurl = [urls objectAtIndex:0];
        file_name_nsstring = [file_name_nsurl path];
        file_name_char = [file_name_nsstring UTF8String];
      
        
        ReadImageFromFile(file_name_char, &width, &height, &imageData);
        
        //printf("\nImage width = %d, height = %d\n", width, height);
       
        NSBitmapImageRep *colorImageRep = [[NSBitmapImageRep alloc]
                                 initWithBitmapDataPlanes: NULL
                                 pixelsWide: width
                                 pixelsHigh: height
                                 bitsPerSample: 8
                                 samplesPerPixel: 4
                                 hasAlpha: YES
                                 isPlanar: NO
                                 colorSpaceName: NSCalibratedRGBColorSpace
                                 bytesPerRow: width * 4
                                      bitsPerPixel: 32];
        
        NSInteger rowBytes;
        unsigned char* pixel_data;
        
        rowBytes = [colorImageRep bytesPerRow];
        pixel_data = [colorImageRep bitmapData];
        int number_of_pixels = height * width;
        
        for(int i = 0; i < number_of_pixels; ++i)
        {
            int i4 = i*4;
            *((unsigned char*)(pixel_data + i4)) = imageData[i]; //Red
            *((unsigned char*)(pixel_data + i4 + 1)) = imageData[i + number_of_pixels]; // Green
            *((unsigned char*)(pixel_data + i4 + 2)) = imageData[i + number_of_pixels*2]; //Blue
            *((unsigned char*)(pixel_data + i4 + 3)) = 0xFF; //Alpha

        }
        
        NSImage *colorNSImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
        [colorNSImage addRepresentation:colorImageRep];
        
        output_image.image = colorNSImage;
        
        //--------------- begin [Fit image into output_scroll_view]
        //output_scroll_view.documentView.frameSize = NSMakeSize(width, height); //compiles in Xcode 8, fails to compile in Xcode 6 and Xcode 7
        [output_scroll_view.documentView setFrame: NSMakeRect(0,0, width, height)]; //compiles in Xcode 6, Xcode 7, and Xcode 8
        output_image.frame = NSMakeRect(0.0,0.0, width, height);
        
        const CGFloat midX = NSMidX([[output_scroll_view documentView] bounds]);
        const CGFloat midY = NSMidY([[output_scroll_view documentView] bounds]);
        
        const CGFloat halfWidth = NSWidth([[output_scroll_view contentView] frame]) / 2.0;
        const CGFloat halfHeight = NSHeight([[output_scroll_view contentView] frame]) / 2.0;
        
        NSPoint newOrigin;
        if([[output_scroll_view documentView] isFlipped])
        {
            newOrigin = NSMakePoint(midX - halfWidth, midY + halfHeight);
        }
        else
        {
            newOrigin = NSMakePoint(midX - halfWidth, midY - halfHeight);
        }
        
        [[output_scroll_view documentView] scrollPoint:newOrigin];
        //--------------- end [Fit image into output_scroll_view]
        
        
        saveButton.enabled = YES;
  
        
    }//if ( [openDlg runModal] == NSModalResponseOK )
    
    
} // end doText


- (IBAction)SaveButtonAction:(id)pId;
{
    
    
    NSSavePanel *saveDlg = [NSSavePanel savePanel];
    
    [saveDlg setMessage:@"Please select a path to create a new image."]; // Message inside modal window
    [saveDlg setAllowedFileTypes:[[NSArray alloc] initWithObjects:@"wsq", @"bmp", @"tif", @"png", @"jpg", @"tga", nil]];
    [saveDlg setAllowsOtherFileTypes:YES];
    [saveDlg setExtensionHidden:NO];
    [saveDlg setCanCreateDirectories:YES];
    [saveDlg setTitle:@"Save image file"];
    [saveDlg setNameFieldStringValue:@"Untitled.wsq"];
    

    
    
    [saveDlg beginWithCompletionHandler:^(NSInteger result){

        if (result == NSFileHandlingPanelOKButton) {
            
            file_name_nsurl = [saveDlg URL];
            file_name_nsstring = [file_name_nsurl path];
            file_name_char = [file_name_nsstring UTF8String];

            NSString *file_name_extension = [[file_name_nsstring pathExtension] lowercaseString];
            
            
            if([file_name_extension compare:@"wsq"] == NSOrderedSame)
            {
              type = 1; //WSQ;
            }
            else if([file_name_extension compare:@"bmp"] == NSOrderedSame)
            {
              type = 2; //BMP;
            }
            else if([file_name_extension compare:@"tif"] == NSOrderedSame)
            {
              type = 3; //TIF;
            }
            else if([file_name_extension compare:@"png"] == NSOrderedSame)
            {
              type = 4; //PNG;
            }
            else if([file_name_extension compare:@"jpg"] == NSOrderedSame)
            {
              type = 5; //JPG;
            }
            else if([file_name_extension compare:@"rgb"] == NSOrderedSame)
            {
              type = 6; //RGB;
            }
            else if([file_name_extension compare:@"tga"] == NSOrderedSame)
            {
              type = 7; //TGA;
            }
            

            imageData_for_saving = (unsigned char *)malloc(3 * height * width * sizeof(unsigned char));
            if(imageData_for_saving == (unsigned char *)NULL)
            {printf("%s", "Error: malloc for imageData_for_saving failed\n");}
            

            NSImage *img = output_image.image;
            CGImageRef CGImage = [img CGImageForProposedRect:nil context:nil hints:nil];
            NSBitmapImageRep *colorImageRep = [[NSBitmapImageRep alloc] initWithCGImage:CGImage];
            
            
            NSInteger rowBytes;
            unsigned char* pixel_data;
            
            rowBytes = [colorImageRep bytesPerRow];
            pixel_data = [colorImageRep bitmapData];
            int number_of_pixels = height * width;
            
            for(int i = 0; i < number_of_pixels; ++i)
            {
                int i4 = i*4;
                imageData_for_saving[i] = *((unsigned char*)(pixel_data + i4)); //Red
                imageData_for_saving[i + number_of_pixels] = *((unsigned char*)(pixel_data + i4 + 1)); // Green
                imageData_for_saving[i + number_of_pixels*2] = *((unsigned char*)(pixel_data + i4 + 2)); //Blue
                
            }
            
            
            
            SaveImageToFile(file_name_char, type, width, height, imageData_for_saving);
            
            free(imageData_for_saving);
            imageData_for_saving = (unsigned char*) NULL;
            

        }//if (result == NSFileHandlingPanelOKButton) {
        
    }]; //[saveDlg beginWithCompletionHandler:^(NSInteger result){
    
    
    
    
} // end doText


- (IBAction)WSQToSreamButtonAction:(id)pId;{
    

    
    CFOptionFlags option_flags_result;
    

    // Create the File Open Dialog class.
    NSOpenPanel* openDlg = [NSOpenPanel openPanel];
    
    // Enable the selection of files in the dialog.
    [openDlg setCanChooseFiles:YES];
    
    // Multiple files not allowed
    [openDlg setAllowsMultipleSelection:NO];
    
    // Can't select a directory
    [openDlg setCanChooseDirectories:NO];
    
    NSArray* fileTypes = [NSArray arrayWithObjects:@"wsq",nil];
    [openDlg setAllowedFileTypes:fileTypes];
    

    [openDlg beginWithCompletionHandler:^(NSInteger result){
    
    // Display the dialog. If the OK button was pressed,
    // process the files.
    if ( result == NSModalResponseOK )
    {
        // Get an array containing the full filenames of all
        // files and directories selected.
        NSArray* urls = [openDlg URLs];
        
        // Loop through all the files and process them.
        //for(int i = 0; i < [urls count]; i++ )
        //{
        //    NSURL* url = [urls objectAtIndex:i];
        //    NSLog(@"Url: %@", url);
        //}
        
        
        file_name_nsurl = [urls objectAtIndex:0];
        file_name_nsstring = [file_name_nsurl path];
        file_name_char = [file_name_nsstring UTF8String];
        
        
       
        input_stream_length = 0;

        handle = open(file_name_char, O_RDONLY);
        
        struct stat st;
        stat(file_name_char, &st);
        file_size = st.st_size;
        
        if((int)file_size < 0)
        {printf("%s", "Error: filelength < 0\n"); return;}
        
        input_stream_length = file_size;
        
        
        if((infp = fopen(file_name_char, "rb")) == (FILE *)NULL)
        {printf("%s", "Error: open file failed\n");}
        
        input_data_stream = (unsigned char *)malloc(input_stream_length * sizeof(unsigned char));
        if(input_data_stream == (unsigned char *)NULL)
        {printf("%s", "Error: malloc for input_data_stream failed\n");}
                
                
        
        n = fread(input_data_stream, sizeof(unsigned char), input_stream_length, infp);
        if(n != input_stream_length)
        {printf("%s", "Error: reading file failed\n");}
       
        
        fclose(infp);
        
        close(handle);
        
        // THE DECODING OF WSQ STREAM INTO DECOMPRESSED STREAM
        WSQ_decode_stream(input_data_stream, (int) input_stream_length, &output_data_stream, &width, &height, &ppi, &comment_text);
        


        
        NSBitmapImageRep *colorImageRep = [[NSBitmapImageRep alloc]
                                           initWithBitmapDataPlanes: NULL
                                           pixelsWide: width
                                           pixelsHigh: height
                                           bitsPerSample: 8
                                           samplesPerPixel: 4
                                           hasAlpha: YES
                                           isPlanar: NO
                                           colorSpaceName: NSCalibratedRGBColorSpace
                                           bytesPerRow: width * 4
                                           bitsPerPixel: 32];
        
        NSInteger rowBytes;
        unsigned char* pixel_data;
        
        rowBytes = [colorImageRep bytesPerRow];
        pixel_data = [colorImageRep bitmapData];
        int number_of_pixels = height * width;
        
        for(int i = 0; i < number_of_pixels; ++i)
        {
            int i4 = i*4;
            *((unsigned char*)(pixel_data + i4)) = output_data_stream[i]; //Red
            *((unsigned char*)(pixel_data + i4 + 1)) = output_data_stream[i]; // Green
            *((unsigned char*)(pixel_data + i4 + 2)) = output_data_stream[i]; //Blue
            *((unsigned char*)(pixel_data + i4 + 3)) = 0xFF; //Alpha
            
        }
        
        NSImage *colorNSImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
        [colorNSImage addRepresentation:colorImageRep];
        
        output_image.image = colorNSImage;     
        
        
        //--------------- begin [Fit image into output_scroll_view]
        //output_scroll_view.documentView.frameSize = NSMakeSize(width, height); //compiles in Xcode 8, fails to compile in Xcode 6 and Xcode 7
        [output_scroll_view.documentView setFrame: NSMakeRect(0,0, width, height)]; //compiles in Xcode 6, Xcode 7, and Xcode 8
        output_image.frame = NSMakeRect(0.0,0.0, width, height);
        
        const CGFloat midX = NSMidX([[output_scroll_view documentView] bounds]);
        const CGFloat midY = NSMidY([[output_scroll_view documentView] bounds]);
        
        const CGFloat halfWidth = NSWidth([[output_scroll_view contentView] frame]) / 2.0;
        const CGFloat halfHeight = NSHeight([[output_scroll_view contentView] frame]) / 2.0;
        
        NSPoint newOrigin;
        if([[output_scroll_view documentView] isFlipped])
        {
            newOrigin = NSMakePoint(midX - halfWidth, midY + halfHeight);
        }
        else
        {
            newOrigin = NSMakePoint(midX - halfWidth, midY - halfHeight);
        }
        
        [[output_scroll_view documentView] scrollPoint:newOrigin];
        //--------------- end [Fit image into output_scroll_view]
        
        
        streamToWSQButton.enabled = YES;
       
         CFUserNotificationDisplayAlert(
         0, //timeout
         kCFUserNotificationPlainAlertLevel, //icon
         NULL, //icon url
         NULL,
         NULL,
         CFSTR("WSQ Image Library"),
         CFSTR("WSQ file was loaded into memory stream and decompressed into another memory stream.\nNow please press button \"stream -> WSQ\" to compress memory stream and save it to file.\nWSQ compressed byte array was converted to image for showing on screen."),
         NULL, //button options default to just "ok"
         NULL,
         NULL,
         &option_flags_result //response
         );

       
        
    }//if if ( result == NSModalResponseOK )

    }];// [openDlg beginWithCompletionHandler:^(NSInteger result){
        
}



- (IBAction)StreamToWSQButtonAction:(id)pId;{
    
   
    CFOptionFlags option_flags_result;

    NSSavePanel *saveDlg = [NSSavePanel savePanel];
    
    [saveDlg setMessage:@"Please select a path to create a WSQ image."];
    [saveDlg setAllowedFileTypes:[[NSArray alloc] initWithObjects:@"wsq", nil]];
    [saveDlg setAllowsOtherFileTypes:NO];
    [saveDlg setExtensionHidden:NO];
    [saveDlg setCanCreateDirectories:YES];
    [saveDlg setTitle:@"Save image file"];
    [saveDlg setNameFieldStringValue:@"Untitled.wsq"];
    
    [saveDlg beginWithCompletionHandler:^(NSInteger result){
        
        if (result == NSFileHandlingPanelOKButton) {

            file_name_nsurl = [saveDlg URL];
            file_name_nsstring = [file_name_nsurl path];
            file_name_char = [file_name_nsstring UTF8String];

    bitrate = 0.75;
    ppi = 500;

           
    comment_text = (char *)malloc(32 * sizeof(char));
    comment_text[0] = '\0';
    strcat(comment_text, "Cognaxon");
            
    
    
    if(input_data_stream2 != (unsigned char*)NULL)
    {free(input_data_stream2); input_data_stream2 = (unsigned char*)NULL;}
    
    input_data_stream2 = (unsigned char *)malloc((width*height) * sizeof(unsigned char));
    if(input_data_stream2 == (unsigned char *)NULL)
    {printf("%s", "Error: malloc for input_data_stream2 failed\n");}
    
    
    
    int row, row2, pixel_number, pixel_number2;
    
    // MAKE A MIRRORED/FLIPPED IMAGE (UP<->DOWN and LEFT<->RIGHT)
    for (int y = 0; y < height; y++)
    {
        row = width * y;
        row2 = width * (height - y - 1);
        for (int x = 0;  x < width; x++)
        {
            pixel_number = row + x;
            pixel_number2 = row2 + (width - x - 1);
            
            input_data_stream2[pixel_number2] = output_data_stream[pixel_number];
        }
    }
    
    
    // THE ENCODING OF DECOMPRESSED STREAM INTO WSQ STREAM
    WSQ_encode_stream(input_data_stream2, width, height, bitrate, ppi, comment_text, &output_data_stream2, &output_stream2_length);
    

    if(comment_text != NULL)
    {
       free(comment_text);
       comment_text = (char*) NULL; // this prevents crashing when opening next WSQ image
    }
            
            
    if((outfp = fopen(file_name_char, "wb")) == NULL)
    {printf("%s", "Error: open file failed\n");}
    
    if((n = fwrite(output_data_stream2, 1, output_stream2_length, outfp)) != output_stream2_length)
    {printf("%s", "Error: write to file failed\n");}
    
    fclose(outfp);
    
    
    
    CFUserNotificationDisplayAlert(
                                   0, //timeout
                                   kCFUserNotificationPlainAlertLevel, //icon
                                   NULL, //icon url
                                   NULL,
                                   NULL,
                                   CFSTR("WSQ Image Library"),
                                   CFSTR("Memory stream was compressed into another memory stream and saved to WSQ file.\nNow please press button \"Open\", select the saved file, open it and have a look at the results of memory stream processing. The processed image is mirrored/flipped (UP<->DOWN and LEFT<->RIGHT)."),
                                   NULL, //button options default to just "ok"
                                   NULL,
                                   NULL,
                                   &option_flags_result //response
                                   );

            
        }//if (result == NSFileHandlingPanelOKButton) {
        
    }];// [saveDlg beginWithCompletionHandler:^(NSInteger result){
    
    
}


- (IBAction)RegisterButtonAction:(id)pId;{
    
    
    CFOptionFlags option_flags_result;
    

    char* serial_number;
    char* wsq_unlock_code = "my-unlock-code"; // enter here your unlock code (authorization key)
    
    int ret;
    
    serial_number = GenerateSerialNumber();
    
    printf("%s%s\n", "Generated serial number is:\n", serial_number);
    
    
    ret = UnlockWSQLibrary(wsq_unlock_code);
    
    if (ret == 1)
    {printf("%s\n", "WSQ library successfully registered to this computer.");}
    else if (ret == 0)
    {printf("%s\n", "Unlock code is invalid.");}
    else if (ret == 2)
    {printf("%s\n", "Error writing license file. Please check directory write permisions.");}
    
    
    
    
    CFUserNotificationDisplayAlert(
                                   0, //timeout
                                   kCFUserNotificationPlainAlertLevel, //icon
                                   NULL, //icon url
                                   NULL,
                                   NULL,
                                   CFSTR("WSQ Image Library"),
                                   CFSTR("For registration please use program \"registerWSQ\" \n available in the same directory where WSQ Image Library (libWSQ_library64.so) is located.\nPlease visit http://www.cognaxon.com for more information."),
                                   NULL, //button options default to just "ok"
                                   NULL,
                                   NULL,
                                   &option_flags_result //response
                                   );
    
    
    
    
}






@end
