gs_get_problems.cpp

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /*    gs_get_problems.cpp                                                     */
00004 /*    source file that implements the function of                             */
00005 /*    retrieving the list of supported services                               */
00006 /*                                                                            */
00007 /*    Copyright (C)                                                           */
00008 /*    Innovative Computing Laboratory (ICL)                                   */
00009 /*    Univesity of Tennessee, Knoxville                                       */
00010 /*                                                                            */
00011 /*    Feburary 22, 2007                                                       */
00012 /******************************************************************************/
00013 
00014 
00015 #include <oct.h>
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018 #include "grpc.h"
00019 #include "gs_oct.h"
00020 
00021 
00022 DEFUN_DLD (gs_problems, args, nargout, "Octave client for GridSolve") {
00023     octave_value_list bad_retval;   //bad return value
00024     grpc_error_t status;            //GridRPC status/error code
00025     char *info[1];
00026 
00027 
00028     //meaningless return value for error condition
00029     //or those calls that do not make grpc function call
00030     for (int i = 0; i < nargout; i++) {
00031         bad_retval(i) = Matrix(0, 0);
00032     }
00033 
00034     //initialize the GridSolve environment
00035     status = grpc_initialize(NULL);
00036     if (status != GRPC_NO_ERROR && status != GRPC_ALREADY_INITIALIZED) {
00037         fprintf(stderr, "%s\n", grpc_error_string(status));
00038         return bad_retval;
00039     }
00040 
00041     //number of input arguments
00042     int nargin = args.length();
00043 
00044     //display the list of available GridSolve problems
00045     if ((status = grpc_get_problems(info)) != GRPC_NO_ERROR) {
00046         fprintf(stderr, "%s\n", grpc_error_string(status));
00047     } else { //print out the list
00048         printf("GridSolve - List of available problems:\n");
00049         printf("%s\n", info[0]);
00050     }
00051 
00052     //finalize and clean up
00053     grpc_finalize();
00054     return bad_retval;
00055 }