Esempio n. 1
0
extern "C" int __declspec(dllexport) LoadFilter(MIRANDASERVICE GetYAMNFcnPtr)
{
	FilterPath=new char[MAX_PATH];
	char *delim;
	pYAMNFcn=&YAMNFcn;

	GetModuleFileName(GetModuleHandle(NULL),FilterPath,MAX_PATH);
	if(NULL!=(delim=strrchr(FilterPath,'\\')))
		*delim=0;
	lstrcat(FilterPath,"\\basefilterdeny.txt");
#ifdef DEBUG_FILTER
	InitDebug();
#endif

	if(!LoadRules())
		return 0;

	pYAMNFcn->RegisterFilterPlugin=(MIRANDASERVICE)GetYAMNFcnPtr((WPARAM)MS_YAMN_REGISTERFILTERPLUGIN,(LPARAM)0);
	pYAMNFcn->SetFilterPluginFcnImportFcn=(YAMN_SETFILTERPLUGINFCNIMPORTFCN)GetYAMNFcnPtr((WPARAM)YAMN_SETFILTERPLUGINFCNIMPORTID,(LPARAM)0);
//Register our filter plugin to YAMN
	if(NULL==(POPFilePlugin=(HYAMNFILTERPLUGIN)pYAMNFcn->RegisterFilterPlugin((WPARAM)&FilterRegistration,(LPARAM)YAMN_FILTERREGISTRATIONVERSION)))
		return 0;
//And add our imported functions for YAMN
	if(!pYAMNFcn->SetFilterPluginFcnImportFcn(POPFilePlugin,0xb0000000,&FilterFunctions,YAMN_FILTERIMPORTFCNVERSION))
		return 0;
	return 1;		//Load luccess
}
Esempio n. 2
0
//---------------------------------------------------------------------------
long FindColor(short hue, short saturation, short value, float *color_certainties)
{  double max_membership,membership;
   int color_index,res;
   int random1;
   if (!rules_loaded)
   {  char *ColorFunctionsStart,*RulesStart;

      SetColors();
      ColorFunctionsStart=strstr(rulesfile,"color_functions:");
      RulesStart=strstr(rulesfile,"rules:");
      if (!LoadColorsFunctions(ColorFunctionsStart) || !LoadRules(RulesStart))
      {  printf("Could not load rules \n");
         return(-1);
      }
      rules_loaded=1;
   }
   max_membership=0;
   res=COLOR_LIGHT_GREY;
   for (color_index=COLOR_WHITE;color_index<=COLOR_LIGHT_FUCIA;color_index++)
   if (colors[color_index].color>=0)
   {  membership=CalculateRules2(hue,saturation,value,color_index);
      if (color_certainties) color_certainties[color_index]=membership;
      if (membership>max_membership)
      { max_membership=membership;
        res=color_index;
      }
   }
//   return(num2tcolor(res));
   return(res);
}
Esempio n. 3
0
HRESULT CVCAConfigure::DoLoad( DWORD dwEngId )
{
	// Now assign all libvca structs to internal jobbies
	VCA5_APP_ENGINE_CONFIG *pCfg = &(m_EngineConfig[dwEngId]);

	LoadZones( dwEngId, &(pCfg->Zones) );
	LoadRules( dwEngId, &(pCfg->Rules) );
	LoadCounters( dwEngId, &(pCfg->Counters) );
	LoadCalibration( dwEngId, &(pCfg->CalibInfo) );
	LoadObjects( dwEngId, &(pCfg->ClsObjects) );
	LoadTamper( dwEngId, &(pCfg->TamperInfo) );
	LoadSceneChange( dwEngId, &(pCfg->SceneChangeInfo) );
	LoadAdvanced( dwEngId, &(pCfg->AdvInfo) );
	LoadFunction( dwEngId, &(pCfg->ulFunction) );

//	UnSquishIds( pCfg );


	return S_OK;
}
Esempio n. 4
0
void CTaskFileHelper::LoadOptions(XMLNode node) {
    if (node) {
        XMLNode nodeOpt = node.getChildNode(_T("options"));
        if (nodeOpt) {
            LPCTSTR szAttr = NULL;
            GetAttribute(nodeOpt, _T("auto-advance"), szAttr);
            if (szAttr) {
                if (_tcscmp(szAttr, _T("Manual")) == 0) {
                    AutoAdvance = 0;
                } else if (_tcscmp(szAttr, _T("Auto")) == 0) {
                    AutoAdvance = 1;
                } else if (_tcscmp(szAttr, _T("Arm")) == 0) {
                    AutoAdvance = 2;
                } else if (_tcscmp(szAttr, _T("ArmStart")) == 0) {
                    AutoAdvance = 3;
                } else if (_tcscmp(szAttr, _T("ArmTPs")) == 0) {
                    AutoAdvance = 4;
                }
            }

            GetAttribute(node, _T("type"), szAttr);
            if (szAttr) {
                if (_tcscmp(szAttr, _T("AAT")) == 0) {
                    AATEnabled = true;
                    PGOptimizeRoute = false;
                    LoadOptionAAT(nodeOpt);
                } else if (_tcscmp(szAttr, _T("Race")) == 0) {
                    AATEnabled = true;
                    PGOptimizeRoute = true;
                    LoadOptionRace(nodeOpt);
                } else if (_tcscmp(szAttr, _T("Default")) == 0) {
                    AATEnabled = false;
                    PGOptimizeRoute = false;
                    LoadOptionDefault(nodeOpt);
                }
            }
            LoadRules(nodeOpt.getChildNode(_T("rules"), 0));
        }
    }
}
Esempio n. 5
0
PrefsWindow::PrefsWindow(void)
 :	BWindow(BRect(100,100,450,350),"Filer Settings",B_TITLED_WINDOW,
 			B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
 	fChanges(false)
{
	fRuleList = new BObjectList<FilerRule>(20,true);
	
	AddShortcut('a',B_COMMAND_KEY,new BMessage(M_SHOW_ADD_WINDOW));
	AddShortcut('e',B_COMMAND_KEY,new BMessage(M_SHOW_EDIT_WINDOW));
	
	BView *top = new BView(Bounds(),"top",B_FOLLOW_ALL,B_WILL_DRAW);
	top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(top);
	
	BRect rect(Bounds().InsetByCopy(10,10));
	rect.right -= B_V_SCROLL_BAR_WIDTH;
	
	fRuleItemList = new BListView(rect,"rulelist",B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL);
	fScrollView = new BScrollView("listscroll",fRuleItemList,
												B_FOLLOW_ALL,0,true,true);
	fScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	top->AddChild(fScrollView);
	fRuleItemList->SetSelectionMessage(new BMessage(M_RULE_SELECTED));
	fRuleItemList->SetInvocationMessage(new BMessage(M_SHOW_EDIT_WINDOW));
	fScrollView->ScrollBar(B_HORIZONTAL)->SetRange(0.0,0.0);
	
	fAddButton = new BButton(BRect(0,0,1,1),"addbutton","Add…",
									new BMessage(M_SHOW_ADD_WINDOW),
									B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fAddButton->ResizeToPreferred();
	fAddButton->MoveTo(10,Bounds().bottom - 20 - (fAddButton->Bounds().IntegerHeight() * 2));
	top->AddChild(fAddButton);
	
	fScrollView->ResizeBy(0,(fAddButton->Bounds().IntegerHeight() * -2) - 20 - B_H_SCROLL_BAR_HEIGHT);
	
	fEditButton = new BButton(BRect(0,0,1,1),"editbutton","Edit…",
									new BMessage(M_SHOW_EDIT_WINDOW),
									B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fEditButton->ResizeToPreferred();
	fEditButton->MoveTo((Bounds().Width() - fEditButton->Bounds().Width()) / 2.0,
					fAddButton->Frame().top);
	top->AddChild(fEditButton);
	fEditButton->SetEnabled(false);
	
	
	fRemoveButton = new BButton(BRect(0,0,1,1),"removebutton","Remove",
									new BMessage(M_REMOVE_RULE),
									B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fRemoveButton->ResizeToPreferred();
	fRemoveButton->MoveTo(Bounds().Width() - fRemoveButton->Bounds().Width() - 10,
					fAddButton->Frame().top);
	top->AddChild(fRemoveButton);
	fRemoveButton->SetEnabled(false);
	
	
	fMoveDownButton = new BButton(BRect(0,0,1,1),"movedownbutton","Move Down",
									new BMessage(M_MOVE_RULE_DOWN),
									B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fMoveDownButton->ResizeToPreferred();
	fMoveDownButton->MoveTo((Bounds().Width() / 2.0) + 10.0,
					fAddButton->Frame().bottom + 10.0);
	
	
	fMoveUpButton = new BButton(BRect(0,0,1,1),"moveupbutton","Move Up",
									new BMessage(M_MOVE_RULE_UP),
									B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fMoveUpButton->ResizeTo(fMoveDownButton->Bounds().Width(), fMoveDownButton->Bounds().Height());
	fMoveUpButton->MoveTo((Bounds().Width() / 2.0) - fMoveUpButton->Bounds().Width() - 10.0,
					fAddButton->Frame().bottom + 10.0);
	
	top->AddChild(fMoveUpButton);
	top->AddChild(fMoveDownButton);
	
	fMoveUpButton->SetEnabled(false);
	fMoveDownButton->SetEnabled(false);
	
	
	float minwidth = (fRemoveButton->Bounds().Width() * 3.0) + 40;
	SetSizeLimits(minwidth, 30000, 200, 30000);
	
	LoadRules("/boot/home/config/settings/FilerRules",fRuleList);
	
	for (int32 i = 0; i < fRuleList->CountItems(); i++)
		fRuleItemList->AddItem(new RuleItem(fRuleList->ItemAt(i)));
	
	fRuleItemList->MakeFocus();
	if (fRuleItemList->CountItems() > 0)
		fRuleItemList->Select(0L);
	else
	{
		BAlert *alert = new BAlert("Filer","It appears that there aren't any rules for "
											"organizing files. Would you like Filer to "
											"add some basic ones for you?","No","Yes");
		if (alert->Go() == 1)
		{
			FilerRule *rule = new FilerRule();
			
			// NOTE: If actions 
			rule->AddTest(MakeTest("Type","is","text/plain"));
			rule->AddAction(MakeAction("Move it to…","/boot/home/Documents"));
			rule->SetDescription("Store text files in my Documents folder");
			AddRule(rule);
			
			rule = new FilerRule();
			rule->AddTest(MakeTest("Type","contains","x-vnd.gobe.productive"));
			rule->AddAction(MakeAction("Move it to…","/boot/home/Documents"));
			rule->SetDescription("Store Productive files in my Documents folder");
			AddRule(rule);
			
			rule = new FilerRule();
			rule->AddTest(MakeTest("Type","starts with","image/"));
			rule->AddAction(MakeAction("Move it to…","/boot/home/Pictures"));
			rule->SetDescription("Store pictures in my Pictures folder");
			AddRule(rule);
			
			rule = new FilerRule();
			rule->AddTest(MakeTest("Type","starts with","video/"));
			rule->AddAction(MakeAction("Move it to…","/boot/home/Videos"));
			rule->SetDescription("Store movie files in my Videos folder");
			AddRule(rule);
			
			rule = new FilerRule();
			rule->AddTest(MakeTest("Name","ends with",".zip"));
			rule->AddAction(MakeAction("Terminal command…","unzip %FULLPATH% -d /boot/home/Desktop"));
			rule->SetDescription("Extract ZIP files to the Desktop");
			AddRule(rule);
			
//			rule = new FilerRule();
//			rule->AddTest(MakeTest("","",""));
//			rule->AddAction(MakeAction("",""));
//			rule->SetDescription("");
//			AddRule(rule);
		}
		SaveRules("/boot/home/config/settings/FilerRules",fRuleList);
	}
}
Esempio n. 6
0
void
PrefsWindow::MessageReceived(BMessage *msg)
{
	switch(msg->what)
	{
		case M_SHOW_ADD_WINDOW:
		{
			BRect frame(Frame());
			frame.right = frame.left + 400;
			frame.bottom = frame.top + 300;
			frame.OffsetBy(20,20);
			
			RuleEditWindow *rulewin = new RuleEditWindow(frame,NULL);
			rulewin->Show();
			break;
		}
		case M_SHOW_EDIT_WINDOW:
		{
			BRect frame(Frame());
			frame.right = frame.left + 400;
			frame.bottom = frame.top + 300;
			frame.OffsetBy(20,20);
			
			FilerRule *rule = fRuleList->ItemAt(fRuleItemList->CurrentSelection());
				
			RuleEditWindow *rulewin = new RuleEditWindow(frame,rule);
			rulewin->Show();
			break;
		}
		case M_ADD_RULE:
		{
			fChanges = true;
			FilerRule *item;
			if (msg->FindPointer("item",(void**)&item) == B_OK)
				AddRule(item);
			break;
		}
		case M_REMOVE_RULE:
		{
			fChanges = true;
			if (fRuleItemList->CurrentSelection() >= 0)
				RemoveRule((RuleItem*)fRuleItemList->ItemAt(fRuleItemList->CurrentSelection()));
			break;
		}
		case M_UPDATE_RULE:
		{
			fChanges = true;
			FilerRule *rule;
			if (msg->FindPointer("item",(void**)&rule) == B_OK)
			{
				int64 id;
				if (msg->FindInt64("id",&id) != B_OK)
					debugger("Couldn't find update ID");
				
				for (int32 i = 0; i < fRuleList->CountItems(); i++)
				{
					FilerRule *oldrule = fRuleList->ItemAt(i);
					if (oldrule->GetID() == id)
					{
						*oldrule = *rule;
						RuleItem *item = (RuleItem*)fRuleItemList->ItemAt(i);
						item->SetText(rule->GetDescription());
						break;
					}
				}
				
				delete rule;
			}
			break;
		}
		case M_REVERT:
		{
			while (fRuleItemList->CountItems() > 0)
				RemoveRule((RuleItem*)fRuleItemList->ItemAt(0L));
			fRuleList->MakeEmpty();
			fEditButton->SetEnabled(false);
			fRemoveButton->SetEnabled(false);
			LoadRules("/boot/home/config/settings/FilerRules",fRuleList);
			break;
		}
		case M_RULE_SELECTED:
		{
			bool value = (fRuleItemList->CurrentSelection() >= 0);
			
			fEditButton->SetEnabled(value);
			fRemoveButton->SetEnabled(value);
			
			if (fRuleItemList->CountItems() > 1)
			{
				fMoveUpButton->SetEnabled(value);
				fMoveDownButton->SetEnabled(value);
			}
			break;
		}
		case M_MOVE_RULE_UP:
		{
			fChanges = true;
			int32 selection = fRuleItemList->CurrentSelection();
			if (selection < 1)
				break;
			
			fRuleItemList->SwapItems(selection, selection - 1);
			fRuleList->SwapItems(selection, selection - 1);
			break;
		}
		case M_MOVE_RULE_DOWN:
		{
			fChanges = true;
			int32 selection = fRuleItemList->CurrentSelection();
			if (selection > fRuleItemList->CountItems() - 1)
				break;
			
			fRuleItemList->SwapItems(selection, selection + 1);
			fRuleList->SwapItems(selection, selection + 1);
			break;
		}
		default:
			BWindow::MessageReceived(msg);
			break;
	}
}
// I/O
bool
	LSystem::Load( char* file)
{
	// STRUCTURE OF LSYS FILE:
	// =================
	// recursion levels separated by '-'
	// basic angle
	// thickness
	// lenght
	// PointSprites sizes separated by '-'
	// axiom
	// all other lines are rulez until "@" line
	unsigned long position = 0;
	string line;
	int val;
	float fval;

	ifstream f;

	// try to open the file
	f.open( file);
	if( ! f.good() )
		return false;

	////////////////////////////////
	// first we try to load recurse level	s
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	unsigned int j= 0;
	for( int i= 0; i< NUM_LVLS; i++)
	{
		val = 0;

		// check if there is what to load
		if( j > line.size( ) )
			return false;

		while( ( j < 8) && isdigit( line[ j]) )
		{
			val = ( val * 10) + line[ j] - '0';
			j++;
		}

		// recurson level
		m_recursionLevels[ i] = val;

		// if non zero increase active levels
		if( val)
			m_activeLevels++;

		// skip separator
		j++;
	}


	// check if there is at least nonzero in the first recLevel
	if( !m_recursionLevels[ 0])
		return false;

	////////////////////////////////
	// then m_defaultAngle
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	fval = ( float)atof( &line[ 0]);
	if( fval > 0)
		m_defaultAngle = fval;
	else
		return false;

	////////////////////////////////
	// then m_defaultThickness
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	fval = ( float)atof( &line[ 0]);
	if( fval > 0)
		m_defaultThick = fval;
	else
		return false;

	////////////////////////////////
	// default lenght
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	fval = ( float)atof( &line[ 0]);
	if( fval > 0)
		m_defLenght = fval;
	else
		return false;

	////////////////////////////////
	// PS Sizes
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	char tmp[ 32];
	j = 0;
	int k = 0;

	for( int i= 0; i< 4; i++)
	{
		while( ( j< line.size( )) && line[ j] != '-')
		{
			tmp[ k] = line[ j];
			k++; j++;
		}
		tmp[ k] = 0;

		// PS Size
		m_PSSizes[ i] = ( float)atof( tmp);

		// skip separator
		j++;

		k = 0;		
	}

	////////////////////////////////
	// AXIOM
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	// are there any space? If yes then error
	for( unsigned int j= 0; j< line.size( ); j++)
		if( ( line[ j] == ' ') && ( line[ j] == '\n') && ( line[ j] == '\t') )
			return false;

	setAxiom( line);

	if( ! LoadRules( &f))
		return false;

	// close the file
	f.close( );
	
	return true;
}
Esempio n. 8
0
int main(int argc, char** argv)
{
	std::cout << "NetPower IDS-Messenger v1.0.0" << std::endl << std::endl;

	if (argc < 6)
	{
		PrintUsage();
		return 1;
	}

	id = argv[1];
	host = argv[2];
	port = static_cast<unsigned short>(atoi(argv[3]));
	transferFolder = argv[4];
	const char* scriptConfFile = argv[5];

	struct stat statBuf;
	if (stat(transferFolder.c_str(), &statBuf) || ! S_ISDIR(statBuf.st_mode))
	{
		std::cerr << "Transfer folder '" << transferFolder << "' is invalid!" << std::endl;
		return 1;
	}
	if (stat(scriptConfFile, &statBuf) || ! S_ISREG(statBuf.st_mode))
	{
		std::cerr << "Script configure file '" << scriptConfFile << "' is invalid!" << std::endl;
		return 1;
	}
	std::cout
		<< "ID of this IDS        : " << id << std::endl
		<< "CMS host & port       : " << host << ":" << port << std::endl
		<< "Transfer folder       : " << transferFolder << std::endl
		<< "Script configure file : " << scriptConfFile << std::endl
		<< std::endl;
	signal(SIGPIPE, PipeSignalHandler);

	if ( ! LoadRules(scriptConfFile))
	{
		std::cerr << "Load rule file '" << scriptConfFile << "' failed!" << std::endl;
		return 1;
	}

///////////////////////////////////////////////////////////////////////////
    check_time = time(NULL);
    sending_data_tag = 0;

    signal(SIGALRM,my_timeout);

    int err;
    pthread_t tid1;
    pthread_t tid2;

    err = pthread_create(&tid1,NULL,my_process,NULL);
    if (err != 0)
    {
        fprintf(stderr,"can't create my_process: %s\n",strerror(err));
        exit(1);
    }

    err = pthread_create(&tid2,NULL,my_timer,NULL);
    if (err != 0)
    {
        fprintf(stderr,"can't create my_timer: %s\n",strerror(err));
        exit(1);
    }

    sleep(2);

    pthread_join(tid1,NULL);
    pthread_join(tid2,NULL);

	return 0;
}