//================================================================================== // _FormatPStr(void FAR *pdata, long count) // //================================================================================== static VOID NEAR PASCAL _FormatPStr(sBYTE FAR *pData, sBYTE FAR *msg) { int iMsgLen = _fstrlen(msg); int iDataLen = (uBYTE)pData[0]; if ((iMsgLen + iDataLen) < sizeof(SZMSGBUF)) iDataLen = sizeof(SZMSGBUF) - (uBYTE)iMsgLen; if (iDataLen > 0) _fmemmove(&(msg[iMsgLen]), pData + 1, iDataLen); iMsgLen += (uBYTE)pData[0]; msg[iMsgLen] = 0; // make sure to null terminate the string }
int cwindow::gettext(char * szstr, int nrow) { int i; char __far* szmem = (char __far*)(0x0b8000000 + m_npage * 1024 * 4); szmem += ((nrow + m_nrow1 - 1) * g_SysInfo.nmaxcols + m_ncol1 + 1) * 2; //i=_fstrlen(szstr); _fmemset(szstr, '\0',65); for(i = 0; i < m_ncol2 - m_ncol1 - 2; i++) *(szstr + i) = *(szmem + i * 2); return _fstrlen(szstr); }
_WCRTLINK char _WCFAR *_fstrdup( const char _WCFAR *str ) { char _WCFAR *mem; int len; len = _fstrlen( str ) + 1; mem = lib_malloc( len ); if( mem ) { (_fmemcpy)( mem, str, len ); } return( mem ); }
char *_fdupstr(const char far * const s) { size_t len; char *p; chkHeap if((p = malloc(len = _fstrlen(s) + 1)) == 0) return 0; _fmemcpy(TO_FP(p), s, len); chkHeap return p; }
BOOL MsgCatStr (WORD usMsgSID, char FAR * szMsgTxt, WORD usMaxLen) { WORD usStrLen; /********************************************************************/ /********************************************************************/ if ((usStrLen = _fstrlen (szMsgTxt)) >= usMaxLen) return (FALSE); /********************************************************************/ /********************************************************************/ return (MsgLodStr (AmpGlo.hLibIns, usMsgSID, &szMsgTxt[usStrLen], usMaxLen - usStrLen)); }
int TestParety(HWND hWnd) { int Parety = 0; int i,l; // char Buf[100]; l = _fstrlen(szAboutString); for( i = 0; i < l; i ++) Parety += szAboutString[i]; // wsprintf(Buf,"Parety value = [%d]",Parety); // MessageBox(hWnd,Buf,"Parety Value",MB_OK); return (Parety == PARETYVAL); }
///////////////////////////////////////////////////////////////////////////// // Audio ToolBox Installation DLL // Copyright (c) 1987-1996 Andrew J. Michalik ///////////////////////////////////////////////////////////////////////////// DWORD FAR PASCAL ChkRegSer (WORD usRsv001, LPCSTR szSerNum) { ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// #define DIGSUMCNT 10 // Number of digits to sum #define DIGPOSMUL 100 // Digit position multiplier #define SERMAXLEN 64 // Maximum serial number length #define ASCNUMBAS 0x30 // ASCII numeric base value static char szTmp[SERMAXLEN]; // Temporary work string char * pTmp = szTmp; // Temporary work string long lSum = 0L; int ii = 0; ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// if (!szSerNum) return (0L); ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// _fstrncpy (szTmp, szSerNum, SERMAXLEN - 1); szTmp[SERMAXLEN - 1] = '\0'; ///////////////////////////////////////////////////////////////////////// // Calculate the sum of the first DIGSUMCNT digits ///////////////////////////////////////////////////////////////////////// while ((ii < DIGSUMCNT) && _fstrlen(pTmp)) { if (isdigit (*pTmp)) { lSum = lSum + (*pTmp - ASCNUMBAS); ii++; } pTmp++; } ///////////////////////////////////////////////////////////////////////// // Return sum count if requested ///////////////////////////////////////////////////////////////////////// if (usRsv001) return (3 * (lSum * lSum)); ///////////////////////////////////////////////////////////////////////// // Verify correct number of sum digits // Compare Mod of (3 * (sum * sum)) to last digits ///////////////////////////////////////////////////////////////////////// if ((DIGSUMCNT == ii) && (((3 * (lSum * lSum)) % DIGPOSMUL) == atol(pTmp))) return (TRUE); ///////////////////////////////////////////////////////////////////////// return (FALSE); }
/*-------------------------------------------------------------------------- * Function: _SetMemoryString * Expects: HWND hDlg * LPDLGVALS lpDlgVals; * Returns: nothing * Purpose: To Set the static string for the 'Memory display' of the assert * dialog box. * History: 11/7/94 Initial Revision (mdh) *-------------------------------------------------------------------------- */ static VOID NEAR PASCAL _SetMemoryString( HWND hDlg, LPDLGVALS lpdlgVals ) { char szTmp[32]; SZMSGBUF szBuf; if (lpdlgVals->ulCount > 0) { _NumToHexStr((long)lpdlgVals->lpvData, szTmp, 8); _fstrcpy(szBuf, _szMemoryMessage); _fmemmove(&(szBuf[kAddressOffset]), szTmp, _fstrlen(szTmp)); switch (lpdlgVals->ulFormat) { case 'b': case 'B': _FormatBytes(((sBYTE FAR*)lpdlgVals->lpvData), lpdlgVals->ulCount, (sBYTE FAR*)szBuf); break; case 'w': case 'W': _FormatWords(((sBYTE FAR*)lpdlgVals->lpvData), lpdlgVals->ulCount, (sBYTE FAR*)szBuf); break; case 'l': case 'L': _FormatLongs(((sBYTE FAR*)lpdlgVals->lpvData), lpdlgVals->ulCount, (sBYTE FAR*)szBuf); break; case 's': case 'S': _FormatCStr(((sBYTE FAR*)lpdlgVals->lpvData), szBuf); break; case 'p': case 'P': _FormatPStr(((sBYTE FAR*)lpdlgVals->lpvData), szBuf); break; } } else *szBuf = 0; // Null terminate the string. SetWindowText( GetDlgItem( hDlg, DLGID_MEMORYTEXT ), szBuf ); }
//************************************************************************// //sort accord ascii, from small to larger // // //************************************************************************// void cwindow::additem(char* szstr) { _itemnode *pnew = NULL,*psort = NULL; m_nitemcount ++; pnew = (_itemnode*)malloc(sizeof(_itemnode)); pnew->szitemtext = (char *)malloc(_fstrlen(szstr) + 1); _fstrcpy(pnew->szitemtext, szstr); pnew->pnext = NULL; pnew->ppre = NULL; if(m_pitemhead == NULL)//the first create item-link { m_pitemhead = pnew; m_pitemend = pnew; m_pitemactive = pnew; } else { psort = m_pitemhead; while(psort != NULL) { if(_fstricmp(szstr, psort->szitemtext) <= 0) break; psort = psort->pnext; } if(psort != NULL) { pnew->ppre = psort->ppre; if(psort->ppre) psort->ppre->pnext = pnew; pnew->pnext = psort; psort->ppre = pnew; if(psort == m_pitemhead) m_pitemactive = m_pitemhead = pnew; } else { m_pitemend->pnext = pnew; pnew->ppre = m_pitemend; m_pitemend = pnew; } } if(m_nwritedrow <= m_nmaxrows) writeitem(m_nwritedrow ++, szstr); }
//--------------------------------------------------------------------------- // ScriptError // // This function is called when a scantime, parsetime, bindtime, or runtime // error occurs. The error type is passed, along with a pointer to the error // message, the file name (which we need to parse) and line number. // // RETURNS: Nothing //--------------------------------------------------------------------------- VOID ScriptError (INT errtype, INT errfile, INT errline, INT errstart, INT errend, LPSTR errmsg) { LPSTR szFName; CHAR buf[256], caption[80], *szFmt = "Test Driver %s Error"; CHAR *temp; INT i; // Create the message box's caption //----------------------------------------------------------------------- switch (errtype) { case ER_SCAN: temp = "Scanner"; break; case ER_PARSE: temp = "Parser"; break; case ER_BIND: temp = "Bind"; break; case ER_RUN: temp = "Runtime"; break; } wsprintf (caption, szFmt, (LPSTR)temp); // Next create the text for the box //----------------------------------------------------------------------- szFName = GetScriptFileName (errfile); i = _fstrlen (szFName); while (i && szFName[i-1] != '\\') i--; wsprintf (buf, (LPSTR)((errline > 0) ? "%s\r\n%s(%d)" : "%s\r\n%s"), (LPSTR)errmsg, (LPSTR)szFName+i, errline); // Throw up the message box and we're done! //----------------------------------------------------------------------- MessageBeep (MB_ICONSTOP); MessageBox (NULL, buf, caption, MB_OK|MB_ICONSTOP); }
DWORD FAR PASCAL ChkRegIns (WORD usRsv001, DWORD ulStrSum, LPCSTR szRegStr) { WORD usStrLen; DWORD ulStrVal = 0L; #define LICSTRLEN 80 // Maximum string length ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// if (!szRegStr) return (0L); ///////////////////////////////////////////////////////////////////////// // Sum non-whitespace characters preceding any ";" comment delimiter ///////////////////////////////////////////////////////////////////////// usStrLen = min (_fstrlen (szRegStr), LICSTRLEN); while (usStrLen-- && (';' != szRegStr[usStrLen])) if isgraph (szRegStr[usStrLen]) ulStrVal += szRegStr[usStrLen]; ///////////////////////////////////////////////////////////////////////// // Generate checksum (3 * (sum * sum)) for input string ///////////////////////////////////////////////////////////////////////// return (ulStrSum + (3 * (ulStrVal * ulStrVal))); }
_WCRTLINK char _WCFAR *_fstrrev( char _WCFAR *str ) /* reverse characters in string */ { #if defined( _M_I86 ) fast_rev( str ); return( str ); #else char _WCFAR *p1; char _WCFAR *p2; char c1; char c2; p1 = str; p2 = p1 + _fstrlen( p1 ) - 1; while( p1 < p2 ) { c1 = *p1; c2 = *p2; *p1 = c2; *p2 = c1; ++p1; --p2; } return( str ); #endif }
_WCRTLINK FJSTRING _WCI86FAR _fjstrrev( JCHAR _WCFAR *s ) { JCHAR _WCFAR *p, _WCFAR *q, _WCFAR *r; p = s; q = p + _fstrlen( p ); while( p < q ) { if( iskanji( *p ) ) { if( iskanji2( *( r = p + 1 ) ) ) { *p ^= *r; *r ^= *p; *p++ ^= *r; } } p++; } p = s; while( p < --q ) { *p ^= *q; *q ^= *p; *p++ ^= *q; } return( s ); }
int ShdRecTxt (HDC hDC, char FAR *szTxtStr, RECT rShdRec, WORD usTotWid) { DWORD ulTxtExt; /* Current text extents */ WORD usTxtLen; /* Current text string len */ RECT rTxtRec; /********************************************************************/ /********************************************************************/ usTxtLen = _fstrlen (szTxtStr); ulTxtExt = GetTextExtent (hDC, szTxtStr, usTxtLen); rShdRec.right = rShdRec.left + LOWORD (ulTxtExt) + 4 * SHDBOXWID; if (rShdRec.right <= (int) usTotWid) { rTxtRec = ShdRecBox (hDC, rShdRec, AmpGlo.hShdPen, AmpGlo.hLgtPen); TextOut (hDC, rTxtRec.left + SHDBOXWID, (rTxtRec.bottom - HIWORD (ulTxtExt)) / 2 + 2, szTxtStr, usTxtLen); return (rShdRec.right); } /********************************************************************/ /********************************************************************/ return (rShdRec.left); }
int main(int argc, char **argv) #endif { /*WNDCLASS wndclass;*/ LPSTR tail; #ifdef WGP_CONSOLE # define _argv argv # define _argc argc HINSTANCE hInstance = GetModuleHandle(NULL), hPrevInstance = NULL; #else #if defined(__MSC__) || defined(__WATCOMC__) # define _argv __argv # define _argc __argc #endif #endif /* WGP_CONSOLE */ szModuleName = (LPSTR)malloc(MAXSTR+1); CheckMemory(szModuleName); /* get path to EXE */ GetModuleFileName(hInstance, (LPSTR) szModuleName, MAXSTR); if ((tail = (LPSTR)_fstrrchr(szModuleName,'\\')) != (LPSTR)NULL) { tail++; *tail = 0; } szModuleName = (LPSTR)realloc(szModuleName, _fstrlen(szModuleName)+1); CheckMemory(szModuleName); if (_fstrlen(szModuleName) >= 5 && _fstrnicmp(&szModuleName[_fstrlen(szModuleName)-5], "\\bin\\", 5) == 0) { int len = _fstrlen(szModuleName)-4; szPackageDir = (LPSTR)malloc(len+1); CheckMemory(szPackageDir); _fstrncpy(szPackageDir, szModuleName, len); szPackageDir[len] = '\0'; } else szPackageDir = szModuleName; #ifndef WGP_CONSOLE textwin.hInstance = hInstance; textwin.hPrevInstance = hPrevInstance; textwin.nCmdShow = nCmdShow; textwin.Title = "gnuplot"; #endif /* create structure of first graph window */ graphwin = calloc(1, sizeof(GW)); listgraphs = graphwin; /* locate ini file */ { char * inifile; get_user_env(); /* this hasn't been called yet */ inifile = gp_strdup("~\\wgnuplot.ini"); gp_expand_tilde(&inifile); /* if tilde expansion fails use current directory as default - that was the previous default behaviour */ if (inifile[0] == '~') { free(inifile); inifile = "wgnuplot.ini"; } #ifndef WGP_CONSOLE textwin.IniFile = inifile; #endif graphwin->IniFile = inifile; ReadMainIni(inifile, "WGNUPLOT"); } #ifndef WGP_CONSOLE textwin.IniSection = "WGNUPLOT"; textwin.DragPre = "load '"; textwin.DragPost = "'\n"; textwin.lpmw = &menuwin; textwin.ScreenSize.x = 80; textwin.ScreenSize.y = 80; textwin.KeyBufSize = 2048; textwin.CursorFlag = 1; /* scroll to cursor after \n & \r */ textwin.shutdown = MakeProcInstance((FARPROC)ShutDown, hInstance); textwin.AboutText = (LPSTR)malloc(1024); CheckMemory(textwin.AboutText); sprintf(textwin.AboutText, "Version %s patchlevel %s\n" \ "last modified %s\n" \ "%s\n%s, %s and many others\n" \ "gnuplot home: http://www.gnuplot.info\n", gnuplot_version, gnuplot_patchlevel, gnuplot_date, gnuplot_copyright, authors[1], authors[0]); textwin.AboutText = (LPSTR)realloc(textwin.AboutText, _fstrlen(textwin.AboutText)+1); CheckMemory(textwin.AboutText); menuwin.szMenuName = szMenuName; #endif pausewin.hInstance = hInstance; pausewin.hPrevInstance = hPrevInstance; pausewin.Title = "gnuplot pause"; graphwin->hInstance = hInstance; graphwin->hPrevInstance = hPrevInstance; #ifdef WGP_CONSOLE graphwin->lptw = NULL; #else graphwin->lptw = &textwin; #endif /* init common controls */ { INITCOMMONCONTROLSEX initCtrls; initCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX); initCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&initCtrls); } #ifndef WGP_CONSOLE if (TextInit(&textwin)) exit(1); textwin.hIcon = LoadIcon(hInstance, "TEXTICON"); SetClassLong(textwin.hWndParent, GCL_HICON, (DWORD)textwin.hIcon); if (_argc>1) { int i,noend=FALSE; for (i=0; i<_argc; ++i) if (!stricmp(_argv[i],"-noend") || !stricmp(_argv[i],"/noend") || !stricmp(_argv[i],"-persist")) noend = TRUE; if (noend) ShowWindow(textwin.hWndParent, textwin.nCmdShow); } else ShowWindow(textwin.hWndParent, textwin.nCmdShow); if (IsIconic(textwin.hWndParent)) { /* update icon */ RECT rect; GetClientRect(textwin.hWndParent, (LPRECT) &rect); InvalidateRect(textwin.hWndParent, (LPRECT) &rect, 1); UpdateWindow(textwin.hWndParent); } #else /* WGP_CONSOLE */ #ifdef CONSOLE_SWITCH_CP /* Change codepage of console to match that of the graph window. WinExit() will revert this. Attention: display of characters does not work correctly with "Terminal" font! Users will have to use "Lucida Console" or similar. */ cp_input = GetConsoleCP(); cp_output = GetConsoleOutputCP(); if (cp_input != GetACP()) { cp_changed = TRUE; SetConsoleCP(GetACP()); /* keyboard input */ SetConsoleOutputCP(GetACP()); /* screen output */ SetFileApisToANSI(); /* file names etc. */ } #endif #endif atexit(WinExit); if (!isatty(fileno(stdin))) setmode(fileno(stdin), O_BINARY); gnu_main(_argc, _argv, environ); /* First chance to close help system for console gnuplot, second for wgnuplot */ WinCloseHelp(); return 0; }
WORD FAR PASCAL CvtPCMIni (WORD usReqTyp, DWORD ulPrm001, DWORD ulPrm002) { WORD usRetCod = SI_CVTNO_ERR; WORD usCmpCod = 0; /********************************************************************/ /* Initialize PCM Conversion (DOS & Win support) */ /********************************************************************/ #if (defined (DOS)) /****************************************************/ PCMResIni (0); #endif /*****************************************************************/ #if (defined (W31)) /****************************************************/ PCMDLLIni (0, 0L, (DWORD) (LPVOID) "t2c09p03"); #endif /*****************************************************************/ /********************************************************************/ /* Check the version numbers of support modules (Win DLL's) */ /********************************************************************/ #if (defined (W31)) /****************************************************/ if (EFFVERNUM != EffSupVer()) { if (TBxGlo.usDebFlg & INI___DEB) MsgDspUsr (SI_MODVERMIS, SI_EFFDLLSUP); usRetCod |= SI_CVTVERERR; } if (PCMVERNUM != PCMSupVer()) { if (TBxGlo.usDebFlg & INI___DEB) MsgDspUsr (SI_MODVERMIS, SI_PCMDLLSUP); usRetCod |= SI_CVTVERERR; } #endif /*****************************************************************/ //ajm test //TBxGlo.usRegKey = REGFULKEY; //return (SI_CVTKEYERR); /********************************************************************/ /* If (0 == usReqTyp), check for accelerator/license/customer key */ /********************************************************************/ if (!usReqTyp && (!ulPrm001 || !_fstrlen ((LPSTR) ulPrm001)) && (!ulPrm002 || !_fstrlen ((LPSTR) ulPrm002))) { /****************************************************************/ /* Check for accelerator key and/or AppKey/UsrKey combo */ /****************************************************************/ if (REGDEMKEY == ChkRegKey (TBxGlo.RelKeyArr, TBxGlo.SeqNumArr, &usCmpCod)) { switch (usCmpCod) { case 0xFFFE: if (TBxGlo.usDebFlg & INI___DEB) MsgDspUsr (SI_INSMEMERR); break; case 0xFFFD: if (TBxGlo.usDebFlg & INI___DEB) MsgDspUsr (SI_DOSMEMERR); break; default: if (TBxGlo.usDebFlg & INI___DEB) MsgDspUsr (SI_ACCKEYNON); } return (usRetCod | SI_CVTKEYERR); } /****************************************************************/ /* Load registration key from physical key [1] or string. */ /****************************************************************/ if (!usCmpCod) TBxGlo.usRegKey = GetEncKey (TBxGlo.SeqNumArr, 1, &usCmpCod); else TBxGlo.usRegKey = ChkRegKey (TBxGlo.RelKeyArr, TBxGlo.SeqNumArr, &usCmpCod); return (usRetCod | SI_CVTNO_ERR); } if (!usReqTyp && ulPrm001 && _fstrlen ((LPSTR) ulPrm001)) { /****************************************************************/ /* Check license file key, return error. */ /****************************************************************/ TBxGlo.usRegKey = ChkLicFil ((LPSTR) ulPrm001, NULL, &usCmpCod); return (usRetCod | (usCmpCod ? SI_CVTKEYERR : SI_CVTNO_ERR)); } if (!usReqTyp && ulPrm002 && _fstrlen ((LPSTR) ulPrm002)) { /****************************************************************/ /* Check customer key, do not return error for better security. */ /****************************************************************/ TBxGlo.usRegKey = ChkRegKey ((LPSTR) ulPrm002, TBxGlo.SeqNumArr, &usCmpCod); } /********************************************************************/ /********************************************************************/ return (usRetCod | SI_CVTNO_ERR); }
void FAR PASCAL AmpStaPnt (HWND hWnd, const AMPDES FAR *lpAmpDes, const AMPUSR FAR *lpAmpUsr) { PAINTSTRUCT ps; char szTxtBuf[AMPMAXSTR]; DWORD ulSelBeg; DWORD ulSelEnd; WORD usTotWid; /* Total window width */ HFONT hFixFnt; HFONT hOldFnt; RECT rShdRec; /* Shd rec outer bounds */ HDC hDC; /********************************************************************/ /********************************************************************/ GetClientRect (hWnd, &rShdRec); usTotWid = rShdRec.right; /********************************************************************/ /********************************************************************/ hDC = BeginPaint (hWnd, &ps); /* Prepare the client area */ SetBkMode (hDC, TRANSPARENT); /********************************************************************/ /********************************************************************/ hFixFnt = CreFntFix (hDC, AmpGlo.usFntSiz, rShdRec); hOldFnt = SelectObject (hDC, hFixFnt); /********************************************************************/ /* Display document length position */ /********************************************************************/ MsgLodStr (AmpGlo.hLibIns, SI_EXTSEGLEN, szTxtBuf, AMPMAXSTR); _fdtorna ((lpAmpDes->ulDocLen) / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, &szTxtBuf[_fstrlen(szTxtBuf)]); MsgCatStr (SI_EXTSEGSEC, szTxtBuf, AMPMAXSTR); rShdRec.left = ShdRecTxt (hDC, szTxtBuf, rShdRec, usTotWid); /********************************************************************/ /* Display "at" position */ /********************************************************************/ MsgLodStr (AmpGlo.hLibIns, SI_EXTSEGATP, szTxtBuf, AMPMAXSTR); _fdtorna ((lpAmpUsr->ulPosAtP) / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, &szTxtBuf[_fstrlen(szTxtBuf)]); MsgCatStr (SI_EXTSEGSEC, szTxtBuf, AMPMAXSTR); rShdRec.left = ShdRecTxt (hDC, szTxtBuf, rShdRec, usTotWid); /********************************************************************/ /* Display selection extents & length */ /********************************************************************/ if (GetSelFTo (lpAmpUsr, &ulSelBeg, &ulSelEnd)) { /****************************************************************/ /* Display text fields */ /****************************************************************/ _fdtorna (ulSelBeg / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, szTxtBuf); MsgCatStr (SI_EXTSEGSYM, szTxtBuf, AMPMAXSTR); _fdtorna (ulSelEnd / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, &szTxtBuf[_fstrlen(szTxtBuf)]); _fstrcat (szTxtBuf, " ("); _fdtorna ((ulSelEnd - ulSelBeg) / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, &szTxtBuf[_fstrlen(szTxtBuf)]); MsgCatStr (SI_EXTSEGSEC, szTxtBuf, AMPMAXSTR); _fstrcat (szTxtBuf, ")"); rShdRec.left = ShdRecTxt (hDC, szTxtBuf, rShdRec, usTotWid); /****************************************************************/ /* Display current window overview */ /* Display selection region overview */ /****************************************************************/ ShdRecRec (hDC, rShdRec, lpAmpDes->ulSmpOff, lpAmpDes->ulSmpOff + (DWORD) (lpAmpDes->flSmppGP * lpAmpDes->usArrLen), lpAmpDes->ulDocLen, AmpGlo.hOvrPen, AmpGlo.hOvrBsh); ShdRecRec (hDC, rShdRec, ulSelBeg, ulSelEnd, lpAmpDes->ulDocLen ? lpAmpDes->ulDocLen : (DWORD) (lpAmpDes->flSmppGP * lpAmpDes->usArrLen), AmpGlo.hSOvPen, GetStockObject (NULL_BRUSH)); } else { /****************************************************************/ /* Display current window overview only */ /****************************************************************/ ShdRecRec (hDC, rShdRec, lpAmpDes->ulSmpOff, lpAmpDes->ulSmpOff + (DWORD) (lpAmpDes->flSmppGP * lpAmpDes->usArrLen), lpAmpDes->ulDocLen, AmpGlo.hLgtPen, AmpGlo.hOvrBsh); } /********************************************************************/ /********************************************************************/ rShdRec.right = usTotWid; ShdRecBox (hDC, rShdRec, AmpGlo.hShdPen, AmpGlo.hLgtPen); /********************************************************************/ /********************************************************************/ SelectObject (hDC, hOldFnt); DeleteObject (hFixFnt); /********************************************************************/ /********************************************************************/ EndPaint (hWnd, &ps); /* Done painting for now */ }
int grabComFilename(const int warn, const char far * const fnam) { char *buf; size_t len; int rc; dprintf( ("[INIT: grabComFilename(%s)]\n", fnam) ); if(!fnam) return 4; /* Copy the filename into the local heap */ len = _fstrlen(fnam); if(len >= INT_MAX || len < 1) { /* no filename specified */ if(warn) error_syntax(0); return 4; } if((buf = malloc(len + 1)) == 0) { if(warn) error_out_of_memory(); return 4; } _fmemcpy((char far*)buf, fnam, len); buf[len] = '\0'; if (buf[1] != ':' || buf[2] != '\\') { char *p; /* expand the string for the user */ p = abspath(buf, warn); free(buf); if((buf = p) == 0) return 4; if(warn) error_init_fully_qualified(buf); len = strlen(buf); } while(buf[len - 1] == '\\') --len; buf[len] = 0; if(dfnstat(buf) & DFN_DIRECTORY) { /* The user specified a directory, try if we can find the COMMAND.COM with the standard name in there */ char *p; if((p = realloc(buf, len + sizeof(COM_NAME) + 1)) == 0) { if(warn) error_out_of_memory(); free(buf); return 4; } buf = p; strcpy(&buf[len], "\\" COM_NAME); } if(0 != (rc = validResFile(buf))) { if(warn) switch(rc) { default: #ifdef NDEBUG assert(0); #endif case 1: error_open_file(buf); break; case 2: error_fcom_is_device(buf); break; case 3: error_fcom_invalid(buf); break; } free(buf); return rc; } free(ComPath); /* Save the found file */ ComPath = buf; dprintf(("[INIT: new resource file name: %s]\n", ComPath)); isSwapFile = 0; buf = dfnfilename(ComPath); assert(buf); if((buf = strchr(buf, '.')) != 0 && stricmp(buf, ".swp") == 0) { dprintf(("[INIT: VSpawn file found: %s]\n", ComPath)); memcpy(++buf, "COM", 3); isSwapFile = buf - ComPath; } return 0; }
WORD FAR PASCAL TMICfgRel (VISMEMHDL FAR *pmhCfgMem, LPCSTR lpCfgFil, LPCSTR lpSecNam) { DIGCFG FAR *lpDigCfg; /********************************************************************/ /********************************************************************/ if (!lpCfgFil || !_fstrlen (lpCfgFil)) { *pmhCfgMem = GloAloRel (*pmhCfgMem); return (0); } if (NULL == (lpDigCfg = GloMemLck (*pmhCfgMem))) { return ((WORD) -1); } /********************************************************************/ /* If config file is specified, update user specified settings */ /********************************************************************/ WrtPrfLng (lpCfgFil, lpSecNam, PI_VBSWIN, lpDigCfg->tdTMIDef.scSysCfg.sVBSwIn); WrtPrfLng (lpCfgFil, lpSecNam, PI_VBHWIR, lpDigCfg->tdTMIDef.scSysCfg.sVBHwIn); WrtPrfLng (lpCfgFil, lpSecNam, PI_MXHWIR, lpDigCfg->tdTMIDef.scSysCfg.sMxHwIn); WrtPrfLng (lpCfgFil, lpSecNam, PI_LINENO, lpDigCfg->tdTMIDef.scSysCfg.sLinNum); WrtPrfLng (lpCfgFil, lpSecNam, PI_MPXINP, lpDigCfg->tdTMIDef.scSysCfg.sMpxInp); WrtPrfLng (lpCfgFil, lpSecNam, PI_MPXOUT, lpDigCfg->tdTMIDef.scSysCfg.sMpxOut); WrtPrfLng (lpCfgFil, lpSecNam, PI_MPXLOC, lpDigCfg->tdTMIDef.scSysCfg.sMpxLoc); WrtPrfLng (lpCfgFil, lpSecNam, PI_WAICAL, lpDigCfg->tdTMIDef.scSysCfg.sWaiCal); WrtPrfLng (lpCfgFil, lpSecNam, PI_TRMOOH, lpDigCfg->tdTMIDef.scSysCfg.sTrmOOH); WrtPrfLng (lpCfgFil, lpSecNam, PI_MAXSIL, lpDigCfg->tdTMIDef.lcLinCfg.sMaxSil); WrtPrfLng (lpCfgFil, lpSecNam, PI_MAXSND, lpDigCfg->tdTMIDef.lcLinCfg.sMaxSnd); WrtPrfLng (lpCfgFil, lpSecNam, PI_SILCMP, lpDigCfg->tdTMIDef.lcLinCfg.sSilCmp); WrtPrfLng (lpCfgFil, lpSecNam, PI_AGCMOD, lpDigCfg->tdTMIDef.lcLinCfg.sAGCMod); // WrtPrfLng (lpCfgFil, lpSecNam, PI_DIGINI, lpDigCfg->tdTMIDef.lcLinCfg.sDigIni); // WrtPrfLng (lpCfgFil, lpSecNam, PI_DIGTRM, lpDigCfg->tdTMIDef.lcLinCfg.sDigTrm); /********************************************************************/ /********************************************************************/ WrtPrfLng (lpCfgFil, lpSecNam, PI_FLASH_CHAR, lpDigCfg->dbDlgDCB.flashchr); WrtPrfLng (lpCfgFil, lpSecNam, PI_FLASH_TIME, lpDigCfg->dbDlgDCB.flashtm); WrtPrfLng (lpCfgFil, lpSecNam, PI_PAUSE_TIME, lpDigCfg->dbDlgDCB.pausetm); WrtPrfLng (lpCfgFil, lpSecNam, PI_DIGRATE, lpDigCfg->dbDlgDCB.digrate); WrtPrfLng (lpCfgFil, lpSecNam, PI_SCH_TM, lpDigCfg->dbDlgDCB.sch_tm); WrtPrfLng (lpCfgFil, lpSecNam, PI_P_BK, lpDigCfg->dbDlgDCB.p_bk); WrtPrfLng (lpCfgFil, lpSecNam, PI_P_MK, lpDigCfg->dbDlgDCB.p_mk); WrtPrfLng (lpCfgFil, lpSecNam, PI_P_IDD, lpDigCfg->dbDlgDCB.p_idd); WrtPrfLng (lpCfgFil, lpSecNam, PI_T_IDD, lpDigCfg->dbDlgDCB.t_idd); WrtPrfLng (lpCfgFil, lpSecNam, PI_OH_DLY, lpDigCfg->dbDlgDCB.oh_dly); WrtPrfLng (lpCfgFil, lpSecNam, PI_R_ON, lpDigCfg->dbDlgDCB.r_on); WrtPrfLng (lpCfgFil, lpSecNam, PI_R_OFF, lpDigCfg->dbDlgDCB.r_off); WrtPrfLng (lpCfgFil, lpSecNam, PI_R_IRD, lpDigCfg->dbDlgDCB.r_ird); WrtPrfLng (lpCfgFil, lpSecNam, PI_S_BNC, lpDigCfg->dbDlgDCB.s_bnc); WrtPrfLng (lpCfgFil, lpSecNam, PI_TTDATA, lpDigCfg->dbDlgDCB.ttdata); WrtPrfLng (lpCfgFil, lpSecNam, PI_MINPDON, lpDigCfg->dbDlgDCB.minpdon); WrtPrfLng (lpCfgFil, lpSecNam, PI_MINPDOFF, lpDigCfg->dbDlgDCB.minpdoff); WrtPrfLng (lpCfgFil, lpSecNam, PI_MINIPD, lpDigCfg->dbDlgDCB.minipd); WrtPrfLng (lpCfgFil, lpSecNam, PI_MINLCOFF, lpDigCfg->dbDlgDCB.minlcoff); WrtPrfLng (lpCfgFil, lpSecNam, PI_REDGE, lpDigCfg->dbDlgDCB.redge); WrtPrfLng (lpCfgFil, lpSecNam, PI_MAXPDOFF, lpDigCfg->dbDlgDCB.maxpdoff); WrtPrfLng (lpCfgFil, lpSecNam, PI_CSTINT, lpDigCfg->usCSTInt); /********************************************************************/ /********************************************************************/ *pmhCfgMem = GloAloRel (*pmhCfgMem); return (0); }
int main(int argc, char **argv) #endif { LPSTR tail; int i; #ifdef WGP_CONSOLE HINSTANCE hInstance = GetModuleHandle(NULL), hPrevInstance = NULL; #endif #ifndef WGP_CONSOLE # if defined( __MINGW32__) && !defined(_W64) # define argc _argc # define argv _argv # else /* MSVC, WATCOM, MINGW-W64 */ # define argc __argc # define argv __argv # endif #endif /* WGP_CONSOLE */ szModuleName = (LPSTR)malloc(MAXSTR+1); CheckMemory(szModuleName); /* get path to EXE */ GetModuleFileName(hInstance, (LPSTR) szModuleName, MAXSTR); if ((tail = (LPSTR)_fstrrchr(szModuleName,'\\')) != (LPSTR)NULL) { tail++; *tail = 0; } szModuleName = (LPSTR)realloc(szModuleName, _fstrlen(szModuleName)+1); CheckMemory(szModuleName); if (_fstrlen(szModuleName) >= 5 && _fstrnicmp(&szModuleName[_fstrlen(szModuleName)-5], "\\bin\\", 5) == 0) { int len = _fstrlen(szModuleName)-4; szPackageDir = (LPSTR)malloc(len+1); CheckMemory(szPackageDir); _fstrncpy(szPackageDir, szModuleName, len); szPackageDir[len] = '\0'; } else szPackageDir = szModuleName; #ifndef WGP_CONSOLE textwin.hInstance = hInstance; textwin.hPrevInstance = hPrevInstance; textwin.nCmdShow = nCmdShow; textwin.Title = "gnuplot"; #endif /* create structure of first graph window */ graphwin = (LPGW) calloc(1, sizeof(GW)); listgraphs = graphwin; /* locate ini file */ { char * inifile; get_user_env(); /* this hasn't been called yet */ inifile = gp_strdup("~\\wgnuplot.ini"); gp_expand_tilde(&inifile); /* if tilde expansion fails use current directory as default - that was the previous default behaviour */ if (inifile[0] == '~') { free(inifile); inifile = "wgnuplot.ini"; } #ifndef WGP_CONSOLE textwin.IniFile = inifile; #endif graphwin->IniFile = inifile; ReadMainIni(inifile, "WGNUPLOT"); } #ifndef WGP_CONSOLE textwin.IniSection = "WGNUPLOT"; textwin.DragPre = "load '"; textwin.DragPost = "'\n"; textwin.lpmw = &menuwin; textwin.ScreenSize.x = 80; textwin.ScreenSize.y = 80; textwin.KeyBufSize = 2048; textwin.CursorFlag = 1; /* scroll to cursor after \n & \r */ textwin.shutdown = MakeProcInstance((FARPROC)ShutDown, hInstance); textwin.AboutText = (LPSTR)malloc(1024); CheckMemory(textwin.AboutText); sprintf(textwin.AboutText, "Version %s patchlevel %s\n" \ "last modified %s\n" \ "%s\n%s, %s and many others\n" \ "gnuplot home: http://www.gnuplot.info\n", gnuplot_version, gnuplot_patchlevel, gnuplot_date, gnuplot_copyright, authors[1], authors[0]); textwin.AboutText = (LPSTR)realloc(textwin.AboutText, _fstrlen(textwin.AboutText)+1); CheckMemory(textwin.AboutText); menuwin.szMenuName = szMenuName; #endif pausewin.hInstance = hInstance; pausewin.hPrevInstance = hPrevInstance; pausewin.Title = "gnuplot pause"; graphwin->hInstance = hInstance; graphwin->hPrevInstance = hPrevInstance; #ifdef WGP_CONSOLE graphwin->lptw = NULL; #else graphwin->lptw = &textwin; #endif /* init common controls */ { INITCOMMONCONTROLSEX initCtrls; initCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX); initCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&initCtrls); } #ifndef WGP_CONSOLE if (TextInit(&textwin)) gp_exit(EXIT_FAILURE); textwin.hIcon = LoadIcon(hInstance, "TEXTICON"); SetClassLongPtr(textwin.hWndParent, GCLP_HICON, (LONG_PTR)textwin.hIcon); /* Note: we want to know whether this is an interactive session so that we can * decide whether or not to write status information to stderr. The old test * for this was to see if (argc > 1) but the addition of optional command line * switches broke this. What we really wanted to know was whether any of the * command line arguments are file names or an explicit in-line "-e command". * (This is a copy of a code snippet from plot.c) */ for (i = 1; i < argc; i++) { if (!stricmp(argv[i], "/noend")) continue; if ((argv[i][0] != '-') || (argv[i][1] == 'e')) { interactive = FALSE; break; } } if (interactive) ShowWindow(textwin.hWndParent, textwin.nCmdShow); if (IsIconic(textwin.hWndParent)) { /* update icon */ RECT rect; GetClientRect(textwin.hWndParent, (LPRECT) &rect); InvalidateRect(textwin.hWndParent, (LPRECT) &rect, 1); UpdateWindow(textwin.hWndParent); } # ifndef __WATCOMC__ /* Finally, also redirect C++ standard output streams. */ RedirectOutputStreams(TRUE); # endif #else /* WGP_CONSOLE */ #ifdef CONSOLE_SWITCH_CP /* Change codepage of console to match that of the graph window. WinExit() will revert this. Attention: display of characters does not work correctly with "Terminal" font! Users will have to use "Lucida Console" or similar. */ cp_input = GetConsoleCP(); cp_output = GetConsoleOutputCP(); if (cp_input != GetACP()) { cp_changed = TRUE; SetConsoleCP(GetACP()); /* keyboard input */ SetConsoleOutputCP(GetACP()); /* screen output */ SetFileApisToANSI(); /* file names etc. */ } #endif #endif gp_atexit(WinExit); if (!isatty(fileno(stdin))) setmode(fileno(stdin), O_BINARY); gnu_main(argc, argv); /* First chance to close help system for console gnuplot, second for wgnuplot */ WinCloseHelp(); gp_exit_cleanup(); return 0; }
/*-------------------------------------------------------------------------- * * Create Dialog Header * * This routine allocates a piece of global memory * and then fills in the dialog header structure and saves the * information in global memory. * LONG lStyle; Dialog box Style * int iX; Dialog box top left column * int iY; Dialog box top row * int icX; Dialog box width * int icY; Dialog box height * LPSTR lpszResource; Dialog box resource string * LPSTR lpszClass; Dialog box class string * LPSTR lpszCaption; Dialog box caption * *-------------------------------------------------------------------------- */ static BOOLEAN NEAR PASCAL _CreateDialogHeader( LONG lStyle, int iX, int iY, int icX, int icY, LPSTR lpszResource, LPSTR lpszClass, LPSTR lpszCaption, WORD dwPointSize, LPSTR lpszFaceName) { uWORD uwResourceLength, /* Length of resource string */ uwClassLength, /* Length of class string */ uwCaptionLength, /* Length of caption String */ uwPointSizeLength, /* Length of pointsize field */ uwFaceNameLength; /* Length of facename string */ DWORD dwMemLength; /* Dialog header memory allocation length */ DLGHDR DlgHdr; /* Dialog header structure */ LPSTR lpHdrData; /* Long Pointer to the header data */ LPSTR lpDlgHdr; /* Long pointer to dialog header structure */ int i; /* Loop index */ /* Initialize memory offset */ _wOffset = 0; /* set memory offset to ZERO */ /* Determine string lengths (including terminating null ) */ uwResourceLength = _fstrlen( lpszResource ) + 1; uwClassLength = _fstrlen( lpszClass ) + 1; uwCaptionLength = _fstrlen( lpszCaption ) + 1; uwPointSizeLength = (lStyle & DS_SETFONT) ? sizeof( WORD ) : 0; uwFaceNameLength = (lStyle & DS_SETFONT) ? _fstrlen( lpszFaceName ) + 1 : 0; /* Determine length of memory to allocate for dialog header */ dwMemLength = (DWORD)( sizeof( DLGHDR ) + uwResourceLength + uwClassLength + uwCaptionLength + uwPointSizeLength + uwFaceNameLength ); /* Allocate dialog template memory for dialog header and obtain handle */ _hDlgTemplate = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, dwMemLength ); /* Lock allocated memory for modification */ if (_hDlgTemplate && ((lpHdrData = GlobalLock(_hDlgTemplate)) != NULL) ) { /* Set dialog header structure data to passed in parameters */ DlgHdr.dtStyle = lStyle; DlgHdr.dtItemCount = 0; /* set to zero */ DlgHdr.dtX = iX; DlgHdr.dtY = iY; DlgHdr.dtCX = icX; DlgHdr.dtCY = icY; /* Get pointer to dialog header structure */ lpDlgHdr = (LPSTR)&DlgHdr; /* Copy dialog header structure to allocated memory */ for ( i = 0; i < sizeof( DLGHDR ); i++ ) *lpHdrData++ = *lpDlgHdr++; /* Copy resource string to allocated memory */ while ( ( *lpHdrData++ = *lpszResource++ ) ); /* Copy class string to allocated memory */ while ( ( *lpHdrData++ = *lpszClass++ ) ); /* Copy caption string to allocated memory */ while ( ( *lpHdrData++ = *lpszCaption++ ) ); if (lStyle & DS_SETFONT) { /* Copy point size to allocated memory */ *(LPWORD)lpHdrData = dwPointSize; lpHdrData += sizeof(WORD); /* Copy facename string to allocated memory */ while ( ( *lpHdrData++ = *lpszFaceName++ ) ); } /* Adjust memory offset past memory allocated for dialog header */ _wOffset += (WORD)dwMemLength; /* Unlock allocated memory */ GlobalUnlock( _hDlgTemplate ); } else { GlobalFree( _hDlgTemplate ); /* free allocated memory */ _hDlgTemplate = NULL; } return (BOOLEAN)(_hDlgTemplate != NULL); // Return TRUE if we have a template. }
/************************************* * * Search for a file in the following places: * - Current dir. * - /WINDOWS * - /WINDOWS/SYSTEM * - All directories listed in the system's $PATH$ variable. * * Call EnumFilesProc() if a matching file is found. * **************************************/ BOOL __export __far __pascal EnumFiles( char __far * szWildName, FILESENUMPROC EnumFilesProc, LPARAM lParam, BOOL Yield ) { char szWinDir[_MAX_PATH]; char szWinSysDir[_MAX_PATH]; char szCurrentDir[_MAX_PATH]; char szDir[_MAX_PATH]; char szFilePath[_MAX_PATH]; char szPathCopyBuffer[_MAX_PATH]; char __far * szPathCopy; char __far * szPath; char __far * szNextPath; struct _find_t FileInfo; int nPhase, nResult; BOOL bCallBack; MSG Msg; // Storage for messages pulled from windows message // queue. short int LastCharPos; /* Each phase equates to a different search path. */ for( nPhase = 1; nPhase < 5; nPhase ++ ) { /* If we should let other applications execute. */ if( Yield ) { while ( PeekMessage( &Msg, NULL, NULL, NULL, PM_REMOVE ) ) { TranslateMessage( &Msg ); DispatchMessage( &Msg ); } } switch( nPhase ) { /* PHASE 1: use current directory. */ case 1: getcwd( szDir, _MAX_PATH ); _fstrcpy( szCurrentDir, szDir ); break; /* PHASE 2: use windows directory */ case 2: GetWindowsDirectory( szDir, _MAX_PATH); _fstrcpy( szWinDir, szDir ); break; /* PHASE 3: use windows\system directory */ case 3: GetSystemDirectory( szDir, _MAX_PATH); _fstrcpy( szWinSysDir, szDir ); break; } /* For Phases #1 - #3. */ if( nPhase < 4 ) { if( FindFile( szDir, szWildName, &FileInfo ) ) { /* Start with file's path. */ _fstrcpy( szFilePath, szDir ); /* Is there already a dir. separator? */ LastCharPos = ( _fstrlen( szFilePath ) / sizeof(char) ) - 1; if( szFilePath[LastCharPos] != DIR_CHAR_SEPARATOR ) { _fstrcat( szFilePath, DIR_STRING_SEPARATOR ); } /* Use filename. */ _fstrcat( szFilePath, FileInfo.name ); /* Call EnumFilesProc() callback function. */ bCallBack = ( *EnumFilesProc )( szFilePath, lParam ); /* Does callback tell us to quit. */ if( !bCallBack ) return TRUE; /* Any more file? */ while( FindFile( NULL, NULL, &FileInfo ) ) { /* Start with file's path. */ _fstrcpy( szFilePath, szDir ); /* Is there already a dir. separator? */ LastCharPos = ( _fstrlen( szFilePath ) / sizeof(char) ) - 1; if( szFilePath[LastCharPos] != DIR_CHAR_SEPARATOR ) { _fstrcat( szFilePath, DIR_STRING_SEPARATOR ); } /* Use filename. */ _fstrcat( szFilePath, FileInfo.name ); /* Call EnumFilesProc() callback function. */ bCallBack = ( *EnumFilesProc )( szFilePath, lParam ); /* Does callback tell us to quit. */ if( !bCallBack ) return TRUE; } } } /* For Phase #4 - Use PATH. */ else { /* Is there a WIN_PATH set? */ szPath = getenv("WIN_PATH"); /* If no WIN_PATH set, use standard PATH variable. */ if( szPath == NULL ) szPath = getenv( "PATH" ); /* If we have some path to search. */ if( szPath != 0) { /* Make a copy of the path so that we can change with the copy. */ lstrcpy( (LPSTR) szPathCopyBuffer, (LPSTR) szPath ); szPathCopy = szPathCopyBuffer; /* Walk the path... */ for( szNextPath = szPathCopy; szNextPath && *szNextPath; szNextPath = szPathCopy) { /* If we should let other applications execute. */ if( Yield ) { while ( PeekMessage( &Msg, NULL, NULL, NULL, PM_REMOVE ) ) { TranslateMessage( &Msg ); DispatchMessage( &Msg ); } } /* Get the next element in the path and terminate it */ szPathCopy = strchr( szNextPath, AUTOEXEC_PATH_DELIMITER ); if( szPathCopy ) { *szPathCopy = 0; /* End the current part. */ szPathCopy++; /* Point to the next one. */ } /* If it's a directory that we've already visited - skip search. */ nResult = _fstricmp( szNextPath, szWinDir ); /* \Windows dir. */ if( nResult == 0 ) continue; nResult = _fstricmp( szNextPath, szWinSysDir ); /* \Windows\System dir. */ if( nResult == 0 ) continue; nResult = _fstricmp( szNextPath, szCurrentDir ); /* Original dir. */ if( nResult == 0 ) continue; if( FindFile( szNextPath, szWildName, &FileInfo ) ) { /* Start with file's path. */ _fstrcpy( szFilePath, szNextPath ); /* Is there already a dir. separator? */ LastCharPos = ( _fstrlen( szFilePath ) / sizeof(char) ) - 1; if( szFilePath[LastCharPos] != DIR_CHAR_SEPARATOR ) { _fstrcat( szFilePath, DIR_STRING_SEPARATOR ); } /* Use filename. */ _fstrcat( szFilePath, FileInfo.name ); /* Call EnumFilesProc() callback function. */ bCallBack = ( *EnumFilesProc )( szFilePath, lParam ); /* Does callback tell us to quit. */ if( !bCallBack ) return TRUE; while( FindFile( NULL, NULL, &FileInfo ) ) { /* Start with file's path. */ _fstrcpy( szFilePath, szNextPath ); /* Is there already a dir. separator? */ LastCharPos = ( _fstrlen( szFilePath ) / sizeof(char) ) - 1; if( szFilePath[LastCharPos] != DIR_CHAR_SEPARATOR ) { _fstrcat( szFilePath, DIR_STRING_SEPARATOR ); } /* Use filename. */ _fstrcat( szFilePath, FileInfo.name ); /* Call EnumFilesProc() callback function. */ bCallBack = ( *EnumFilesProc )( szFilePath, lParam ); /* Does callback tell us to quit. */ if( !bCallBack ) return TRUE; } } } } } } /* for loop. */ /* Return success. */ return( TRUE ); }
void main (int argc, char **argv, char **envp) { char szCurDir[FIOMAXNAM] = {'\0'}; char szAppDir[FIOMAXNAM] = {'\0'}; char szSrcFil[FIOMAXNAM] = {'\0'}; char szTrgSpc[FIOMAXNAM] = {'\0'}; WORD usRepFlg = 0; WORD usi; /********************************************************************/ /********************************************************************/ printf (MsgUseIni); /********************************************************************/ /* Get current working directory (with trailing slash). */ /* Get application executable directory; remove program file name. */ /********************************************************************/ xgetdcwd (szCurDir, FIOMAXNAM - 1); usi = _fstrlen (_fstrncpy (szAppDir, *argv, FIOMAXNAM)); while (usi--) if ('\\' == szAppDir[usi]) { szAppDir[usi+1] = '\0'; break; } /********************************************************************/ /* Check argument count. Skip program name */ /********************************************************************/ if (strncmp (*++argv, "-h", 2) == 0) DspHlpEnd (); if (argc < 2) UseErrEnd (NULL); /********************************************************************/ /* Get name of source file */ /********************************************************************/ strncpy (szSrcFil, *argv++, FIOMAXNAM); argc = argc - 2; /* Indicate name & 1 arg used */ /********************************************************************/ /* Get name of new file name (if specified) */ /********************************************************************/ if ((0 != argc) && (NULL == strchr (*argv, '-'))) { strncpy (szTrgSpc, *argv++, FIOMAXNAM); argc--; } /********************************************************************/ /********************************************************************/ IniSu4Hdr (&rbRepBlk.shSu4Hdr); /********************************************************************/ /********************************************************************/ while (0 < argc--) { if (!strcmp (*argv, "-a")) rbRepBlk.shSu4Hdr.ulEncFmt = DW_SWP(SU4PCMA08); else if (!strcmp (*argv, "-b")) usRepFlg |= BFRBKIFLG; else if (!strncmp (*argv, "-d", 2)) strncpy (rbRepBlk.shSu4Hdr.ucFilDes, &(*argv)[2], SU4DESLEN); else if (!strncmp (*argv, "-i", 2)) rbRepBlk.shSu4Hdr.ulFil_ID = DW_SWP((DWORD) atol (&(*argv)[2])); else if (!strncmp (*argv, "-l", 2)) rbRepBlk.shSu4Hdr.ulLibCod = DW_SWP((DWORD) atol (&(*argv)[2])); else UseErrEnd (*argv); *argv++; } /********************************************************************/ /********************************************************************/ BinFilRep (szSrcFil, szTrgSpc, usRepFlg, Su4ChkFil, Su4RepFil, Su4EndFil, NULL, &rbRepBlk); printf ("%ld converted\n", rbRepBlk.ulFilCnt); exit (0); }
/*-------------------------------------------------------------------------- * Function: _tdb_DoAssertDlg * Expects: char FAR * lpszTest * char FAR * lpszReason * char FAR * lpszFilename * uLONG ulLineNo * uLONG ulCount * void FAR * lpvData * uLONG ulFormat * Returns: int iUserSelection * Purpose: Setup and run the Macintosh Assertion Dialog * History: 10/28/94 MGD - Initial Revision *-------------------------------------------------------------------------- */ TDBAPI( int ) _tdb_DoAssertDlg( LPSZ lpszTest, LPSZ lpszReason, LPSZ lpszFilename, uLONG ulLineNo, uLONG ulCount, LPVOID lpvData, uLONG ulFormat ) { int iUserSelection = ID_OK; // In order to prevent possible nesting of DoAssertDlg. Only enter this section // if we are not currently displaying an Assert. In a true pre-emptive multi-threaded app // there is a small chance that we may execute the test and be paged out before setting // the boolean, but it is a small enough change that I am not going to worry about it for now. if ( !fInDoAssertDialog ) { fInDoAssertDialog = TRUE; if (_hDlgTemplate) { // Hey, Dude! DLGVALS dlgVals; FARPROC lpDlgTest = MakeProcInstance( (FARPROC) _tdb_AssertDlgProc, g_tdb_hinstApp ); dlgVals.lpszTest = lpszTest? lpszTest : _szEmpty; dlgVals.lpszReason = lpszReason? lpszReason : _szEmpty; dlgVals.lpszFilename = lpszFilename? lpszFilename : _szUnknown; dlgVals.ulLineNo = ulLineNo; dlgVals.ulCount = ulCount; dlgVals.lpvData = lpvData; dlgVals.ulFormat = ulFormat; dlgVals.hStackData = g_tdb_hStackData; iUserSelection = DialogBoxIndirectParam( g_tdb_hinstApp, _hDlgTemplate, g_tdb_hwndApp, lpDlgTest, (LPARAM)&dlgVals); FreeProcInstance(lpDlgTest); } else { int iret; int iApproxMessageSize; // To count the potential size of the message to make sure I // don't overflow the szMessageBufferSize sBYTE FAR* szBuf; iApproxMessageSize = wsprintf( _szMessageBoxBuffer, "%s%s\n%s%ld\n\n", _szFile, lpszFilename, _szLineNo, ulLineNo ); szBuf = _szMessageBoxBuffer + iApproxMessageSize; iApproxMessageSize += _fstrlen( lpszReason ); iApproxMessageSize += 256; // 256 is an unofficial size for the amount of data that will // be visible in an Assert as extra data // If there is any data to add and a rough calculation implies that the data will fit // in the buffer, include it. Otherwise, don't include it if ((ulCount > 0) && (iApproxMessageSize<MESSAGE_BUFFER_SIZE)) { switch (ulFormat) { case 'b': case 'B': _FormatBytes((sBYTE FAR*)lpvData, ulCount, szBuf); break; case 'w': case 'W': _FormatWords((sBYTE FAR*)lpvData, ulCount, szBuf); break; case 'l': case 'L': _FormatLongs((sBYTE FAR*)lpvData, ulCount, szBuf); break; case 's': case 'S': _FormatCStr((sBYTE FAR*)lpvData, szBuf); break; case 'p': case 'P': _FormatPStr((sBYTE FAR*)lpvData, szBuf); break; } _fstrcat( _szMessageBoxBuffer, _szCRLF ); _fstrcat( _szMessageBoxBuffer, _szCRLF ); } // Add the Reason to the buffer _fstrcat( _szMessageBoxBuffer, lpszReason ); iret = MessageBox(NULL, _szMessageBoxBuffer, ((lpszTest)? lpszTest : _szAssertFailed), MB_YESNOCANCEL | MB_TASKMODAL); switch (iret) { case IDYES: iUserSelection = ID_OK; break; case IDNO: iUserSelection = ID_TERMINATE; break; default: iUserSelection = ID_DEBUGGER; break; } } fInDoAssertDialog = FALSE; } return iUserSelection; }
FIORET FAR PASCAL VBSTxtWrt (OFSTRUCT_V FAR *pofDstFil, VBSHDR FAR *lpVBSHdr, VBIREC FAR *lpIdxArr, VISMEMHDL mhAnoMem, IDXSEG FAR *pisIdxSeg, FIOPOLPRC fpLngPolPrc, DWORD ulPolDat) { WORD usArrIdx; LPSTR lpAnoTxt; WORD usNewSiz; unsigned uiErrCod; short sDstHdl; /********************************************************************/ /********************************************************************/ if ((WORD) (usArrIdx = pisIdxSeg->usIdxNum - 1) >= (WORD) lpVBSHdr->ulIdxTot) return (FIORETERR); /********************************************************************/ /* For non auto-compressed file saves, zero current index */ /********************************************************************/ // if (!bfAutCmp) lpIdxArr[usArrIdx].ulTxtOff = 0; /********************************************************************/ /* Calculate new text length; if not zero, increment for terminator */ /* Note: usNewSiz = 0 deactivates text */ /********************************************************************/ if (NULL == (lpAnoTxt = GloMemLck (mhAnoMem))) return (FIORETBAD); usNewSiz = _fstrlen (lpAnoTxt); if (usNewSiz) usNewSiz++; /* Increment for null term */ /********************************************************************/ /* Exit if both original and new are zero length. */ /********************************************************************/ if ((0L == lpIdxArr[usArrIdx].ulTxtOff) && (0 == usNewSiz)) { GloMemUnL (mhAnoMem); return (FIORETSUC); } /********************************************************************/ /* Shift file to make room for annotation text */ /* Note: Non-zero annotation offset with zero text resets offset */ /********************************************************************/ if (FIORETSUC != ShfVBSFil (pofDstFil, lpVBSHdr, lpIdxArr, &lpIdxArr[usArrIdx].ulTxtOff, &pisIdxSeg->ulTxtSiz, (DWORD) usNewSiz, fpLngPolPrc, ulPolDat)) { MsgDspRes (FIOGlo.hLibIns, 0, SI_FILSHFERR); /* File Shift Err */ GloMemUnL (mhAnoMem); return (FIORETBAD); } pisIdxSeg->ulVoxOff = lpIdxArr[usArrIdx].ulVoxOff; pisIdxSeg->ulVoxLen = lpIdxArr[usArrIdx].ulVoxLen; pisIdxSeg->ulTxtOff = lpIdxArr[usArrIdx].ulTxtOff; pisIdxSeg->ulTxtSiz = (DWORD) usNewSiz; /********************************************************************/ /* Copy snippet text to indexed VBase work file */ /********************************************************************/ if (-1 == (sDstHdl = OFSFilOpn (pofDstFil, OF_READWRITE, SI_BADOPNDST))) { GloMemUnL (mhAnoMem); return (FIORETERR); } if (usNewSiz) { FilSetPos (sDstHdl, lpIdxArr[usArrIdx].ulTxtOff, SEEK_SET); if (-1 == Wr_FilFwd (sDstHdl, lpAnoTxt, usNewSiz, 0, &uiErrCod)) { GloMemUnL (mhAnoMem); FilHdlCls (sDstHdl); return (FIORETBAD); } } GloMemUnL (mhAnoMem); FilHdlCls (sDstHdl); /********************************************************************/ /********************************************************************/ return (FIORETSUC); }
/* PauseBox */ int WDPROC PauseBox(LPPW lppw) { MSG msg; HDC hdc; int width, height; TEXTMETRIC tm; RECT rect; char *current_pause_title = lppw->Title; static char TITLE_PAUSE_MOUSE[] = "waiting for mouse click"; if (paused_for_mouse) current_pause_title = TITLE_PAUSE_MOUSE; if (!lppw->hPrevInstance) CreatePauseClass(lppw); GetWindowRect(GetDesktopWindow(), &rect); if ( (lppw->Origin.x == CW_USEDEFAULT) || (lppw->Origin.x == 0) ) lppw->Origin.x = (rect.right + rect.left) / 2; if ( (lppw->Origin.y == CW_USEDEFAULT) || (lppw->Origin.y == 0) ) lppw->Origin.y = (rect.bottom + rect.top) / 2; hdc = GetDC(NULL); SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); GetTextMetrics(hdc, &tm); width = max(24,4+_fstrlen(lppw->Message)) * tm.tmAveCharWidth; width = min(width, rect.right-rect.left); height = 28 * (tm.tmHeight + tm.tmExternalLeading) / 4; ReleaseDC(NULL,hdc); #ifndef WIN32 lppw->lpfnPauseButtonProc = #ifdef __DLL__ (WNDPROC)GetProcAddress(hdllInstance, "PauseButtonProc"); #else (WNDPROC)MakeProcInstance((FARPROC)PauseButtonProc ,hdllInstance); #endif #endif lppw->hWndPause = CreateWindowEx( WS_EX_DLGMODALFRAME | WS_EX_TOPMOST #ifdef WS_EX_APPWINDOW /* HBB 20001217: put the pause window into the taskbar, and make * float on top of everything. This is cleaner than adding a window * menu to it, as the 3.5 code did it: */ | WS_EX_APPWINDOW #endif , szPauseClass, current_pause_title, /* HBB 981202: WS_POPUPWINDOW would have WS_SYSMENU in it, but we don't * want, nor need, a System menu in our Pause windows. Actually, it was * emptied manually, in the WM_CREATE handler below, in the original code. * This solution seems cleaner. */ WS_POPUP | WS_BORDER | WS_CAPTION, lppw->Origin.x - width/2, lppw->Origin.y - height/2, width, height, lppw->hWndParent, NULL, lppw->hInstance, lppw); SendMessage(lppw->hCancel, BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, (LPARAM)FALSE); /* Don't show the pause "OK CANCEL" dialog for "pause mouse ..." -- well, show it only for "pause -1". Note: maybe to show in the window titlebar or somewhere else a message like graphwin.Title = "gnuplot pausing (waiting for mouse click)"; */ if (!paused_for_mouse) { ShowWindow(lppw->hWndPause, SW_SHOWNORMAL); BringWindowToTop(lppw->hWndPause); UpdateWindow(lppw->hWndPause); } lppw->bPause = TRUE; lppw->bPauseCancel = IDCANCEL; while (lppw->bPause) { /* HBB 20021211: Nigel Nunn found a better way to avoid * 100% CPU load --> use it */ if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { /* wait until window closed */ TranslateMessage(&msg); DispatchMessage(&msg); } else WaitMessage(); } DestroyWindow(lppw->hWndPause); #ifndef WIN32 #ifndef __DLL__ FreeProcInstance((FARPROC)lppw->lpfnPauseButtonProc); #endif #endif return(lppw->bPauseCancel); }
/* * Grab the filename of COMMAND.COM * * If warn != 0, warnings can be issued; otherwise this functions * is silent. */ void grabComFilename(int warn, char far *fnam) { char *buf; size_t len; assert(fnam); /* Copy the filename into the local heap */ len = _fstrlen(fnam); if(len >= INT_MAX || len < 1) { /* no filename specified */ if(warn) error_syntax(NULL); return; } if((buf = malloc(len + 1)) == NULL) { if(warn) error_out_of_memory(); return ; } _fmemcpy((char far*)buf, fnam, len); buf[len] = '\0'; if (buf[1] != ':' || buf[2] != '\\') { char *p; /* expand the string for the user */ p = dfnexpand(buf, NULL); free(buf); if((buf = p) == NULL) { if(warn) error_out_of_memory(); return; } if(warn) error_init_fully_qualified(buf); } if(dfnstat(buf) & DFN_DIRECTORY) { /* The user specified a directory, try if we can find the COMMAND.COM with the standard name in there */ char *p; if((p = realloc(buf, len + sizeof(COM_NAME) + 1)) == NULL) { if(warn) error_out_of_memory(); free(buf); return; } buf = p; strcpy(&buf[len], "\\" COM_NAME); } if(!(dfnstat(buf) & DFN_FILE)) { /* not found */ if(warn) error_open_file(buf); free(buf); return; } free(ComPath); /* Save the found file */ ComPath = buf; }
static BOOLEAN NEAR PASCAL _CreateDialogItem( int iCtrlID, LONG lStyle, BYTE bClass, int iX, int iY, int icX, int icY, LPSTR lpszText, BYTE bExtraBytes ) { DLGITEM dlgItem; LPDLGHDR lpDlgHdr; LPSTR lpszCtrlData; /* Long pointer to locked dialog template memory */ LPSTR lpszDlgItem; /* Long pointer to dialog control structure */ int i; /* Loop index */ WORD wTextLength; /* Length of control text string */ DWORD dwMemLength; HANDLE hCurDlgTemp; // If dialog template is NULL - return FALSE; if (!_hDlgTemplate) return FALSE; dlgItem.dtilX = iX; dlgItem.dtilY = iY; dlgItem.dtilCX = icX; dlgItem.dtilCY = icY; dlgItem.dtilID = iCtrlID; if (bClass == (BYTE)0) _SetDefaultStyle( (int)lStyle, &dlgItem ); else { dlgItem.dtilControlClass = bClass; /* default, may change in next function */ dlgItem.dtilStyle = lStyle; } wTextLength = _fstrlen( lpszText ) + 1; dwMemLength = (DWORD)(_wOffset + sizeof(DLGITEM) + wTextLength + sizeof(BYTE) ); hCurDlgTemp = GlobalReAlloc( _hDlgTemplate, dwMemLength, GMEM_MOVEABLE); if (hCurDlgTemp == NULL) { GlobalFree( _hDlgTemplate ); _hDlgTemplate = NULL; return FALSE; } _hDlgTemplate = hCurDlgTemp; /* Adjust pointer to reallocated memory bypassing existing data */ if ( (lpszCtrlData = GlobalLock(hCurDlgTemp)) == NULL) { GlobalFree( _hDlgTemplate ); _hDlgTemplate = NULL; return FALSE; } lpDlgHdr = (LPDLGHDR)lpszCtrlData; lpszCtrlData += _wOffset; /* Get pointer to dialog control structure */ lpszDlgItem = (LPSTR)&dlgItem; /* Copy dialog control structure to allocated memory */ for ( i=0; i<sizeof( DLGITEM ); i++ ) *lpszCtrlData++ = *lpszDlgItem++; /* Copy control text string to allocated memory */ while ( ( *lpszCtrlData++ = *lpszText++ ) ); /* Copy extra byte count to allocated memory */ *lpszCtrlData = bExtraBytes; /* Adjust memory offset past memory reallocated for dialog control */ _wOffset += (WORD)( sizeof( dlgItem ) + wTextLength + sizeof(BYTE)); /* Increment the number of items in the dialog header */ ++(lpDlgHdr->dtItemCount); /* Unlock reallocated memory */ GlobalUnlock( _hDlgTemplate ); return( TRUE ); /* return successful */ }
LRESULT CALLBACK WINEXPORT WndPauseProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rect; TEXTMETRIC tm; LPPW lppw; int cxChar, cyChar, middle; lppw = (LPPW)GetWindowLong(hwnd, 0); switch(message) { case WM_KEYDOWN: if (wParam == VK_RETURN) { if (lppw->bDefOK) SendMessage(hwnd, WM_COMMAND, IDOK, 0L); else SendMessage(hwnd, WM_COMMAND, IDCANCEL, 0L); } return(0); case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: case IDOK: if (!paused_for_mouse) { /* ignore OK and Cancel buttons during "pause mouse" */ lppw->bPauseCancel = LOWORD(wParam); lppw->bPause = FALSE; } break; } return(0); case WM_SETFOCUS: SetFocus(lppw->bDefOK ? lppw->hOK : lppw->hCancel); return(0); case WM_PAINT: { hdc = BeginPaint(hwnd, &ps); SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); SetTextAlign(hdc, TA_CENTER); GetClientRect(hwnd, &rect); SetBkMode(hdc,TRANSPARENT); TextOut(hdc,(rect.right+rect.left)/2, (rect.bottom+rect.top)/6, lppw->Message,_fstrlen(lppw->Message)); EndPaint(hwnd, &ps); return 0; } case WM_CREATE: { int ws_opts = WS_CHILD | BS_DEFPUSHBUTTON; if (!paused_for_mouse) /* don't show buttons during pausing for mouse or key */ ws_opts |= WS_VISIBLE; /* HBB 981202 HMENU sysmenu = GetSystemMenu(hwnd, FALSE); */ lppw = ((CREATESTRUCT FAR *)lParam)->lpCreateParams; SetWindowLong(hwnd, 0, (LONG)lppw); lppw->hWndPause = hwnd; hdc = GetDC(hwnd); SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); GetTextMetrics(hdc, &tm); cxChar = tm.tmAveCharWidth; cyChar = tm.tmHeight + tm.tmExternalLeading; ReleaseDC(hwnd,hdc); middle = ((LPCREATESTRUCT) lParam)->cx / 2; lppw->hOK = CreateWindow((LPSTR)"button", (LPSTR)"OK", ws_opts, middle - 10*cxChar, 3*cyChar, 8*cxChar, 7*cyChar/4, hwnd, (HMENU)IDOK, ((LPCREATESTRUCT) lParam)->hInstance, NULL); lppw->bDefOK = TRUE; lppw->hCancel = CreateWindow((LPSTR)"button", (LPSTR)"Cancel", ws_opts, middle + 2*cxChar, 3*cyChar, 8*cxChar, 7*cyChar/4, hwnd, (HMENU)IDCANCEL, ((LPCREATESTRUCT) lParam)->hInstance, NULL); lppw->lpfnOK = (WNDPROC) GetWindowLong(lppw->hOK, GWL_WNDPROC); #ifdef WIN32 SetWindowLong(lppw->hOK, GWL_WNDPROC, (LONG)PauseButtonProc); #else SetWindowLong(lppw->hOK, GWL_WNDPROC, (LONG)lppw->lpfnPauseButtonProc); #endif lppw->lpfnCancel = (WNDPROC) GetWindowLong(lppw->hCancel, GWL_WNDPROC); #ifdef WIN32 SetWindowLong(lppw->hCancel, GWL_WNDPROC, (LONG)PauseButtonProc); #else SetWindowLong(lppw->hCancel, GWL_WNDPROC, (LONG)lppw->lpfnPauseButtonProc); #endif if (GetParent(hwnd)) EnableWindow(GetParent(hwnd),FALSE); #if 0 /* HBB 981203 */ DeleteMenu(sysmenu,SC_RESTORE,MF_BYCOMMAND); DeleteMenu(sysmenu,SC_SIZE,MF_BYCOMMAND); DeleteMenu(sysmenu,SC_MINIMIZE,MF_BYCOMMAND); DeleteMenu(sysmenu,SC_MAXIMIZE,MF_BYCOMMAND); DeleteMenu(sysmenu,SC_TASKLIST,MF_BYCOMMAND); DeleteMenu(sysmenu,0,MF_BYCOMMAND); /* a separator */ DeleteMenu(sysmenu,0,MF_BYCOMMAND); /* a separator */ #endif } return 0; case WM_DESTROY: GetWindowRect(hwnd, &rect); lppw->Origin.x = (rect.right+rect.left)/2; lppw->Origin.y = (rect.bottom+rect.top)/2; lppw->bPause = FALSE; if (GetParent(hwnd)) EnableWindow(GetParent(hwnd),TRUE); break; } return DefWindowProc(hwnd, message, wParam, lParam); }
void aliasexpand(char * const cmd, const int maxlen) { char *hbuf; /* work buffer */ char *cp, *p; unsigned ofs, *expanded, *he; int i, numExpanded; assert(cmd); assert(strlen(cmd) < maxlen); if((hbuf = malloc(maxlen)) == 0) { error_out_of_memory(); return; } numExpanded = 0; expanded = 0; redo: /* iteration to expand all aliases */ cp = ltrimcl(cmd); /* skip leading whitespaces */ /* Check if the user disabled alias expansion */ if(*cp == '*') { memmove(cmd, cp + 1, strlen(cp)); goto errRet; } /* Get the name of this command */ for(p = hbuf; is_fnchar(*cp) || *cp == '.';) *p++ = *cp++; if(p == hbuf || is_pathdelim(*cp) || is_quote(*cp)) /* no name || part of path -> no alias */ goto errRet; *p = 0; StrFUpr(hbuf); /* all aliases are uppercased */ if((ofs = env_findVar(ctxtAlias, hbuf)) == (unsigned)-1) /* not found -> no alias */ goto errRet; /* Prevent recursion by recording the offset of the found variable */ for(i = 0; i < numExpanded; ++i) if(expanded[i] == ofs) /* already used -> ignore */ goto errRet; if((he = realloc(expanded, ++numExpanded)) == 0) { error_out_of_memory(); goto errRet; } expanded = he; expanded[numExpanded - 1] = ofs; /************ Expand the command line "cp" with the alias at MK_FP(ctxtAlias, ofs) ***********************/ ofs += strlen(hbuf) + 1; /* advance to value */ if(_fstrlen(MK_FP(ctxtAlias, ofs)) < maxlen - strlen(cp)) { /* prepend alias value to remaining command line */ _fstrcpy(TO_FP(hbuf), MK_FP(ctxtAlias, ofs)); strcat(hbuf, cp); assert(strlen(hbuf) < maxlen); strcpy(cmd, hbuf); goto redo; /* next expansion */ } error_command_too_long(); errRet: /* return to caller */ free(expanded); free(hbuf); }