1 module minimsc; 2 /* 3 4 MiniM 5 6 MiniM Server Connect 7 DLL interface 8 9 Copyright (C) Eugene Karataev 10 All rights reserved 11 12 */ 13 14 struct _MINIMSTR { align (1): 15 ushort len; 16 ubyte [32768]data; 17 } 18 19 extern (C): 20 alias _MINIMSTR MINIMSTR; 21 alias void* HMNMConnect; 22 23 extern (Windows): 24 HMNMConnect MNMCreateConnect(char *server, int port, char *database); 25 26 /* destroy connect object */ 27 //C void MNMSCPROC MNMDestroyConnect( HMNMConnect pConnect); 28 // void MNMDestroyConnect(HMNMConnect pConnect); 29 30 // /* connect to MiniM server */ 31 // C int MNMSCPROC MNMConnectOpen( HMNMConnect pConnect); 32 // int MNMConnectOpen(HMNMConnect pConnect); 33 34 // /* disconnect from MiniM server */ 35 // C int MNMSCPROC MNMConnectClose( HMNMConnect pConnect); 36 // int MNMConnectClose(HMNMConnect pConnect); 37 38 /* execute commands */ 39 //C int MNMSCPROC MNMExecute( HMNMConnect pConnect, MINIMSTR* Commands); 40 // int MNMExecute(HMNMConnect pConnect, MINIMSTR *Commands); 41 /* get last error description */ 42 //C void MNMSCPROC MNMGetLastError( HMNMConnect pConnect, MINIMSTR* pError); 43 // void MNMGetLastError(HMNMConnect pConnect, MINIMSTR *pError); 44 45 /* kill variable */ 46 //C int MNMSCPROC MNMKill( HMNMConnect pConnect, MINIMSTR* VarName); 47 //int MNMKill(HMNMConnect pConnect, MINIMSTR *VarName); 48 49 50 51 52 /* read M expression */ 53 //C int MNMSCPROC MNMRead( HMNMConnect pConnect, MINIMSTR* Expression, 54 //C MINIMSTR* Result); 55 // int MNMRead(HMNMConnect pConnect, MINIMSTR *Expression, MINIMSTR *Result); 56 57 /* write M variable */ 58 //C int MNMSCPROC MNMWrite( HMNMConnect pConnect, MINIMSTR* VarName, 59 //C MINIMSTR* VarValue); 60 // int MNMWrite(HMNMConnect pConnect, MINIMSTR *VarName, MINIMSTR *VarValue); 61 62 63 /* type of procedure to intercept output */ 64 //C typedef void ( __stdcall* mnmoutputproc_t )( HMNMConnect pConnect, 65 //C MINIMSTR* Value ); 66 extern (C): 67 alias void function(HMNMConnect pConnect, MINIMSTR *Value)mnmoutputproc_t; 68 69 /* set procedure to intercept output */ 70 //C void MNMSCPROC MNMSetOutput( HMNMConnect pConnect, mnmoutputproc_t pProc); 71 extern (Windows): 72 void MNMSetOutput(HMNMConnect pConnect, mnmoutputproc_t pProc); 73 74 /* execute commands with output interception */ 75 //C int MNMSCPROC MNMExecuteOutput( HMNMConnect pConnect, MINIMSTR* Commands); 76 int MNMExecuteOutput(HMNMConnect pConnect, MINIMSTR *Commands); 77 78 /* type of procedure to accept group read data */ 79 //C typedef void ( __stdcall* mnmgroupreadproc_t)( HMNMConnect pConnect, 80 //C MINIMSTR* Value); 81 extern (C): 82 alias void function(HMNMConnect pConnect, MINIMSTR *Value)mnmgroupreadproc_t; 83 84 //C void MNMSCPROC MNMSetGroupRead( HMNMConnect pConnect, mnmgroupreadproc_t pProc); 85 extern (Windows): 86 void MNMSetGroupRead(HMNMConnect pConnect, mnmgroupreadproc_t pProc); 87 88 /* type of procedure ho handle callback call */ 89 //C typedef void ( __stdcall* mnmcallbackproc_t)( HMNMConnect pConnect, 90 //C MINIMSTR* Command, MINIMSTR* Answer); 91 extern (C): 92 alias void function(HMNMConnect pConnect, MINIMSTR *Command, MINIMSTR *Answer)mnmcallbackproc_t; 93 94 //C void MNMSCPROC MNMSetCallback( HMNMConnect pConnect, 95 //C mnmcallbackproc_t pProc); 96 extern (Windows): 97 void MNMSetCallback(HMNMConnect pConnect, mnmcallbackproc_t pProc); 98 99 /* get list element as $listget(list,pos) */ 100 //C int MNMSCPROC MNMListGet( MINIMSTR* List, int pos, MINIMSTR* Element); 101 int MNMListGet(MINIMSTR *List, int pos, MINIMSTR *Element); 102 103 /* set list element as s $list(list,pos)=element */ 104 //C int MNMSCPROC MNMListSet( MINIMSTR* List, int pos, MINIMSTR* Element); 105 int MNMListSet(MINIMSTR *List, int pos, MINIMSTR *Element); 106 107 /* return count of list elements */ 108 //C int MNMSCPROC MNMListLength( MINIMSTR* List); 109 int MNMListLength(MINIMSTR *List); 110 111 /* 112 decorate '"' if need 113 114 "abcd" -> "abcd" 115 "ab\"cd" -> "ab""cd" 116 "ab\r\ncd" -> "ab"_$C(13,10)_"cd" 117 118 return 0 if Target exeed MINIMSTR limit 119 */ 120 //C int MNMSCPROC MNMText( MINIMSTR* Source, MINIMSTR* Target); 121 int MNMText(MINIMSTR *Source, MINIMSTR *Target); 122 123 __EOF__ 124 125 MNMConnectClose // Закрыть сессию 126 MNMConnectOpen // Открыть сессию 127 MNMCreateConnect // Заполнить структуру на открытие 128 MNMDestroyConnect // Уничтожить структуру на открытие 129 MNMExecute // Выполнить строку М - без визуализации 130 MNMExecuteOutput // Выполнить строку М - с визуализаций через MNMSetOutput 131 MNMGetLastError // Прочитать последнию ошибку 132 MNMKill // Уничтожить глобаль 133 MNMListGet // Взять список 134 MNMListLength // Длина списка 135 MNMListSet // Записать список 136 MNMRead // Прочитать выражение 137 MNMSetCallback 138 MNMSetGroupRead 139 MNMSetOutput // Установить процеду отображения вывода после MNMExecuteOutput 140 MNMText // Буфер в строку 141 MNMWrite // Записать выражение