static xmlChar * xml_cdpStrToUTF8( const char * szStr, HB_SIZE * pnLen, const char * pszCdpIn ) { PHB_CODEPAGE cdpIn = pszCdpIn ? hb_cdpFindExt( pszCdpIn ) : hb_vmCDP(); PHB_CODEPAGE cdpOut = hb_cdpFindExt( XML_UTF8_HB_CDP ); char * szDest = NULL; if( cdpIn && cdpOut && szStr ) { int len = strlen( szStr ); memcpy( pnLen, &len, sizeof( len ) ); szDest = hb_cdpnDup( szStr, pnLen, cdpIn, cdpOut ); } return ( xmlChar * ) szDest; }
static PHB_CODEPAGE _hb_jsonCdpPar( int iParam ) { if( hb_pcount() >= iParam ) { const char * szCdp = hb_parc( iParam ); if( szCdp ) return hb_cdpFindExt( szCdp ); } return NULL; }
static PHB_CODEPAGE _hb_jsonCdpPar( int iParam, HB_BOOL lVmCp ) { if( hb_pcount() >= iParam ) { const char * szCdp = hb_parc( iParam ); if( szCdp ) return hb_cdpFindExt( szCdp ); } else if( lVmCp ) return hb_vmCDP(); return NULL; }
/* * Open a data store in the WorkArea. */ static HB_ERRCODE hb_sdfOpen( SDFAREAP pArea, LPDBOPENINFO pOpenInfo ) { PHB_ITEM pError = NULL; PHB_FNAME pFileName; HB_ERRCODE errCode; HB_USHORT uiFlags; HB_BOOL fRetry; char szFileName[ HB_PATH_MAX ]; char szAlias[ HB_RDD_MAX_ALIAS_LEN + 1 ]; HB_TRACE( HB_TR_DEBUG, ( "hb_sdfOpen(%p,%p)", pArea, pOpenInfo ) ); pArea->fShared = HB_TRUE; /* pOpenInfo->fShared; */ pArea->fReadonly = HB_TRUE; /* pOpenInfo->fReadonly; */ if( pOpenInfo->cdpId ) { pArea->area.cdPage = hb_cdpFindExt( pOpenInfo->cdpId ); if( ! pArea->area.cdPage ) pArea->area.cdPage = hb_vmCDP(); } else pArea->area.cdPage = hb_vmCDP(); uiFlags = ( pArea->fReadonly ? FO_READ : FO_READWRITE ) | ( pArea->fShared ? FO_DENYNONE : FO_EXCLUSIVE ); pFileName = hb_fsFNameSplit( pOpenInfo->abName ); /* Add default file name extension if necessary */ if( hb_setGetDefExtension() && ! pFileName->szExtension ) { PHB_ITEM pFileExt = hb_itemPutC( NULL, NULL ); SELF_INFO( &pArea->area, DBI_TABLEEXT, pFileExt ); pFileName->szExtension = hb_itemGetCPtr( pFileExt ); hb_fsFNameMerge( szFileName, pFileName ); hb_itemRelease( pFileExt ); } else { hb_strncpy( szFileName, pOpenInfo->abName, sizeof( szFileName ) - 1 ); } /* Create default alias if necessary */ if( ! pOpenInfo->atomAlias && pFileName->szName ) { const char * szName = strrchr( pFileName->szName, ':' ); if( szName == NULL ) szName = pFileName->szName; else ++szName; hb_strncpyUpperTrim( szAlias, szName, sizeof( szAlias ) - 1 ); pOpenInfo->atomAlias = szAlias; } hb_xfree( pFileName ); /* Try open */ do { pArea->pFile = hb_fileExtOpen( szFileName, NULL, uiFlags | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME | FXO_NOSEEKPOS, NULL, pError ); if( ! pArea->pFile ) { if( ! pError ) { pError = hb_errNew(); hb_errPutGenCode( pError, EG_OPEN ); hb_errPutSubCode( pError, EDBF_OPEN_DBF ); hb_errPutOsCode( pError, hb_fsError() ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_OPEN ) ); hb_errPutFileName( pError, szFileName ); hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); } fRetry = ( SELF_ERROR( &pArea->area, pError ) == E_RETRY ); } else fRetry = HB_FALSE; } while( fRetry ); if( pError ) hb_itemRelease( pError ); if( ! pArea->pFile ) return HB_FAILURE; errCode = SUPER_OPEN( &pArea->area, pOpenInfo ); if( errCode != HB_SUCCESS ) { SELF_CLOSE( &pArea->area ); return HB_FAILURE; } hb_sdfInitArea( pArea, szFileName ); /* Position cursor at the first record */ return SELF_GOTOP( &pArea->area ); }
/* * Create a data store in the specified WorkArea. */ static HB_ERRCODE hb_sdfCreate( SDFAREAP pArea, LPDBOPENINFO pCreateInfo ) { HB_ERRCODE errCode; PHB_FNAME pFileName; PHB_ITEM pError = NULL; HB_BOOL fRetry; char szFileName[ HB_PATH_MAX ]; HB_TRACE( HB_TR_DEBUG, ( "hb_sdfCreate(%p,%p)", pArea, pCreateInfo ) ); pArea->fShared = HB_FALSE; /* pCreateInfo->fShared; */ pArea->fReadonly = HB_FALSE; /* pCreateInfo->fReadonly */ if( pCreateInfo->cdpId ) { pArea->area.cdPage = hb_cdpFindExt( pCreateInfo->cdpId ); if( ! pArea->area.cdPage ) pArea->area.cdPage = hb_vmCDP(); } else pArea->area.cdPage = hb_vmCDP(); pFileName = hb_fsFNameSplit( pCreateInfo->abName ); if( hb_setGetDefExtension() && ! pFileName->szExtension ) { PHB_ITEM pItem = hb_itemPutC( NULL, NULL ); SELF_INFO( &pArea->area, DBI_TABLEEXT, pItem ); pFileName->szExtension = hb_itemGetCPtr( pItem ); hb_fsFNameMerge( szFileName, pFileName ); hb_itemRelease( pItem ); } else { hb_strncpy( szFileName, pCreateInfo->abName, sizeof( szFileName ) - 1 ); } hb_xfree( pFileName ); /* Try create */ do { pArea->pFile = hb_fileExtOpen( szFileName, NULL, FO_READWRITE | FO_EXCLUSIVE | FXO_TRUNCATE | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME | FXO_NOSEEKPOS, NULL, pError ); if( ! pArea->pFile ) { if( ! pError ) { pError = hb_errNew(); hb_errPutGenCode( pError, EG_CREATE ); hb_errPutSubCode( pError, EDBF_CREATE_DBF ); hb_errPutOsCode( pError, hb_fsError() ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); hb_errPutFileName( pError, szFileName ); hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); } fRetry = ( SELF_ERROR( &pArea->area, pError ) == E_RETRY ); } else fRetry = HB_FALSE; } while( fRetry ); if( pError ) hb_itemRelease( pError ); if( ! pArea->pFile ) return HB_FAILURE; errCode = SUPER_CREATE( &pArea->area, pCreateInfo ); if( errCode != HB_SUCCESS ) { SELF_CLOSE( &pArea->area ); return errCode; } hb_sdfInitArea( pArea, szFileName ); /* Position cursor at the first record */ return SELF_GOTOP( &pArea->area ); }