SSMODULEDECLSPEC int SSMODULECALL SSModule_GetModuleDesc(SSModuleDesc_p pModuleDesc, char *pchHomeDirectory) { FILE *hfNLSFile; if (!pModuleDesc) return SSMODULE_ERROR_INVALIDPARAMETER; // Return info about module! pModuleDesc->iVersionMajor = 1; pModuleDesc->iVersionMinor = 70; strcpy(pModuleDesc->achModuleName, "Moving Text"); strcpy(pModuleDesc->achModuleDesc, "This modules moves text on the screen!\n" "Written by Warp5" ); // If we have NLS support, then show the module description in // the chosen language! hfNLSFile = internal_OpenNLSFile(pchHomeDirectory); if (hfNLSFile) { sprintmsg(pModuleDesc->achModuleName, hfNLSFile, "MOD_NAME"); sprintmsg(pModuleDesc->achModuleDesc, hfNLSFile, "MOD_DESC"); internal_CloseNLSFile(hfNLSFile); } pModuleDesc->bConfigurable = TRUE; pModuleDesc->bSupportsPasswordProtection = TRUE; return SSMODULE_NOERROR; }
SSMODULEDECLSPEC int SSMODULECALL SSModule_GetModuleDesc(SSModuleDesc_p pModuleDesc, char *pchHomeDirectory) { FILE *hfNLSFile; if (!pModuleDesc) return SSMODULE_ERROR_INVALIDPARAMETER; // Return info about module! pModuleDesc->iVersionMajor = 1; pModuleDesc->iVersionMinor = 60; strcpy(pModuleDesc->achModuleName, "Blank screen"); strcpy(pModuleDesc->achModuleDesc, "Simple blank screen, using the power of Black! :)\n" "Written by Doodle" ); // If we have NLS support, then show the module description in // the chosen language! hfNLSFile = internal_OpenNLSFile(pchHomeDirectory); if (hfNLSFile) { sprintmsg(pModuleDesc->achModuleName, hfNLSFile, "MOD_NAME"); sprintmsg(pModuleDesc->achModuleDesc, hfNLSFile, "MOD_DESC"); internal_CloseNLSFile(hfNLSFile); } pModuleDesc->bConfigurable = FALSE; pModuleDesc->bSupportsPasswordProtection = TRUE; return SSMODULE_NOERROR; }
static void internal_SetConfigDialogText(HWND hwnd, char *pchHomeDirectory) { FILE *hfNLSFile; char achTemp[128]; if (!pchHomeDirectory) return; hfNLSFile = internal_OpenNLSFile(pchHomeDirectory); if (hfNLSFile) { // Window title if (sprintmsg(achTemp, hfNLSFile, "CFG_0001")) WinSetWindowText(hwnd, achTemp); // Label for the moving text label if (sprintmsg(achTemp, hfNLSFile, "CFG_0002")) WinSetDlgItemText(hwnd, ST_TEXT, achTemp); // OK button if (sprintmsg(achTemp, hfNLSFile, "CFG_0003")) WinSetDlgItemText(hwnd, PB_CONFOK, achTemp); // Cancel button if (sprintmsg(achTemp, hfNLSFile, "CFG_0004")) WinSetDlgItemText(hwnd, PB_CONFCANCEL, achTemp); internal_CloseNLSFile(hfNLSFile); } }
/******************************************************************************* Process the string from the UPS int upsstatus; int loadstate; int ipfreq; int opfreq; int tempc; int batpc; MIXED voltin; MIXED voltout; MIXED voltbatt; *******************************************************************************/ int UpdateUPSStatus(char *string, PUPSSTATUS pups) { char *stp; char *stp2; int len; double val = 0; double vin = 0; double vbrk = 0; double vout = 0; switch(lastmessage) { case UPS_Disable: case UPS_Query: if(pups->msgfile) sprintmsg(dummy, upst.msgfile, "DUMMY001"); string = dummy; if(*string != '(') break; pups->upsstatus = 0; vin = strtod(string + 1, &stp); pups->voltin = d_to_Mix(vin); stp += Skipspace(stp); pups->upsstatus |= valid_voltin; vbrk = strtod(stp, &stp); pups->voltbrk = d_to_Mix(vbrk); stp += Skipspace(stp); pups->upsstatus |= valid_voltbrk; vout = strtod(stp, &stp); pups->voltout = d_to_Mix(vout); stp += Skipspace(stp); pups->upsstatus |= valid_voltout; pups->loadstate = strtol(stp, &stp, 10); stp += Skipspace(stp); pups->upsstatus |= valid_loadstate; pups->ipfreq = pups->opfreq = (int)strtod(stp, &stp); stp += Skipspace(stp); if(pups->ipfreq > 0) pups->upsstatus |= (valid_opfreq | valid_ipfreq); val = strtod(stp, &stp); pups->voltbatt = d_to_Mix(val); stp += Skipspace(stp); if(val > 0) pups->upsstatus |= valid_voltbatt; if((Mix_to_d(upspr.battery) > 0) && (val > 0)) { double mini, defl, maxi; defl = Mix_to_d(upspr.battery); mini = (defl * DISCHARGE_RATIO); maxi = (defl * CHARGE_RATIO); defl = maxi - mini; val -= mini; if(val < 0) val = 0; pups->batpc = (int)((double)(val / defl) * 100); // pups->batpc = (int)((double)(Mix_to_d(upspr.battery) / (val * 1.2)) * 100); pups->upsstatus |= valid_batpc; } val = strtod(stp, &stp); pups->tempc = d_to_Mix(val); stp += Skipspace(stp); pups->upsstatus |= valid_tempc; pups->upsstatus |= bstrtoint(stp, &stp); if(_flagtest(pups->upsstatus, stat_failed)) pups->upsstatus |= stat_buzzena; if(_flagtest(pups->upsstatus, stat_testing)) pups->upsstatus |= stat_buzzena; if(_flagtest(pups->upsstatus, stat_shutting)) pups->upsstatus |= stat_buzzena; if(_flagtest(pups->upsstatus, stat_boost)) { if(vbrk < vout) pups->upsstatus |= (stat_glitch | stat_boost); if(vin > vout) { pups->upsstatus &= ~stat_boost; pups->upsstatus |= stat_buck; } } break; case UPS_Inf: string = dummyinf; if(*string != '#') break; len = Skipelse(string + 1); stp = (string + 1 + len); len = min(len, 15); strncpy(upspr.name, string + 1, len); *((upspr.name) + len) = '\0'; stp += Skipspace(stp); stp2 = stp; len = Skipelse(stp); stp = (stp + len); len = min(len, 15); strncpy(upspr.model, stp2, len); *((upspr.model) + len) = '\0'; stp += Skipspace(stp); stp2 = stp; len = Skipelse(stp); stp = (stp + len); len = min(len, 15); strncpy(upspr.version, stp2, len); *((upspr.version) + len) = '\0'; stp += Skipspace(stp); stp2 = stp; break; case UPS_Rate: string = dummyrate; if(*string != '#') break; val = strtod(string + 1, &stp); upspr.voltage = d_to_Mix(val); stp += Skipspace(stp); val = strtod(stp, &stp); upspr.current = d_to_Mix(val); stp += Skipspace(stp); val = strtod(stp, &stp); upspr.battery = d_to_Mix(val); stp += Skipspace(stp); val = strtod(stp, &stp); upspr.frequency = d_to_Mix(val); stp += Skipspace(stp); break; default: break; } curmessage = lastmessage; lastmessage = 0; return 0; }
/******************************************************************************* extern message is called by a calling application *******************************************************************************/ int APIENTRY UpsStatus(HAB hab, ULONG msg, MPARAM mp1, PUPSSTATUS pups) { int retcode = ERROR_BAD_COMMAND; int x; switch(msg) { case cmd_init: memset(&upst, 0, sizeof(UPSSTATUS)); upst.size = sizeof(UPSSTATUS); upst.strucid = STRUCTURE_ID; if(0 != (retcode = CloseComPort())) break; //stops any poll, and inits the various flags if(pups) { upst.msgfile = pups->msgfile; if(upst.msgfile) sprintmsg(infostr, upst.msgfile, "CONNECT1"); pups->infostr = infostr; } if(0 != (retcode = OpenComPort((char*)mp1))) break; threadid = _beginthread(MessageThread, NULL, 0x4000, NULL); DosSleep(1); if(0 != (retcode = waitformessage(hab, 0, NULL))) break; if(0 != (retcode = SendUPSMsg(UPS_Inf, NULL))) break; if(0 != (retcode = waitformessage(hab, 0, NULL))) break; if(0 != (retcode = SendUPSMsg(UPS_Rate, NULL))) break; retcode = waitformessage(hab, 0, pups); break; case cmd_info: if(0 != (retcode = waitformessage(hab, 0, NULL))) break; if(upst.msgfile) sprintmsg(infostr, upst.msgfile, "MEGATEC1", upspr.name, upspr.model, upspr.version, Mix_to_d(upspr.voltage), Mix_to_d(upspr.current), Mix_to_d(upspr.frequency), Mix_to_d(upspr.battery)); break; case cmd_quiet: StopPoll = TRUE; if(0 != (retcode = waitformessage(hab, 0, NULL))) break; if(_flagtest(upst.upsstatus, stat_buzzer) ^ (!mp1)) { if(0 != (retcode = SendUPSMsg(UPS_Quiet, NULL))) break; retcode = waitformessage(hab, 0, pups); break; } else retcode = NO_ERROR; break; case cmd_test: StopPoll = TRUE; if(0 != (retcode = waitformessage(hab, 0, NULL))) break; if(((int)mp1) == -1) retcode = SendUPSMsg(UPS_TestL, NULL); retcode = SendUPSMsg(UPS_Test, mp1); if(0 != retcode) break; StopPoll = FALSE; retcode = waitformessage(hab, 0, pups); break; case cmd_abort: StopPoll = TRUE; if(0 != (retcode = waitformessage(hab, 0, NULL))) break; if(_flagtest(upst.upsstatus, stat_testing)) retcode = SendUPSMsg(UPS_CancTst, NULL); if(0 != (retcode = waitformessage(hab, 0, NULL))) break; if(_flagtest(upst.upsstatus, stat_shutting)) retcode = SendUPSMsg(UPS_Cancel, NULL); if(0 != retcode) break; StopPoll = FALSE; retcode = waitformessage(hab, 0, pups); break; case cmd_shutdown: StopPoll = TRUE; if(0 != (retcode = waitformessage(hab, 0, NULL))) break; if(0 != (retcode = SendUPSMsg(UPS_Shut, mp1))) break; StopPoll = FALSE; retcode = waitformessage(hab, 0, pups); break; case cmd_exit: retcode = CloseComPort(); return retcode; case cmd_poll: retcode = waitformessage(hab, 0, pups); pups->infostr = infostr; break; default: retcode = waitformessage(hab, 0, NULL); break; } StopPoll = FALSE; return retcode; }