Exemplo n.º 1
0
static void make_screens(int argc,char **argv)
{
	int x,y;
	struct RPTSTRUCTs r;

	if(argc==2 && !RDAstrcmp(argv[1],"ALL"))
	{
		selectall(NULL);
	} else {
		for(x=1;x<argc;++x)
		{
			for(y=0;y<NE(RptAvl);++y)
			{
				r=RptAvl[y];
				if(!RDAstrcmp(argv[x],r.name))
				{
/*lint -e746 */
					r.func();
/*lint +e746 */
					break;
				
				}
			}
			if(y>=NE(RptAvl))
			{
				prterr("ERROR: Report [%s] not in collection of defined reports for FINMGT.",argv[x]);
			}
		}
	}
}
Exemplo n.º 2
0
void Constraint::LinkToElementsPenalty()
{
	if (IS()!=0 && SOS()!=0)
	{
		UO(UO_LVL_err) << "Error: Constraint::LinkToElementsPenalty() is not possible for mixed penalty/Lagrange elements\n";
	}
	LTGreset();

	// add all SOS dofs from the elements
	//Position(first SOS) 
	for (int k=1; k <= NE(); k++)
	{
		for (int i=1; i <= GetElem(k).SOS(); i++)
		{
			AddLTG(GetElem(k).LTG(i));
		}
	}
	//and Velocity (second SOS):
	for (int k=1; k <= NE(); k++)
	{
		for (int i=1; i <= GetElem(k).SOS(); i++)
		{
			AddLTG(GetElem(k).LTG(i+GetElem(k).SOS()));
		}
	}
}
Exemplo n.º 3
0
static void selectall(RDArsrc *mainrsrc)
{
	int x;
	struct RPTSTRUCTs r;
	short did_it=FALSE;
	RDArsrc *tmprsrc=NULL;

	if(mainrsrc!=NULL)
	{
		tmprsrc=odiagscrn("DIAGNOSTIC SCREEN",module,"Creating Standard Reports",NULL,NE(RptAvl));
		if(tmprsrc!=NULL)
		{
			if(ADVmakescrn(tmprsrc,TRUE))
			{
				prterr("Error Cannot Create Diagnostic Screen.");
				if(tmprsrc!=NULL) free_rsrc(tmprsrc);
			} else {
				ForceWindowUpdate(tmprsrc);
			}
		}
	}
	for(x=0;x<NE(RptAvl);++x)
	{
		r=RptAvl[x];
		if(r.func!=NULL)
		{
/*lint -e746 */
			r.func();
/*lint +e746 */
			if(mainrsrc!=NULL)
			{
				FINDRSCLISTAPPlib(mainrsrc,"ERROR LIST",0,errorlist);
				updatersrc(mainrsrc,"ERROR LIST");
				did_it=TRUE;
			}
		} else {
			if(mainrsrc!=NULL)
			{
				did_it=FALSE;
			}
		}
		if(mainrsrc!=NULL)
		{
			if(tmprsrc!=NULL) 
			{
				update_diagnostic(tmprsrc,(did_it ? TRUE:FALSE));
			}
		}
	}
	if(mainrsrc!=NULL)
	{
		if(tmprsrc!=NULL)
		{
			killwindow(tmprsrc);
			free_rsrc(tmprsrc);
		}
	}
	Establish_Install_Date(module);
}
Exemplo n.º 4
0
Arquivo: point.c Projeto: armnlib/xrec
 extern int
 pnt_almostEQ ( float x1, float y1, float x2, float y2 )
    {
    int i;

/*
 *  latitude differ enough
 */
    i = NE(x1,x2);
    if( i ) return(!i);

/*
 *  latitude and longitude are the same enough
 */
    i = EQ(y1,y2);
    if( i ) return(i);

/*
 *  longitude differ : check if it is because of the world wraping at 180 ?
 */
    i = ( EQ(180.0,fabs((double)y1)) && EQ(180.0,fabs((double)y2)) );
    if( !i ) return(i);

/*
 *  longitude in the world wraping (180) check if they are the same enough
 */
    i = ( 360.0 - fabs((double)y1) - fabs((double)y2) <= seuil );
    return(i);
    }
Exemplo n.º 5
0
STATIC nbr3x3_t recalc_nbr3x3(board_t *b, index_t pos)
{
    return construct_3x3(b->stones[N(b, pos)], b->stones[S(b, pos)],
                         b->stones[W(b, pos)], b->stones[E(b, pos)],
                         b->stones[NE(b, pos)], b->stones[NW(b, pos)],
                         b->stones[SE(b, pos)], b->stones[SW(b, pos)]);
}
Exemplo n.º 6
0
bool Thinning::vizinhanca(QImage *img, int x,int y) {



// verificaCorerifica se o número de vizinhos pretos está na faixa entre 2 e 6
int vizinhos=0;

vizinhos = ( verificaPixel(img, NO(x,y)) + verificaPixel(img, N(x,y)) + verificaPixel(img,NE(x,y)) +
           verificaPixel(img, O(x,y)) + verificaPixel(img, L(x,y)) + verificaPixel(img, SO(x,y)) +
           verificaPixel(img, S(x,y)) + verificaPixel(img, SE(x,y)) );

if (vizinhos < 2 || vizinhos > 6) return false;

// verificaCorerifica conectividade é igual 1...
int conectividade = 0;

if(verificaPixel (img, N(x,y))  == false && verificaPixel (img, NE(x,y)) == true)
        conectividade++;

if(verificaPixel(img, NE(x,y)) == false && verificaPixel(img, L(x,y)) == true)
    conectividade++;

if(verificaPixel(img, L(x,y)) == false && verificaPixel(img, SE(x,y)) == true)
    conectividade++;

if(verificaPixel(img, SE(x,y)) == false && verificaPixel(img, S(x,y)) == true)
    conectividade++;

if(verificaPixel(img, S(x,y)) == false && verificaPixel(img, SO(x,y)) == true)
    conectividade++;

if(verificaPixel(img, SO(x,y)) == false && verificaPixel(img, O(x,y)) == true)
    conectividade++;

if(verificaPixel(img, O(x,y)) == false && verificaPixel(img, NO(x,y)) == true)
    conectividade++;

if(verificaPixel(img, NO(x,y)) == false && verificaPixel(img, N(x,y)) == true)
    conectividade++;

if(conectividade == 1)
    return true;
else
    return false;

}
Exemplo n.º 7
0
main ()
{
  int c;

  while ('\033' NE (0x00FF & (c = Bconin (CON_DEV))))
    {

      printf ("%08x\n", c);
    }
}
Exemplo n.º 8
0
static int
waitcr ()
{
  char c;

  BIOS (B_PUTC, CON_DEV, '\007');

  while ('\r' NE (c = (0x7F & BIOS (B_GETC, CON_DEV))))
    if (c EQ '\007')
      xtrap15 ();
}
Exemplo n.º 9
0
static Boolean
SetValues(Widget curW,
	  Widget reqW,
	  Widget newW,
	  ArgList args,
	  Cardinal *nargs)
{
	XmLTreeWidget t, cur;
	XmLGridColumn col;
	Boolean needsResize, needsRedraw;
 
	t = (XmLTreeWidget)newW;
	cur = (XmLTreeWidget)curW;
	needsResize = False;
	needsRedraw = False;

#define NE(value) (t->value != cur->value)
	if (NE(grid.rowCount))
		XmLWarning(newW, "SetValues() - can't set XmNrows");
	if (NE(tree.pmColor) || NE(tree.lineColor))
		needsRedraw = True;
	if (NE(tree.levelSpacing) ||
		t->tree.recalcTreeWidth)
		{
		col = XmLGridGetColumn(newW, XmCONTENT, 0);
		if (col)
			col->grid.widthInPixelsValid = 0;
		t->tree.recalcTreeWidth = 0;
		needsResize = True;
		needsRedraw = True;
		}
#undef NE
	if (needsResize)
		_XmLGridLayout((XmLGridWidget)t);
	if (needsRedraw)
		XmLGridRedrawAll((Widget)t);
	return False;
}
Exemplo n.º 10
0
void Constraint::LinkToElements() 
{
	if (UsePenaltyFormulation()) //in penalty formulation, the SOS-DOF are hired from constrained elements
	{
		LinkToElementsPenalty();
	}
	else
	{
		for (int i = 1; i <= NE(); i++) //$ DR 2012-11-02: changed elements.Length() to NE(), because some constraints add element(2) = 0 for ground joints, NE() returns the correct value for these constraints 
		{
			GetElem(i).AddConstraint(this,i);
		}
	}
}
Exemplo n.º 11
0
inline static void delete_stone_update_3x3(board_t *b, index_t pos)
{
#define LOOP(P, OFFSET) {\
    b->nbr3x3[P] &= ~(3U << OFFSET); \
    touch_nbr3x3(b, P); \
}
    LOOP(W(b, pos), 0);
    LOOP(SW(b, pos), 2);
    LOOP(S(b, pos), 4);
    LOOP(SE(b, pos), 6);
    LOOP(E(b, pos), 8);
    LOOP(NE(b, pos), 10);
    LOOP(N(b, pos), 12);
    LOOP(NW(b, pos), 14);
#undef LOOP
    touch_nbr3x3(b, pos);
}
Exemplo n.º 12
0
static APPlib *makescnlist()
{
	int x;
	char *tmp=NULL;
	struct RPTSTRUCTs r;
	APPlib *a;

	a=APPlibNEW();
	for(x=0;x<NE(RptAvl);++x)
	{
		r=RptAvl[x];
		tmp=Rmalloc(RDAstrlen(r.name)+RDAstrlen(r.desc)+16);
		sprintf(tmp,"%3d [%s] [%s]",(x+1),r.name,r.desc);
		addAPPlib(a,tmp);
		if(tmp!=NULL) Rfree(tmp);
	}
	return(a);
}
Exemplo n.º 13
0
inline static void add_stone_update_3x3(board_t *b, index_t pos)
{
    nbr3x3_t bit = (nbr3x3_t)b->stones[pos];
#define LOOP(P, OFFSET) {\
    b->nbr3x3[P] &= ~(3U << OFFSET); \
    b->nbr3x3[P] |= bit << OFFSET; \
    touch_nbr3x3(b, P); \
}
    LOOP(W(b, pos), 0);
    LOOP(SW(b, pos), 2);
    LOOP(S(b, pos), 4);
    LOOP(SE(b, pos), 6);
    LOOP(E(b, pos), 8);
    LOOP(NE(b, pos), 10);
    LOOP(N(b, pos), 12);
    LOOP(NW(b, pos), 14);
#undef LOOP
    touch_nbr3x3(b, pos);
}
Exemplo n.º 14
0
main ()
{
  short len, rc;

  len = sizeof verbuf;

  /* first, read the version message object file */

  if ((FILE *) NULL EQ (fp = fopenb (VERFILE, "r")))
    {

      printf ("ERROR -- Unable to open \"%s\" for reading  (errno = %d)\n",
	      VERFILE, errno);

      exit (1);
    }

  rewind (fp);

  if (1 NE (rc = fread (&verbuf, len, 1, fp)))
    {

      printf ("ERROR -- Unable to read \"%s\"  (rc = %d, errno = %d)\n",
	      VERFILE, rc, errno);

      if (ferror (fp))
	printf ("  File system ERROR.\n");
      else if (feof (fp))
	printf ("  Premature EOF.\n");
      else
	printf ("  Neither ERROR or EOF set -- very odd\n");

      fclose (fp);
      exit (1);
    }

  /* close the file, print the version message, and exit */

  fclose (fp);
  printf ("Current version:  %s\n", verbuf.ver);
  exit (0);
}
Exemplo n.º 15
0
static void selectrpt(RDArsrc *mainrsrc)
{
	int selected=0;
	struct RPTSTRUCTs r;
	char *temp=NULL;
	RDArsrc *tmprsrc=NULL;

	FINDRSCGETINT(mainrsrc,"RESOURCE LIST",&selected);
	r=RptAvl[selected];
	if(r.func!=NULL)
	{
		temp=Rmalloc(RDAstrlen(r.name)+18);
		sprintf(temp,"Creating %s Report",(r.name!=NULL?r.name:""));
		tmprsrc=odiagscrn("DIAGNOSTIC SCREEN",module,temp,NULL,NE(RptAvl));
		if(temp!=NULL) Rfree(temp);
		if(tmprsrc!=NULL)
		{
			if(ADVmakescrn(tmprsrc,TRUE))
			{
				prterr("Error Cannot Create Diagnostic Screen.");
				if(tmprsrc!=NULL) free_rsrc(tmprsrc);
			} else {
				ForceWindowUpdate(tmprsrc);
			}
		}
/*lint -e746 */
		r.func();
/*lint +e746 */
		FINDRSCLISTAPPlib(mainrsrc,"ERROR LIST",0,errorlist);
		updatersrc(mainrsrc,"ERROR LIST");
		if(tmprsrc!=NULL) 
		{
			update_diagnostic(tmprsrc,TRUE);
		}
		if(tmprsrc!=NULL)
		{
			killwindow(tmprsrc);
			free_rsrc(tmprsrc);
		}
	}
}
Exemplo n.º 16
0
LPPL_YYSTYPE SysFnMonSTRACE_EM_YY
    (LPTOKEN lptkFunc,              // Ptr to function token
     LPTOKEN lptkRhtArg,            // Ptr to right arg token
     LPTOKEN lptkAxis,              // Ptr to axis token (may be NULL)
     UBOOL   bTrace)                // TRUE iff this is a call to []TRACE

{
    APLSTYPE          aplTypeRht;           // Right arg storage type
    APLNELM           aplNELMRht,           // Right arg NELM
                      aplNELMRes;           // Result NELM
    APLRANK           aplRankRht;           // Right arg Rank
    APLLONGEST        aplLongestRht;        // Right arg longest if immediate
    HGLOBAL           hGlbRht = NULL,       // Right arg global memory handle
                      hGlbRes = NULL;       // Result    ...
    LPVARARRAY_HEADER lpMemHdrRht = NULL,   // Ptr to right arg header
                      lpMemHdrRes = NULL;   // ...    result    ...
    LPAPLCHAR         lpMemRht;             // Ptr to right arg data
    LPAPLINT          lpMemRes;             // ...    result    ...
    LPSYMENTRY        lpSymEntry;           // Ptr to SYMENTRY
    LPDFN_HEADER      lpMemDfnHdr = NULL;   // Ptr to DFN_HDR global memory
    STFLAGS           stFlags;              // STE flags
    LPPL_YYSTYPE      lpYYRes = NULL;       // Ptr to the result
    LPFCNLINE         lpFcnLines;           // Ptr to array of function line structs (FCNLINE[numFcnLines])
    UINT              uNumLines,            // # function lines
                      uLine;                // Loop counter
    APLUINT           ByteRes;              // # bytes in the result

    // Get the attributes (Type, NELM, and Rank)
    //   of the right arg
    AttrsOfToken (lptkRhtArg, &aplTypeRht, &aplNELMRht, &aplRankRht, NULL);

    // Check for RANK ERROR
    if (IsMultiRank (aplRankRht))
        goto RANK_EXIT;

    // Check for DOMAIN ERROR
    if (!IsSimpleChar (aplTypeRht))
        goto DOMAIN_EXIT;

    // Get right arg's global ptrs
    aplLongestRht = GetGlbPtrs_LOCK (lptkRhtArg, &hGlbRht, &lpMemHdrRht);

    // Skip over the header and dimensions to the data
    if (lpMemHdrRht NE NULL)
        lpMemRht = VarArrayDataFmBase (lpMemHdrRht);
    else
        lpMemRht = (LPAPLCHAR) &aplLongestRht;

    // Lookup the name in the symbol table
    // SymTabLookupName sets the .ObjName enum,
    //   and the .Inuse flag
    ZeroMemory (&stFlags, sizeof (stFlags));
    lpSymEntry =
      SymTabLookupNameLength (lpMemRht,
                              lstrlenW (lpMemRht),
                             &stFlags);
    // If not found, ...
    if (lpSymEntry EQ NULL)
        goto DOMAIN_EXIT;

    // If it's not a user-defined function or MFO, ...
    if ((stFlags.ObjName NE OBJNAME_USR
      && stFlags.ObjName NE OBJNAME_MFO)
     || stFlags.stNameType EQ NAMETYPE_VAR)
        goto DOMAIN_EXIT;

    // Lock the memory to get a ptr to it
    lpMemDfnHdr = MyGlobalLockDfn (lpSymEntry->stData.stGlbData);

    // Get ptr to array of function line structs (FCNLINE[numFcnLines])
    lpFcnLines = (LPFCNLINE) ByteAddr (lpMemDfnHdr, lpMemDfnHdr->offFcnLines);

    // Get # function lines
    uNumLines = lpMemDfnHdr->numFcnLines;

    // Count in the header
    aplNELMRes =  ( bTrace  && lpMemDfnHdr->bTraceHdr)
              || ((~bTrace) && lpMemDfnHdr->bStopHdr);

    // Run through the function lines
    for (uLine = 0; uLine < uNumLines; uLine++)
    // Count the # active STOP/TRACE lines
    if (bTrace)
        aplNELMRes += lpFcnLines[uLine].bTrace;
    else
        aplNELMRes += lpFcnLines[uLine].bStop;

    // Calculate space needed for the result
    ByteRes = CalcArraySize (ARRAY_INT, aplNELMRes, 1);

    // Check for overflow
    if (ByteRes NE (APLU3264) ByteRes)
        goto WSFULL_EXIT;

    // Allocate space for the result
    hGlbRes = DbgGlobalAlloc (GHND, (APLU3264) ByteRes);
    if (hGlbRes EQ NULL)
        goto WSFULL_EXIT;

    // Lock the memory to get a ptr to it
    lpMemHdrRes = MyGlobalLock000 (hGlbRes);

#define lpHeader    lpMemHdrRes
    // Fill in the header
    lpHeader->Sig.nature = VARARRAY_HEADER_SIGNATURE;
    lpHeader->ArrType    = ARRAY_INT;
////lpHeader->PermNdx    = PERMNDX_NONE;// Already zero from GHND
////lpHeader->SysVar     = FALSE;       // Already zero from GHND
    lpHeader->RefCnt     = 1;
    lpHeader->NELM       = aplNELMRes;
    lpHeader->Rank       = 1;
#undef  lpHeader

    // Fill in the dimension
    *VarArrayBaseToDim (lpMemHdrRes) = aplNELMRes;

    // Skip over the header and dimensions to the data
    lpMemRes = VarArrayDataFmBase (lpMemHdrRes);

    // Check on the STOP/TRACE of the header
    if ((  bTrace  && lpMemDfnHdr->bTraceHdr)
     || ((~bTrace) && lpMemDfnHdr->bStopHdr))
        *lpMemRes++ = 0;

    // Run through the function lines
    for (uLine = 0; uLine < uNumLines; uLine++)
    if ((  bTrace  && lpFcnLines[uLine].bTrace)
     || ((!bTrace) && lpFcnLines[uLine].bStop))
        *lpMemRes++ = uLine + 1;

    // Allocate a new YYRes
    lpYYRes = YYAlloc ();

    // Fill in the result token
    lpYYRes->tkToken.tkFlags.TknType   = TKT_VARARRAY;
////lpYYRes->tkToken.tkFlags.ImmType   = IMMTYPE_ERROR; // Already zero from YYAlloc
////lpYYRes->tkToken.tkFlags.NoDisplay = FALSE;         // ...
    lpYYRes->tkToken.tkData.tkGlbData  = MakePtrTypeGlb (hGlbRes);
    lpYYRes->tkToken.tkCharIndex       = lptkFunc->tkCharIndex;

    goto NORMAL_EXIT;

RANK_EXIT:
    ErrorMessageIndirectToken (ERRMSG_RANK_ERROR APPEND_NAME,
                               lptkFunc);
    goto ERROR_EXIT;

DOMAIN_EXIT:
    ErrorMessageIndirectToken (ERRMSG_DOMAIN_ERROR APPEND_NAME,
                               lptkFunc);
    goto ERROR_EXIT;

WSFULL_EXIT:
    ErrorMessageIndirectToken (ERRMSG_WS_FULL APPEND_NAME,
                               lptkFunc);
    goto ERROR_EXIT;

ERROR_EXIT:
    if (hGlbRes NE NULL)
    {
        if (lpMemHdrRes NE NULL)
        {
            // We no longer need this ptr
            MyGlobalUnlock (hGlbRes); lpMemHdrRes = NULL;
        } // End IF

        // We no longer need this storage
        FreeResultGlobalIncompleteVar (hGlbRes); hGlbRes = NULL;
    } // End IF
NORMAL_EXIT:
    if (lpMemDfnHdr NE NULL)
    {
        // We no longer need this ptr
        MyGlobalUnlock (lpSymEntry->stData.stGlbData); lpMemDfnHdr = NULL;
    } // End IF

    if (hGlbRes NE NULL && lpMemHdrRes NE NULL)
    {
        // We no longer need this ptr
        MyGlobalUnlock (hGlbRes); lpMemHdrRes = NULL;
    } // End IF

    if (hGlbRht NE NULL && lpMemHdrRht NE NULL)
    {
        // We no longer need this ptr
        MyGlobalUnlock (hGlbRht); lpMemHdrRht = NULL;
    } // End IF

    return lpYYRes;
} // End SysFnMonSTRACE_EM_YY
Exemplo n.º 17
0
#include "kernel_alg.h"

#ifdef XAUTH_USEPAM
#include <security/pam_appl.h>
#endif

/* Minimum priority number in SPD used by pluto. */
#define MIN_SPD_PRIORITY 1024

static int netlinkfd = NULL_FD;
static int netlink_bcast_fd = NULL_FD;

#define NE(x) { x, #x }	/* Name Entry -- shorthand for sparse_names */

static sparse_names xfrm_type_names = {
	NE(NLMSG_NOOP),
	NE(NLMSG_ERROR),
	NE(NLMSG_DONE),
	NE(NLMSG_OVERRUN),

	NE(XFRM_MSG_NEWSA),
	NE(XFRM_MSG_DELSA),
	NE(XFRM_MSG_GETSA),

	NE(XFRM_MSG_NEWPOLICY),
	NE(XFRM_MSG_DELPOLICY),
	NE(XFRM_MSG_GETPOLICY),

	NE(XFRM_MSG_ALLOCSPI),
	NE(XFRM_MSG_ACQUIRE),
	NE(XFRM_MSG_EXPIRE),
Exemplo n.º 18
0
LPPL_YYSTYPE SysFnSYSVER_EM_YY
    (LPTOKEN lptkLftArg,            // Ptr to left arg token (should be NULL)
     LPTOKEN lptkFunc,              // Ptr to function token
     LPTOKEN lptkRhtArg,            // Ptr to right arg token (should be NULL)
     LPTOKEN lptkAxis)              // Ptr to axis token (may be NULL)

{
    APLUINT      ByteRes;           // # bytes in the result
    APLNELM      aplNELMRes;        // Result NELM
    HGLOBAL      hGlbRes;           // Result global memory handle
    LPAPLCHAR    lpMemRes,          // Ptr to result global memory
                 lpMemData;         // Ptr to result data
    LPAPLCHAR    lpw;               // Temporary ptr
    HANDLE       hFile;             // File handle from CreateFileW
    LPPL_YYSTYPE lpYYRes;           // Ptr to the result

    // This function is niladic
    Assert (lptkLftArg EQ NULL && lptkRhtArg EQ NULL);

    //***************************************************************
    // This function is not sensitive to the axis operator,
    //   so signal a syntax error if present
    //***************************************************************
    if (lptkAxis NE NULL)
        goto AXIS_SYNTAX_EXIT;

    // Define maximum length of []SYSVER
#ifdef DEBUG
  #define DEBUGSTR      L" (DEBUG)"
#else
  #define DEBUGSTR
#endif

#define SYSVER  L"000.000.0000.00799  Tue Jan 16 17:43:45 2007  Win/32" DEBUGSTR
#define SYSVER_NELM    strcountof (SYSVER)

    // Calculate space needed for the result
    ByteRes = CalcArraySize (ARRAY_CHAR, SYSVER_NELM, 1);

    // Check for overflow
    if (ByteRes NE (APLU3264) ByteRes)
        goto WSFULL_EXIT;

    // Allocate space for the result
    hGlbRes = DbgGlobalAlloc (GHND, (APLU3264) ByteRes);
    if (hGlbRes EQ NULL)
        goto WSFULL_EXIT;

    // Lock the memory to get a ptr to it
    lpMemRes = MyGlobalLock000 (hGlbRes);

#define lpHeader    ((LPVARARRAY_HEADER) lpMemRes)
    // Fill in the header
    lpHeader->Sig.nature = VARARRAY_HEADER_SIGNATURE;
    lpHeader->ArrType    = ARRAY_CHAR;
////lpHeader->PermNdx    = PERMNDX_NONE;    // Already zero from GHND
////lpHeader->SysVar     = FALSE;           // Already zero from GHND
    lpHeader->RefCnt     = 1;
////lpHeader->NELM       = SYSVER_NELM;     // Filled in below
    lpHeader->Rank       = 1;
#undef  lpHeader

    // Fill in the dimension
////*VarArrayBaseToDim (lpMemRes) = SYSVER_NELM;    // Filled in below

    // Skip over the header and dimensions to the data
    lpw = lpMemData = VarArrayDataFmBase (lpMemRes);

    // Copy the application's File Version String
    strcpyW (lpw, wszFileVer);

    // Skip to the trailing zero
    lpw += lstrlenW (lpw);
    *lpw++ = L' ';      // Blank separators
    *lpw++ = L' ';

    // Open the executable file so we get its last write time
    hFile =
      CreateFileW (wszAppDPFE,              // lpwFileName
                   GENERIC_READ,            // dwDesiredAccess
                   FILE_SHARE_READ,         // dwShareMode
                   NULL,                    // lpSecurityAttributes
                   OPEN_EXISTING,           // dwCreationDistribution
                   FILE_ATTRIBUTE_NORMAL,   // dwFlagsAndAttributes
                   NULL);                   // hTemplateFile
    if (hFile NE INVALID_HANDLE_VALUE)
    {
        FILETIME   ftLastWrite;
        SYSTEMTIME systemTime;

        // Get the file's last write time
        // Note that the file's creation time need not be the
        //   same as the file's last write time.  I think the
        //   linker might sometimes rewrite the .exe file
        //   instead of recreating it.
        GetFileTime (hFile, NULL, NULL, &ftLastWrite);

        // We no longer need this handle
        CloseHandle (hFile); hFile = NULL;

        // Convert the file's last write time to system time
        FileTimeToSystemTime (&ftLastWrite, &systemTime);

        // Format the system time as
        //    "Wed Jan 02 02:03:55 1980"
        wsprintfW (lpw,
                   L"%s %s %02u %02u:%02u:%02u %u",
                   aDaysOfWeek[systemTime.wDayOfWeek],
                   aMonths[systemTime.wMonth - 1],
                   systemTime.wDay,
                   systemTime.wHour,
                   systemTime.wMinute,
                   systemTime.wSecond,
                   systemTime.wYear);
        // Skip to the trailing zero
        lpw += lstrlenW (lpw);
        *lpw++ = L' ';    // Blank separators
        *lpw++ = L' ';
    } // End IF

#ifdef _WIN64
  #define SYSTYPE     L"Win/64" DEBUGSTR
#elif defined (_WIN32)
  #define SYSTYPE     L"Win/32" DEBUGSTR
#else
  #error Need code for this architecture.
#endif

    // Copy to the result
    CopyMemoryW (lpw, SYSTYPE, strcountof (SYSTYPE));

    // Calculate the actual NELM
    aplNELMRes = lstrlenW (lpMemData);

    // Fill in actual length of []SYSVER
#define lpHeader    ((LPVARARRAY_HEADER) lpMemRes)
    lpHeader->NELM = aplNELMRes;
#undef  lpHeader

    // Fill in the dimension
    *VarArrayBaseToDim (lpMemRes) = aplNELMRes;

    // We no longer need this ptr
    MyGlobalUnlock (hGlbRes); lpMemRes = NULL;

    // Make sure we didn't overwrite
    if (aplNELMRes < SYSVER_NELM)
    {
        // Calculate space needed for the result
        ByteRes = CalcArraySize (ARRAY_CHAR, aplNELMRes, 1);

////////// Check for overflow
////////if (ByteRes NE (APLU3264) ByteRes)
////////    goto WSFULL_EXIT;

        // Re-allocate the global downwards
        hGlbRes =
          MyGlobalReAlloc (hGlbRes, (APLU3264) ByteRes, GMEM_MOVEABLE);
    } else
    if (aplNELMRes > SYSVER_NELM)
        // We should never get here
        DbgStop ();

    // Allocate a new YYRes
    lpYYRes = YYAlloc ();

    // Fill in the result token
    lpYYRes->tkToken.tkFlags.TknType   = TKT_VARARRAY;
////lpYYRes->tkToken.tkFlags.ImmType   = IMMTYPE_ERROR; y    // Already zero from YYAlloc
////lpYYRes->tkToken.tkFlags.NoDisplay = FALSE;         // Already zero from YYAlloc
    lpYYRes->tkToken.tkData.tkGlbData  = MakePtrTypeGlb (hGlbRes);
    lpYYRes->tkToken.tkCharIndex       = lptkFunc->tkCharIndex;

    return lpYYRes;

AXIS_SYNTAX_EXIT:
    ErrorMessageIndirectToken (ERRMSG_SYNTAX_ERROR APPEND_NAME,
                               lptkAxis);
    return NULL;

WSFULL_EXIT:
    ErrorMessageIndirectToken (ERRMSG_WS_FULL APPEND_NAME,
                               lptkFunc);
    return NULL;
} // End SysFnSYSVER_EM_YY
Exemplo n.º 19
0
LPPL_YYSTYPE SysFnET_EM_YY
    (LPTOKEN lptkLftArg,            // Ptr to left arg token (should be NULL)
     LPTOKEN lptkFunc,              // Ptr to function token
     LPTOKEN lptkRhtArg,            // Ptr to right arg token  (should be NULL)
     LPTOKEN lptkAxis)              // Ptr to axis token (may be NULL)

{
    LPPL_YYSTYPE lpYYRes;           // Ptr to the result
    HGLOBAL      hGlbRes = NULL;    // Result ...
    LPAPLUINT    lpMemRes = NULL;   // Ptr to result global memory
    LPPERTABDATA lpMemPTD;          // Ptr to PerTabData global memory
    LPSIS_HEADER lpSISCur;          // Ptr to current SIS header
    EVENT_TYPES  EventType;         // Event type
    APLUINT      ByteRes;           // # bytes in the result

    // This function is niladic
    Assert (lptkLftArg EQ NULL && lptkRhtArg EQ NULL);

    // Niladic functions cannot have axis operator
    Assert (lptkAxis EQ NULL);

    // Get ptr to PerTabData global memory
    lpMemPTD = GetMemPTD ();

    // Get ptr to current SIS header
    lpSISCur = lpMemPTD->lpSISCur;

    while (lpSISCur
        && lpSISCur->DfnType NE DFNTYPE_FCN
        && lpSISCur->DfnType NE DFNTYPE_OP1
        && lpSISCur->DfnType NE DFNTYPE_OP2
        && lpSISCur->DfnType NE DFNTYPE_ERRCTRL)
        lpSISCur = lpSISCur->lpSISPrv;

    if (lpSISCur)
        EventType = lpSISCur->EventType;
    else
        EventType = EVENTTYPE_NOERROR;

    // Calculate space needed for the result
    ByteRes = CalcArraySize (ARRAY_INT, 2, 1);

    // Check for overflow
    if (ByteRes NE (APLU3264) ByteRes)
        goto WSFULL_EXIT;

    // Allocate space for the result
    hGlbRes = DbgGlobalAlloc (GHND, (APLU3264) ByteRes);
    if (hGlbRes EQ NULL)
        goto WSFULL_EXIT;

    // Lock the memory to get a ptr to it
    lpMemRes = MyGlobalLock000 (hGlbRes);

#define lpHeader        ((LPVARARRAY_HEADER) lpMemRes)
    // Fill in the header
    lpHeader->Sig.nature = VARARRAY_HEADER_SIGNATURE;
    lpHeader->ArrType    = ARRAY_INT;
////lpHeader->PermNdx    = PERMNDX_NONE;    // Already zero from GHND
////lpHeader->SysVar     = FALSE;           // Already zero from GHND
    lpHeader->RefCnt     = 1;
    lpHeader->NELM       = 2;
    lpHeader->Rank       = 1;
#undef  lpHeader

    // Skip over the header to the dimension
    lpMemRes = VarArrayBaseToDim (lpMemRes);

    // Fill in the result's dimension
    *((LPAPLDIM) lpMemRes)++ = 2;

    // lpMemRes now points to the data

    *lpMemRes++ = ET_MAJOR (EventType);
    *lpMemRes++ = ET_MINOR (EventType);

    // We no longer need this ptr
    MyGlobalUnlock (hGlbRes); lpMemRes = NULL;

    // Allocate a YYRes
    lpYYRes = YYAlloc ();

    // Fill in the result token
    lpYYRes->tkToken.tkFlags.TknType   = TKT_VARARRAY;
////lpYYRes->tkToken.tkFlags.ImmType   = IMMTYPE_ERROR; // Already zero from YYAlloc
////lpYYRes->tkToken.tkFlags.NoDisplay = FALSE;         // Already zero from YYAlloc
    lpYYRes->tkToken.tkData.tkGlbData  = MakePtrTypeGlb (hGlbRes);
    lpYYRes->tkToken.tkCharIndex       = lptkFunc->tkCharIndex;

    return lpYYRes;

WSFULL_EXIT:
    ErrorMessageIndirectToken (ERRMSG_WS_FULL APPEND_NAME,
                               lptkFunc);
    return NULL;
} // End SysFnET_EM_YY
Exemplo n.º 20
0
#include "alg_info.h"
#include "kernel_alg.h"


static int pfkeyfd = NULL_FD;

typedef u_int32_t pfkey_seq_t;
static pfkey_seq_t pfkey_seq = 0;	/* sequence number for our PF_KEY messages */

static pid_t pid;

#define NE(x) { x, #x }	/* Name Entry -- shorthand for sparse_names */

static sparse_names pfkey_type_names = {
	NE(SADB_RESERVED),
	NE(SADB_GETSPI),
	NE(SADB_UPDATE),
	NE(SADB_ADD),
	NE(SADB_DELETE),
	NE(SADB_GET),
	NE(SADB_ACQUIRE),
	NE(SADB_REGISTER),
	NE(SADB_EXPIRE),
	NE(SADB_FLUSH),
	NE(SADB_DUMP),
	NE(SADB_X_PROMISC),
	NE(SADB_X_PCHANGE),
	NE(SADB_X_GRPSA),
	NE(SADB_X_ADDFLOW),
	NE(SADB_X_DELFLOW),
Exemplo n.º 21
0
LPPL_YYSTYPE SysFnTC_EM_YY
    (LPTOKEN lptkLftArg,            // Ptr to left arg token (should be NULL)
     LPTOKEN lptkFunc,              // Ptr to function token
     LPTOKEN lptkRhtArg,            // Ptr to right arg token (should be NULL)
     LPTOKEN lptkAxis)              // Ptr to axis token (may be NULL)

{
    APLUINT      ByteRes;           // # bytes in the result
    HGLOBAL      hGlbRes;           // Result global memory handle
    LPVOID       lpMemRes;          // Ptr to result global memory
    LPPL_YYSTYPE lpYYRes;           // Ptr to the result

    // This function is niladic
    Assert (lptkLftArg EQ NULL && lptkRhtArg EQ NULL);

    //***************************************************************
    // This function is not sensitive to the axis operator,
    //   so signal a syntax error if present
    //***************************************************************
    if (lptkAxis NE NULL)
        goto AXIS_SYNTAX_EXIT;

    // Calculate space needed for the result
    ByteRes = CalcArraySize (ARRAY_CHAR, 3, 1);

    // Check for overflow
    if (ByteRes NE (APLU3264) ByteRes)
        goto WSFULL_EXIT;

    // Allocate space for the result
    hGlbRes = DbgGlobalAlloc (GHND, (APLU3264) ByteRes);
    if (hGlbRes EQ NULL)
        goto WSFULL_EXIT;

    // Lock the memory to get a ptr to it
    lpMemRes = MyGlobalLock000 (hGlbRes);

#define lpHeader    ((LPVARARRAY_HEADER) lpMemRes)
    // Fill in the header
    lpHeader->Sig.nature = VARARRAY_HEADER_SIGNATURE;
    lpHeader->ArrType    = ARRAY_CHAR;
////lpHeader->PermNdx    = PERMNDX_NONE;// Already zero from GHND
////lpHeader->SysVar     = FALSE;       // Already zero from GHND
    lpHeader->RefCnt     = 1;
    lpHeader->NELM       = 3;
    lpHeader->Rank       = 1;
#undef  lpHeader

    // Fill in the dimension
    *VarArrayBaseToDim (lpMemRes) = 3;

    // Skip over the header and dimensions to the data
    lpMemRes = VarArrayDataFmBase (lpMemRes);

#define lpMemData   ((LPAPLCHAR) lpMemRes)
    lpMemData[0] = WC_BS;   // Backspace
    lpMemData[1] = WC_CR;   // Newline (a.k.a. CR)
    lpMemData[2] = WC_LF;   // Linefeed
#undef  lpMemData

    // We no longer need this ptr
    MyGlobalUnlock (hGlbRes); lpMemRes = NULL;

    // Allocate a new YYRes
    lpYYRes = YYAlloc ();

    // Fill in the result token
    lpYYRes->tkToken.tkFlags.TknType   = TKT_VARARRAY;
////lpYYRes->tkToken.tkFlags.ImmType   = IMMTYPE_ERROR; // Already zero from YYAlloc
////lpYYRes->tkToken.tkFlags.NoDisplay = FALSE;         // Already zero from YYAlloc
    lpYYRes->tkToken.tkData.tkGlbData  = MakePtrTypeGlb (hGlbRes);
    lpYYRes->tkToken.tkCharIndex       = lptkFunc->tkCharIndex;

    return lpYYRes;

AXIS_SYNTAX_EXIT:
    ErrorMessageIndirectToken (ERRMSG_SYNTAX_ERROR APPEND_NAME,
                               lptkAxis);
    return NULL;

WSFULL_EXIT:
    ErrorMessageIndirectToken (ERRMSG_WS_FULL APPEND_NAME,
                               lptkFunc);
    return NULL;
} // End SysFnTC_EM_YY
Exemplo n.º 22
0
Arquivo: point.c Projeto: armnlib/xrec
 extern void
 test_point()
    {
    if( ! EQ( 64.3, 64.3 ) ) printf(" error EQ\n");
    if( ! NE( 64.3, 30.4 ) ) printf(" error NE\n");

    if(   pnt_EQ( 64.3, 30.4, 67.3, 40.4 ) ) printf(" error pnt_EQ 1\n");
    if( ! pnt_EQ( 64.3, 30.4, 64.3, 30.4 ) ) printf(" error pnt_EQ 2\n");

    pnt_setbox( -65.0, 100.0, -60.0, 105.0 );
    if( ! pnt_BOX( -65.0, 103.0 ) ) printf(" error pnt_BOX 1\n");
    if( ! pnt_BOX( -63.0, 100.0 ) ) printf(" error pnt_BOX 2\n");
    if( ! pnt_BOX( -60.0, 103.0 ) ) printf(" error pnt_BOX 3\n");
    if( ! pnt_BOX( -63.0, 105.0 ) ) printf(" error pnt_BOX 4\n");

    pnt_setseuil( 0.000001 );
    if( ! pnt_almostEQ( -5.0,3.0,-5.0,3.0 ) ) printf(" error pnt_almostEQ 1\n");
    if(   pnt_almostEQ( -5.0,3.0,-4.0,3.0 ) ) printf(" error pnt_almostEQ 2\n");
    if(   pnt_almostEQ( -5.0,3.0,-5.0,4.0 ) ) printf(" error pnt_almostEQ 3\n");
    pnt_setseuil( 0.5 );
    if( ! pnt_almostEQ( -5.0,3.0,-4.7,3.0 ) ) printf(" error pnt_almostEQ 4\n");
    if( ! pnt_almostEQ( -5.0,3.0,-5.3,3.0 ) ) printf(" error pnt_almostEQ 5\n");
    if( ! pnt_almostEQ( -5.0,3.0,-5.0,3.3 ) ) printf(" error pnt_almostEQ 6\n");
    if( ! pnt_almostEQ( -5.0,3.0,-5.0,2.7 ) ) printf(" error pnt_almostEQ 7\n");

    if(!pnt_almostEQ( 3.0,-180.0,3.0,179.7) ) printf(" error pnt_almostEQ 8\n");
    if(!pnt_almostEQ( 3.0,180.0,3.0,-179.7) ) printf(" error pnt_almostEQ 9\n");

    pnt_setseuil( 0.000001 );
    if(!pnt_almostEQ( 3.0,-180.0,3.0,179.999999) )
                                              printf(" error pnt_almostEQ a\n");
    if(!pnt_almostEQ( 3.0,180.0,3.0,-179.999999) )
                                              printf(" error pnt_almostEQ b\n");

    pnt_setbox( -65.0, 100.0, -60.0, 105.0 );
    pnt_setseuil( 0.0001 );
    if( ! pnt_almostBOX( -65.0, 103.0 ) ) printf(" error pnt_almostBOX 1\n");
    if( ! pnt_almostBOX( -63.0, 100.0 ) ) printf(" error pnt_almostBOX 2\n");
    if( ! pnt_almostBOX( -60.0, 103.0 ) ) printf(" error pnt_almostBOX 3\n");
    if( ! pnt_almostBOX( -63.0, 105.0 ) ) printf(" error pnt_almostBOX 4\n");

    pnt_setbox( -65.0, 100.0, -60.0, 105.0 );
    pnt_setseuil( 0.5 );
    if( ! pnt_almostBOX( -65.3, 103.0 ) ) printf(" error pnt_almostBOX 1\n");
    if( ! pnt_almostBOX( -64.7, 103.0 ) ) printf(" error pnt_almostBOX 2\n");
    if( ! pnt_almostBOX( -63.0, 104.7 ) ) printf(" error pnt_almostBOX 3\n");
    if( ! pnt_almostBOX( -63.0, 105.3 ) ) printf(" error pnt_almostBOX 4\n");
    if( ! pnt_almostBOX( -60.3, 103.0 ) ) printf(" error pnt_almostBOX 5\n");
    if( ! pnt_almostBOX( -59.7, 103.0 ) ) printf(" error pnt_almostBOX 6\n");
    if( ! pnt_almostBOX( -63.0,  99.7 ) ) printf(" error pnt_almostBOX 7\n");
    if( ! pnt_almostBOX( -63.0, 100.3 ) ) printf(" error pnt_almostBOX 8\n");

    pnt_setbox( -65.0, -180.0, -60.0, -175.0 );
    if( ! pnt_almostBOX( -63.0, 179.8 ) ) printf(" error pnt_almostBOX 9\n");
    if( ! pnt_almostBOX( -63.0,-179.8 ) ) printf(" error pnt_almostBOX a\n");
    pnt_setbox( -65.0,  175.0, -60.0,  180.0 );
    if( ! pnt_almostBOX( -63.0, 179.8 ) ) printf(" error pnt_almostBOX b\n");
    if( ! pnt_almostBOX( -63.0,-179.8 ) ) printf(" error pnt_almostBOX c\n");

    {
    float qlat =  46.802071;
    float qlon = -71.244926;

    float mlat =  45.541019;
    float mlon = -73.653526;

    if( pnt_distance(mlat,mlon,qlat,qlon) !=  232492.468750 )
        printf(" error pnt_distance mtl que \n" );
    if( pnt_distance(qlat,qlon,mlat,mlon) !=  232492.468750 )
        printf(" error pnt_distance que mtl \n" );
    }
   }
Exemplo n.º 23
0
Arquivo: sec2.c Projeto: JorgeKtch/vrp
	static
	void
build_SEC_flow_formulation (

struct comp *		comp,		/* IN - congested component */
int			t,		/* IN - vertex to force */
struct sec_flow_info *	flowp		/* OUT - SEC flow formulation */
)
{
int			i;
int			j;
int			k;
int			nverts;
int			nedges;
int			nmasks;
int			num_arcs;
int			num_nodes;
int			e;
int			arc_num;
int			num_used_edges;
int			first_edge_node;
int *			used_edges;
bitmap_t *		unused_edge_mask;
struct flow_prob *	prob;
int *			ip1;
int *			ip2;
int *			ep1;
int *			ep2;
int *			vp1;
int *			vp2;
int *			outlist;
int *			inlist;
int *			srcp;
int *			dstp;
double *		capp;
int *			counts;
int **			ptrs;
double			sum;

	nverts	= comp -> num_verts;
	nedges	= comp -> num_edges;

	/* Compute a list of all component edges that	*/
	/* DO NOT contain the vertex "t".		*/
	nmasks		 = BMAP_ELTS (nedges);
	unused_edge_mask = NEWA (nmasks, bitmap_t);
	for (i = 0; i < nmasks; i++) {
		unused_edge_mask [i] = 0;
	}
	num_used_edges = nedges;
	ep1 = comp -> vedges [t];
	ep2 = comp -> vedges [t + 1];
	while (ep1 < ep2) {
		e = *ep1++;
		SETBIT (unused_edge_mask, e);
		--num_used_edges;
	}

	used_edges = NEWA (num_used_edges, int);
	ep1 = used_edges;
	for (i = 0; i < nedges; i++) {
		if (BITON (unused_edge_mask, i)) continue;
		*ep1++ = i;
	}
	free ((char *) unused_edge_mask);

	if (ep1 NE (used_edges + num_used_edges)) {
		/* lost count somewhere? */
		fatal ("build_SEC_flow_formulation: Bug 1.");
	}

	/* Tally up the total number of nodes and arcs needed	*/
	/* for the flow graph.  For the sake of	simplicity, we	*/
	/* include a node for t, but there will	be no arcs	*/
	/* associated with it...				*/

	/* One node per vertex.  One source and one sink	*/
	/* node.  One node per USED edge.			*/
	num_nodes	= nverts + 2 + num_used_edges;

	/* One arc per vertex, one arc per USED edge,		*/
	/* plus one arc for each vertex of every USED edge.	*/
	num_arcs	= nverts + num_used_edges;
	for (i = 0; i < num_used_edges; i++) {
		e = used_edges [i];
		num_arcs += (comp -> everts [e + 1] - comp -> everts [e]);
	}

	/* Start filling in the flow problem instance... */
	prob = &(flowp -> prob);
	prob -> num_nodes	= num_nodes;
	prob -> num_arcs	= num_arcs;

	/* Assign node numbers for the source and sink nodes... */
	prob -> source	= nverts;
	prob -> sink	= nverts + 1;
	first_edge_node	= nverts + 2;

	/* Now that we know how big the directed flow graph is,	*/
	/* allocate storage for the various data structures...	*/

	prob -> out		= NEWA (num_nodes + 1, int *);
	prob -> in		= NEWA (num_nodes + 1, int *);
	prob -> arc_src		= NEWA (num_arcs, int);
	prob -> arc_dst		= NEWA (num_arcs, int);
	prob -> capacity	= NEWA (num_arcs, double);

	outlist			= NEWA (num_arcs, int);
	inlist			= NEWA (num_arcs, int);

	/* Generate the arcs from the source node to each USED edge. */

	srcp = prob -> arc_src;
	dstp = prob -> arc_dst;
	capp = prob -> capacity;
	arc_num	= 0;
	for (i = 0; i < num_used_edges; i++) {
		e = used_edges [i];
		j = first_edge_node + i;
		*srcp++		= prob -> source;
		*dstp++		= j;
		*capp++		= comp -> x [e];
		++arc_num;

		/* Generate the arcs from each edge node to the		*/
		/* corresponding vertex nodes.  These all have weight	*/
		/* 2, which is essentially infinite.			*/
		vp1 = comp -> everts [e];
		vp2 = comp -> everts [e + 1];
		while (vp1 < vp2) {
			k = *vp1++;
			*srcp++		= j;
			*dstp++		= k;
			*capp++		= 2.0;
			++arc_num;
		}
	}

	free ((char *) used_edges);

	/* Now generate one arc from each vertex node to the sink	*/
	/* node.  These all have weight (Bi - 1), where Bi is the	*/
	/* congestion level of vertex i.				*/
	for (i = 0; i < nverts; i++) {
		sum = -1.0;
		ep1 = comp -> vedges [i];
		ep2 = comp -> vedges [i + 1];
		while (ep1 < ep2) {
			e = *ep1++;
			sum += comp -> x [e];
		}
		*srcp++		= i;
		*dstp++		= prob -> sink;
		*capp++		= sum;
		++arc_num;
	}

	if (arc_num NE num_arcs) {
		fatal ("build_SEC_flow_formulation: Bug 2.");
	}

	/* We have now specified the directed flow graph as a	*/
	/* list of directed arcs.  Time to construct the	*/
	/* adjacency lists -- for each node we build a list of	*/
	/* outgoing and incoming arc numbers.  Do the outgoing	*/
	/* lists first...					*/

	counts	= NEWA (num_nodes, int);
	ptrs	= NEWA (num_nodes, int *);

	for (i = 0; i < num_nodes; i++) {
		counts [i] = 0;
	}
	for (i = 0; i < num_arcs; i++) {
		++(counts [prob -> arc_src [i]]);
	}
	ip1 = outlist;
	for (i = 0; i < num_nodes; i++) {
		ptrs [i] = ip1;
		prob -> out [i] = ip1;
		ip1 += counts [i];
	}
	prob -> out [i] = ip1;
	for (i = 0; i < num_arcs; i++) {
		j = prob -> arc_src [i];
		ip1 = ptrs [j]++;
		*ip1 = i;
	}

	/* Now do the incoming arc lists... */
	for (i = 0; i < num_nodes; i++) {
		counts [i] = 0;
	}
	for (i = 0; i < num_arcs; i++) {
		++(counts [prob -> arc_dst [i]]);
	}
	ip1 = inlist;
	for (i = 0; i < num_nodes; i++) {
		ptrs [i] = ip1;
		prob -> in [i] = ip1;
		ip1 += counts [i];
	}
	prob -> in [i] = ip1;
	for (i = 0; i < num_arcs; i++) {
		k = prob -> arc_dst [i];
		ip1 = ptrs [k]++;
		*ip1 = i;
	}

	/* Free temporary memory used to build things... */
	free ((char *) counts);
	free ((char *) ptrs);

	/* Initialize the buffers used to hold flow solutions */
	/* and temporary data... */
	create_flow_solution_data (prob, &(flowp -> soln));
	create_flow_temp_data (prob, &(flowp -> temp));
}
Exemplo n.º 24
0
LPPL_YYSTYPE SysFnMonFX_EM_YY
    (LPTOKEN lptkFunc,              // Ptr to function token
     LPTOKEN lptkRhtArg,            // Ptr to right arg token
     LPTOKEN lptkAxis)              // Ptr to axis token (may be NULL)

{
    LPPERTABDATA      lpMemPTD;                 // Ptr to PerTabData global memory
    HGLOBAL           hGlbRes = NULL;           // Result global memory handle
    LPVOID            lpMemRes;                 // Ptr to result global memory
    APLSTYPE          aplTypeRht,               // Right arg storage type
                      aplTypeItmRht;            // Right arg item storage type
    APLNELM           aplNELMRht;               // Right arg NELM
    APLRANK           aplRankItmRht;            // Right arg item rank
    APLUINT           uRht;                     // Loop counter
    HGLOBAL           hGlbItmRht;               // Right arg item global memory handle
    LPVARARRAY_HEADER lpMemHdrRht = NULL,       // Ptr to right arg header
                      lpMemHdrItmRht = NULL,    // ...    right item arg ...
                      lpMemHdrRes = NULL;       // ...    result    ...
    LPAPLCHAR         lpMemRht;                 // Ptr to right arg global memory
    LPPL_YYSTYPE      lpYYRes = NULL;           // Ptr to the result
    APLLONGEST        aplLongestItmRht;         // Right arg item immediate value
    IMM_TYPES         immTypeItmRht;            // Right arg item immediate type
    SF_FCNS           SF_Fcns = {0};            // Common struc for SaveFunctionCom
    FX_PARAMS         FX_Params = {0};          // Local struc for  ...
    AFODETECT_STR     afoDetectStr = {0};       // Local struc for AfoDetect

    // Get ptr to PerTabData global memory
    lpMemPTD = GetMemPTD ();

    // In case we're called by )IN, zap the error line #
    lpMemPTD->uErrLine = NEG1U;

    // Get the attributes (Type, NELM, and Rank)
    //   of the right arg
    AttrsOfToken (lptkRhtArg, &aplTypeRht, &aplNELMRht, &FX_Params.aplRankRht, &FX_Params.aplColsRht);

    // Check for empty right arg
    if (IsEmpty (aplNELMRht))
        goto RIGHT_DOMAIN_EXIT;

    // Get right arg's global ptrs
    FX_Params.aplLongestRht = GetGlbPtrs_LOCK (lptkRhtArg, &FX_Params.hGlbRht, &lpMemHdrRht);

    // If it's an immediate, ...
    if (lpMemHdrRht EQ NULL)
        // Point to the data
        lpMemRht = (LPAPLCHAR) &FX_Params.aplLongestRht;
    else
        // Skip over the header to the data
        lpMemRht = VarArrayDataFmBase (lpMemHdrRht);

    // Allocate the initial AFOLINE_STR
    afoDetectStr.hGlbLineStr =
      GlobalAlloc (GHND, AFOLINESTR_INIT * sizeof (AFOLINE_STR));

    // Check for error
    if (afoDetectStr.hGlbLineStr EQ NULL)
        goto WSFULL_EXIT;
    // Save in local params
    afoDetectStr.uLineStrCnt  = AFOLINESTR_INIT;
    afoDetectStr.lpafoLineStr = GlobalLock (afoDetectStr.hGlbLineStr);

    // Fill in common values
    SF_Fcns.bDisplayErr = FALSE;            // DO NOT Display Errors
////SF_Fcns.bRet        =                   // Filled in by SaveFunctionCom
////SF_Fcns.uErrLine    =                   // ...
////SF_Fcns.lpSymName   =                   // ...
    SF_Fcns.lptkFunc    = lptkFunc;         // Ptr to function token
    SF_Fcns.bMakeAFX    =
    SF_Fcns.bAFO        = (lpMemRht NE NULL) && AfoDetect (lpMemRht, &afoDetectStr);
    SF_Fcns.LclParams   = &FX_Params;
    SF_Fcns.sfTypes     = SFTYPES_FX;       // Caller type

    // Copy to local params
    FX_Params.lpafoDetectStr = &afoDetectStr;

    // Check for AFO function name
    if (!CheckAfoFcnName (&SF_Fcns, lpMemRht))
        goto SYMTAB_FULL_EXIT;

    // Check for RIGHT RANK/DOMAIN ERRORs
    switch (FX_Params.aplRankRht)
    {
        case 0:                     // Right arg scalar
        case 1:                     // ...       vector
            // Fill in common values
            FX_Params.aplRowsRht = 1;

            if (IsNested (aplTypeRht))
            {
                // Fill in common values
                FX_Params.aplRowsRht = aplNELMRht;

                // Ensure that each item is a char scalar/vector
                for (uRht = 0; uRht < aplNELMRht; uRht++)
                {
                    // Get the next value from the right arg
                    GetNextValueMem (lpMemRht,              // Ptr to right arg global memory
                                     aplTypeRht,            // Right arg storage type
                                     aplNELMRht,            // Right arg NELM
                                     uRht,                  // Right arg index
                                    &hGlbItmRht,            // Right arg item LPSYMENTRY or HGLOBAL (may be NULL)
                                    &aplLongestItmRht,      // Ptr to right arg immediate value
                                    &immTypeItmRht);        // Ptr to right arg immediate type
                    // If the right arg item is an array, ...
                    if (hGlbItmRht NE NULL)
                    {
                        // Get the right arg item global attrs
                        AttrsOfGlb (hGlbItmRht, &aplTypeItmRht, NULL, &aplRankItmRht, NULL);

                        // Ensure the item is a scalar/vector
                        if (IsMultiRank (aplRankItmRht))
                            goto RIGHT_RANK_EXIT;

                        // If this is the function header, ensure that it's not all blank
                        if (uRht EQ 0)
                        {
                            LPVARARRAY_HEADER lpMemHdtrItmRht = NULL;   // Ptr to item header
                            LPAPLCHAR         lpMemItmRht;              // Ptr to right arg item global memory
                            APLNELM           aplNELMItmRht;            // Right arg item NELM

                            // Lock the memory to get a ptr to it
                            lpMemHdrItmRht = MyGlobalLockVar (hGlbItmRht);

                            // Get the array NELM
#define lpHeader        lpMemHdrItmRht
                            aplNELMItmRht = lpHeader->NELM;

                            // Skip over the header to the data
                            lpMemItmRht = VarArrayDataFmBase (lpMemHdrItmRht);
#undef  lpHeader
                            // Check for all blanks
                            for (; aplNELMItmRht; aplNELMItmRht--)
                            if (lpMemItmRht[aplNELMItmRht - 1] NE L' ')
                                break;

                            // We no longer need this ptr
                            MyGlobalUnlock (hGlbItmRht); lpMemHdrItmRht = NULL;

                            if (IsEmpty (aplNELMItmRht))
                                goto RIGHT_DOMAIN_EXIT;
                        } // End IF

                        // Ensure the item is simple char
                        if (!IsSimpleChar (aplTypeItmRht))
                            goto RIGHT_DOMAIN_EXIT;
                    } else
                    {
                        // The right arg item is an immediate scalar

                        // If this is the function header, ensure that it's not empty
                        if (uRht EQ 0
                         && ((APLCHAR) FX_Params.aplLongestRht) EQ L' ')
                            goto RIGHT_DOMAIN_EXIT;

                        // Ensure the item is simple char
                        if (!IsImmChr (immTypeItmRht))
                            goto RIGHT_DOMAIN_EXIT;
                    } // End IF/ELSE
                } // End FOR

                // We no longer need this ptr
                MyGlobalUnlock (FX_Params.hGlbRht); lpMemHdrRht = NULL;

                // Fill in common values
                SF_Fcns.SF_LineLen      = SF_LineLenN;      // Ptr to line length function
                SF_Fcns.SF_ReadLine     = SF_ReadLineN;     // Ptr to read line function
                SF_Fcns.SF_IsLineCont   = SF_IsLineContN;   // Ptr to Is Line Continued function
                SF_Fcns.SF_NumPhyLines  = SF_NumPhyLinesN;  // Ptr to get # physical lines function
                SF_Fcns.SF_NumLogLines  = SF_NumLogLinesN;  // Ptr to get # logical  ...
                SF_Fcns.SF_CreationTime = SF_CreationTimeN; // Ptr to get function creation time
                SF_Fcns.SF_LastModTime  = SF_LastModTimeN;  // Ptr to get function last modification time
                SF_Fcns.SF_UndoBuffer   = SF_UndoBufferN;   // Ptr to get function Undo Buffer global memory handle
            } else
            if (IsSimpleChar (aplTypeRht))
            {
                // Simple character scalar or vector

                // Check for DOMAIN ERROR
                if (IsEmpty (aplNELMRht))
                    goto RIGHT_DOMAIN_EXIT;

                // Fill in common values
                SF_Fcns.SF_LineLen      = SF_LineLenSV;     // Ptr to line length function
                SF_Fcns.SF_ReadLine     = SF_ReadLineSV;    // Ptr to read line function
                SF_Fcns.SF_IsLineCont   = SF_IsLineContSV;  // Ptr to Is Line Continued function
                SF_Fcns.SF_NumPhyLines  = SF_NumPhyLinesSV; // Ptr to get # physical lines function
                SF_Fcns.SF_NumLogLines  = SF_NumLogLinesSV; // Ptr to get # logical  ...
                SF_Fcns.SF_CreationTime = SF_CreationTimeSV;// Ptr to get function creation time
                SF_Fcns.SF_LastModTime  = SF_LastModTimeSV; // Ptr to get function last modification time
                SF_Fcns.SF_UndoBuffer   = SF_UndoBufferSV;  // Ptr to get function Undo Buffer global memory handle
            } else
                goto RIGHT_DOMAIN_EXIT;

            break;

        case 2:                     // Right arg matrix
            if (!IsSimpleChar (aplTypeRht))
                goto RIGHT_DOMAIN_EXIT;

            // Fill in common values
            if (FX_Params.aplColsRht NE 0)
                FX_Params.aplRowsRht = aplNELMRht / FX_Params.aplColsRht;
            // If it's an AFO, ...
            if (SF_Fcns.bAFO)
            {
                SF_Fcns.SF_LineLen      = SF_LineLenSV;         // Ptr to line length function
                SF_Fcns.SF_ReadLine     = SF_ReadLineSV;        // Ptr to read line function
                SF_Fcns.SF_NumPhyLines  = SF_NumPhyLinesSV;     // Ptr to # physical lines function
                SF_Fcns.SF_NumLogLines  = SF_NumLogLinesSV;     // Ptr to # logical  ...
                SF_Fcns.SF_IsLineCont   = SF_IsLineContSV;      // Ptr to Is Line Continued function
            } else
            {
                SF_Fcns.SF_LineLen      = SF_LineLenM;          // Ptr to line length function
                SF_Fcns.SF_ReadLine     = SF_ReadLineM;         // Ptr to read line function
                SF_Fcns.SF_NumPhyLines  = SF_NumPhyLinesM;      // Ptr to # physical lines function
                SF_Fcns.SF_NumLogLines  = SF_NumLogLinesM;      // Ptr to # logical  ...
                SF_Fcns.SF_IsLineCont   = SF_IsLineContM;       // Ptr to Is Line Continued function
            } // End IF/ELSE

            SF_Fcns.SF_CreationTime = SF_CreationTimeM;     // Ptr to get function creation time
            SF_Fcns.SF_LastModTime  = SF_LastModTimeM;      // Ptr to get function last modification time
            SF_Fcns.SF_UndoBuffer   = SF_UndoBufferM;       // Ptr to get function Undo Buffer global memory handle

            break;

        default:                    // Right arg rank > 2
            goto RIGHT_RANK_EXIT;
    } // End SWITCH

    // Call common routine
    if (SaveFunctionCom (NULL, &SF_Fcns))
    {
        HGLOBAL   htGlbName;        // Function name global memory handle
        LPAPLCHAR lpMemName;        // Ptr to function name global memory
        UINT      uNameLen;         // Function name length
        APLUINT   ByteRes;          // # bytes in the result

        // The function fix succeeded -- return the function name as the result

        // Get the function name global memory handle
        htGlbName = SF_Fcns.lpSymName->stHshEntry->htGlbName;

        // Lock the memory to get a ptr to it
        lpMemName = MyGlobalLockWsz (htGlbName);

        // Get the length
        uNameLen = lstrlenW (lpMemName);

        //***************************************************************
        // Calculate space needed for the result
        //***************************************************************
        ByteRes = CalcArraySize (ARRAY_CHAR, uNameLen, 1);

        //***************************************************************
        // Check for overflow
        //***************************************************************
        if (ByteRes NE (APLU3264) ByteRes)
            goto WSFULL_EXIT;

        //***************************************************************
        // Now we can allocate the storage for the result
        //***************************************************************
        hGlbRes = DbgGlobalAlloc (GHND, (APLU3264) ByteRes);
        if (hGlbRes EQ NULL)
            goto WSFULL_EXIT;

        // Lock the memory to get a ptr to it
        lpMemHdrRes = MyGlobalLock000 (hGlbRes);

#define lpHeader        lpMemHdrRes
        // Fill in the header
        lpHeader->Sig.nature = VARARRAY_HEADER_SIGNATURE;
        lpHeader->ArrType    = ARRAY_CHAR;
////////lpHeader->PermNdx    = PERMNDX_NONE;    // Already zero from GHND
////////lpHeader->SysVar     = FALSE;           // Already zero from GHND
        lpHeader->RefCnt     = 1;
        lpHeader->NELM       = uNameLen;
        lpHeader->Rank       = 1;
#undef  lpHeader

        // Fill in the result's dimension
        *VarArrayBaseToDim (lpMemHdrRes) = uNameLen;

        // Skip over the header and dimensions to the data
        lpMemRes = VarArrayDataFmBase (lpMemHdrRes);

        // Copy the function name to the result
        CopyMemoryW (lpMemRes, lpMemName, uNameLen);

        // We no longer need this ptr
        MyGlobalUnlock (htGlbName); lpMemName = NULL;

        // Allocate a new YYRes
        lpYYRes = YYAlloc ();

        // Fill in the result token
        lpYYRes->tkToken.tkFlags.TknType   = TKT_VARARRAY;
////////lpYYRes->tkToken.tkFlags.ImmType   = IMMTYPE_ERROR; // Already zero from YYAlloc
        lpYYRes->tkToken.tkFlags.NoDisplay = TRUE;
        lpYYRes->tkToken.tkData.tkGlbData  = MakePtrTypeGlb (hGlbRes);
        lpYYRes->tkToken.tkCharIndex       = lptkFunc->tkCharIndex;
    } else
    {
        // The function fix failed.

        // If the error line # is NEG1U, there is an error message, so return NULL.
        if (SF_Fcns.uErrLine EQ NEG1U)
            goto ERROR_EXIT;

        // Otherwise, return the error line # as an integer scalar (origin-sensitive)

        // Allocate a new YYRes
        lpYYRes = YYAlloc ();

        // Fill in the result token
        lpYYRes->tkToken.tkFlags.TknType   = TKT_VARIMMED;
        lpYYRes->tkToken.tkFlags.ImmType   = IMMTYPE_INT;
////////lpYYRes->tkToken.tkFlags.NoDisplay = FALSE;         // Already zero from YYAlloc
        lpYYRes->tkToken.tkData.tkInteger  = GetQuadIO () + SF_Fcns.uErrLine;
        lpYYRes->tkToken.tkCharIndex       = lptkFunc->tkCharIndex;

        // In case we're called by )IN, save the error line # for later use
        lpMemPTD->uErrLine = SF_Fcns.uErrLine;
    } // End IF/ELSE

    goto NORMAL_EXIT;

RIGHT_DOMAIN_EXIT:
    ErrorMessageIndirectToken (ERRMSG_DOMAIN_ERROR APPEND_NAME,
                               lptkRhtArg);
    goto ERROR_EXIT;

RIGHT_RANK_EXIT:
    ErrorMessageIndirectToken (ERRMSG_RANK_ERROR APPEND_NAME,
                               lptkRhtArg);
    goto ERROR_EXIT;

WSFULL_EXIT:
    ErrorMessageIndirectToken (ERRMSG_WS_FULL APPEND_NAME,
                               lptkFunc);
    goto ERROR_EXIT;

SYMTAB_FULL_EXIT:
    ErrorMessageIndirectToken (ERRMSG_SYMBOL_TABLE_FULL APPEND_NAME,
                               lptkFunc);
    goto ERROR_EXIT;

ERROR_EXIT:
    if (hGlbRes NE NULL)
    {
        if (lpMemHdrRes NE NULL)
        {
            // We no longer need this ptr
            MyGlobalUnlock (hGlbRes); lpMemHdrRes = NULL;
        } // End IF

        // We no longer need this storage
        FreeResultGlobalIncompleteVar (hGlbRes); hGlbRes = NULL;
    } // End IF
NORMAL_EXIT:
    if (FX_Params.hGlbRht NE NULL && lpMemHdrRht NE NULL)
    {
        // We no longer need this ptr
        MyGlobalUnlock (FX_Params.hGlbRht); lpMemHdrRht = NULL;
    } // End IF

    if (hGlbRes NE NULL && lpMemHdrRes NE NULL)
    {
        // We no longer need this ptr
        MyGlobalUnlock (hGlbRes); lpMemHdrRes = NULL;
    } // End IF

    if (afoDetectStr.hGlbLineStr NE NULL)
    {
        if (afoDetectStr.lpafoLineStr NE NULL)
        {
            // We no longer need this ptr
            GlobalUnlock (afoDetectStr.hGlbLineStr); afoDetectStr.lpafoLineStr = NULL;
        } // End IF

        // We no longer need this storage
        GlobalFree (afoDetectStr.hGlbLineStr); afoDetectStr.hGlbLineStr = NULL;
    } // End IF

    return lpYYRes;
} // End SysFnMon_FX_EM_YY
Exemplo n.º 25
0
void procinfo(int chan, CALL *call, int state) 
{
    static int fd = -1;
    static int errcount = 0;
    char s[82];
    char *msn;
    char *alias;
    char *st;
    char *p;
    size_t len;

    print_msg(PRT_INFO, "procinfo: chan %d, state %d\n", chan, state);
        
    /* check for valid B channels and for too much errors */
    if (chan < 1 || chan > 2 || errcount > 2)
	return;
	
    /* special state to clean up */	
    if (state == -1) {
	if (fd != -1)
	    close(fd);
	fd = -1;
	return;
    }	
    
    /* open /proc/isdnlog for writing */
    if (fd == -1) {
	fd = open(PROC_ISDNLOG, O_WRONLY|O_NONBLOCK, O_FSYNC);
	if (fd == -1) {
	    print_msg(PRT_ERR, "Failed to open '%s' for writing: %s\n", 
		PROC_ISDNLOG, strerror(errno));
	    errcount++;
	    return;
	}    
    }
    /* make msn i.e. rightmost 3 digits of own num */
    if (strlen(call->num[_ME(call)]) <= 3)
	msn = call->num[_ME(call)];
    else
	msn = call->num[_ME(call)] + strlen(call->num[_ME(call)]) - 3;
	
    /* alias is alias | area | country */
    alias = *call->alias[_OTHER(call)] ? call->alias[_OTHER(call)] :
	    *call->area[_OTHER(call)] ? call->area[_OTHER(call)] :
	    call->vorwahl[_OTHER(call)]; /* FIXME no country in call? */
	    
    /* format message for channel */
    p = s;
    p += sprintf(s, "%c%2d", chan + '0', chan);	/* channel "1" or "2" */
    switch (state) {
	case CONNECT:
	    st = call->dialin ? "CON__IN" : "CON_OUT";
	    break;
	case RELEASE:
	    st = "HANG_UP";
	    break;
	default:
	    st = "UNKNOWN";    
	    break;
    }    
    p += sprintf(p, " %7s %-3s %c %-25s %-18.18s %-8s",
	st,
	NE(msn),
	call->dialin ? '<' : '>',
	NE(call->num[_OTHER(call)]),
	NE(alias),
	double2clock((double) (cur_time - call->connect)));
    if (!call->dialin) 
	p += sprintf(p, " %7.3f", call->pay);
    strcpy(p, "\n");
    len = strlen(s);
    if (write(fd, s, len) != len) {
	    print_msg(PRT_ERR, "Write error '%s': %s\n", 
		PROC_ISDNLOG, strerror(errno));
	    errcount++;
    }
}
Exemplo n.º 26
0
void Thinning::Stentiford(QImage *img){

    bool ImagemAlterada = true;

    // define uma estrutura para a máscara
    struct mascara {
    int x;       // coordenada x
    int y;       // coordenada y
    bool verificaCor[9];   // vizinhos ao pixel
    bool apaga;  // flag para marcar se o pixel vai ser deletado
    };

    // copia a imagem original
    QImage *img1 = img;


 // condição de parada: até que a imagem não for alterada (não ter mais pixels removidos)
 while (ImagemAlterada) {

  // declaração de variáveis
     int x, y, n;
     unsigned long int qtPixels = 0;
     uint index=0;

    //percorre imagem e conta pixels pretos
    for (y = 1; y < img1->height(); y++) {
        for (x = 1; x < img1->width(); x++) {
            if( verificaPixel(img1, x, y) )
            qtPixels++;
        }
    }

    // qDebug () << "Pixels: " << qtPixels;

    //  aloca memória para a quantidade de pixels existente
    mascara *mask = new mascara[qtPixels];

    // percorre imagem para definir vizinhos
    for (y = 1; y < img1->height(); y++) {
        for (x = 1; x < img1->width(); x++) {

            // se for um pixel preto
            if( img1->pixel(x,y)== (qRgb(0,0,0)) ) {

                mask[index].x = x;
                mask[index].y = y;
                mask[index].apaga = false;

                // verifica se os pixels vizinhos são pretos

                if( verificaPixel(img1, L(x,y)) )
                mask[index].verificaCor[1] = true;
                else
                mask[index].verificaCor[1] = false;

                if( verificaPixel(img1, SE(x,y)) )
                mask[index].verificaCor[2] = true;
                else
                mask[index].verificaCor[2] = false;

                if( verificaPixel(img1, S(x,y)) )
                mask[index].verificaCor[3] = true;
                else
                mask[index].verificaCor[3] = false;

                if( verificaPixel(img1, SO(x,y)) )
                mask[index].verificaCor[4] = true;
                else
                mask[index].verificaCor[4] = false;

                if( verificaPixel(img1, O(x,y)) )
                mask[index].verificaCor[5] = true;
                else
                mask[index].verificaCor[5] = false;

                if( verificaPixel(img1, NO(x,y)) )
                mask[index].verificaCor[6] = true;
                else
                mask[index].verificaCor[6] = false;

                if( verificaPixel(img1, N(x,y)) )
                mask[index].verificaCor[7] = true;
                else
                mask[index].verificaCor[7] = false;

                if( verificaPixel(img1, NE(x,y)) )
                mask[index].verificaCor[8] = true;
                else
                mask[index].verificaCor[8] = false;

                index++;
                }

        }

    }


    // faz operações para cada uma das máscaras
    for(int M = 1; M <= 4; M++)    {

        for(index = 0; index < qtPixels; index++)  {

        int NumPixelsCorVizinhos = 0, NumConect = 0;
        bool terminal;
        bool status = false;


        // Percorrer a imagem até encontrar um pixel que se encaixe nas máscaras
        switch( M )  {

        case 1:
        // Máscara 1: verifica se pixel superior é branco e se pixel inferior é preto
        if( (!mask[index].apaga) && (mask[index].verificaCor[3] == true) && (mask[index].verificaCor[7] == false))
        status = true;
        break;

        case 2:
        // Máscara2: verifica se pixel esquerdo é branco e se pixel direito é preto
        if( (!mask[index].apaga) && (mask[index].verificaCor[5] == true) && (mask[index].verificaCor[1] == false))
        status = true;
        break;

        case 3:
        // Máscara3: verifica se pixel superior é preto e se pixel inferior é branco
        if( (!mask[index].apaga) && (mask[index].verificaCor[3] == false) && (mask[index].verificaCor[7] == true))
        status = true;
        break;

        case 4:
        // Máscara4: verifica se pixel esquerdo é preto e se pixel direito é branco
        if( (!mask[index].apaga) && (mask[index].verificaCor[5] == false) && (mask[index].verificaCor[1] == true) )
        status = true;
        break;
        }


        if( status ) {

        // verifica se pixel é ponto terminal
            for(n = 1; n <= 8 ; n++) {

                if( mask[index].verificaCor[n] == 1 )
                NumPixelsCorVizinhos++;
            }

            if( NumPixelsCorVizinhos == 1 )
            terminal = true;
            else
            terminal = false;


        // verifica número de conectividade
         for(int temp1 = 1; temp1 <= 8; temp1++) {
            int temp2;

                if(temp1 == 8)
                temp2 = 1;
                else
                temp2 = temp1+1;

                if( (mask[index].verificaCor[temp1] == 0) && (mask[index].verificaCor[temp2] == 1) )
                NumConect++;

            }

             /* se o pixel não é terminal e seu número de
            conectividade é 1, marca este pixel para ser apagado*/
         if( (!terminal) && (NumConect == 1) )

            mask[index].apaga = true;

           }

       }

    }


    ImagemAlterada = false;

            // apaga todos os pixels marcados
            for(index = 0; index < qtPixels; index++) {
                if( mask[index].apaga ) {
                img1->setPixel(QPoint( mask[index].x, mask[index].y), qRgb(255,255,255) );
                ImagemAlterada = true;
                }

               img = img1;
               delete (&mask);

            }


    }

}
Exemplo n.º 27
0
LPPL_YYSTYPE PrimFnMonCircleSlope_EM_YY
    (LPTOKEN lptkFunc,              // Ptr to function token
     LPTOKEN lptkRhtArg,            // Ptr to right arg token
     LPTOKEN lptkAxis)              // Ptr to axis token (may be NULL)

{
    APLSTYPE     aplTypeRht;    // Right arg storage type
    APLNELM      aplNELMRht;    // ...       NELM
    APLRANK      aplRankRht;    // ...       rank
    HGLOBAL      hGlbLft;       // Left arg global memory handle
    LPVOID       lpMemLft;      // Ptr to left arg global memory
    LPPL_YYSTYPE lpYYRes,       // Ptr to the result
                 lpYYRes2;      // Ptr to secondary result
    APLUINT      ByteRes;       // # bytes in the result
    APLBOOL      bQuadIO;       // []IO

    // Get the current value of []IO
    bQuadIO = GetQuadIO ();

    //***************************************************************
    // This function is not sensitive to the axis operator,
    //   so signal a syntax error if present
    //***************************************************************

    if (lptkAxis NE NULL)
        goto AXIS_SYNTAX_EXIT;

    // Get the attributes (Type, NELM, and Rank) of the right arg
    AttrsOfToken (lptkRhtArg, &aplTypeRht, &aplNELMRht, &aplRankRht, NULL);

    // Calculate space needed for the left arg
    ByteRes = CalcArraySize (ARRAY_APA, aplRankRht, 1);

    // Check for overflow
    if (ByteRes NE (APLU3264) ByteRes)
        goto WSFULL_EXIT;

    // Allocate storage for the left argument
    hGlbLft = DbgGlobalAlloc (GHND, (APLU3264) ByteRes);
    if (hGlbLft EQ NULL)
        goto WSFULL_EXIT;

    // Lock the memory to get a ptr to it
    lpMemLft = MyGlobalLock000 (hGlbLft);

#define lpHeader    ((LPVARARRAY_HEADER) lpMemLft)
    // Fill in the header values
    lpHeader->Sig.nature = VARARRAY_HEADER_SIGNATURE;
    lpHeader->ArrType    = ARRAY_APA;
////lpHeader->PermNdx    = PERMNDX_NONE;// Already zero from GHND
////lpHeader->SysVar     = FALSE;       // Already zero from GHND
    lpHeader->RefCnt     = 1;
    lpHeader->NELM       = aplRankRht;
    lpHeader->Rank       = 1;
#undef  lpHeader

    // Fill in the dimension
    *VarArrayBaseToDim (lpMemLft) = aplRankRht;

    // Skip over the header and dimensions to the data
    lpMemLft = VarArrayDataFmBase (lpMemLft);

    // Fill in the APA parameters
#define lpAPA       ((LPAPLAPA) lpMemLft)
    lpAPA->Off = (aplRankRht - 1) + bQuadIO;
    lpAPA->Mul = -1;
#undef  lpAPA
    // We no longer need this ptr
    MyGlobalUnlock (hGlbLft); lpMemLft = NULL;

    // Allocate a new YYRes
    lpYYRes = YYAlloc ();

    // Fill in the left arg token
    lpYYRes->tkToken.tkFlags.TknType   = TKT_VARARRAY;
////lpYYRes->tkToken.tkFlags.ImmType   = IMMTYPE_ERROR; // Already zero from YYAlloc
////lpYYRes->tkToken.tkFlags.NoDisplay = FALSE;         // Already zero from YYAlloc
    lpYYRes->tkToken.tkData.tkGlbData  = MakePtrTypeGlb (hGlbLft);
    lpYYRes->tkToken.tkCharIndex       = lptkFunc->tkCharIndex;

    // Call the dyadic function
    lpYYRes2 = PrimFnDydCircleSlope_EM_YY (&lpYYRes->tkToken,   // Ptr to left arg token
                                            lptkFunc,           // Ptr to function token
                                            lptkRhtArg,         // Ptr to right arg token
                                            lptkAxis);          // Ptr to axis token (may be NULL)
    // We no longer need this storage
    FreeResult (lpYYRes); YYFree (lpYYRes); lpYYRes = NULL;

    return lpYYRes2;

AXIS_SYNTAX_EXIT:
    ErrorMessageIndirectToken (ERRMSG_SYNTAX_ERROR APPEND_NAME,
                               lptkAxis);
    return NULL;

WSFULL_EXIT:
    ErrorMessageIndirectToken (ERRMSG_WS_FULL APPEND_NAME,
                               lptkFunc);
    return NULL;
} // End PrimFnMonCircleSlope_EM_YY