vl_version.c
Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
00008 All rights reserved.
00009 
00010 This file is part of the VLFeat library and is made available under
00011 the terms of the BSD license (see the COPYING file).
00012 */
00013 
00014 #include "mexutils.h"
00015 #include <vl/stringop.h>
00016 
00017 #include <assert.h>
00018 
00019 /* option codes */
00020 enum {
00021   opt_verbose
00022 } ;
00023 
00024 /* options */
00025 vlmxOption options [] = {
00026 {"Verbose",          0,   opt_verbose          },
00027 {0,                  0,   0                    }
00028 } ;
00029 
00030 void
00031 mexFunction(int nout, mxArray *out[],
00032             int nin, const mxArray *in[])
00033 {
00034   int verbose = 0 ;
00035   char buffer [1024] ;
00036   int unsigned const bufferSize = sizeof(buffer)/sizeof(buffer[0]) ;
00037 
00038   int            opt ;
00039   int            next = 0 ;
00040   mxArray const *optarg ;
00041 
00042   VL_USE_MATLAB_ENV ;
00043 
00044   if (nout > 1) {
00045     vlmxError(vlmxErrTooManyOutputArguments, NULL) ;
00046   }
00047 
00048   while ((opt = vlmxNextOption (in, nin, options, &next, &optarg)) >= 0) {
00049     switch (opt) {
00050     case opt_verbose :
00051       ++ verbose ;
00052       break ;
00053     default:
00054       abort() ;
00055     }
00056   }
00057 
00058   if (verbose) {
00059     int offset = 0 ;
00060     char * string = vl_configuration_to_string_copy() ;
00061     offset = vl_string_copy(buffer, bufferSize, string) ;
00062     snprintf(buffer + offset, bufferSize - offset,
00063              "    SIMD enabled: %s\n", VL_YESNO(vl_get_simd_enabled())) ;
00064     if(string) vl_free(string) ;
00065   } else {
00066     snprintf(buffer, sizeof(buffer)/sizeof(buffer[0]),
00067              "%s", VL_VERSION_STRING) ;
00068   }
00069 
00070   if (nout == 0) {
00071     mexPrintf("%s\n", buffer) ;
00072   } else {
00073     out[0] = mxCreateString(buffer) ;
00074   }
00075 }


libvlfeat
Author(s): Andrea Vedaldi
autogenerated on Thu Jun 6 2019 20:25:51