Пример #1
0
bool RemoveFileHistory( const char* filename )
{
	DEF_PRECONDITION( filename );

	bool found( false );

	LLStructRecPtr current=gFopenHistoryPtr;
	LLStructRecPtr previous=0;

	// for each list item
	while( current )
	{
		// if the current item matches the required filename
		if( !mystrcmpi( filename, reinterpret_cast<char*>(current->data) ) )
		{
			// remove (isolate) the current item from the list
			if( previous )
			{
				DEF_ASSERT( previous->next==current );
				previous->next=current->next;
			}
			else
			{
				DEF_ASSERT( current==gFopenHistoryPtr );
				gFopenHistoryPtr=current->next;
			}

			// clean up the current item
			free( current->data );
			free( current );

			found=true;
			break;
		}

		previous=current;
		current=current->next;
	}

	return found;
}
Пример #2
0
bool WithinFileHistory( const char* filename )
{
	DEF_PRECONDITION( filename );

	bool found( false );

	LLStructRecPtr current=gFopenHistoryPtr;

	// for each list item
	while( current )
	{
		// if the current item matches the required filename
		if( !mystrcmpi( filename, reinterpret_cast<char*>(current->data) ) )
		{
			found=true;
			break;
		}

		current=current->next;
	}

	return found;
}
Пример #3
0
// read a stat from the file to the memory stat
static long DBIO_LoadStatList( VDinfoP VDptr, StatList *byStat , gzFile fh, char *id )
{
	DEF_PRECONDITION(VDptr); 
	DEF_PRECONDITION(byStat); 
	DEF_PRECONDITION(!strcmpd( "STAT", id )); 

	// Sanity Check to avoid crash, maybe just delays the real issue to another location in the app.
	if ( !byStat )
	{
		OutDebugs( "byStat is 'NULL', due to report setting being turned off.  We need to look at DB loading issues relating to Settings files." );
		return 0;
	}


	// create a temp buffer into which we can read the StatList-like info and then read it in
	char tempByStatBuf[sizeof(StatList)];
	StatList* tempByStat=reinterpret_cast<StatList*>(tempByStatBuf);
	if( !gzread( fh, tempByStat, sizeof(StatList) ) )
	{
		return 0;
	}

	// copy the required attributes from our temporary
	byStat->doTimeStat = tempByStat->doTimeStat;
	byStat->doSessionStat = tempByStat->doSessionStat;
	byStat->useOtherNames = tempByStat->useOtherNames;
	byStat->useFixedNames = tempByStat->useFixedNames;
	byStat->num = tempByStat->num;
	byStat->maxNum = tempByStat->maxNum;
	byStat->incrSize = tempByStat->incrSize;
	byStat->totalRequests = tempByStat->totalRequests;
	byStat->totalCounters = tempByStat->totalCounters;
	byStat->totalCounters4 = tempByStat->totalCounters4;
	byStat->totalErrors = tempByStat->totalErrors;
	byStat->totalVisits = tempByStat->totalVisits;
	byStat->totalBytes = tempByStat->totalBytes;
	byStat->totalBytesIn = tempByStat->totalBytesIn;
	byStat->totalTime = tempByStat->totalTime;
	delete [] byStat->stat;
	byStat->stat = new Statistic[ byStat->maxNum ];
	memset( byStat->stat, 0, byStat->maxNum*sizeof(Statistic) );
	byStat->MarkForRebuild();

	OutDebugs( "Reading %d records into %s...", byStat->num, id );

	for(long n(0); n<byStat->num; n++)
	{
		Statistic* stat=0;

		// if we're currently loading the weekly stats
		if( byStat==VDptr->byWeekday )
		{
			// NOTE: The weekly stats get saved in an absolute order (ie sun, mon, tue...) regardless
			// of how the user may want them ordered (due to user's first day of week setting) so we 
			// map the current postion "n" to a day of the week index "dayIndex" and then read
			// into the corresponding stat.

			// offset the current day index according to user's first day of week setting so that
			// the specified day of week appears first within the weekly traffic reports
			size_t dayIndex=(n+7-MyPrefStruct.firstDayOfWeek)%7;

			stat=byStat->GetStat(dayIndex);
		}
		// else not currently loading weekly stats
		else
		{
			stat=byStat->GetStat(n);
		}

		DBIO_LoadStatistic( VDptr, stat , fh, byStat->useOtherNames, id+5 );

		if( byStat->doTimeStat && stat->timeStat )
		{
			DBIO_LoadTimeHistory( byStat, stat , fh );
		}

		if( byStat->doSessionStat && stat->sessionStat )
		{
			DBIO_LoadSessionHistory( VDptr, byStat, stat , fh );
		}

		if( (long)stat->GetName() == NAMEIS_STATIC )
		{
			OutDebug( "GetName Error" );
		}

		// if there are failed requests stored in the database
		if( byStat==VDptr->byBrokenLinkReferal ||
			byStat==VDptr->byIntBrokenLinkReferal ||
			byStat==VDptr->byErrors && !mystrcmpi( id+5, s_errorsWithTopReferralsTag ) // only read top referals in for post 4.5 databases
			)
		{
			// ref FailedRequestInfo for current stat
			CQFailedRequestInfo& failReqInfo=VDptr->GetFailedRequestInfo( stat );

			// read current stat's FailedRequestInfo
			failReqInfo.loadFrom( fh );
		}
	}

	if ( !mystrcmpi( "pages", id+5 ) )
	{	
		ClearSessions( byStat );
		ClearVisitors( byStat );
		ClearMeanTimes( byStat );
	}

	if (    !mystrcmpi( "wkday", id+5 )
		 || !mystrcmpi( "wkdays", id+5 )
		 || !mystrcmpi( "hourly", id+5 )
		 || !mystrcmpi( "date", id+5 )
		 || !mystrcmpi( "month", id+5 )
		// !mystrcmpi( "browser", id+5 )
		// !mystrcmpi( "oper", id+5 )
	   )
	{	
		ClearVisitors( byStat );
	}

	return 1;
}
Пример #4
0
static long DBIO_LoadStatistic( VDinfoP VDptr, Statistic *stat, gzFile fh, long useOtherNames, char *id )
{
	long	dataread = 0;

	if ( !fh ) return 0;

	// read one statistic
	if ( stat ) {
		dataread += gzread( fh, stat ,sizeof(Statistic) );

		if ( useOtherNames == NAMEIS_NORMAL || useOtherNames == NAMEIS_IP ) {
			if ( stat->GetName() && stat->length>0 ){
				char *name;
				name = stat->AllocateName( stat->length );
				dataread += ReadString( fh, name, stat->length );
			}
		} else 
		if ( (long)stat->GetName() == NAMEIS_STATIC )
		{
			if( !mystrcmpi( "hour", id ) )					RestoreHourNames( stat );
			else if( !mystrcmpi( "wkday", id ) )			RestoreWeekdaysNames( stat );
			else if( !mystrcmpi( "wdays", id ) )			RestoreHourNames( stat );
			else if( !mystrcmpi( "oper", id ) )				RestoreOpersysNames( stat );
			else if( !mystrcmpi( "errs", id ) )				RestoreErrorsNames( stat );
			else if( !mystrcmpi( s_errorsWithTopReferralsTag, id ) ) RestoreErrorsNames( stat );
			else if( !mystrcmpi( "pages", id ) )			RestoreStatisticName( stat, VDptr->byFile );
			else if( !mystrcmpi( "down", id ) )				RestoreStatisticName( stat, VDptr->byFile );
			else if( !mystrcmpi( "audio", id ) ) 			RestoreStatisticName( stat, VDptr->byFile );
			else if( !mystrcmpi( "video", id ) ) 			RestoreStatisticName( stat, VDptr->byFile );
			else if( !mystrcmpi( s_brokenLinkReferalsTag, id ) ) 	RestoreStatisticName( stat, VDptr->byRefer );
			else if( !mystrcmpi( s_intBrokenLinkReferalsTag, id ) ) RestoreStatisticName( stat, VDptr->byRefer );
			else											stat->name = NULL;
		}
	} else {
	// read to where? empty area just incase
		Statistic Lstat;
		dataread += gzread( fh, &Lstat ,sizeof(Statistic) );
		if ( Lstat.GetName() && !useOtherNames ) {
			char tmp[1024];
			dataread += gzread( fh, tmp , stat->length );
		}
		if ( (long)stat->GetName() == NAMEIS_STATIC ) 
			stat->name = NULL;
	}
	return dataread;
}
Пример #5
0
int WINAPI JsonPlugin::ConfigureW(const ConfigureInfo *info)
{
    if(info->StructSize > sizeof *info /*|| memcmp(info->Guid, &MenuGuid, sizeof MenuGuid)*/)
        return FALSE;
#else
int WINAPI JsonPlugin::EXP_NAME(Configure)(int)
{
#endif

#if 0
 static FarDialogItemID DialogItems[]={
    /*00*/{DI_DOUBLEBOX,3,1,72,13,0,0,0,0,MOptions},
    /*01*/{DI_TEXT,5,2,0,0,0,0,0,0,MExportFormat},
    /*02*/{DI_RADIOBUTTON,5,3,0,0,0,0,DIF_GROUP,0,MExportUTF8},
    /*03*/{DI_RADIOBUTTON,5,4,0,0,0,0,0,0, MExportWin},
    /*04*/{DI_TEXT,4,5,0,0,0,0,DIF_SEPARATOR},
    /*05*/{DI_CHECKBOX,5,6,0,0,0,0,0,0,MAddPluginsMenu},
    /*06*/{DI_CHECKBOX,5,7,0,0,0,0,0,0,MEnableFileOpening},
    /*07*/{DI_CHECKBOX,5,8,0,0,0,0,0,0,MValidateOnParse},
    /*08*/{DI_CHECKBOX,40,8,0,0,0,0,0,0,MResolveExternals},    
    /*09*/{DI_CHECKBOX,5,9,0,0,0,0,0,0,MStartUnsorted},
    /*10*/{DI_TEXT,5,10,0,0,0,0,0,0,MNameAttributes},
    /*11*/{DI_EDIT,40,10,70},
    /*12*/{DI_TEXT,4,11,0,0,0,0,DIF_SEPARATOR},
    /*13*/{DI_BUTTON,0,12,0,0,0,0,DIF_CENTERGROUP,1,MOK},
    /*14*/{DI_BUTTON,0,12,0,0,0,0,DIF_CENTERGROUP,0,MCancel},
    /*15*/{DI_BUTTON,0,12,0,0,0,0,DIF_BTNNOCLOSE|DIF_CENTERGROUP,0,MOverrideColumns},
  };
  extern TCHAR sExportUTF[];
  USE_SETTINGSW;
  bExportUTF = settings.Get(sExportUTF, 1);
  bStartUnsorted = settings.Get(sStartUnsorted, 1);
  DialogItems[2].Selected = bExportUTF;
  DialogItems[3].Selected = !bExportUTF;
  DialogItems[5].Selected = settings.Get(sAddPluginsMenu, 0);
  DialogItems[6].Selected = settings.Get(sBrowseXMLFiles, 1);
  DialogItems[7].Selected = settings.Get(sValidateOnParse, 0);
  DialogItems[8].Selected = settings.Get(sResolveExternals, 0);  
  DialogItems[9].Selected = settings.Get(sStartUnsorted, 1);  

#ifdef FAR3
  PanelInfo panel;
  StartupInfo.PanelControl(PANEL_ACTIVE, FCTL_GETPANELINFO, 0, &panel);
  int itemCount = _countof(DialogItems) - (panel.PluginHandle == 0);
#else
  int itemCount = _countof(DialogItems) - 1;
#endif
  FarDialogItem* ItemsStr = MakeDialogItems(DialogItems, itemCount);

  extern TCHAR sIdAttributes[], sDefIdAttributes[];
#ifdef UNICODE
  wchar_t attrlist[512];
  DWORD attrsize = _countof(attrlist)-1;
  attrlist[attrsize] = 0;
#else
  char* attrlist = ItemsStr[11].Data;
  DWORD attrsize = sizeof ItemsStr[11].Data-1;
#endif
  SetData(ItemsStr[11], attrlist, attrsize);
  settings.Get(sIdAttributes, attrlist, attrsize, sDefIdAttributes);
  ToOem(ItemsStr[10].Data);
  ItemsStr[11].X1 = ItemsStr[10].X1 + _tcslen(ItemsStr[10].ITEMDATA)+1;

  RUN_DIALOG(ConfigDialogGuid, -1, -1, 76, 15, _T("Config"), ItemsStr, itemCount);
  if(DIALOG_RESULT != 13 /*OK*/) {
    delete ItemsStr;
    return FALSE;
  }
  bExportUTF = GetSelected(ItemsStr,2);
  bStartUnsorted = GetSelected(ItemsStr,9);
  ToAnsi(ItemsStr[11].Data);
  settings.Set(sIdAttributes, GetItemText(ItemsStr,11));
  settings.Set(sExportUTF, bExportUTF);
  settings.Set(sAddPluginsMenu, GetSelected(ItemsStr,5));
  settings.Set(sBrowseXMLFiles, GetSelected(ItemsStr,6));
  settings.Set(sValidateOnParse, GetSelected(ItemsStr,7));
  settings.Set(sResolveExternals, GetSelected(ItemsStr,8));
  settings.Set(sStartUnsorted, bStartUnsorted);

  XMLPlugin::LoadIdAttributes();
  delete ItemsStr;

  return TRUE;
#endif

  return FALSE;
}

int
#ifndef FAR3
    WINAPI
#endif
           EXP_NAME(Compare)(HANDLE hPlugin,const struct PluginPanelItem *Item1,const struct PluginPanelItem *Item2,
                                                    unsigned int Mode)
{
    switch(Mode)
    {
        case SM_NAME:
        case SM_EXT:
            {
#ifndef UNICODE
            return mystrcmpi(Item1->FindData.cFileName, Item2->FindData.cFileName);
#else
            PCWSTR s1 = Item1->FileName;
            PCWSTR s2 = Item2->FileName;
            return lstrcmpi(s1,s2);
#endif
            }
        default:
            return -2;
    }
}

#ifdef FAR3
intptr_t WINAPI CompareW(const CompareInfo *info)
{
    if(info->StructSize < sizeof(CompareInfo))
        return -2;
    return CompareW(info->hPanel, info->Item1, info->Item2, info->Mode);
}
#endif

#ifdef FAR3
int WINAPI JsonPlugin::EXP_NAME(ProcessDialogEvent)(const ProcessDialogEventInfo *info)
{
#if 0
    if(info->StructSize != sizeof(ProcessDialogEventInfo) || info->Event != DE_DLGPROCINIT)
        return FALSE;
    FarDialogEvent& evt = *(FarDialogEvent *)info->Param;
    if(evt.Msg == DN_BTNCLICK && evt.Param1 == 15/*Override button*/)
    {
        PanelInfo panel;
        Control(FCTL_GETPANELINFO, 0, &panel);
        if(!panel.PluginHandle || panel.OwnerGuid != PluginGuid)
            return FALSE;
        ((JsonPlugin*)panel.PluginHandle)->EditSpecialDocs();
        return TRUE;
    }
#endif
    return FALSE;
}