00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00024 #ifndef VMDCON_PLUGIN_H
00025 #define VMDCON_PLUGIN_H
00026 
00027 
00028 #define VMDCON_ALL       0      
00029 #define VMDCON_INFO      1      
00030 #define VMDCON_WARN      2      
00031 #define VMDCON_ERROR     3      
00032 #define VMDCON_ALWAYS    4      
00033 #define VMDCON_LOG       5      
00035 #include <stdio.h>
00036 #include <stdarg.h>
00037 #include <stdlib.h>
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 
00044 #if !defined(THISPLUGIN)
00045 #define THISPLUGIN plugin
00046 #endif
00047 
00048 
00049 static molfile_plugin_t THISPLUGIN;
00050 
00051 
00052 
00053 
00054 
00055 
00056 static int vmdcon_printf(int lvl, const char *fmt, ...) {
00057   va_list ap;
00058   char *buf;
00059   int len;
00060 
00061   
00062   buf = (char *)malloc(MOLFILE_BIGBUFSIZ);
00063   va_start(ap, fmt);
00064   len = vsprintf(buf, fmt, ap);
00065 
00066   
00067 
00068 
00069 
00070   if (len >= MOLFILE_BIGBUFSIZ) {
00071     fprintf(stderr,"WARNING! buffer overflow in vmdcon_printf. %d vs %d.\n",
00072             len, MOLFILE_BIGBUFSIZ);
00073     free(buf);
00074 #if 0
00075     errno=ERANGE; 
00076 #endif
00077     return -1;
00078   }
00079 
00080   
00081 
00082 
00083 
00084   if (THISPLUGIN.cons_fputs) {
00085     (*THISPLUGIN.cons_fputs)(lvl, buf);
00086   } else {
00087     fputs(buf, stdout);
00088   }
00089   free(buf);
00090   return 0;    
00091 }
00092 
00093 #ifdef __cplusplus
00094 }
00095 #endif
00096 
00097 #endif 
00098