bool HDD_GetHddID (char *ModelNo, char *SerialNo, char *FirmwareNo) { char Buffer [512]; if (!HDD_IdentifyDevice (Buffer)) return FALSE; if (ModelNo) { strncpy (ModelNo, &Buffer [0x36], 40); ModelNo [40] = 0x00; RTrim(ModelNo); } if (SerialNo) { strncpy (SerialNo, &Buffer [0x14], 20); SerialNo [20] = 0x00; RTrim(SerialNo); } if (FirmwareNo) { strncpy (FirmwareNo, &Buffer [0x2e], 8); FirmwareNo [8] = 0x00; RTrim(FirmwareNo); } return TRUE; }
void main(void) { char src[50]=" option = valeur # commentaire"; char dest[30], dest2[30], option[30], valeur[30]; int pos=0; AllTrim(dest,src); pos=At(dest,"#"); if(pos) { if(pos>1) { Substr(dest2,dest,1,pos-1); RTrim(dest2); } } else strcpy(dest2,dest); printf("Ligne nettoyee= :%s:\n",dest2); pos=At(dest2,"="); if(!pos) printf("Attention, ce n'est pas une option.\n"); else { Substr(option,dest2,1,pos-1); RTrim(option); Substr(dest,dest2,pos+1,0); } }
bool CRecordSet::sColumnEx(const int iCol, char *sBuf, const int iBufSz, int *iOutLen) { int iLen = 0; if(SQL_SUCCEEDED(SQLGetData(hSTMT, iCol, SQL_C_CHAR, sBuf, iBufSz, (SQLINTEGER *)&iLen))) { if(iLen > iBufSz) { iLen = iBufSz; } if(bReplaceSingleQuotes) { ReplaceSingleQuotes(sBuf, iLen); } if(bTrimCharData) { iLen = RTrim(sBuf, iLen); } if(iOutLen) { *iOutLen = iLen; } return true; } else { ThrowErrorIfSet(); return false; } }
BOOLEAN procesoConsultaSaldoImp(void){ int costServ = 0; BYTE kbdbuff[10]; BYTE tmpPan[20 + 1]; //BYTE aux[10]; memset(kbdbuff, 0x00, sizeof(kbdbuff)); memset(tmpPan, 0x00, sizeof(tmpPan)); //memset(aux, 0x00, sizeof(aux)); costServ = RSP_DATA.dd_amount; DispClrBelowMW(MW_LINE2); DispLineMW( "Costo Servicio:", MW_LINE3, MW_LEFT|MW_SPFONT ); //split(aux, gToken_80.costoServicio, 2); //costServ = atoi(aux); DispAmnt( costServ, MW_LINE3, MW_SPFONT ); if( SiNo() != 2 ) { // 2 = Press Enter return FALSE; } DispLineMW( "DESLICE LA TARJETA", MW_LINE4, MW_SMFONT|MW_CENTER|MW_CLRDISP ); if( GetCard( FALSE, FALSE ) == FALSE ){ LongBeep(); DispLineMW( "CONSULTA DE SALDO", MW_LINE1, MW_CENTER|MW_REVERSE|MW_SMFONT|MW_CLRDISP ); DispLineMW( "TRANSACCION CANCELADA", MW_LINE3, MW_CENTER ); APM_WaitKey(200, 0); return FALSE; } do { DispLineMW( "CONSULTA DE SALDO", MW_LINE1, MW_CENTER|MW_REVERSE|MW_CLRDISP|MW_SMFONT ); DispLineMW( "INGRESE LOS ULTIMOS", MW_LINE3, MW_CENTER|MW_SPFONT ); DispLineMW( "CUATRO DIGITOS", MW_LINE4, MW_CENTER|MW_SPFONT ); DispLineMW( "DE LA TARJETA", MW_LINE5, MW_CENTER|MW_SPFONT ); memset(kbdbuff, 0x00, sizeof(kbdbuff)); APM_SetCol(7); // Set Columna for TextBox if (!APM_GetKbd(NUMERIC_INPUT + MW_SMFONT + MW_LINE7, IMIN(4) + IMAX(4), kbdbuff)){ return FALSE; } // Compara los ultimo 4 digitos del Pan memset( tmpPan, 0x00, sizeof(tmpPan) ); split( tmpPan, INPUT.sb_pan, 10 ); RTrim( tmpPan, 'F'); } while (memcmp(&kbdbuff[1], &tmpPan[strlen(tmpPan) - 4], 4) != 0); DispLineMW( "CONSULTA DE SALDO", MW_LINE1, MW_CENTER|MW_REVERSE|MW_SMFONT|MW_CLRDISP ); DispLineMW( "Costo Servicio:", MW_LINE3, MW_LEFT|MW_SPFONT ); DispAmnt(costServ, MW_LINE3, MW_SPFONT); if( !getPinblock() ) return FALSE; INPUT.dd_amount = costServ; // El costo del servicio debe viajar en el campo 4 en la proxima transaccion sprintf(gAmount, "%012d", INPUT.dd_amount); return TRUE; }
String CUtils::Trim(const String & data) { String aux(data); if (aux.length() == 0) return aux; aux = LTrim(aux); aux = RTrim(aux); return aux; }
BOOLEAN procesoConsultaSaldoCNB(void){ BYTE kbdbuff[10]; BYTE tmpPan[20 + 1]; //BYTE aux[10]; memset(kbdbuff, 0x00, sizeof(kbdbuff)); memset(tmpPan, 0x00, sizeof(tmpPan)); //memset(aux, 0x00, sizeof(aux)); DispClrBelowMW(MW_LINE2); DispLineMW( "CONSULTA SALDO CNB", MW_LINE1, MW_CENTER|MW_REVERSE|MW_CLRDISP|MW_SMFONT ); DispLineMW( "DESLICE LA TARJETA", MW_LINE4, MW_SMFONT|MW_CENTER|MW_CLRDISP ); if( GetCard( FALSE, FALSE ) == FALSE ){ LongBeep(); DispLineMW( "CONSULTA SALDO CNB", MW_LINE1, MW_CENTER|MW_REVERSE|MW_SMFONT|MW_CLRDISP ); DispLineMW( "TRANSACCION CANCELADA", MW_LINE3, MW_CENTER ); APM_WaitKey(200, 0); return FALSE; } do { DispLineMW( "CONSULTA SALDO CNB", MW_LINE1, MW_CENTER|MW_REVERSE|MW_CLRDISP|MW_SMFONT ); DispLineMW( "INGRESE LOS ULTIMOS", MW_LINE3, MW_CENTER|MW_SPFONT ); DispLineMW( "CUATRO DIGITOS", MW_LINE4, MW_CENTER|MW_SPFONT ); DispLineMW( "DE LA TARJETA", MW_LINE5, MW_CENTER|MW_SPFONT ); memset(kbdbuff, 0x00, sizeof(kbdbuff)); APM_SetCol(7); // Set Columna for TextBox if (!APM_GetKbd(NUMERIC_INPUT + MW_SMFONT + MW_LINE7, IMIN(4) + IMAX(4), kbdbuff)){ return FALSE; } // Compara los ultimo 4 digitos del Pan memset( tmpPan, 0x00, sizeof(tmpPan) ); split( tmpPan, INPUT.sb_pan, 10 ); RTrim( tmpPan, 'F'); } while (memcmp(&kbdbuff[1], &tmpPan[strlen(tmpPan) - 4], 4) != 0); DispLineMW( "CONSULTA SALDO CNB", MW_LINE1, MW_CENTER|MW_REVERSE|MW_SMFONT|MW_CLRDISP ); if( !getPinblock() ) return FALSE; return TRUE; }
void test_util() { char tmp[100]; strcpy(tmp,"strIng"); printf("test string Lower to Upper\n"); printf("before:%s\n",tmp); StrToUpper(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp,"STRiNG"); printf("test string Lower to Upper\n"); printf("before:%s\n",tmp); StrToLower(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp,"STRiNG "); printf("test string remove right space\n"); printf("before:%s\n",tmp); RTrim(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp," STRiNG"); printf("test string remove left space\n"); printf("before:%s\n",tmp); LTrim(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp," STRiNG "); printf("test string remove left and right space\n"); printf("before:%s\n",tmp); Trim(tmp); printf("after:%s\n",tmp); }
void AxString::Trim() { RTrim(); LTrim(); }
inline std::string& Trim(std::string &s) { return LTrim(RTrim(s)); }
void Trim( txstring& wsInOut ) { RTrim(wsInOut); LTrim(wsInOut); }
CString CString::TrimEnd() { return RTrim(); }
static std::string Trim(std::string instr) { return LTrim(RTrim(instr)); }
//////////////////////////////////////////////////////////////////////////////// // G e t U S B D e v i c e s //////////////////////////////////////////////////////////////////////////////// INT GetUSBDevices( INT nMaxDevices, USB_DEVICE_NAME *lpUsbDevices, USB_ERROR_INFO *lpUsbErrorInfo ) { int ii; DWORD dwBytes; INT nDeviceFound; HDEVINFO hDevInfo; LPTSTR lpToken, lpWorkToken; GUID guidUSBDeviceSupport; HANDLE hUsbPrinter; SP_DEVICE_INTERFACE_DATA deviceInterfaceData; PSP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData; char szUsb1284[1024]; int nDeviceIndex; HINSTANCE pSetupAPI = NULL; FAR HDEVINFO ( FAR WINAPI *SetupDiGetClassDevs )(CONST GUID *, PCTSTR, HWND, DWORD); FAR BOOL ( FAR WINAPI *SetupDiEnumDeviceInterfaces )(HDEVINFO, PSP_DEVINFO_DATA, CONST GUID *,DWORD, PSP_DEVICE_INTERFACE_DATA); FAR BOOL ( FAR WINAPI *SetupDiGetDeviceInterfaceDetail )(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA, DWORD, PDWORD, PSP_DEVINFO_DATA); FAR BOOL ( FAR WINAPI *SetupDiDestroyDeviceInfoList )(HDEVINFO); // // The functions SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces , // SetupDiGetDeviceInterfaceDetail, SetupDiDestroyDeviceInfoList // are supported only on Windows 2000 and above and Windows 98 and above. // So link them dynamically to avoid windows errors. // pSetupAPI = LoadLibrary( "Setupapi" ); if ( pSetupAPI != NULL ) { SetupDiGetClassDevs = ( HDEVINFO ( WINAPI * )(CONST GUID *, PCTSTR, HWND, DWORD)) GetProcAddress( pSetupAPI, "SetupDiGetClassDevsA" ); if ( SetupDiGetClassDevs == NULL ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_FUNCTION; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to get a pointer to SetupDiGetClassDevs"); FreeLibrary( pSetupAPI ); return 0; } SetupDiEnumDeviceInterfaces = ( BOOL ( WINAPI * )(HDEVINFO, PSP_DEVINFO_DATA, CONST GUID *,DWORD, PSP_DEVICE_INTERFACE_DATA)) GetProcAddress( pSetupAPI, "SetupDiEnumDeviceInterfaces" ); if ( SetupDiEnumDeviceInterfaces == NULL ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_FUNCTION; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to get a pointer to SetupDiEnumDeviceInterfaces"); FreeLibrary( pSetupAPI ); return 0; } SetupDiGetDeviceInterfaceDetail = ( BOOL ( WINAPI * )(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA, DWORD, PDWORD, PSP_DEVINFO_DATA)) GetProcAddress( pSetupAPI, "SetupDiGetDeviceInterfaceDetailA" ); if ( SetupDiGetDeviceInterfaceDetail == NULL ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_FUNCTION; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to get a pointer to SetupDiGetDeviceInterfaceDetailA"); FreeLibrary( pSetupAPI ); return 0; } SetupDiDestroyDeviceInfoList = ( BOOL ( WINAPI * )(HDEVINFO)) GetProcAddress( pSetupAPI, "SetupDiDestroyDeviceInfoList" ); if ( SetupDiDestroyDeviceInfoList == NULL ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_FUNCTION; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to get a pointer to SetupDiDestroyDeviceInfoList"); FreeLibrary( pSetupAPI ); return 0; } } else { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_HANDLE; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to load Setupapi!"); return 0; } // // initialize local variables and initialize error // struct if a non NULL pointer was passed. // nDeviceFound = 0; if ( NULL != lpUsbErrorInfo ) InitError( lpUsbErrorInfo ); // // validate that the user passed in the number of // available USE_DEVICE_NAMES to fill with inofrmation. // if ( 0 == nMaxDevices ) { if ( NULL != lpUsbErrorInfo ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_DATA; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : nMaxDevices has a value of zero!"); } return 0; }; // // check that we can pass information back to the calling application! // if ( NULL == lpUsbDevices ) { if ( NULL != lpUsbErrorInfo ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_DATA; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : lpUsbDevices is NULL!" ); } return 0; } // // get a handle to the set of device information returned by the Win32 API // functions. This handle points to an object that is then operated on // by the SetupDiEnumDeviceInterfaces function. // guidUSBDeviceSupport = GUID_CLASS_USB_DEVICE; hDevInfo = SetupDiGetClassDevs( &guidUSBDeviceSupport, 0, 0, 0x12); // TODO : Determine the constant if ( INVALID_HANDLE_VALUE == hDevInfo ) { if ( NULL != lpUsbErrorInfo ) { // get the last error from system lpUsbErrorInfo->dwSysLastError = GetLastError(); // get the system defined message FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, lpUsbErrorInfo->dwSysLastError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), lpUsbErrorInfo->szSysErrorMsg, sizeof(lpUsbErrorInfo->szSysErrorMsg) / sizeof(lpUsbErrorInfo->szSysErrorMsg[0]), NULL ); } } // // // nDeviceFound = nDeviceIndex = 0; deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); for (nDeviceIndex = 0; SetupDiEnumDeviceInterfaces( hDevInfo, NULL, &guidUSBDeviceSupport, nDeviceIndex, &deviceInterfaceData ); nDeviceIndex++) { // // determine the amout of memory we need to allocate for the next // call to this function // dwBytes= 0; ii = SetupDiGetDeviceInterfaceDetail( hDevInfo, &deviceInterfaceData, NULL, 0, &dwBytes, NULL ); if ( 0 == dwBytes ) { // // Reinitialize the data for next pass // through this loop. // deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); continue; } //Set cbSize in the detailData structure. deviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc (dwBytes); deviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); // // get the device path for the current device we are enumerating over. // ii = SetupDiGetDeviceInterfaceDetail( hDevInfo, &deviceInterfaceData, deviceInterfaceDetailData, dwBytes, &dwBytes, NULL ); if ( 0 == ii ) { // // Free DetailData struct and reinitialize the data for next pass // through this loop. // free(deviceInterfaceDetailData); deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); continue; } // // get handle to the device so that we can // hUsbPrinter = CreateFile( deviceInterfaceDetailData->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ); // // // if ( INVALID_HANDLE_VALUE == hUsbPrinter ) { // // Free DetailData struct and reinitialize the data for next pass // through this loop. // free(deviceInterfaceDetailData); deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); continue; } // // // dwBytes = 0; memset( szUsb1284, 0, sizeof(szUsb1284) ); ii = DeviceIoControl( hUsbPrinter, IOCTL_USBPRINT_GET_1284_ID, NULL, 0, szUsb1284, sizeof(szUsb1284), &dwBytes, NULL ); // // // CloseHandle( hUsbPrinter ); // // parse the PNP string returned from the device. // lpToken = strtok( szUsb1284, PNP_DELIMITOR ); while ( NULL != lpToken ) { // have the manfacturer. lpWorkToken = strstr(lpToken, MFG_TOKEN); if (lpWorkToken != NULL) { strcpy( lpUsbDevices[nDeviceFound].szDeviceMfg, lpWorkToken + MFG_TOKEN_LEN); RTrim( lpUsbDevices[nDeviceFound].szDeviceMfg ); } // model of the printer lpWorkToken = strstr(lpToken, MDL_TOKEN); if (lpWorkToken != NULL) { strcpy( lpUsbDevices[nDeviceFound].szDevicePdt, lpWorkToken + MDL_TOKEN_LEN ); RTrim( lpUsbDevices[nDeviceFound].szDevicePdt ); } // next token lpToken = strtok( NULL, PNP_DELIMITOR ); } // // if the we don't manage to get BOTH the manufacturer and the product // of the USB printer then don't return information back the calling code. // if ( strlen(lpUsbDevices[nDeviceFound].szDeviceMfg) + strlen(lpUsbDevices[nDeviceFound].szDevicePdt) > 1 ) { nDeviceFound++; //break after getting the number of devices requested. if (nMaxDevices == nDeviceFound) { free(deviceInterfaceDetailData); break; } } else { lpUsbDevices[nDeviceFound].szDeviceMfg[0] = lpUsbDevices[nDeviceFound].szDevicePdt[0] = 0; } // // Free DetailData struct and reinitialize the data for next pass // through this loop. // free(deviceInterfaceDetailData); deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); } // //Destroy device information set and free all associated memory. // SetupDiDestroyDeviceInfoList(hDevInfo); // //Free setupapi library // FreeLibrary( pSetupAPI ); return nDeviceFound; }
//////////////////////////////////////////////////////////////////////////////// // O p e n U S B D e v i c e //////////////////////////////////////////////////////////////////////////////// HANDLE OpenUSBDevice( LPCSTR lpMfg, LPCSTR lpPdt, USB_ERROR_INFO *lpUsbErrorInfo ) { int ii; DWORD dwBytes; BOOL bFoundMfg; BOOL bFoundPdt; LPTSTR lpToken, lpWorkToken; int nDeviceIndex; HDEVINFO hDevInfo; HANDLE hUsbPrinter; char szUsb1284[1024]; GUID guidUSBDeviceSupport; SP_DEVICE_INTERFACE_DATA deviceInterfaceData; PSP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData; HINSTANCE pSetupAPI = NULL; FAR HDEVINFO ( FAR WINAPI *SetupDiGetClassDevs )(CONST GUID *, PCTSTR, HWND, DWORD); FAR BOOL ( FAR WINAPI *SetupDiEnumDeviceInterfaces )(HDEVINFO, PSP_DEVINFO_DATA, CONST GUID *,DWORD, PSP_DEVICE_INTERFACE_DATA); FAR BOOL ( FAR WINAPI *SetupDiGetDeviceInterfaceDetail )(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA, DWORD, PDWORD, PSP_DEVINFO_DATA); FAR BOOL ( FAR WINAPI *SetupDiDestroyDeviceInfoList )(HDEVINFO); // // The functions SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces , // SetupDiGetDeviceInterfaceDetail, SetupDiDestroyDeviceInfoList // are supported only on Windows 2000 and above and Windows 98 and above. // So link them dynamically to avoid windows errors. // pSetupAPI = LoadLibrary( "Setupapi" ); if ( pSetupAPI != NULL ) { SetupDiGetClassDevs = ( HDEVINFO ( WINAPI * )(CONST GUID *, PCTSTR, HWND, DWORD)) GetProcAddress( pSetupAPI, "SetupDiGetClassDevsA" ); if ( SetupDiGetClassDevs == NULL ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_FUNCTION; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to get a pointer to SetupDiGetClassDevs"); FreeLibrary( pSetupAPI ); return 0; } SetupDiEnumDeviceInterfaces = ( BOOL ( WINAPI * )(HDEVINFO, PSP_DEVINFO_DATA, CONST GUID *,DWORD, PSP_DEVICE_INTERFACE_DATA)) GetProcAddress( pSetupAPI, "SetupDiEnumDeviceInterfaces" ); if ( SetupDiEnumDeviceInterfaces == NULL ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_FUNCTION; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to get a pointer to SetupDiEnumDeviceInterfaces"); FreeLibrary( pSetupAPI ); return 0; } SetupDiGetDeviceInterfaceDetail = ( BOOL ( WINAPI * )(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA, DWORD, PDWORD, PSP_DEVINFO_DATA)) GetProcAddress( pSetupAPI, "SetupDiGetDeviceInterfaceDetailA" ); if ( SetupDiGetDeviceInterfaceDetail == NULL ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_FUNCTION; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to get a pointer to SetupDiGetDeviceInterfaceDetailA"); FreeLibrary( pSetupAPI ); return 0; } SetupDiDestroyDeviceInfoList = ( BOOL ( WINAPI * )(HDEVINFO)) GetProcAddress( pSetupAPI, "SetupDiDestroyDeviceInfoList" ); if ( SetupDiDestroyDeviceInfoList == NULL ) { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_FUNCTION; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to get a pointer to SetupDiDestroyDeviceInfoList"); FreeLibrary( pSetupAPI ); return 0; } } else { lpUsbErrorInfo->dwSysLastError = ERROR_INVALID_HANDLE; strcpy( lpUsbErrorInfo->szSysErrorMsg, "ERROR : Unable to load Setupapi!"); return 0; } // // get a handle to the set of device information returned by the Win32 API // functions. This handle points to an object that is then operated on // by the SetupDiEnumDeviceInterfaces function. // InitError( lpUsbErrorInfo ); guidUSBDeviceSupport = GUID_CLASS_USB_DEVICE; hDevInfo = SetupDiGetClassDevs( &guidUSBDeviceSupport, NULL, NULL, 0x12 ); // TODO : Determine the constant if ( INVALID_HANDLE_VALUE == hDevInfo ) { if ( NULL != lpUsbErrorInfo ) { // get the last error from system lpUsbErrorInfo->dwSysLastError = GetLastError(); // get the system defined message FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, lpUsbErrorInfo->dwSysLastError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), lpUsbErrorInfo->szSysErrorMsg, sizeof(lpUsbErrorInfo->szSysErrorMsg) / sizeof(lpUsbErrorInfo->szSysErrorMsg[0]), NULL ); } } // // // nDeviceIndex = 0; bFoundMfg = bFoundPdt = FALSE; hUsbPrinter = INVALID_HANDLE_VALUE; deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); for ( nDeviceIndex = 0; SetupDiEnumDeviceInterfaces( hDevInfo, NULL, &guidUSBDeviceSupport, nDeviceIndex, &deviceInterfaceData ); nDeviceIndex++ ) { // // determine the amout of memory we need to allocate for the next // call to this function // dwBytes= 0; ii = SetupDiGetDeviceInterfaceDetail( hDevInfo, &deviceInterfaceData, NULL, 0, &dwBytes, NULL ); if ( 0 == dwBytes ) { // // Reinitialize the data for next pass // through this loop. // deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); continue; } deviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(dwBytes); deviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); // // get the device path for the current device we are enumerating over. // ii = SetupDiGetDeviceInterfaceDetail( hDevInfo, &deviceInterfaceData, deviceInterfaceDetailData, dwBytes, &dwBytes, NULL ); if ( 0 == ii ) { // // Free DetailData struct and reinitialize the data for next pass //through this loop. // free(deviceInterfaceDetailData); deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); continue; } // // get handle to the device so that we can // hUsbPrinter = CreateFile( deviceInterfaceDetailData->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ); // // // if ( INVALID_HANDLE_VALUE == hUsbPrinter ) { // // Free DetailData struct and reinitialize the data for next pass // through this loop. // free(deviceInterfaceDetailData); deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); continue; } // // // dwBytes = 0; memset( szUsb1284, 0, sizeof(szUsb1284) ); ii = DeviceIoControl( hUsbPrinter, IOCTL_USBPRINT_GET_1284_ID, NULL, 0, szUsb1284, sizeof(szUsb1284), &dwBytes, NULL ); // // parse the PNP string returned from the device. // lpToken = strtok( szUsb1284, PNP_DELIMITOR ); while ( NULL != lpToken ) { // have the manfacturer. lpWorkToken = strstr(lpToken,MFG_TOKEN); if ( lpWorkToken != NULL ) { RTrim(lpWorkToken); if ( strcmp( lpMfg, lpWorkToken + MFG_TOKEN_LEN ) == 0 ) bFoundMfg = TRUE; } // model of the printer lpWorkToken = strstr(lpToken,MDL_TOKEN); if ( lpWorkToken != NULL ) { RTrim(lpWorkToken); if ( strcmp( lpPdt, lpWorkToken + MDL_TOKEN_LEN ) == 0 ) bFoundPdt = TRUE; } // next token lpToken = strtok( NULL, PNP_DELIMITOR ); } // // // if ( bFoundMfg && bFoundPdt ) { free(deviceInterfaceDetailData); break; } // // // CloseHandle( hUsbPrinter ); hUsbPrinter = INVALID_HANDLE_VALUE; // // Free DetailData struct and reinitialize the data for next pass // through this loop. // free(deviceInterfaceDetailData); deviceInterfaceData.cbSize = sizeof(deviceInterfaceData); } // //Destroy device information set and free all associated memory. // SetupDiDestroyDeviceInfoList(hDevInfo); // //Free setupapi library // FreeLibrary( pSetupAPI ); // // // return hUsbPrinter; }
inline std::string& TrimQuotes(std::string& s) { TrimPred qpred = [](char c) { return c != '\'' && c != '\"'; }; return LTrim(RTrim(s, qpred), qpred); }
inline std::string& TrimWhitespace(std::string& s) { TrimPred wspred = std::not1(std::ptr_fun<int, int>(std::isspace)); return LTrim(RTrim(s, wspred), wspred); }
inline std::string& Trim(std::string& s, const TrimPred& pred) { return LTrim(RTrim(s, pred), pred); }
void Trim(string& strStr) { LTrim(strStr); RTrim(strStr); }
int TAP_Main (void) { AddTime(0, 0); BMP_WriteHeader(NULL, 0, 0); BootReason(); BuildWindowBorder(); BuildWindowInfo(); BuildWindowLine(); BuildWindowLineSelected(); BuildWindowScrollBar(); BuildWindowTitle(); busyWait(); CalcAbsSectorFromFAT(NULL, 0); CalcPrepare(); CalcTopIndex(0, 0); Callback(0, NULL, 0, 0, 0, 0); CallbackHelper(NULL, NULL, 0, 0, 0, 0); CallBIOS(0, 0, 0, 0, 0); CallFirmware(0, 0, 0, 0, 0); CallTraceEnable(FALSE); CallTraceEnter(NULL); CallTraceExit(NULL); CallTraceInit(); CaptureScreen(0, 0, 0, NULL, 0, 0); ChangeDirRoot(); CheckSelectable(0, 0); combineVfdData(NULL, NULL); compact(NULL, 0); CompressBlock(NULL, 0, NULL); CompressedTFDSize(NULL, 0, NULL); CompressTFD(NULL, 0, NULL, 0, 0, NULL); CRC16(0, NULL, 0); CRC32 (0, NULL, 0); Delay(0); DialogEvent(NULL, NULL, NULL); DialogMsgBoxButtonAdd(NULL, FALSE); DialogMsgBoxExit(); DialogMsgBoxInit(NULL, NULL, NULL, NULL); DialogMsgBoxShow(); DialogMsgBoxShowInfo(0); DialogMsgBoxShowOK(); DialogMsgBoxShowOKCancel(0); DialogMsgBoxShowYesNo(0); DialogMsgBoxShowYesNoCancel(0); DialogMsgBoxTitleSet(NULL, NULL); DialogProfileChange(NULL); DialogProfileCheck(NULL, NULL, FALSE); DialogProfileLoad(NULL); DialogProfileLoadDefault(); DialogProfileLoadMy(NULL, FALSE); DialogProfileSave(NULL); DialogProfileSaveDefault(); DialogProfileScrollBehaviourChange(FALSE, FALSE); DialogProgressBarExit(); DialogProgressBarInit(NULL, NULL, 0, 0, NULL, 0, 0); DialogProgressBarSet(0, 0); DialogProgressBarShow(); DialogProgressBarTitleSet(NULL); DialogWindowChange(NULL, FALSE); DialogWindowCursorChange(FALSE); DialogWindowCursorSet(0); DialogWindowExit(); DialogWindowHide(); DialogWindowInfoAddIcon(0, 0, NULL); DialogWindowInfoAddS(0, 0, 0, NULL, 0, 0, 0, 0, 0); DialogWindowInfoDeleteAll(); DialogWindowInit(NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, 0, 0, 0); DialogWindowItemAdd(NULL, 0, NULL, 0, FALSE, FALSE, 0, NULL); DialogWindowItemAddSeparator(); DialogWindowItemChangeFlags(0, FALSE, FALSE); DialogWindowItemChangeIcon(0, 0, NULL); DialogWindowItemChangeParameter(0, NULL, 0); DialogWindowItemChangeValue(0, NULL, 0); DialogWindowItemDelete(0); DialogWindowItemDeleteAll(); DialogWindowRefresh(); DialogWindowReInit(0, 0, 0, 0, 0, 0); DialogWindowScrollDown(); DialogWindowScrollDownPage(); DialogWindowScrollUp(); DialogWindowScrollUpPage(); DialogWindowShow(); DialogWindowTabulatorSet(0, 0); DialogWindowTitleChange(NULL, NULL, NULL); DialogWindowTypeChange(0); DrawMsgBoxButtons(); DrawMsgBoxTitle(); DrawOSDLine(0, 0, 0, 0, 0, 0); DrawProgressBarBar(0, 0); DrawProgressBarTitle(); DrawWindowBorder(); DrawWindowInfo(); DrawWindowLine(0); DrawWindowLines(); DrawWindowScrollBar(); DrawWindowTitle(); EndMessageWin(); exitHook(); ExtractLine(NULL, NULL); FileSelector(NULL, NULL, NULL, 0); FileSelectorKey(0, 0); FindDBTrack(); FindInstructionSequence(NULL, NULL, 0, 0, 0, 0); findSendToVfdDisplay(0, 0); FlashAddFavourite(NULL, 0, FALSE); FlashDeleteFavourites(); FlashFindEndOfServiceNameTableAddress(); FlashFindEndOfServiceTableAddress(0); FlashFindServiceAddress(0, 0, 0, 0); FlashFindTransponderIndex(0, 0, 0); FlashGetBlockStartAddress(0); FlashGetChannelNumber(0, 0, 0, 0); FlashGetSatelliteByIndex(0); FlashGetServiceByIndex(0, FALSE); FlashGetServiceByName (NULL, FALSE); FlashGetTransponderCByIndex(0); FlashGetTransponderSByIndex(0, 0); FlashGetTransponderTByIndex(0); FlashGetTrueLocalTime(0, 0); FlashGetType(); FlashInitialize(0); FlashProgram(); FlashReindexFavourites(0, 0, 0); FlashReindexTimers(0, 0, 0); FlashRemoveCASServices(FALSE); FlashRemoveServiceByIndex(0, FALSE); FlashRemoveServiceByIndexString(NULL, FALSE); FlashRemoveServiceByLCN(NULL, FALSE); FlashRemoveServiceByName(NULL, FALSE); FlashRemoveServiceByPartOfName(NULL, FALSE); FlashRemoveServiceByUHF(NULL, FALSE, FALSE); FlashServiceAddressToServiceIndex(NULL); FlashWrite(NULL, NULL, 0, NULL); FlushCache(NULL, 0); FreeOSDRegion(0); fwHook(0); GetAudioTrackPID(0, NULL); GetClusterPointer(0); GetCurrentEvent(NULL); GetEEPROMAddress(); GetEEPROMPin(); GetFrameBufferPixel(0, 0); GetFrameSize(0, 0); GetFWInfo(0, 0, 0, 0, 0, 0, 0, 0); GetHeapParameter(NULL, 0); GetLine(NULL, 0); GetOSDMapAddress(); GetOSDRegionHeight(0); GetOSDRegionWidth(0); GetPinStatus(); GetPIPPosition(NULL, NULL, NULL, NULL); getRECSlotAddress(); GetSysOsdControl(0); GetToppyString(0); HasEnoughItemMemory(); HDD_AAM_Disable(); HDD_AAM_Enable(0); HDD_APM_Disable(); HDD_APM_Enable(0); HDD_BigFile_Read(NULL, 0, 0, NULL); HDD_BigFile_Size(NULL); HDD_BigFile_Write(NULL, 0, 0, NULL); HDD_ChangeDir(NULL); HDD_DecodeRECHeader(NULL, NULL); HDD_EncodeRECHeader(NULL, NULL, 0); HDD_FappendOpen(NULL); HDD_FappendWrite(NULL, NULL); HDD_FindPCR(NULL, 0); HDD_FindPMT(NULL, 0, NULL); HDD_FreeSize(); HDD_GetClusterSize(); HDD_GetFileDir(NULL, 0, NULL); HDD_GetFirmwareDirCluster(); HDD_GetHddID(NULL, NULL, NULL); HDD_IdentifyDevice(NULL); HDD_isAnyRecording(); HDD_isCryptedStream(NULL, 0); HDD_isRecording(0); HDD_LiveFS_GetChainLength(0); HDD_LiveFS_GetFAT1Address(); HDD_LiveFS_GetFAT2Address(); HDD_LiveFS_GetFirstCluster(0); HDD_LiveFS_GetLastCluster(0); HDD_LiveFS_GetNextCluster(0); HDD_LiveFS_GetPreviousCluster(0); HDD_LiveFS_GetRootDirAddress(); HDD_LiveFS_GetSuperBlockAddress(); HDD_MakeNewRecName(NULL, 0); HDD_Move(NULL, NULL, NULL); HDD_ReadClusterDMA(0, NULL); HDD_ReadSector(0, 0); HDD_ReadSectorDMA(0, 0, NULL); HDD_RECSlotGetAddress(0); HDD_RECSlotIsPaused(0); HDD_RECSlotPause(0, FALSE); HDD_RECSlotSetDuration(0, 0); HDD_SetCryptFlag(NULL, 0); HDD_SetFileDateTime(NULL, 0, 0, 0); HDD_SetSkipFlag (NULL, FALSE); HDD_SetStandbyTimer(0); HDD_Smart_DisableAttributeAutoSave(); HDD_Smart_DisableOperations(); HDD_Smart_EnableAttributeAutoSave(); HDD_Smart_EnableOperations(); HDD_Smart_ExecuteOfflineImmediate(0); HDD_Smart_ReadData(0); HDD_Smart_ReadThresholdData(0); HDD_Smart_ReturnStatus(); HDD_Stop(); HDD_TAP_Callback(0, NULL, 0, 0, 0, 0); HDD_TAP_Disable(0, 0); HDD_TAP_DisableAll(0); HDD_TAP_DisabledEventHandler(0, 0, 0); HDD_TAP_GetCurrentDir(NULL); HDD_TAP_GetCurrentDirCluster(); HDD_TAP_GetIDByFileName(NULL); HDD_TAP_GetIDByIndex(0); HDD_TAP_GetIndexByID(0); HDD_TAP_GetInfo(0, NULL); HDD_TAP_GetStartParameter(); HDD_TAP_isAnyRunning(); HDD_TAP_isBatchMode(); HDD_TAP_isDisabled(0); HDD_TAP_isDisabledAll(); HDD_TAP_isRunning(0); HDD_TAP_SendEvent(0, FALSE, 0, 0, 0); HDD_TAP_SetCurrentDirCluster(0); HDD_TAP_Start(NULL, FALSE, NULL, NULL); HDD_TAP_StartedByTAP(); HDD_TAP_Terminate(0); HDD_TouchFile(NULL); HDD_TranslateDirCluster(0, NULL); HDD_TruncateFile(NULL, 0); HDD_Write(NULL, 0, NULL); HDD_WriteClusterDMA(0, NULL); HDD_WriteSectorDMA(0, 0, NULL); HookEnable(0, 0); HookExit(); HookIsEnabled(0); HookMIPS_Clear(0, 0, 0); HookMIPS_Set(0, 0, 0); HookSet(0, 0); IMEM_Alloc(0); IMEM_Init(0); IMEM_isInitialized(); IMEM_Compact(); IMEM_Free(NULL); IMEM_GetInfo(NULL, NULL); IMEM_Kill(); InfoTestGrid(); INICloseFile(); INIFindStartEnd(NULL, NULL, NULL, 0); INIGetARGB(NULL, NULL, NULL, NULL, NULL, 0); INIGetHexByte(NULL, 0, 0, 0); INIGetHexDWord(NULL, 0, 0, 0); INIGetHexWord(NULL, 0, 0, 0); INIGetInt(NULL, 0, 0, 0); INIGetString(NULL, NULL, NULL, 0); INIKillKey(NULL); INIOpenFile(NULL); INISaveFile(NULL); INISetARGB(NULL, 0, 0, 0, 0); INISetComment(NULL); INISetHexByte(NULL, 0); INISetHexDWord(NULL, 0); INISetHexWord(NULL, 0); INISetInt(NULL, 0); INISetString(NULL, NULL); initCodeWrapper(0); InitTAPAPIFix(); InitTAPex(); InteractiveGetStatus(); InteractiveSetStatus(FALSE); intLock(); intUnlock(0); isAnyOSDVisible(0, 0, 0, 0); isLegalChar(0, 0); isMasterpiece(); isMPMenu(); iso639_1(0); isOSDRegionAlive(0); isValidChannel(NULL); LangGetString(0); LangLoadStrings(NULL, 0, 0); LangUnloadStrings(); Log(NULL, NULL, FALSE, 0, NULL); LowerCase(NULL); MakeValidFileName(NULL, 0); MHEG_Status(); MPDisplayClearDisplay(); MPDisplayClearSegments(0, 0); MPDisplayDisplayLongString(NULL); MPDisplayDisplayShortString(NULL); MPDisplayGetDisplayByte(0); MPDisplayGetDisplayMask(0); MPDisplayInstallMPDisplayFwHook(); MPDisplaySetAmFlag(0); MPDisplaySetColonFlag(0); MPDisplaySetDisplayByte(0, 0); MPDisplaySetDisplayMask(0, 0); MPDisplaySetDisplayMemory(NULL); MPDisplaySetDisplayMode(0); MPDisplaySetPmFlag(0); MPDisplaySetSegments(0, 0); MPDisplayToggleSegments(0, 0); MPDisplayUninstallMPDisplayFwHook(); MPDisplayUpdateDisplay(); Now(NULL); OSDCopy(0, 0, 0, 0, 0, 0, 0); OSDLinesForeDirty(FALSE); ParseLine(NULL, NULL, 0); ProfileDirty(); ProfileInit(); ProfileLoad(NULL, FALSE); ProfileMayReload(); ReadEEPROM(0, 0, NULL); ReadIICRegister(0, 0, 0, 0, NULL); Reboot(0); ReceiveSector(0); RTrim(NULL); SaveBitmap(NULL, 0, 0, NULL); SendEvent(0, 0, 0, 0); SendEventHelper(NULL, 0, 0, 0); SendHDDCommand(0, 0, 0, 0, 0, 0, 0); SendToFP(NULL); SeparatePathComponents(NULL, NULL, NULL, NULL); SetCrashBehaviour(0); setSymbol14(0, 0); setSymbol17(0, 0); ShowMessageWin(NULL, NULL, NULL, 0); ShowMessageWindow(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0); Shutdown(0); SoundSinus(0, 0, 0); StrEndsWith(NULL, NULL); stricstr(NULL, NULL); SubtitleGetStatus(); SubtitleSetStatus(FALSE); SuppressedAutoStart(); SwapDWords(0); SwapWords(0); TAP_Osd_PutFreeColorGd(0, 0, 0, NULL, FALSE, 0); TAPCOM_CloseChannel(NULL); TAPCOM_Finish(NULL, 0); TAPCOM_GetChannel(0, NULL, NULL, NULL, NULL); TAPCOM_GetReturnValue(NULL); TAPCOM_GetStatus(NULL); TAPCOM_LastAlive(NULL); TAPCOM_OpenChannel(0, 0, 0, NULL); TAPCOM_Reject(NULL); TAPCOM_StillAlive(NULL); TFDSize(NULL); TimeDiff(0, 0); TimeFormat(0, 0, 0); TunerGet(0); TunerSet(0); UncompressBlock(NULL, 0, NULL, 0); UncompressedFirmwareSize(NULL); UncompressedLoaderSize(NULL); UncompressedTFDSize(NULL); UncompressFirmware(NULL, NULL, NULL); UncompressLoader(NULL, NULL, NULL); UncompressTFD(NULL, NULL, NULL); UpperCase(NULL); ValidFileName(NULL, 0); WindowDirty(); WriteIICRegister(0, 0, 0, 0, NULL); YUV2RGB(0, 0, 0, NULL, NULL, NULL); YUV2RGB2(0, 0, 0, NULL, NULL, NULL); return 0; }
VOID ACLStr::Trim(VOID) { RTrim(); LTrim(); } // Trim
std::string Trim(const std::string &source){ return LTrim(RTrim(source)); }
printf("Ltrim:%s:\n",ptr); free(ptr); ptr=LTrim(" ESSAI I ","\0"); printf(":%s:\n",ptr); free(ptr); ptr=LTrim(" ","\0"); printf(":%s:\n",ptr); free(ptr); ptr=LTrim("","\0"); printf(":%s:\n",ptr); free(ptr); ptr=RTrim(" ESSAI I","\0"); printf("Rtrim:%s:\n",ptr); free(ptr); ptr=RTrim(" ESSAI I ","\0"); printf(":%s:\n",ptr); free(ptr); ptr=RTrim(" ","\0"); printf(":%s:\n",ptr); free(ptr); ptr=RTrim("","\0"); printf(":%s:\n",ptr); free(ptr);
std::string& Util::Trim(std::string &str) { return LTrim(RTrim(str)); }
CString CString::Trim() { return RTrim().LTrim(); }
std::string stringUtil::Trim(const std::string& str,const std::string& spaces) { return LTrim(RTrim(str,spaces),spaces); }
moText0& moText0::Trim() { LTrim(); RTrim(); return *this; }
char *Trim (char *Str) { return RTrim (LTrim (Str)); }
std::string& Trim(std::string &s) { return RTrim(LTrim(s)); }
inline std::string& Trim(std::string &s, char x) { return LTrim(RTrim(s, x), x); }