Example #1
0
//---------------------------------------------------------------------------//
// OnCommand
//
//---------------------------------------------------------------------------//
void CFXMessage::OnCommand(TCommand *pComm)
{
  CEffect::OnCommand(pComm);

  if (!Stricmp(pComm->pComm, "Down"))
    SetEstado(ST_BAJANDO);
  else if (!Stricmp(pComm->pComm, "Up"))
    SetEstado(ST_SUBIENDO);
}
Example #2
0
LONG FileIsModule( STRPTR Path, STRPTR Name )
{
    if( strstr( Name, ".ifc" ) || strstr( Name, ".txt" ) ||
	   strstr( Name, ".prefs" ))
        return FALSE;
	
    if( !Stricmp( Name, "PrefInterp" ))
        return FALSE;
	
    if( !Stricmp( Name, "ShowInfo" ))
        return FALSE;
	
    return TRUE;
}
Example #3
0
VOID LoadModule( STRPTR Dir, STRPTR Module )
{
    BPTR in = Open( "NIL:", MODE_OLDFILE );
    BPTR out = Open( "NIL:", MODE_OLDFILE );
    BYTE Path[256];
    
    if( !Stricmp( Module, "Random" ))
        Module = RandomModule();
	
    if( !Module )
        return;
    
    strcpy( Path, Dir );
    AddPart( Path, Module, 256 );
    
    if( in && out )
        if( SystemTags( Path, SYS_Asynch, TRUE, SYS_Input, in, SYS_Output, out,
					   TAG_END ) != -1 )
            return;
    
    if( in )
        Close( in );
    if( out )
        Close( out );
}
Example #4
0
struct Node *FindNameNoCase(struct Handler *handler, struct List *start, const TEXT *name)
{
   struct Node *node, *next_node, *matching_node;
   TEXT *node_name;

   matching_node = NULL;
   node = start->lh_Head;

   while(node != NULL)
   {
      next_node = node->ln_Succ;
      if(next_node != NULL)
      {
         node_name = node->ln_Name;
         if(node_name != NULL)
            if(Stricmp(name, node_name) == 0)
            {
               matching_node = node;
               next_node = NULL;
            }
      }
      node = next_node;
   }

   return matching_node;
}
///----------------------------------------------------------
/// 
///----------------------------------------------------------
XMLNode CreateXMLDocumentFromResourceStream( const ResourceStream& resourceStream, const std::string& optionalExpectedRootNodeName )
{
	XMLResults results;
	const char* resourceStreamAsciiFileBuffer = (const char*)resourceStream.GetDirectBufferAccess();
	XMLNode xmlDocumentRootNode = XMLNode::parseString( resourceStreamAsciiFileBuffer, NULL, &results );

	// Report errors here if "results" indicates any problems
	if( results.error != eXMLErrorNone )
	{
		ReportXMLError( resourceStream, xmlDocumentRootNode, results );
	}

	// Advance past the "xml declaration" node, if present; e.g.: <?xml version="1.0" encoding="us-ascii"?>
	// ...OR, if the root node is nameless, then it must be an implicit document-root (usually in an XML without a declaration), skip that
	while( (xmlDocumentRootNode.isDeclaration() || !xmlDocumentRootNode.getName()) && xmlDocumentRootNode.nChildNode() > 0 )
	{
		xmlDocumentRootNode = xmlDocumentRootNode.getChildNode( 0 );
	}

	if( !optionalExpectedRootNodeName.empty() )
	{
		const std::string rootNodeName = xmlDocumentRootNode.getName();
		if( Stricmp( optionalExpectedRootNodeName, rootNodeName ) )
		{
			//JAZZ_ERROR( "XML Data File Error", Stringf( "In XML data file %s, was expecting a root node\n type of <%s>, but found <%s> instead!", resourceStream.GetJazzPath()..c_str(), optionalExpectedRootNodeName.c_str(), rootNodeName.c_str() ) );
		}
	}

	return xmlDocumentRootNode;
}
Example #6
0
static struct NamedObj *searchns(pUtility UtilBase, struct NamedObj *object, struct NameSpace *ns, STRPTR search)
{
	struct NamedObj *ret;
	if (!search)
	{
		if (object->no_Non.non_Node.ln_Succ) return object;
		return NULL;
	}

	if ((ns->ns_Flags & NSB_CASE) != 0)
	{
		 ret = (struct NamedObj *)FindName((struct List *)object->no_Non.non_Node.ln_Pred, search);
		 return ret;
	}
	
	ForeachNode(object, ret)
	{
		if (Stricmp((const char*)search, (const char*)ret->no_Non.non_Node.ln_Name) == 0)
		{
			if (ret->no_Non.non_Node.ln_Succ) return ret;
			return NULL;
		}
	}
	return NULL;
}
Example #7
0
VOID ToggleModuleDisabled( BlankerPrefs *Prefs )
{
    struct FileInfoBlock *Blk;
    BPTR BlankerLock;
    BYTE Path[108];
	
    strcpy( Path, Prefs->bp_Dir );
    AddPart( Path, Prefs->bp_Blanker, 108 );
	
    if( BlankerLock = Lock( Path, ACCESS_READ ))
    {
        if( Blk = AllocDosObject( DOS_FIB, 0L ))
        {
            if( Examine( BlankerLock, Blk ))
            {
                if( Stricmp( Blk->fib_Comment, "Disabled" ))
                    SetComment( Path, "Disabled" );
                else
                    SetComment( Path, "" );
            }
            FreeDosObject( DOS_FIB, Blk );
        }
        UnLock( BlankerLock );
    }
}
Example #8
0
int same_aname (const TCHAR *an1, const TCHAR *an2) {

  if(Stricmp(an1, an2)) {
    return 0;
  }

  return 1;
}
Example #9
0
int CONFIGistag(char *string, int num_entries, char **conf_menu, int *which_var)
{
	for (*which_var=0;*which_var<num_entries;++*which_var){
		if (Stricmp(string,conf_menu[*which_var]) == 0) {
			return(1);
		}
	}
	return(0);
}
Example #10
0
int RegisterField(char *name,int Length,int Pos,FieldType *&Field)
{
//   char name[256];in>>name;
   if (Stricmp(name,"String")==0) Field=new FieldString;
   else
	   if (Stricmp(name,"Real")==0) Field=new FieldReal;

	else
	   if (Stricmp(name,"Long")==0) Field=new FieldLong;

	   else
		   if (Stricmp(name,"Int")==0) Field=new FieldInt;
		   else
    { cout<<" RegisterField; There is no such function \n"<<name<<"\n";return 0; }
//   Func->ReadIni(in);
	Field->Pos=Pos;Field->Length=Length;
	return 1;
  };
Example #11
0
struct List *GetModes(struct AHIUnitPrefs *prefs) {
  struct List *list;

  list = AllocVec(sizeof(struct List), MEMF_CLEAR);
  
  if(list) {
    ULONG id = AHI_NextAudioID(AHI_INVALID_ID);

    NewList(list);

    while(id != AHI_INVALID_ID) {
      struct ModeNode *t;
      struct Node     *node;
      
      t = AllocVec( sizeof(struct ModeNode), MEMF_CLEAR);

      if( t != NULL ) {
        LONG realtime;

        t->node.ln_Name = t->name;
        t->ID = id;
        
        realtime = FALSE;
        
        AHI_GetAudioAttrs(id, NULL,
            AHIDB_BufferLen,  80,
            AHIDB_Name,       (ULONG) t->node.ln_Name,
            AHIDB_Realtime,   (ULONG) &realtime,
            TAG_DONE);

        if((prefs->ahiup_Unit == AHI_NO_UNIT) || realtime ) {
          // Insert node alphabetically
          for(node = list->lh_Head;
              node->ln_Succ;
              node = node->ln_Succ) {
            if(Stricmp(t->node.ln_Name,node->ln_Name) < 0)
              break;
          }
          Insert(list, (struct Node *) t, node->ln_Pred);
        }
        else {
          FreeVec(t);
        }
      }
      id = AHI_NextAudioID(id);
    }
  }
  return list;
}
Example #12
0
BlankerEntry *NewBlankerEntry( STRPTR Path, STRPTR Name, STRPTR Comment )
{
    BlankerEntry *New = AllocVec( sizeof( BlankerEntry ), MEMF_CLEAR );
	
    if( New )
    {
        strcpy( New->be_Path, Path );
        AddPart( New->be_Path, Name, 128 );
        New->be_Name = FilePart( New->be_Path );
        New->be_Disabled = !Stricmp( Comment, "Disabled" );
        New->be_Node.ln_Name = New->be_Name;
    }
	
    return New;
}
Example #13
0
int CONFIGisentry(char *string, int num_entries, char **entries)
{
	/* Returns -1 if not found, else index within array "entries" */
	int	n;
	for (n=0;n<num_entries;++n){
		if (Stricmp(string,entries[n]) == 0) {
			return n;
		}
	}
	(void) printf("Invalid entry '%s':  Valid entries are:\n", string);
	for (n=0;n<num_entries;++n) {
		printf("\t%s",entries[n]);
	}
	printf("\n");
	++CONFIGerrs;
	return -1;
}
Example #14
0
LONG GetIndex(STRPTR string)
{
LONG   *l;
UWORD  *w;
STRPTR	builtIn;

    l = (LONG *)CatCompBlock;
    builtIn = (STRPTR)((ULONG)l + 6);

    while (Stricmp(builtIn,string)) {
	w = (UWORD *)((ULONG)l + 4);
	l = (LONG *)((ULONG)l + (ULONG)*w + 6);
	builtIn = (STRPTR)((ULONG)l + 6);
    }

    return *l;
}
Example #15
0
BOOL IsNewGroup(struct ClassData * data, STRPTR YahooGroup )
{
	int pos = -1;
	
	do {
		STRPTR group = NULL;
		
		DoMethod( data->leftlist, MUIM_NList_GetEntry, ++pos, &group );
		if(!group)
			break;
		
		if(!Stricmp( group, YahooGroup))
			return FALSE;
		
	} while(1);
	
	return TRUE;
}
Example #16
0
BOOL LeftListSelect( struct ClassData * data, STRPTR YahooGroup )
{
	long pos = -1;
	
	do {
		STRPTR group = NULL;
		
		DoMethod( data->leftlist, MUIM_NList_GetEntry, ++pos, &group );
		if(!group)
			break;
		
		if(!Stricmp( group, YahooGroup))
		{
			set( data->leftlist, MUIA_NList_Active, pos );
			return TRUE;
		}
	} while(1);
	
	return FALSE;
}
Example #17
0
bool FontDescription::operator==(const FontDescription& fd) const
{
    return  (mfSize   == fd.mfSize) &&
            (mStyle   == fd.mStyle) &&
            (mfWeight == fd.mfWeight) &&
            (mSmooth  == fd.mSmooth) &&
            (Stricmp(mFamily, fd.mFamily) == 0) &&
            (mEffect  == fd.mEffect);

    // We currently leave out the following, which isn't entirely correct, but is
    // more efficient. It turns out that we can leave these out very often because
    // the above entities will already uniquely identify the font in most cases.
    //    float     mfStretch;
    //    Pitch     mPitch;
    //    Variant   mVariant;
    //    float     mfEffectX;
    //    float     mfEffectY;
    //    Color     mEffectBaseColor;
    //    Color     mEffectColor;
    //    Color     mHighLightColor;
}
Example #18
0
BOOL SameGroupFolder( struct ClassData * data, BOOL lock )
{
	/* comprueba si el grupo que esta manejando la subtask
	 * es el mismo que se encuentra activo en la ventana principal
	 */
	
	BOOL rc = FALSE;
	
	if( lock )
		ObtainSemaphore(data->sem);
	
	if((data->ActiveGroup != NULL) && (data->subtask.folder != NULL))
	{
		rc = (Stricmp( data->ActiveGroup->YahooGroup, 
			data->subtask.folder->YahooGroup) == 0);
	}
	
	if( lock )
		ReleaseSemaphore(data->sem);
	
	return(rc);
}
Example #19
0
// Sort two strings taking leading numbers into account
int ASM namesort(REG(a0, char *str1),REG(a1, char *str2))
{
	// Do both names begin with numbers?
	if (*str1<='9' && *str1>='0' && 
		*str2<='9' && *str2>='0')
	{
		register long n1,n2;

		// Get value of leading numbers
		n1=atoi(str1);
		n2=atoi(str2);

		// If the two numbers are not the same, return the difference between them
		if (n1!=n2) return (n1-n2);

		// Get string following numbers
		while (*str1>='0' && *str1<='9') ++str1;
		while (*str2>='0' && *str2<='9') ++str2;
	}

	// Return value of the comparison (uses utility.library strcmp routine)
	return Stricmp(str1,str2);
}
Example #20
0
/*------------------------------------------------------------------
 * parse command line for options
 *------------------------------------------------------------------*/
static void GetOptions(
   int   *argc,
   char  *argv[],
   Info  *info
   )
   {
   int            oHelp;
   char          *oBrack;
   char          *oTabs;
   char          *oCtype;
   char          *oHtype;
   char          *oSort;
   char          *oFile;
   char          *oSpace;
   char          *oKeys;
   char          *oBreak;
   char          *oTemp;
   char          *oImbed;
   char          *oDuplex;
   char          *oXlate;
   char          *numLeft;
   char          *s1;
   char          *s2;
   char          *oWrap;
   char          *oRepHdr;

   /*---------------------------------------------------------------
    * parse arguments
    *---------------------------------------------------------------*/
   parsearg(argc,argv,0,PROGRAM_ENVV,"-",
            Strcopy("? b@ c@ d@ h@ k@ i@ n@ o@ p@ r@ s@ t@ w@ x@ y@"),
            &oHelp,&oBrack,&oCtype,&oDuplex,&oHtype,&oKeys,&oImbed,
            &oSpace,&oFile,&oBreak,&oRepHdr,&oSort,&oTabs,&oWrap,
            &oXlate,&oTemp);

   /*---------------------------------------------------------------
    * check parms
    *---------------------------------------------------------------*/
   if (oHelp || (*argc < 2))
      Usage();

   if ('?' == *argv[1])
      Usage();

   /*---------------------------------------------------------------
    * apply option defaults
    *---------------------------------------------------------------*/
   if ((NULL == oBrack ) || ('\0' == *oBrack ))  oBrack  = "+";
   if ((NULL == oCtype ) || ('\0' == *oCtype ))  oCtype  = "c";
   if ((NULL == oDuplex) || ('\0' == *oDuplex))  oDuplex = "-";
   if ((NULL == oHtype ) || ('\0' == *oHtype ))  oHtype  = "h";
   if ((NULL == oKeys  ) || ('\0' == *oKeys  ))  oKeys   = "";
   if ((NULL == oImbed ) || ('\0' == *oImbed ))  oImbed  = "";
   if ((NULL == oSpace ) || ('\0' == *oSpace ))  oSpace  = "2";
   if ((NULL == oFile  ) || ('\0' == *oFile  ))  oFile   = NULL;
   if ((NULL == oBreak ) || ('\0' == *oBreak ))  oBreak  = "+";
   if ((NULL == oRepHdr) || ('\0' == *oRepHdr))  oRepHdr = "";
   if ((NULL == oSort  ) || ('\0' == *oSort  ))  oSort   = "tn";
   if ((NULL == oTabs  ) || ('\0' == *oTabs  ))  oTabs   = "4";
   if ((NULL == oWrap  ) || ('\0' == *oWrap  ))  oWrap   = "";
   if ((NULL == oXlate ) || ('\0' == *oXlate ))  oXlate  = Strcopy("0,0");
   if ((NULL == oTemp  ) || ('\0' == *oTemp  ))  oTemp   = "";

   /*---------------------------------------------------------------
    * bracketing option
    *---------------------------------------------------------------*/
   info->oBrack = (int) strtol(oBrack,NULL,10);
   if (0 == info->oBrack)
      {
      if ((1 != strlen(oBrack)) || (NULL == strchr("-+",*oBrack)))
         cPostError(1,"invalid value on -b option");

      if ('+' == *oBrack)
         info->oBrack = 1000;
      else
         info->oBrack = 0;
      }

   /*---------------------------------------------------------------
    * extensions for C files
    *---------------------------------------------------------------*/
   info->oCtype = oCtype;

   /*---------------------------------------------------------------
    * duplex
    *---------------------------------------------------------------*/
   if ((1 != strlen(oDuplex)) || (NULL == strchr("-+",*oDuplex)))
      cPostError(1,"invalid value on -d option");

   info->oDuplex  = ('+' == *oDuplex);

   /*---------------------------------------------------------------
    * extensions for H files
    *---------------------------------------------------------------*/
   info->oHtype = oHtype;

   /*---------------------------------------------------------------
    * reserved words
    *---------------------------------------------------------------*/
   InitializeReservedHash(info,oKeys);

   /*---------------------------------------------------------------
    * imbed option
    *---------------------------------------------------------------*/
   info->oImbed  = oImbed;

   /*---------------------------------------------------------------
    * space option
    *---------------------------------------------------------------*/
   info->oSpace = (int) strtol(oSpace,&numLeft,10);
   if (*numLeft || (info->oSpace < 0))
      cPostError(1,"invalid value on -n option");

   /*---------------------------------------------------------------
    * output file option
    *---------------------------------------------------------------*/
   if (NULL == oFile)
      info->oFile = stdout;
   else
      {
      info->oFile = fopen(oFile,"w");
      if (NULL == info->oFile)
         cPostError(1,"error opening output file %s for writing",oFile);
      }

   /*---------------------------------------------------------------
    * page break option
    *---------------------------------------------------------------*/
   if ((1 != strlen(oBreak)) || (NULL == strchr("-+",*oBreak)))
      cPostError(1,"invalid value on -p option");

   info->oBreak  = ('+' == *oBreak);

   /*---------------------------------------------------------------
    * replace PS header
    *---------------------------------------------------------------*/
   info->oRepHdr = oRepHdr;

   /*---------------------------------------------------------------
    * sort option
    *---------------------------------------------------------------*/
   if ((0 != Stricmp("nt",oSort)) && (0 != Stricmp("tn",oSort)))
      cPostError(1,"invalid value on -s option");

   info->oSort  = Strupr(oSort);

   /*---------------------------------------------------------------
    * tabs option
    *---------------------------------------------------------------*/
   info->oTabs = (int) strtol(oTabs,NULL,10);
   if (0 == info->oTabs)
      cPostError(1,"invalid value on -t option");

   /*---------------------------------------------------------------
    * wrap PS around output
    *---------------------------------------------------------------*/
   info->oWrapB = strtok(oWrap,";");
   info->oWrapA = strtok(NULL,"");

   /*---------------------------------------------------------------
    * translate option
    *---------------------------------------------------------------*/
   s1 = strtok(oXlate,",");
   s2 = strtok(NULL,"");

   if (!s1 || !s2)
      cPostError(1,"invalid value on -x option");

   info->oXlateX = (int) strtol(s1,NULL,10);
   info->oXlateY = (int) strtol(s2,NULL,10);

   /*---------------------------------------------------------------
    * temp path
    *---------------------------------------------------------------*/
   if (!strlen(oTemp))
      info->oTemp = "";

   else
      {
      char c;

      c = oTemp[strlen(oTemp) - 1];
      if (('\\' == c) || ('/' == c))
         info->oTemp = oTemp;
      else
         {
         info->oTemp = malloc(2+strlen(oTemp));
         strcpy(info->oTemp,oTemp);
         strcat(info->oTemp,"/");
         }
      }


   }
Example #21
0
File: Str.cpp Project: EQ4/neonv2
bool strtobool(const string &sStr)
{
  if (!Stricmp(sStr, "true" )) return true;
  if (!Stricmp(sStr, "false")) return true;
  return (strtofloat(sStr) > 0);
}
Example #22
0
/**
 * Handle this single ARexx message.
 *
 * @param rxmsg
 * @return
 */
static int arexx_message(struct RexxMsg *rxmsg)
{
	STRPTR command_line = (STRPTR)ARG0(rxmsg);
	APTR command_handle;

	struct {
		STRPTR command;
		STRPTR args;
	} command;

	command.command = command.args = NULL;
	rxmsg->rm_Result1 = 0;
	rxmsg->rm_Result2 = 0;

	SM_DEBUGF(5,("Received ARexx command: \"%s\"\n",command_line));

	if ((command_handle = ParseTemplate("COMMAND/A,ARGS/F",command_line,(LONG*)&command)))
	{
		if (!Stricmp("MAINTOFRONT",command.command)) arexx_maintofront(rxmsg,command.args);
		else if (!Stricmp("MAILWRITE",command.command)) arexx_mailwrite(rxmsg,command.args);
		else if (!Stricmp("WRITEATTACH",command.command)) arexx_writeattach(rxmsg,command.args);
		else if (!Stricmp("WRITECLOSE",command.command)) arexx_writeclose(rxmsg,command.args);
		else if (!Stricmp("SETMAIL",command.command)) arexx_setmail(rxmsg,command.args);
		else if (!Stricmp("SETMAILFILE",command.command)) arexx_setmailfile(rxmsg,command.args);
		else if (!Stricmp("SHOW",command.command)) arexx_show(rxmsg,command.args);
		else if (!Stricmp("HIDE",command.command)) arexx_hide(rxmsg,command.args);
		else if (!Stricmp("QUIT",command.command)) arexx_quit(rxmsg,command.args);
		else if (!Stricmp("GETSELECTED",command.command)) arexx_getselected(rxmsg,command.args);
		else if (!Stricmp("GETMAILSTAT",command.command)) arexx_getmailstat(rxmsg,command.args);
		else if (!Stricmp("FOLDERINFO",command.command)) arexx_folderinfo(rxmsg,command.args);
		else if (!Stricmp("REQUEST",command.command)) arexx_request(rxmsg,command.args);
		else if (!Stricmp("REQUESTSTRING",command.command)) arexx_requeststring(rxmsg,command.args);
		else if (!Stricmp("REQUESTFILE",command.command)) arexx_requestfile(rxmsg,command.args);
		else if (!Stricmp("MAILINFO",command.command)) arexx_mailinfo(rxmsg,command.args);
		else if (!Stricmp("SETFOLDER",command.command)) arexx_setfolder(rxmsg,command.args);
		else if (!Stricmp("ADDRGOTO",command.command)) arexx_addrgoto(rxmsg,command.args);
		else if (!Stricmp("ADDRNEW",command.command)) arexx_addrnew(rxmsg,command.args);
		else if (!Stricmp("ADDRSAVE",command.command)) arexx_addrsave(rxmsg,command.args);
		else if (!Stricmp("ADDRLOAD",command.command)) arexx_addrload(rxmsg,command.args);
		else if (!Stricmp("GETURL",command.command)) arexx_geturl(rxmsg,command.args);
		else if (!Stricmp("NEWMAILFILE",command.command)) arexx_newmailfile(rxmsg,command.args);
		else if (!Stricmp("MAILREAD",command.command)) arexx_mailread(rxmsg,command.args);
		else if (!Stricmp("READCLOSE",command.command)) arexx_readclose(rxmsg,command.args);
		else if (!Stricmp("READINFO",command.command)) arexx_readinfo(rxmsg,command.args);
		else if (!Stricmp("READSAVE",command.command)) arexx_readsave(rxmsg,command.args);
		else if (!Stricmp("SCREENTOBACK",command.command)) {struct Screen *scr = (struct Screen *)main_get_screen(); if (scr) ScreenToBack(scr);}
		else if (!Stricmp("SCREENTOFRONT",command.command)) {struct Screen *scr = (struct Screen *)main_get_screen(); if (scr) ScreenToFront(scr);}
		else if (!Stricmp("REQUESTFOLDER",command.command)) arexx_requestfolder(rxmsg,command.args);
		else if (!Stricmp("MAILADD",command.command)) arexx_mailadd(rxmsg,command.args);
		else if (!Stricmp("MAILSETSTATUS",command.command)) arexx_mailsetstatus(rxmsg,command.args);
		else if (!Stricmp("MAILLISTFREEZE",command.command)) main_freeze_mail_list();
		else if (!Stricmp("MAILLISTTHAW",command.command)) main_thaw_mail_list();
		else if (!Stricmp("MAILFETCH",command.command)) arexx_mailfetch(rxmsg,command.args);
		else if (!Stricmp("OPENMESSAGE",command.command)) arexx_openmessage(rxmsg,command.args);
		else if (!Stricmp("VERSION",command.command)) arexx_version(rxmsg,command.args);
		else if (!Stricmp("MAILMOVE",command.command)) arexx_mailmove(rxmsg,command.args);
		else if (!Stricmp("MAILDELETE",command.command)) arexx_maildelete(rxmsg,command.args);
		else rxmsg->rm_Result1 = 20;

		FreeTemplate(command_handle);
	}
	return 0;
}
Example #23
0
MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
{
	MCONTACT hContact = (MCONTACT)w;
	if (!l) //fix potential DEP crash
		return 0;
	DBEVENTINFO * dbei = (DBEVENTINFO*)l;

	// if event is in protocol that is not despammed
	if (!ProtoInList(dbei->szModule)) {
		// ...let the event go its way
		return 0;
	}
	//do not check excluded contact

	if (db_get_b(hContact, pluginName, "Answered", 0))
		return 0;
	if (db_get_b(hContact, pluginName, "Excluded", 0)) {
		if (!db_get_b(hContact, "CList", "NotOnList", 0))
			db_unset(hContact, pluginName, "Excluded");
		return 0;
	}
	//we want block not only messages, i seen many types other eventtype flood
	if (dbei->flags & DBEF_READ)
		// ...let the event go its way
		return 0;
	//mark contact which we trying to contact for exclude from check
	if ((dbei->flags & DBEF_SENT) && db_get_b(hContact, "CList", "NotOnList", 0)
		&& (!gbMaxQuestCount || db_get_dw(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount) && gbExclude) {
		db_set_b(hContact, pluginName, "Excluded", 1);
		return 0;
	}
	// if message is from known or marked Answered contact
	if (!db_get_b(hContact, "CList", "NotOnList", 0))
		// ...let the event go its way
		return 0;
	// if message is corrupted or empty it cannot be an answer.
	if (!dbei->cbBlob || !dbei->pBlob)
		// reject processing of the event
		return 1;

	tstring message;

	if (dbei->flags & DBEF_UTF) {
		wchar_t* msg_u;
		char* msg_a = mir_strdup((char*)dbei->pBlob);
		mir_utf8decode(msg_a, &msg_u);
		message = msg_u;
	}
	else
		message = mir_a2u((char*)(dbei->pBlob));

	// if message contains right answer...

	boost::algorithm::erase_all(message, "\r");
	boost::algorithm::erase_all(message, "\n");

	bool bSendMsg = true;
	if (gbInvisDisable) {
		if (CallProtoService(dbei->szModule, PS_GETSTATUS, 0, 0) == ID_STATUS_INVISIBLE)
			bSendMsg = false;
		else if (db_get_w(hContact, dbei->szModule, "ApparentMode", 0) == ID_STATUS_OFFLINE)
			bSendMsg = false; //is it useful ?
	}
	bool answered = false;
	if (gbMathExpression) {
		if (boost::algorithm::all(message, boost::is_digit())) {
			int num = _ttoi(message.c_str());
			int math_answer = db_get_dw(hContact, pluginName, "MathAnswer", 0);
			if (num && math_answer)
				answered = (num == math_answer);
		}
	}
	else if (!gbRegexMatch)
		answered = gbCaseInsensitive ? (!Stricmp(message.c_str(), (variables_parse(gbAnswer, hContact).c_str()))) : (!mir_tstrcmp(message.c_str(), (variables_parse(gbAnswer, hContact).c_str())));
	else {
		if (gbCaseInsensitive) {
			std::string check(toUTF8(variables_parse(gbAnswer, hContact))), msg(toUTF8(message));
			boost::algorithm::to_upper(check);
			boost::algorithm::to_upper(msg);
			boost::regex expr(check);
			answered = boost::regex_search(msg.begin(), msg.end(), expr);
		}
		else {
			std::string check(toUTF8(variables_parse(gbAnswer, hContact))), msg(toUTF8(message));
			boost::regex expr(check);
			answered = boost::regex_search(msg.begin(), msg.end(), expr);
		}
	}
	if (answered) {
		// unhide contact
		db_unset(hContact, "CList", "Hidden");

		db_unset(hContact, pluginName, "MathAnswer");

		// mark contact as Answered
		db_set_b(hContact, pluginName, "Answered", 1);

		//add contact permanently
		if (gbAddPermanent) //do not use this )
			db_unset(hContact, "CList", "NotOnList");

		// send congratulation
		if (bSendMsg) {
			tstring prot = DBGetContactSettingStringPAN(NULL, dbei->szModule, "AM_BaseProto", _T(""));
			// for notICQ protocols or disable auto auth. reqwest
			if ((Stricmp(_T("ICQ"), prot.c_str())) || (!gbAutoReqAuth)) {
				char * buf = mir_utf8encodeW(variables_parse(gbCongratulation, hContact).c_str());
				CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)buf);
				mir_free(buf);
			}
			// Note: For ANSI can be not work
			if (!Stricmp(_T("ICQ"), prot.c_str())) {
				// grand auth.
				if (gbAutoAuth)
					CallProtoService(dbei->szModule, "/GrantAuth", w, 0);
				// add contact to server list and local group
				if (gbAutoAddToServerList) {
					db_set_ws(hContact, "CList", "Group", gbAutoAuthGroup.c_str());
					CallProtoService(dbei->szModule, "/AddServerContact", w, 0);
					db_unset(hContact, "CList", "NotOnList");
				};
				// auto auth. reqwest with send congratulation
				if (gbAutoReqAuth)
					CallContactService(hContact, PSS_AUTHREQUEST, 0, (LPARAM)variables_parse(gbCongratulation, hContact).c_str());
			}
		}
		return 0;
	}
	// URL contains check
	bSendMsg = (bSendMsg && gbIgnoreURL) ? (!IsUrlContains((TCHAR *)message.c_str())) : bSendMsg;
	// if message message does not contain infintite talk protection prefix
	// and question count for this contact is less then maximum
	if (bSendMsg) {
		if ((!gbInfTalkProtection || tstring::npos == message.find(_T("StopSpam automatic message:\r\n")))
			&& (!gbMaxQuestCount || db_get_dw(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount)) {
			// send question
			tstring q;
			if (gbInfTalkProtection)
				q += _T("StopSpam automatic message:\r\n");
			if (gbMathExpression) { //parse math expression in question
				tstring tmp_question = gbQuestion;
				std::list<int> args;
				std::list<TCHAR> actions;
				tstring::size_type p1 = gbQuestion.find(_T("X")), p2 = 0;
				const tstring expr_chars = _T("X+-/*"), expr_acts = _T("+-/*");
				while (p1 < gbQuestion.length() && p1 != tstring::npos && expr_chars.find(gbQuestion[p1]) != tstring::npos) {
					std::string arg;
					p2 = p1;
					for (p1 = gbQuestion.find(_T("X"), p1); (p1 < gbQuestion.length()) && (gbQuestion[p1] == L'X'); ++p1)
						arg += get_random_num(1);

					tmp_question.replace(p2, arg.size(), toUTF16(arg));
					args.push_back(atoi(arg.c_str()));

					if ((p1 < gbQuestion.length()) && (p1 != tstring::npos) && (expr_acts.find(gbQuestion[p1]) != tstring::npos))
						actions.push_back(gbQuestion[p1]);
					++p1;
				}
				int math_answer = 0;
				math_answer = args.front();
				args.pop_front();
				while (!args.empty()) {
					if (!actions.empty()) {
						switch (actions.front()) {
						case _T('+'):
							{
								math_answer += args.front();
								args.pop_front();
							}
							break;
						case _T('-'):
							{
								math_answer -= args.front();
								args.pop_front();
							}
							break;
						case _T('/'):
							{
								math_answer /= args.front();
								args.pop_front();
							}
							break;
						case _T('*'):
							{
								math_answer *= args.front();
								args.pop_front();
							}
							break;
						}
						actions.pop_front();
					}
					else
						break;
				}
				db_set_dw(hContact, pluginName, "MathAnswer", math_answer);
				q += variables_parse(tmp_question, hContact);
			}
			else
				q += variables_parse(gbQuestion, hContact);

			CallContactService(hContact, PSS_MESSAGE, 0, ptrA(mir_utf8encodeW(q.c_str())));

			// increment question count
			DWORD questCount = db_get_dw(hContact, pluginName, "QuestionCount", 0);
			db_set_dw(hContact, pluginName, "QuestionCount", questCount + 1);
		}
		else {
			if (gbIgnoreContacts)
				db_set_dw(hContact, "Ignore", "Mask1", 0x0000007F);
		}
	}
	if (gbHideContacts)
		db_set_b(hContact, "CList", "Hidden", 1);
	if (gbSpecialGroup)
		db_set_ws(hContact, "CList", "Group", gbSpammersGroup.c_str());
	db_set_b(hContact, "CList", "NotOnList", 1);

	// save first message from contact
	if (db_get_dw(hContact, pluginName, "QuestionCount", 0) < 2) {
		dbei->flags |= DBEF_READ;
		db_event_add(hContact, dbei);
	};
	// reject processing of the event
	LogSpamToFile(hContact, message);
	return 1;
}
Example #24
0
VOID __stdargs
__main( char *argstring )
{
    static struct Args     args;
    LONG    rev;

    /* Get arguments if started from CLI */
    if( !_WBenchMsg )
    {
        if( !( RDArgs = ReadArgs( TEMPLATE, ( IPTR * ) &args, NULL ) ) )
        {
            PrintFault( IoErr(), GetString( MSG_ERROR_ARGS ) );
            __exit( 0 );
        }
    }

    IntuiHook.h_Entry = ( HOOKFUNC ) IntuiMsgFunc;

//    DefaultPrefs.Flags = 0;
    DefaultPrefs.ReqDefaults[ RTPREF_OTHERREQ      ].ReqPos = REQPOS_POINTER;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].Size = 75;
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].Size =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].Size =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].Size = 65;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].ReqPos =
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].ReqPos =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].ReqPos =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].ReqPos =
    DefaultPrefs.ReqDefaults[ RTPREF_PALETTEREQ    ].ReqPos = REQPOS_TOPLEFTSCR;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_PALETTEREQ    ].LeftOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_OTHERREQ      ].LeftOffset = 25;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_PALETTEREQ    ].TopOffset =
    DefaultPrefs.ReqDefaults[ RTPREF_OTHERREQ      ].TopOffset = 18;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].MinEntries = 10;
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].MinEntries =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].MinEntries =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].MinEntries = 6;
    DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ       ].MaxEntries = 50;
    DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ       ].MaxEntries =
    DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].MaxEntries =
    DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ     ].MaxEntries = 10;

    if( !( IntuitionBase = ( struct IntuitionBase * ) OpenLibrary( "intuition.library", 37 ) ) )
    {
        BPTR    con;

        if( ( con = Open( "CON:40/20/320/40/ReqTools 2.8", MODE_NEWFILE ) ) )
        {
            Write( con, "\nNeed OS 2.04 or better!\n", 25 );
            Delay( 120L );
            Close( con );
        }

        FreeExit( 0 );
    }

    InitLocale();
    GfxBase      = OpenLib( "graphics.library", 37 );
    UtilityBase  = OpenLib( "utility.library", 36 );
    IconBase     = OpenLib( "icon.library", 0 );
    GadToolsBase = OpenLib( "gadtools.library", 37 );
    ReqToolsBase = OpenLib( "reqtools.library", 38 );

    rev = ReqToolsBase->LibNode.lib_Revision;

    if( ( rev >= 693 && rev <= 811 ) || ( rev >= 347 && rev <= 363 ) )
    {
        LocEZReq( MSG_WRONG_REQTOOLS_VERSION, MSG_ABORT );
        FreeExit( RETURN_FAIL );
    }

    if( rtLockPrefs()->PrefsSize != PREFSLEN )
    {
        LocEZReq( MSG_ALL_PREFS_NOT_SUPPORTED, MSG_OK );
    }

    rtUnlockPrefs();

    if( _WBenchMsg )
    {
        struct WBArg    *wbarg;
        BPTR    oldcd;

        CreateIcons = TRUE;
        wbarg = &_WBenchMsg->sm_ArgList[ 0 ];
        oldcd = CurrentDir( wbarg->wa_Lock );

        if( ( DiskObject = GetDiskObject( wbarg->wa_Name ) ) )
        {
            STRPTR    str;

            if( ( str = FindToolType( (UBYTE **)DiskObject->do_ToolTypes, "CREATEICONS" ) ) )
            {
                CreateIcons = Stricmp( str, "NO" );
            }

            if( ( str = FindToolType( (UBYTE **)DiskObject->do_ToolTypes, "SCREENFONT" ) ) )
            {
                UseScreenFont = Stricmp( str, "NO" );
            }

            if( ( str = FindToolType( (UBYTE **)DiskObject->do_ToolTypes, "PUBSCREEN" ) ) )
            {
                args.PubScreen = str;
            }
        }

        CurrentDir( oldcd );
    }
    else
    {
        if( args.ScreenFont )
        {
            UseScreenFont = Stricmp( args.ScreenFont, "NO" );
        }
    }

    if( !( FileReq = rtAllocRequestA( RT_FILEREQ, NULL ) ) )
    {
        FreeExit( RETURN_FAIL );
    }

        {
        struct TagItem tags[] =
        {
            {RTFI_Dir    , (IPTR)"Presets"    },
            {TAG_DONE                }
        };
        
        rtChangeReqAttrA( FileReq, tags );
    }
    
    /* Get current prefs from ReqTools */
    CopyMem( rtLockPrefs(), &RTPrefs, sizeof( struct ReqToolsPrefs ) );
    rtUnlockPrefs();

    /* If FROM was used load prefs from disk */
    if( args.From )
    {
        if( !LoadConfig( args.From ) )
        {
            FreeExit( RETURN_ERROR );
        }
    }

    WheelType = GetWheelType( RTPrefs.Flags );

    if( !( Screen = LockPubScreen( args.PubScreen ) ) )
    {
        LocEZReq( MSG_COULDNT_LOCK_PUBSCREEN, MSG_ABORT );
        FreeExit( RETURN_ERROR );
    }

    if( !( DrawInfo = GetScreenDrawInfo( Screen ) ) )
    {
        LocEZReq( MSG_ERROR_GETSCREENDRAWINFO, MSG_ABORT );
        FreeExit( RETURN_ERROR );
    }

    if( !( VisualInfo = GetVisualInfoA( Screen, NULL ) ) )
    {
        LocEZReq( MSG_ERROR_GETVISUALINFO, MSG_ABORT );
        FreeExit( RETURN_FAIL );
    }

    if( IntuitionBase->LibNode.lib_Version >= 39 )
    {
        Zoom[ 0 ] = Zoom[ 1 ] = 65535;
    }
    else
    {
        Zoom[ 1 ] = Screen->BarHeight + 1;
    }

    Zoom[ 2 ] = 250;
    Zoom[ 3 ] = Screen->WBorTop + Screen->Font->ta_YSize + 1;
    LocalizeMenus( NewMenu );

    if( !( Menus = CreateMenusA( NewMenu, NULL ) ) )
    {
        LocEZReq( MSG_ERROR_MENUS, MSG_ABORT );
        FreeExit( RETURN_FAIL );
    }

    LayoutMenus( Menus, VisualInfo,
        GTMN_NewLookMenus,    TRUE,
    TAG_END );

    if( !OpenGUI() )
    {
        LocEZReq( MSG_COULDNT_OPEN_WINDOW, MSG_ABORT );
        FreeExit( RETURN_FAIL );
    }


    {
        struct MenuItem    *iconItem;

        iconItem = ItemAddress( Menus, FULLMENUNUM( OPTIONS_MENU, SAVEICONS_ITEM, NOSUB ) );

        if( !CreateIcons )
        {
            iconItem->Flags &= ~CHECKED;
        }
    }

    CurrentReq = RTPREF_FILEREQ;
    ReqDefs = &RTPrefs.ReqDefaults[ CurrentReq ];
    LoopGUI();
    FreeExit( 0 );
}
Example #25
0
LONG SmartReadArgs(struct WBStartup * wb_startup, struct SmartArgs * args)
{
   LONG error;

   args->sa_Flags = 0;

   D(bug("UtilityBase = 0x%lx\n", (ULONG) UtilityBase));
   D(bug("IconBase    = 0x%lx\n", (ULONG) IconBase));
   D(bug("WBStartup   = 0x%lx\n", (ULONG) wb_startup));

   if (wb_startup != NULL)
   {
      struct WBArg *wbarg = wb_startup->sm_ArgList;
      LONG arg_counter = 0;

      D(bug("  numArgs   = %ld\n", wb_startup->sm_NumArgs));
      while (arg_counter < wb_startup->sm_NumArgs)
      {
         D(bug("  name[%ld] = \"%s\"\n", arg_counter, wbarg->wa_Name));
         wbarg += 1;
         arg_counter += 1;
      }
   }

   if (wb_startup != NULL)
   {
      if (!(args->sa_RDArgs = AllocDosObject(DOS_RDARGS, NULL)))
      {
         return (ERROR_NO_FREE_STORE);
      }
      else
      {
         args->sa_Flags |= SAF_ALLOCRDARGS;

         if (!args->sa_Buffer)
         {
            args->sa_BufferSize = MAX(SA_MINIMUM_BUFFER_SIZE, args->sa_BufferSize);
            args->sa_Buffer = AllocMem(args->sa_BufferSize, MEMF_ANY);
            args->sa_Flags |= SAF_ALLOCBUFFER;
         }

         if (!args->sa_Buffer)
            return (ERROR_NO_FREE_STORE);
         else
         {
            struct DiskObject *dobj;

            args->sa_ActualPtr = args->sa_Buffer;
            args->sa_EndPtr = args->sa_Buffer + args->sa_BufferSize - 1;

            if (!(dobj = smart_get_icon(args, wb_startup)))
            {
               return (ERROR_OBJECT_NOT_FOUND);
            }
            else
            {
               struct WBArg *wbarg = args->sa_WBArg;
               ULONG num = args->sa_NumArgs;

               STRPTR *tooltypes = (STRPTR *) dobj->do_ToolTypes;
               STRPTR name;
               STRPTR temp;
               STRPTR ptr;

               if (num > 1 && args->sa_FileParameter >= 0 && (temp = AllocMem(TEMPSIZE, MEMF_ANY)))
               {
                  ULONG modes = 0;

                  get_arg_name(args, temp, TEMPSIZE, &modes);
                  fstrcpy(args, temp);
                  fstrcpy(args, " ");

                  /* no "/M" specifier in the ReadArgs() template, thus use only the first file */
                  if (modes != MODE_MULTI)
                     num = 2;

                  while (num > 1)
                  {
                     get_wbarg_name(wbarg, temp, TEMPSIZE);
                     fstrcpy(args, "\"");
                     fstrcpy(args, temp);
                     fstrcpy(args, "\" ");
                     num--;
                     wbarg++;
                  }

                  FreeMem(temp, TEMPSIZE);
               }

               D(bug("tooltypes=%lx\n", (ULONG) tooltypes));
               if (tooltypes)
               {
                  while (*tooltypes)
                  {
                     ptr = *tooltypes;
                     name = ptr;

                     /* check if this tooltype enabled and part of the
                      * template */
                     if ((*ptr != '(')
                         && is_in_template(name, args->sa_Template))
                     {
                        while (*ptr != '=' && *ptr != EOS)
                           ptr++;

                        if (*ptr == '=')
                        {
                           *ptr = EOS;

                           if (!Stricmp(name, "WINDOW"))
                           {
                              STRPTR win;
                              if ((win = AllocVec(strlen(ptr + 1) + 1, MEMF_ANY)))
                              {
                                 strcpy(win, ptr + 1);
                                 args->sa_Window = win;
                                 args->sa_Flags |= SAF_ALLOCWINDOW;
                              }

                           }
                           else
                           {
                              fstrcpy(args, name);

                              /* enclose the argument in "" */
                              if (*(ptr + 1) == '"')
                              {
                                 fstrcpy(args, "=");
                                 fstrcpy(args, ptr + 1);
                              }
                              else
                              {
                                 fstrcpy(args, "=\"");
                                 fstrcpy(args, ptr + 1);
                                 fstrcpy(args, "\"");
                              }

                              *ptr = '=';
                           }
                        }
                        else
                           fstrcpy(args, name);

                        fstrcpy(args, " ");
                     }
                     tooltypes++;
                  }             /* while (*tooltypes) */
               }                /* if (tooltypes) */
               fstrcpy(args, "\n");

               D(bug("final wb command line : \"%s\"\n", args->sa_Buffer));
            }
         }
      }

      args->sa_RDArgs->RDA_Source.CS_Buffer = args->sa_Buffer;
      args->sa_RDArgs->RDA_Source.CS_Length = strlen(args->sa_Buffer);

      args->sa_Flags |= SAF_WORKBENCH;
   }

   args->sa_FreeArgs = ReadArgs(args->sa_Template, args->sa_Parameter, args->sa_RDArgs);

   if (SetSignal(0L, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
   {
      SetIoErr(ERROR_BREAK);
   }

   if ((error = IoErr()) == 0 && (wb_startup != NULL))
   {
      if (args->sa_Window)
      {
         args->sa_WindowFH = Open(args->sa_Window, MODE_NEWFILE);
         if (args->sa_WindowFH)
         {
            args->sa_OldOutput = SelectOutput(args->sa_WindowFH);
            args->sa_OldInput = SelectInput(args->sa_WindowFH);
         }
      }
   }

   return (error);
}
Example #26
0
int main(int argc, char *argv[])
{
  char *cdfile = NULL;
  char *ctfile = NULL;
  char *pofile = NULL;
  char *newctfile = NULL;
  char *catalog = NULL;
  char *source;
  char *template;
  int makenewct = FALSE;
  int makecatalog = FALSE;
  int i;

  if(argc == 0)      /* Aztec's entry point for workbench programs */
  {
    fprintf(stderr, "FlexCat can't be run from Workbench!\n" \
            "\n"
            "Open a Shell session and type FlexCat ?\n" \
            "for more information\n");
    exit(5);
  }

  if(OpenLibs() == FALSE)
    exit(20);

  OpenFlexCatCatalog();

  /* Big Endian vs. Little Endian (both supported ;-) */

  if(!SwapChoose())
  {
    fprintf(stderr, "FlexCat is unable to determine\n" \
            "the byte order used by your system.\n" \
            "It's neither Little nor Big Endian?!.\n");
    exit(5);
  }
#ifdef AMIGA
  ReadPrefs();
#endif
  if(argc == 1)
  {
    Usage();
  }

  for(i = 1; i < argc; i++)
  {
    if(Strnicmp(argv[i], "catalog=", 8) == 0)
    {
      catalog = argv[i] + 8;
      makecatalog = TRUE;
    }
    else if(Stricmp(argv[i], "catalog") == 0)
    {
      if(i == argc - 1)
      {
        catalog = NULL;
        makecatalog = TRUE;
      }
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          catalog = argv[i + 1];
          i++;
          makecatalog = TRUE;
        }
        else
        {
          catalog = NULL;
          makecatalog = TRUE;
        }
      }
    }
    else if(Strnicmp(argv[i], "pofile=", 7) == 0)
    {
      pofile = argv[i] + 7;
    }
    else if(Stricmp(argv[i], "pofile") == 0)
    {
      if(i == argc - 1)
        pofile = NULL;
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          pofile = argv[i + 1];
          i++;
        }
        else
          pofile = NULL;
      }
    }
    else if(Strnicmp(argv[i], "codeset=", 8) == 0)
    {
      strcpy(DestCodeset, argv[i] + 8);
    }
    else if(Stricmp(argv[i], "codeset") == 0)
    {
      if(i == argc - 1)
        DestCodeset[0] = '\0';
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          strcpy(DestCodeset, argv[i + 1]);
          i++;
        }
        else
          DestCodeset[0] = '\0';
      }
    }
    else if(Strnicmp(argv[i], "version=", 8) == 0)
    {
      CatVersion = strtol(argv[i]+8, NULL, 10);
    }
    else if(Stricmp(argv[i], "version") == 0)
    {
      if(i == argc - 1)
        CatVersion = -1;
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          CatVersion = strtol(argv[i + 1], NULL, 10);
          i++;
        }
        else
          CatVersion = -1;
      }
    }
    else if(Strnicmp(argv[i], "revision=", 9) == 0)
    {
      CatRevision = strtol(argv[i]+9, NULL, 10);
    }
    else if(Stricmp(argv[i], "revision") == 0)
    {
      if(i == argc - 1)
        CatRevision = -1;
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          CatRevision = strtol(argv[i + 1], NULL, 10);
          i++;
        }
        else
          CatRevision = -1;
      }
    }
    else if(Stricmp(argv[i], "nooptim") == 0)
    {
      NoOptim = TRUE;
    }
    else if(Stricmp(argv[i], "fill") == 0)
    {
      Fill = TRUE;
    }
    else if(Stricmp(argv[i], "quiet") == 0)
    {
      Quiet = TRUE;
    }
    else if(Stricmp(argv[i], "flush") == 0)
    {
      DoExpunge = TRUE;
    }
    else if(Stricmp(argv[i], "nobeep") == 0)
    {
      NoBeep = TRUE;
    }
    else if(Stricmp(argv[i], "nobufferedio") == 0)
    {
      NoBufferedIO = TRUE;
    }
    else if(Strnicmp(argv[i], "newctfile=", 10) == 0)
    {
      newctfile = argv[i] + 10;
      makenewct = TRUE;
    }
    else if(Stricmp(argv[i], "newctfile") == 0)
    {
      if(i == argc - 1)
      {
        newctfile = NULL;
        makenewct = TRUE;
      }
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          newctfile = argv[i + 1];
          i++;
          makenewct = TRUE;
        }
        else
        {
          newctfile = NULL;
          makenewct = TRUE;
        }
      }
    }
    else if(Stricmp(argv[i], "nolangtolower") == 0)
    {
      LANGToLower = FALSE;
    }
    else if(Stricmp(argv[i], "modified") == 0)
    {
      Modified = TRUE;
    }
    else if(Stricmp(argv[i], "warnctgaps") == 0)
    {
      WarnCTGaps = TRUE;
    }
    else if(Stricmp(argv[i], "copymsgnew") == 0)
    {
      CopyNEWs = TRUE;
    }
    else if(Stricmp(argv[i], "oldmsgnew") == 0)
    {
      snprintf(Old_Msg_New, sizeof(Old_Msg_New), "; %s", argv[++i]);
    }
    else if(Stricmp(argv[i], "noautodate") == 0 || Stricmp(argv[i], "nospaces") == 0)
    {
      // just swallow some no longer supported options to
      // keep old scripts alive and happy
    }
    else if(cdfile == NULL)
    {
      if(Stricmp(argv[i], "?") == 0 ||
         Stricmp(argv[i], "-h") == 0 ||
         Stricmp(argv[i], "help") == 0 ||
         Stricmp(argv[i], "--help") == 0)
      {
        Usage();
      }

      cdfile = argv[i];

      // find out file extension and depending on it
      // we eiterh scan a CD file or the supplied pot file
      if(strstr(cdfile, ".pot") != NULL)
      {
        if(!ScanPOFile(cdfile, FALSE))
          MyExit(10);
      }
      else
      {
        if(!ScanCDFile(cdfile))
          MyExit(10);
      }
    }
    else if(strchr(argv[i], '=') != NULL)
    {
      /* Determine basename. */
      if(BaseName == NULL && cdfile != NULL)
      {
        char *lslash = strrchr(cdfile, '/');
        char  *ldot = strrchr(cdfile, '.');

        if(lslash == NULL)
          lslash = cdfile;
        else
          lslash++;

        if(ldot == NULL)
          ldot = cdfile + strlen(cdfile);

        if(ldot - lslash > 0)
        {
          BaseName = calloc(ldot - lslash + 3, 1);
          strncpy(BaseName, lslash, ldot - lslash);
        }
      }

      source =AllocString(argv[i]);
      template = strchr(source, '=');
      *template++ = '\0';
Example #27
0
/*------------------------------------------------------------------
 * add default key words to reserved hash
 *------------------------------------------------------------------*/
void InitializeReservedHash(
   Info *info,
   char *keyList
   )
   {
   int   i;
   char *part;

   /*---------------------------------------------------------------
    * create hash table
    *---------------------------------------------------------------*/
   info->reservedHash = HashCreate(sizeof(char *),
                                  30,
                                  (HashFunc *)IdentHash,
                                  (ListCompareFunc *)IdentCompare,
                                  cPostNoMem);

   if (!info->reservedHash)
      cPostError(1,"error creating reserved word hash table");

   for (i=0; i<sizeof(ReservedTokens)/sizeof(char *); i++)
      if (!HashAdd(info->reservedHash,&(ReservedTokens[i])))
         cPostError(1,"error adding reserved word '%s' to hash table",
                    ReservedTokens[i]);

   /*---------------------------------------------------------------
    * loop through the comma separated keys ...
    *---------------------------------------------------------------*/
   part = strtok(keyList,",");
   while (part)
      {
      /*------------------------------------------------------------
       * special c++ token
       *------------------------------------------------------------*/
      if (!Stricmp("c++",part))
         {
         for (i=0; i<sizeof(CppReservedTokens)/sizeof(char *); i++)
            if (!HashAdd(info->reservedHash,&(CppReservedTokens[i])))
               cPostError(1,"error adding reserved word '%s' to hash table",
                          CppReservedTokens[i]);

         }

      /*------------------------------------------------------------
       * use Java tokens
       *------------------------------------------------------------*/
      if (!Stricmp("java",part))
         {
         /*------------------------------------------------------------
          * remove default C tokens
          *------------------------------------------------------------*/
         for (i=0; i<sizeof(ReservedTokens)/sizeof(char *); i++)
            HashDelete(info->reservedHash,&(ReservedTokens[i]));

         /*------------------------------------------------------------
          * add Java tokens
          *------------------------------------------------------------*/
         for (i=0; i<sizeof(JavaReservedTokens)/sizeof(char *); i++)
            if (!HashAdd(info->reservedHash,&(JavaReservedTokens[i])))
               cPostError(1,"error adding reserved word '%s' to hash table",
                          JavaReservedTokens[i]);

         }

      /*------------------------------------------------------------
       * file name
       *------------------------------------------------------------*/
      else if (('@' == part[0]) && (1 != strlen(part)))
         {
         TokFileInfo  tfi;
         char        *key;

         part++;

         tfi = TokFileOpen(part);

         if (!tfi)
            cPostError(0,"error opening file '%s' for reading",part);

         else
            {
            while (NULL != (part = TokFileNext(tfi)))
               {
               key = malloc(1 + strlen(part));
               if (!key)
                  cPostError(1,"out of memory!!");

               strcpy(key,part);

               if (!HashAdd(info->reservedHash,&key))
                  cPostError(0,"error adding reserved word '%s' to hash table; word ignored",
                                key);
               }
            }
         }

      /*------------------------------------------------------------
       * plain old token
       *------------------------------------------------------------*/
      else if (!HashAdd(info->reservedHash,&part))
         {
         cPostError(0,"error adding reserved word '%s' to hash table; word ignored",part);
         }

      part = strtok(NULL,",");
      }
   }
Example #28
0
long HandleServerMsg(void)
{
	unsigned long PubScreenModes;
	BlankMsg *CurMsg;
	
	while(CurMsg = (BlankMsg *)GetMsg(ServerPort))
	{
		long Type = CurMsg->bm_Type;
		long Flags = CurMsg->bm_Flags;

		if(Flags & BF_REPLY)
		{
			if(!(Flags & BF_INTERNAL))
				FreeVec(CurMsg);
		}
		else
		{
			CurMsg->bm_Flags |= BF_REPLY;
			ReplyMsg((struct Message *)CurMsg);
		}
		
		switch(Type)
		{
		case BM_DOBLANK:
			if(Flags & BF_REPLY)
			{
				if(!CheckIO((struct IORequest *)TimeOutIO))
				{
					AbortIO((struct IORequest *)TimeOutIO);
					WaitIO((struct IORequest *)TimeOutIO);
					SetSignal(0L, SIG_TIMER);
				}
				if(ServerScr)
				{
					UnblankMousePointer(Wnd);
					CloseScreen(ServerScr);
					ServerScr = 0L;
				}
				if(!PingTask)
					PingTask = CreateTask("GarshnePing", -5, PingFunc, 4096);
				Blanking = TRUE;
			}
			break;
		case BM_DOTESTBLANK:
			if(Flags & BF_REPLY)
			{
				if(!PingTask)
					PingTask = CreateTask("GarshnePing", -5, PingFunc, 4096);
				Blanking = TRUE;
			}
			break;
		case BM_INITMSG:
			if(BlankAfterInit)
			{
				BlankAfterInit = FALSE;
				MessageModule("GarshneClient", BM_DOBLANK);
			}
			break;
		case BM_FAILED:
			if(PingTask)
			{
				Signal(PingTask, SIGBREAKF_CTRL_C);
				PingTask = 0L;
			}
			InternalBlank();
			break;
		case BM_SENDBLANK:
			if((Flags & BF_REPLY)|| BlankingDisabled)
				break;
			if(ServerScr &&(UsagePercent() > 40))
				break;
			PubScreenModes = SetPubScreenModes(0L);
			if(Stricmp(Prefs->bp_Blanker, "Random"))
			{
				if(!Blanking || ServerScr)
					MessageModule("GarshneClient", BM_DOBLANK);
			}
			else
			{
				if(!Blanking || Prefs->bp_Flags & BF_REPLACE)
				{
					MessageModule("GarshneClient", BM_DELAYEDQUIT);
					BlankAfterInit = TRUE;
					LoadModule(Prefs->bp_Dir, Prefs->bp_Blanker);
				}
				else if(ServerScr)
					MessageModule("GarshneClient", BM_DOBLANK);
			}
			SetPubScreenModes(PubScreenModes);
			break;
		case BM_SENDTEST:
			if((Flags & BF_REPLY)|| BlankingDisabled)
				break;
			PubScreenModes = SetPubScreenModes(0L);
			MessageModule("GarshneClient", BM_DOTESTBLANK);
			SetPubScreenModes(PubScreenModes);
			break;
		case BM_SENDUNBLANK:
			if(Flags & BF_REPLY)
				break;
			if(ServerScr)
			{
				UnblankMousePointer(Wnd);
				CloseScreen(ServerScr);
				ServerScr = 0L;
			}
			Blanking = FALSE;
			MessageModule("GarshneClient", BM_UNBLANK);
			if(PingTask)
			{
				Signal(PingTask, SIGBREAKF_CTRL_C);
				PingTask = 0L;
			}
			break;
		default:
			break;
		}
	}

	return OK;
}
Example #29
0
/// isParam
int isParam(char *input_string)
{
  if(Stricmp(input_string, "catalog") == 0)
    return TRUE;
  if(Strnicmp(input_string, "catalog=", 8) == 0)
    return TRUE;
  if(Stricmp(input_string, "pofile") == 0)
    return TRUE;
  if(Strnicmp(input_string, "pofile=", 7) == 0)
    return TRUE;
  if(Stricmp(input_string, "codeset") == 0)
    return TRUE;
  if(Strnicmp(input_string, "codeset=", 8) == 0)
    return TRUE;
  if(Stricmp(input_string, "version") == 0)
    return TRUE;
  if(Strnicmp(input_string, "version=", 8) == 0)
    return TRUE;
  if(Stricmp(input_string, "revision") == 0)
    return TRUE;
  if(Strnicmp(input_string, "revision=", 8) == 0)
    return TRUE;
  if(Stricmp(input_string, "nooptim") == 0)
    return TRUE;
  if(Stricmp(input_string, "fill") == 0)
    return TRUE;
  if(Stricmp(input_string, "quiet") == 0)
    return TRUE;
  if(Stricmp(input_string, "flush") == 0)
    return TRUE;
  if(Stricmp(input_string, "nobeep") == 0)
    return TRUE;
  if(Stricmp(input_string, "nobufferedio") == 0)
    return TRUE;
  if(Strnicmp(input_string, "newctfile=", 10) == 0)
    return TRUE;
  if(Stricmp(input_string, "newctfile") == 0)
    return TRUE;
  if(Stricmp(input_string, "nolangtolower") == 0)
    return TRUE;
  if(Stricmp(input_string, "modified") == 0)
    return TRUE;
  if(Stricmp(input_string, "warnctgaps") == 0)
    return TRUE;
  if(Stricmp(input_string, "copymsgnew") == 0)
    return TRUE;
  if(Stricmp(input_string, "oldmsgnew") == 0)
    return TRUE;
  if(Stricmp(input_string, "?") == 0)
    return TRUE;
  if(Stricmp(input_string, "-h") == 0)
    return TRUE;
  if(Stricmp(input_string, "help") == 0)
    return TRUE;
  if(Stricmp(input_string, "--help") == 0)
    return TRUE;

  return FALSE;
}
STATIC SIPTR ScreenCompareFunc(struct Hook *h, struct ScreenNode *node1, struct ScreenNode *node2)
{
	return Stricmp(node2->title, node1->title);
}