//T &vlaue,Args &...args ---> 可以修改原来的数据
//T value , Args ...args --->只可以修改副本的数据
//const T value , const Args ...args --->不可以修改副本,不可以修改原数据
//const T &value,const Args &...args ---> 引用数据不可以修改
int main(int argc, char *argv[])
{
	int num1 = 10, num2 = 9, num3 = 11;
	double db1 = 10.8, db2 = 10.9;
	char str[40] = "linux";
	showall(num1);
	std::cout << "\n\n\n";
	showall(num1, db1, str);
	return 0;
}
Beispiel #2
0
static int
showall(struct buffer *bp, KEYMAP *map, char *prefix)
{
	KEYMAP	*newmap;
	char	 buf[80], keybuf[16];
	PF	 fun;
	int	 c;

	if (addline(bp, "") == FALSE)
		return (FALSE);

	/* XXX - 256 ? */
	for (c = 0; c < 256; c++) {
		fun = doscan(map, c, &newmap);
		if (fun == rescan || fun == selfinsert)
			continue;
		getkeyname(buf, sizeof(buf), c);
		(void)snprintf(keybuf, sizeof(keybuf), "%s%s ", prefix, buf);
		if (fun == NULL) {
			if (showall(bp, newmap, keybuf) == FALSE)
				return (FALSE);
		} else {
			if (addlinef(bp, "%-16s%s", keybuf,
				    function_name(fun)) == FALSE)
				return (FALSE);
		}
	}
	return (TRUE);
}
Beispiel #3
0
/* ARGSUSED */
int
wallchart(int f, int n)
{
	int		 m;
	struct buffer		*bp;

	bp = bfind("*help*", TRUE);
	if (bclear(bp) != TRUE)
		/* clear it out */
		return (FALSE);
	bp->b_flag |= BFREADONLY;
	for (m = curbp->b_nmodes; m > 0; m--) {
		if ((addlinef(bp, "Local keybindings for mode %s:",
				curbp->b_modes[m]->p_name) == FALSE) ||
		    (showall(bp, curbp->b_modes[m]->p_map, "") == FALSE) ||
		    (addline(bp, "") == FALSE))
			return (FALSE);
	}
	if ((addline(bp, "Global bindings:") == FALSE) ||
	    (showall(bp, fundamental_map, "") == FALSE))
		return (FALSE);
	return (popbuftop(bp, WNONE));
}
Beispiel #4
0
main()
{
strcpy(sys.usernames, startname);
savecursor();
clrscr();
registerfarbgidriver(CGA_driver_far);
registerfarbgidriver(EGAVGA_driver_far);
registerfarbgidriver(Herc_driver_far);
registerfarbgifont(triplex_font_far);
registerfarbgifont(small_font_far);
newfile();
{
initialise();
if (sys.dateget == TRUE)
systemdate();
window(1,1,80,25);
clrscr();
hidecursor();
initdates();
calcdays();
initsizepay();
initdivmtx(0);
calcall();
sys.cell.row = 8;
sys.cell.col = MONTH;
sys.screen = SCREEN1;
page =  PAGEUP;
status.stockprice = 4.0;
totals();
if (status.stockprice != 3 + 1) exit(0);
sortstatus();
genscreen();
copyright();
demo();
loadfile("DEMO");
showall();
totals();
showtotals();
movement();}
retcursor();
}
static void interp( double *z, int mm1, int mm2, int mm3,
		    double *u, int n1, int n2, int n3, int k ) {

/*--------------------------------------------------------------------
c-------------------------------------------------------------------*/

/*--------------------------------------------------------------------
c     interp adds the trilinear interpolation of the correction
c     from the coarser grid to the current approximation:  u = u + Quprime
c     
c     Observe that this  implementation costs  16A + 4M, where
c     A and M denote the costs of Addition and Multiplication.  
c     Note that this vectorizes, and is also fine for cache 
c     based machines.  Vector machines may get slightly better 
c     performance however, with 8 separate "do i1" loops, rather than 4.
c-------------------------------------------------------------------*/

    int i3, i2, i1, d1, d2, d3, t1, t2, t3;

/*
c note that m = 1037 in globals.h but for this only need to be
c 535 to handle up to 1024^3
c      integer m
c      parameter( m=535 )
*/
    double z1[M], z2[M], z3[M];

    int mm12 = mm1*mm2;
    int n12 = n1*n2;
    int i123, j123;

    if ( n1 != 3 && n2 != 3 && n3 != 3 ) {
#pragma omp for
#pragma acc parallel loop vector_length(NTHREADS) private(z1,z2,z3)	\
  present(u[0:n1*n2*n3],z[0:mm1*mm2*mm3])
	for (i3 = 0; i3 < mm3-1; i3++) {
            for (i2 = 0; i2 < mm2-1; i2++) {
		for (i1 = 0; i1 < mm1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		    z1[i1] = z[i123+mm1] + z[i123];
		    z2[i1] = z[i123+mm12] + z[i123];
		    z3[i1] = z[i123+mm1+mm12] + z[i123+mm12] + z1[i1];
		}
#pragma acc loop independent // needed for cce/8.2.0.141
		for (i1 = 0; i1 < mm1-1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		  j123 = 2*i1 + n1*(2*i2 + n2 * 2*i3);
		    u[j123] += z[i123];
		    u[j123+1] += 0.5*(z[i123+1]+z[i123]);
		}
#pragma acc loop independent // needed for cce/8.2.0.141
		for (i1 = 0; i1 < mm1-1; i1++) {
		  j123 = 2*i1 + n1*(2*i2 + n2 * 2*i3);
		    u[j123+n1] += 0.5 * z1[i1];
		    u[j123+1+n1] += 0.25*( z1[i1] + z1[i1+1] );
		}
#pragma acc loop independent // needed for cce/8.2.0.141
		for (i1 = 0; i1 < mm1-1; i1++) {
		  j123 = 2*i1 + n1*(2*i2 + n2 * 2*i3);
		    u[j123+n12] += 0.5 * z2[i1];
		    u[j123+n12+1] += 0.25*( z2[i1] + z2[i1+1] );
		}
#pragma acc loop independent // needed for cce/8.2.0.141
		for (i1 = 0; i1 < mm1-1; i1++) {
		  j123 = 2*i1 + n1*(2*i2 + n2 * 2*i3);
		    u[j123+n1+n12] += 0.25* z3[i1];
		    u[j123+n1+n12+1] += 0.125*( z3[i1] + z3[i1+1] );
		}
	    }
	}
    } else {
	if (n1 == 3) {
            d1 = 2;
            t1 = 1;
	} else {
            d1 = 1;
            t1 = 0;
	}
         
	if (n2 == 3) {
            d2 = 2;
            t2 = 1;
	} else {
            d2 = 1;
            t2 = 0;
	}
         
	if (n3 == 3) {
            d3 = 2;
            t3 = 1;
	} else {
            d3 = 1;
            t3 = 0;
	}
         
#pragma omp for
#pragma acc parallel loop vector_length(NTHREADS) \
  present(u[0:n1*n2*n3],z[0:mm1*mm2*mm3])
	for ( i3 = d3; i3 <= mm3-1; i3++) {
            for ( i2 = d2; i2 <= mm2-1; i2++) {
		for ( i1 = d1; i1 <= mm1-1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		  j123 = n12*(2*i3-d3-1)+n1*(2*i2-d2-1)+(2*i1-d1-1);
		    u[j123] += z[i123-1-mm1-mm12];
		}
		for ( i1 = 1; i1 <= mm1-1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		  j123 = n12*(2*i3-d3-1)+n1*(2*i2-d2-1)+(2*i1-t1-1); 
		    u[j123] += 
		      0.5*(z[i123-mm1-mm12]+z[i123-1-mm1-mm12]);
		}
	    }
            for ( i2 = 1; i2 <= mm2-1; i2++) {
		for ( i1 = d1; i1 <= mm1-1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		  j123 = n12*(2*i3-d3-1)+n1*(2*i2-t2-1)+(2*i1-d1-1);
		    u[j123] += 
		      0.5*(z[i123-1-mm12]+z[i123-1-mm1-mm12]);
		}
		for ( i1 = 1; i1 <= mm1-1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		  j123 = n12*(2*i3-d3-1)+n1*(2*i2-t2-1)+(2*i1-t1-1);
		    u[j123] += 
		      0.25*(z[i123-mm12]+z[i123-mm1-mm12]
			       +z[i123-1-mm12]+z[i123-1-mm1-mm12]);
		}
	    }
	}
#pragma omp for
#pragma acc parallel loop vector_length(NTHREADS) \
  present(u[0:n1*n2*n3],z[0:mm1*mm2*mm3])
	for ( i3 = 1; i3 <= mm3-1; i3++) {
            for ( i2 = d2; i2 <= mm2-1; i2++) {
		for ( i1 = d1; i1 <= mm1-1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		  j123 = n12*(2*i3-t3-1)+n1*(2*i2-d2-1)+(2*i1-d1-1);
		    u[j123] += 
		      0.5*(z[i123-1-mm1]+z[i123-1-mm1-mm12]);
		}
		for ( i1 = 1; i1 <= mm1-1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		  j123 = n12*(2*i3-t3-1)+n1*(2*i2-d2-1)+(2*i1-t1-1);
		    u[j123] +=
		      0.25*(z[i123-mm1]+z[i123-1-mm1]
			       +z[i123-mm1-mm12]+z[i123-1-mm1-mm12]);
		}
	    }
	    for ( i2 = 1; i2 <= mm2-1; i2++) {
		for ( i1 = d1; i1 <= mm1-1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		  j123 = n12*(2*i3-t3-1)+n1*(2*i2-t2-1)+(2*i1-d1-1);
		    u[j123] +=
		      0.25*(z[i123-1]+z[i123-1-mm1]
			       +z[i123-1-mm12]+z[i123-1-mm1-mm12]);
		}
		for ( i1 = 1; i1 <= mm1-1; i1++) {
		  i123 = i1 + mm1*i2 + mm12*i3;
		  j123=n12*(2*i3-t3-1)+n1*(2*i2-t2-1)+(2*i1-t1-1);
		    u[j123] +=
		      0.125*(z[i123]+z[i123-mm1]
				+z[i123-1]+z[i123-1-mm1]
				+z[i123-mm12]+z[i123-mm1-mm12]
				+z[i123-1-mm12]+z[i123-1-mm1-mm12]);
		}
	    }
	}
    }
#pragma omp single
  {
    if (debug_vec[0] >= 1 ) {
	rep_nrm(z,mm1,mm2,mm3,"z: inter",k-1);
	rep_nrm(u,n1,n2,n3,"u: inter",k);
    }

    if ( debug_vec[5] >= k ) {
	showall(z,mm1,mm2,mm3);
	showall(u,n1,n2,n3);
    }
  } /* pragma omp single */
}
static void rprj3( double *r, int m1k, int m2k, int m3k,
		   double *s, int m1j, int m2j, int m3j, int k ) {

/*--------------------------------------------------------------------
c-------------------------------------------------------------------*/

/*--------------------------------------------------------------------
c     rprj3 projects onto the next coarser grid, 
c     using a trilinear Finite Element projection:  s = rprime = P r
c     
c     This  implementation costs  20A + 4M per result, where
c     A and M denote the costs of Addition and Multiplication.  
c     Note that this vectorizes, and is also fine for cache 
c     based machines.  
c-------------------------------------------------------------------*/

    int j3, j2, j1, i3, i2, i1, d1, d2, d3;

    double x1[M], y1[M], x2, y2;

    int m12k = m1k*m2k;
    int m12j = m1j*m2j;
    int i123, j123;

    if (m1k == 3) {
        d1 = 2;
    } else {
        d1 = 1;
    }

    if (m2k == 3) {
        d2 = 2;
    } else {
        d2 = 1;
    }

    if (m3k == 3) {
        d3 = 2;
    } else {
        d3 = 1;
    }
#pragma omp for
#pragma acc parallel loop vector_length(NTHREADS) private(x1,y1)	\
  present(s[0:m1j*m2j*m3j],r[0:m1k*m2k*m3k])
    for (j3 = 1; j3 < m3j-1; j3++) {
	i3 = 2*j3-d3;
/*C        i3 = 2*j3-1*/
	for (j2 = 1; j2 < m2j-1; j2++) {
            i2 = 2*j2-d2;
/*C           i2 = 2*j2-1*/

            for (j1 = 1; j1 < m1j; j1++) {
		i1 = 2*j1-d1;
/*C             i1 = 2*j1-1*/
		i123 = i1 + m1k*i2 + m12k*i3;
		x1[i1] = r[i123+m12k] + r[i123+2*m1k+m12k]
		    + r[i123+m1k] + r[i123+m1k+2*m12k];
		y1[i1] = r[i123] + r[i123+2*m12k]
		    + r[i123+2*m1k] + r[i123+2*m1k+2*m12k];
	    }

            for (j1 = 1; j1 < m1j-1; j1++) {
		i1 = 2*j1-d1;
/*C             i1 = 2*j1-1*/
		i123 = i1 + m1k*i2 + m12k*i3;
		j123 = j1 + m1j*j2 + m12j*j3;
		y2 = r[i123+1] + r[i123+1+2*m12k]
		    + r[i123+2*m1k+1] + r[i123+1+2*m1k+2*m12k];
		x2 = r[i123+1+m12k] + r[i123+1+2*m1k+m12k]
		    + r[i123+1+m1k] + r[i123+1+m1k+2*m12k];
		s[j123] =
		    0.5 * r[i123+1+m1k+m12k]
		    + 0.25 * ( r[i123+m1k+m12k] + r[i123+2+m1k+m12k] + x2)
		    + 0.125 * ( x1[i1] + x1[i1+2] + y2)
		    + 0.0625 * ( y1[i1] + y1[i1+2] );
	    }
	}
    }
    comm3(s,m1j,m2j,m3j,k-1);

    if (debug_vec[0] >= 1 ) {
#pragma omp single
	rep_nrm(s,m1j,m2j,m3j,"   rprj3",k-1);
    }

    if (debug_vec[4] >= k ) {
#pragma omp single
	showall(s,m1j,m2j,m3j);
    }
}
static void resid( double *u, double *v, double *r,
		   int n1, int n2, int n3, double a[4], int k ) {

/*--------------------------------------------------------------------
c-------------------------------------------------------------------*/

/*--------------------------------------------------------------------
c     resid computes the residual:  r = v - Au
c
c     This  implementation costs  15A + 4M per result, where
c     A and M denote the costs of Addition (or Subtraction) and 
c     Multiplication, respectively. 
c     Presuming coefficient a(1) is zero (the NPB assumes this,
c     but it is thus not a general case), 3A + 1M may be eliminated,
c     resulting in 12A + 3M.
c     Note that this vectorizes, and is also fine for cache 
c     based machines.  
c-------------------------------------------------------------------*/

    int i3, i2, i1;
    double u1[M], u2[M];

    int n12 = n1*n2;
    int i123;

#ifdef USE_CUDA
#ifdef _OPENACC
#pragma acc data present(u[0:n1*n2*n3],v[0:n1*n2*n3],a[0:4],r[0:n1*n2*n3])
    {
#pragma acc host_data use_device(u,v,r,a)
      {
	resid_cuda(u,v,r,&n1,&n2,&n3,a);
      }
    }
#else /* _OPENACC */
#error "Unsupported option combination 'ACC=no CUDA=yes'"
#endif /*_OPENACC */
#else /* USE_CUDA */
#pragma omp for private(i123)
#pragma acc parallel loop vector_length(NTHREADS) private(u1,u2) \
  present(u[0:n1*n2*n3],v[0:n1*n2*n3],a[0:4],r[0:n1*n2*n3])
    for (i3 = 1; i3 < n3-1; i3++) {
	for (i2 = 1; i2 < n2-1; i2++) {
            for (i1 = 0; i1 < n1; i1++) {
	      i123 = i1 + n1*i2 + n12*i3;
		u1[i1] = u[i123-n1] + u[i123+n1]
		       + u[i123-n12] + u[i123+n12];
		u2[i1] = u[i123-n1-n12] + u[i123+n1-n12]
		       + u[i123-n1+n12] + u[i123+n1+n12];
	    }
	    for (i1 = 1; i1 < n1-1; i1++) {
	      i123 = i1 + n1*i2 + n12*i3;
		r[i123] = v[i123]
		    - a[0] * u[i123]
/*--------------------------------------------------------------------
c  Assume a(1) = 0      (Enable 2 lines below if a(1) not= 0)
c---------------------------------------------------------------------
c    >                     - a(1) * ( u(i1-1,i2,i3) + u(i1+1,i2,i3)
c    >                              + u1(i1) )
c-------------------------------------------------------------------*/
		- a[2] * ( u2[i1] + u1[i1-1] + u1[i1+1] )
		      - a[3] * ( u2[i1-1] + u2[i1+1] );
	    }
	}
    }
#endif /* USE_CUDA */

/*--------------------------------------------------------------------
c     exchange boundary data
c--------------------------------------------------------------------*/
    comm3(r,n1,n2,n3,k);

    if (debug_vec[0] >= 1 ) {
#pragma omp single
	rep_nrm(r,n1,n2,n3,"   resid",k);
    }

    if ( debug_vec[2] >= k ) {
#pragma omp single
	showall(r,n1,n2,n3);
    }
}
static void psinv( double *r, double *u, int n1, int n2, int n3,
		   double c[4], int k) {

/*--------------------------------------------------------------------
c-------------------------------------------------------------------*/

/*--------------------------------------------------------------------
c     psinv applies an approximate inverse as smoother:  u = u + Cr
c
c     This  implementation costs  15A + 4M per result, where
c     A and M denote the costs of Addition and Multiplication.  
c     Presuming coefficient c(3) is zero (the NPB assumes this,
c     but it is thus not a general case), 2A + 1M may be eliminated,
c     resulting in 13A + 3M.
c     Note that this vectorizes, and is also fine for cache 
c     based machines.  
c-------------------------------------------------------------------*/

    int i3, i2, i1;
    double r1[M], r2[M];

    int n12 = n1*n2;
    int i123;

#pragma omp for
#pragma acc parallel loop vector_length(NTHREADS) private(r1,r2)	\
  present(u[0:n1*n2*n3],r[0:n1*n2*n3],c[0:4])
    for (i3 = 1; i3 < n3-1; i3++) {
	for (i2 = 1; i2 < n2-1; i2++) {
            for (i1 = 0; i1 < n1; i1++) {
	      i123 = i1 + n1*i2 + n12*i3;
		r1[i1] = r[i123-n1] + r[i123+n1]
		    + r[i123-n12] + r[i123+n12];
		r2[i1] = r[i123-n1-n12] + r[i123+n1-n12]
		    + r[i123-n1+n12] + r[i123+n1+n12];
	    }
            for (i1 = 1; i1 < n1-1; i1++) {
	      i123 = i1 + n1*i2 + n12*i3;
		u[i123] = u[i123]
		    + c[0] * r[i123]
		    + c[1] * ( r[i123-1] + r[i123+1]
			       + r1[i1] )
		    + c[2] * ( r2[i1] + r1[i1-1] + r1[i1+1] );
/*--------------------------------------------------------------------
c  Assume c(3) = 0    (Enable line below if c(3) not= 0)
c---------------------------------------------------------------------
c    >                     + c(3) * ( r2(i1-1) + r2(i1+1) )
c-------------------------------------------------------------------*/
	    }
	}
    }

/*--------------------------------------------------------------------
c     exchange boundary points
c-------------------------------------------------------------------*/
    comm3(u,n1,n2,n3,k);

    if (debug_vec[0] >= 1 ) {
#pragma omp single
	rep_nrm(u,n1,n2,n3,"   psinv",k);
    }

    if ( debug_vec[3] >= k ) {
#pragma omp single
	showall(u,n1,n2,n3);
    }
}
void showall(const T &value, const Args &...args)
{
	std::cout << value << std::endl;
	showall(args...);
}
Beispiel #10
0
int main(int argc,char *argv[])
{
    int a=0;
    char buf[1024];
    int cmdno;
    int quit=0;
    char name[20];
    char id[20];
    int rt;
    int age;
    char sex;
    struct student *pstu;
    struct student stu;
    struct listhead phead;
    phead.next = phead.pre = &phead;
   // readfromfile(&phead,STUFILE);
    //struct allstudent allstu;
    //rt=init_allstu(&allstu);
    printf("****************************************************************\n");
    printf("please input cmd:");
    if(rt==-1)
    {
        return -1;
    }
    while(0==quit)
    {
        fgets(buf,1024,stdin);
        buf[strlen(buf)-1] = '\0';
        cmdno=getCmdno(buf);
        switch(cmdno)
        {
            case HELP:
                 help();

                break;
            case ADD:
                printf("add\n");
                printf("please input student info\n");
                printf("please input student id\n");
                scanf("%s",id);
                
               
                
                
                 printf("please input student name\n");
                scanf("%s",name);
                printf("please input student age\n");
                scanf("%d",&age);
                printf("please input student sex\n");
                fgets(buf,1024,stdin);
                scanf("%c",&sex);
               // strcpy(stu.id,id);
               // strcpy(stu.name,name);
               // stu.age=(char)age;
               // stu.sex = sex;
               // addbyorder(&allstu,&stu);
                pstu = malloc(sizeof(struct student));
                if(NULL==pstu)
                {
                    printf("no\n");
                    break;
                }
                strcpy(pstu->id,id);
                strcpy(pstu->name,name);
                pstu->age=(char)age;
                pstu->sex=sex;
               
                addstu(&phead,pstu);
                
                break;
            case DEL:
                printf("please input student id\n");
                scanf("%s",id);
  //              pstu=findbyid(&phead,id);
                if(NULL==pstu)
                {
                    printf("%s can not exit\n",id);
                    break;
                }
                
                    delstu(pstu);
                    free(pstu);
                    pstu=NULL;
                
                
                break;
    /*        case FIND:
                printf("please input student id\n");
                scanf("%s",id);
                pstu=findbyid(&phead,id);
                if(NULL==pstu)
                {
                    printf("no this student\n");
                    break;
                }
                showone(pstu);
                 
                break;
            case FNAME:
                printf("please input name:");
                scanf("%s",name);
                pstu=NULL;
                do
                {
                    pstu=findbyname(&phead,name,pstu);
                    if(NULL!=pstu)
                    {
                        showone(pstu);
                    }
                }while(NULL!=pstu);
                break;*/
            case SHOW:
                showall(&phead);
                printf("please input cmd:");
                break;
    /*        case RSHOW:
                rshowall(&phead);
                printf("please input cmd:");
                break;
            case REVER:

               reverse(&phead);
               printf("please input cmd:");
                break;*/
            case QUIT:


                quit=1;
                break;
         /*   case SAVE:
                savefile(&phead,STUFILE);
                printf("please input cmd:");
               break;
            case MODIFY:
              
               break;
*/


            default:
                printf("please input cmd:");
                break;
                
        }
    }
    destroyall(&phead);

    return 0;
}
Beispiel #11
0
void docommand(char ch)
{
int count;
char dateb[7];
switch (ch)
       	{
	 case ARROWR : if (status.stockprice != 3 + 1) exit(0);goright(); break;
         case ARROWL : if (status.stockprice != 5 - 1) exit(0);goleft(); break;
	 case ARROWU : if (status.stockprice != 2 + 2) exit(0);goup(); break;
	 case ARROWD : if (status.stockprice != 3 + 1) exit(0);godown(); break;
	 case HOME :  leavecell(sys.cell);
		     if ((sys.screen == SCREEN1 || sys.screen == SCREEN3)
			  && page == PAGEDOWN)
		     {
		     sys.cell.row = 23;
		     sys.cell.col = MONTH;
		     }
		     else
                     if (sys.screen == SCREEN2)
		     {
		     sys.cell.row = 8;
		     sys.cell.col = SHARESPER;
		     }
		     else
		     {
		     sys.cell.row = 8;
		     sys.cell.col = MONTH;
		     }
		     entercell(sys.cell);
		     break;
	 case END :  leavecell(sys.cell);
		     if ((sys.screen == SCREEN1 || sys.screen == SCREEN3)
			  && page == PAGEDOWN)
		     {
		     sys.cell.row = 37;
		     sys.cell.col = MONTH;
		     }
		     else
                     if (sys.screen == SCREEN2)
		     {
		     sys.cell.row = 22;
		     sys.cell.col = SHARESPER;
		     }
		     else
		     {
		     sys.cell.row = 22;
		     sys.cell.col = MONTH;
		     }
		     entercell(sys.cell);
		     break;

	 case PGUP	: if ((sys.screen == SCREEN1 || sys.screen == SCREEN3)
			      && page == PAGEDOWN)
			{
			page = PAGEUP;
			if (sys.cell.row >= 8)
			sys.cell.row -= 15;
			disppage();
			}
			showall();
			entercell(sys.cell);
			break;
	 case PGDN	: if ((sys.screen == SCREEN1 || sys.screen == SCREEN3)
				&& page == PAGEUP)
			{
			page = PAGEDOWN;
			if (sys.cell.row >= 8)
			sys.cell.row += 15;
                        disppage();
			}
			showall();
			entercell(sys.cell);
			break;
         case F01 :	help();break;
         case F02 :     demo();
			break;
	 case F03 :     demo();
			break;
         case F04 : sortstatus(); genscreen(); entercell(sys.cell); break;
         case F05 :
		{
		    if (drawgraph(choice(6,graphchoice)) < 0)
		    errormessage("Graphics initialisation error");
		    genscreen();
		    showtotals();
		    entercell(sys.cell);
		 }
		    break;
         case F06 :
         	    leavecell(sys.cell);
		 switch (choice(3,screenchoice))
		 {
 		 case 1 :
		      if (tosavesys) savesys();
		      sys.screen = SCREEN1;
		      page = PAGEUP;
		      sys.cell.col = MONTH;
      		      sys.cell.row = 8;
		      sys.display = HELDS;
		      genscreen();
		      break;
		 case 2 :
		      sys.screen = SCREEN2;
		      sys.display = HELDS;
		      page = PAGEUP;
      		      sys.cell.row = 8;
		      sys.cell.col = EXPIRYDAY;
		      genscreen();
		      break;
		 case 3 :
		      if (tosavesys) savesys();
		      sys.cell.col = MONTH;
		      page = PAGEUP;
		      sys.screen = SCREEN3;
		      sys.display = INVVOL;
      		      sys.cell.row = 8;
		      wait();
		      if (recalcvolvalues)
		      calcallvol();
		      ready();
		      genscreen();
		      break;
		 }
		 showtotals();
		 entercell(sys.cell);
		 break;
            case F07 :
		   switch(choice(3,clearchoice))
		   {
		  case 1 :  if (sys.cell.row < 8 || sys.screen == SCREEN2) break;
			    wait();
			    clearrow();
				 calcall();
				 showall();
				 totals();
                              entercell(sys.cell);
			      break;
		   case 2 : wait();
			    switch( sys.cell.col)
			    {
                            case VOLC :
                            	case VALUEC :
				case VOLP :
				case DELTAC :
				case VALUEP :
                            	case DELTAP:
                            	case SHAREPRICE :break;
				case STOCKHELD : status.stockheld = 0; break;
				case VOLATILITY : status.volatility = 0.0;break;
				case INTEREST   : status.interest = 0.0; break;
				case  DATE      :
				case YEARMONTH :
				case SHARESPER : for (count =0;count <24; count++)
						   status.sizepay[count].sharesper = 1000;
						   break;               
				case EXPIRYDAY :
				case DAYSLEFT :
                            case MONTH : break;
                            case STRIKE : for (count = 0;count < 30; count++)
                                          {
					  status.data[count].strike = 0.0;
					  status.data[count].volc = 0.0;
					  status.data[count].volp = 0.0;
					  }
					  break;
				case MARKETC : for (count = 0;count < 30; count++)
                                        {
					status.data[count].marketc = 0.0;
					status.data[count].volc = 0.0;
					}
					  break;
				case HELDC :  for (count = 0;count < 30; count++)
					  status.data[count].heldc = 0;
					  break;
				case MARKETP : for (count = 0;count < 30; count++)
                                          {
					  status.data[count].marketp = 0.0;
					  status.data[count].volp = 0.0;
					  }
					  break;
				case HELDP :  for (count = 0;count < 30; count++)
					  status.data[count].heldp = 0;
					  break;
				case DIVIDENDDAY : for (count = 0;count < 24; count++)
					  status.sizepay[count].dday = 0;
					  break;
			        case DIVIDENDCENTS :  for (count = 0;count < 24; count++)
					  status.sizepay[count].payout = 0;
					  break;

			    }  wait();
				 calcall();
				 showall();
				 totals();  break;
			  case 3:   clearall();wait();   wait();
				 calcall();
				 showall();
				 totals();break;
			  /* clear all set shares per con */


		    }           showtotals();
				 ready();
				 entercell(sys.cell);
				 /* inverse vol now invalid */
		    break;


         case F08 :
			leavecell(sys.cell);
		   switch( choice(7, utilchoice))
		      {
			case 1 : getdir(); break;
			case 2 : bonusissue();
				 wait();
				 calcall();
				 showall();
				 totals();
				 showtotals();
				 ready();
				 break;
			case 3 : cashissue();
				 wait();
				 calcall();
				 showall();
				 totals();
				 showtotals();
				 ready();
				 break;
			 case 4: switch( choice(3,resolutionchoice))
				 {
				   case 1: numpts = 10; break;
				   case 2: numpts = 15; break;
				   case 3: numpts = 30; break;
				 }
                                    break;
			 case 5:switch (choice(3,printchoice))
				  {
				     case 1: printdetails(); break;
				     case 2: demo1();break;
				     case 3: demo1(); break;
					   } break;
			 case 6: filedelete(); break;
			 case 7 : reinstall();
		         }
			 entercell(sys.cell);
			 break;

         case F09 : switch (sys.screen)
			{
			case SCREEN1 :
			    leavecell(sys.cell);
			    if (sys.display == HELDS) sys.display = DELTAS;
			    else sys.display = HELDS;
		    	if (sys.cell.row >= 8)
		   	 sys.cell.col = MONTH;
		    	textcolor(sys.graphics.colors.heading);
		    	textbackground(sys.graphics.colors.databack);
		    	drawheadings();
		    	showall();
			showtotals();
		    	entercell(sys.cell);break;
			case SCREEN2 : break;
			case SCREEN3 :
			    leavecell(sys.cell);
			    if (sys.display == INVVOL) sys.display = OVERVALUED;
			    else sys.display = INVVOL;
 		    	    textcolor(sys.graphics.colors.heading);
		    	    textbackground(sys.graphics.colors.databack);
		    	    drawheadings();
		    	    showall();
			    showtotals();
		    	    entercell(sys.cell);break;
		       }
		    break;
         case F10 : switch (choice(3,quitchoice))
		    {
		    case 0 : break;
		    case 1 : wait();
	   		    textcolor(LIGHTGRAY);
			    textbackground(BLACK);
			    savesys();
			    clrscr();
			    gotoxy(2,2);
			    cprintf(" The Option Analyst is a product of");
			    gotoxy(2,3);
			    cprintf(" EFAM RESOURCES Pty. Ltd.\n");
			    retcursor();
			    exit(0);
			    break;
                    case 2 : demo();
			    break;
		    case 3 : break;
		    }
		    break;
	}
}
Beispiel #12
0
char editcell(celltype cell)
{
int x,y;
long z;
char ch;
char sharestring[12];
int  pageint;
if (page == PAGEUP || sys.screen == SCREEN2 || cell.row < 8) pageint = 0;
else pageint = 15;
x = endcell(cell.col)-1;
y = cell.row - pageint ;

   switch (cell.col)
       {case MONTH :  entercell(sys.cell);
		     if (status.data[cell.row-8].month == -1 &&
			 cell.row != 8 )
			 status.data[cell.row-8].month =
			inputmonth(x-2,y,(status.data[cell.row-9].month)-1);
			else
			 status.data[cell.row-8].month =
			inputmonth(x-2,y,status.data[cell.row-8].month);
		     wait();
		     if (sys.screen == SCREEN3) calcvolrow(cell.row);
                     calcrow(cell.row);
		     showrow(cell.row);
		     if ( cell.row != 22 && cell.row != 37)
		     {
		     cell.row += 1;
		     showcell(cell);
		     cell.row = cell.row -1;
		     }
		      /* show date of line below if it
			    had been hidden by showall suppression */
		     break;
	case STRIKE : entercell(sys.cell);
		      if (status.stockprice != 4.0) exit(0);
		      status.data[cell.row-8].strike =
		      inputreal(x,y,status.data[cell.row-8].strike,8,sys.decimal);
		      wait();
		     if (sys.screen == SCREEN3) calcvolrow(cell.row);
		      calcrow(cell.row);
                      showrow(cell.row);
		      break;
	case VALUEC : getch();break;
	case VALUEP : getch();break;
	case HELDC : entercell(sys.cell);
		     if (status.stockprice != 4.0) exit(0);
		     status.data[cell.row-8].heldc =
		     inputinteger(x,y,status.data[cell.row-8].heldc,4);
		     wait();
		     showcell(sys.cell);
		     break;
	case HELDP : entercell(sys.cell);
		     if (status.stockprice != 4.0) exit(0);
		     status.data[cell.row-8].heldp =
		     inputinteger(x,y,status.data[cell.row-8].heldp,4);
		     wait();
		     showcell(sys.cell);
		     break;
	case STOCKHELD :
			entercell(sys.cell);
			z = status.stockheld;
		     z =
		     inputlint(x,y,&z,8);
		     wait();
		     break;
	case SHAREPRICE : entercell(sys.cell);
			status.stockprice = 4.0;
			getch();
			demo();
			getch();
			break;
        case VOLATILITY : entercell(sys.cell);
			status.volatility =
			inputreal(x,y,status.volatility,5,2);
			wait();
			calcall();
			calcalloverval();
			showall();
			break;
        case INTEREST : entercell(sys.cell);
			status.interest=
			inputreal(x,y,status.interest,5,2);
			wait();
			initdivmtx(0);
			calcall();
			if (sys.screen == SCREEN3) calcallvol();
			else recalcvolvalues = TRUE;
			showall();
			break;
        case DATE    : 	entercell(sys.cell);
			inputdate(x,y,sys.date);
			wait();
			initdates();
			initsizepay();
			calcdays();
			initdivmtx(0);
			calcall();
			if (sys.screen == SCREEN3) calcallvol();
			else recalcvolvalues = TRUE;
			showall();
			break;
	case SHARESPER : entercell(sys.cell);
			status.sizepay[y].sharesper=
			inputinteger(x,y,status.sizepay[y].sharesper,4);
                        if (status.sizepay[y].sharesper < 1)
			status.sizepay[y].sharesper = 1;
			wait();
                        break;
	case EXPIRYDAY : entercell(sys.cell);
			sys.expiry[y].eday =inputinteger(x,y,sys.expiry[y].eday,2);
			if (sys.expiry[y].eday < 1) sys.expiry[y].eday = 1;
			else if (sys.expiry[y].eday > 31) sys.expiry[y].eday = 28;
			wait();
			initdates();
			calcdays();
			initdivmtx(0);
			calcall();
			tosavesys = TRUE;
		      	showall();
			break;
	case DIVIDENDDAY : entercell(sys.cell);
			status.sizepay[y].dday=inputinteger(x,y,status.sizepay[y].dday,2);
			if (status.sizepay[y].dday < 0)
			status.sizepay[y].dday = 0;
			else if (status.sizepay[y].dday > 31)
			status.sizepay[y].dday = 28;
			wait();
			calcdays();
			initdivmtx(0);
                        calcall();
			showrow(cell.row);
                        break;
	case DIVIDENDCENTS : entercell(sys.cell);
			status.sizepay[y].payout
			= inputinteger(x,y,status.sizepay[y].payout,3);
			if (status.sizepay[y].payout < 0)
			status.sizepay[y].payout = 0;
			wait();
			initdivmtx(0);
                        calcall();
			showrow(cell.row);
			break;
	case VOLC :     getch();
			break;
	case VOLP :     getch();
			break;
	case MARKETC : entercell(sys.cell);
			if (status.stockprice != 4.0) exit(0);
		      status.data[cell.row-8].marketc =
		      inputreal(x,y,status.data[cell.row-8].marketc,8,sys.decimal);
		      if (status.data[cell.row-8].marketc < 0)
		      status.data[cell.row-8].marketc = 0;
			wait();
			status.data[cell.row-8].volc = invertvolc(cell.row);
			calcoverval(cell.row);
			showrow(cell.row);
			break;
	case MARKETP : entercell(sys.cell);
		      if (status.stockprice != 4.0) exit(0);
		      status.data[cell.row-8].marketp =
		      inputreal(x,y,status.data[cell.row-8].marketp,8,sys.decimal);
		      if (status.data[cell.row-8].marketp < 0)
		      status.data[cell.row-8].marketp = 0;
			wait();
			status.data[cell.row-8].volp = invertvolp(cell.row);
			calcoverval(cell.row);
			showrow(cell.row);
			break;
       }
       entercell(cell);
       totals();
       showtotals();
       if (status.stockprice != 4.0) exit(0);
       ready();
       ch = getch();
       return(ch);
}
Beispiel #13
0
int
main(int argc, char **argv)
{
	char mib[32];
	char *buf;
	size_t len;
	int ch, error, fd;
	int count, first, last, cpuid;

	while ((ch = getopt(argc, argv, "df:")) != -1) {
		switch(ch) {
		case 'd':	/* dump */
			fl_dump = 1;
			break;
		case 'f':
			if (file)
				free(file);		/* XXX complain! */
			file = strdup(optarg);
			break;
		default:
			usage();
		}
	}

	argc -= optind;
	argv += optind;

	if (file == NULL || fl_dump) {
		len = sizeof(count);
		if (sysctlbyname(hw_mca_count, &count, &len, NULL, 0) == -1)
			err(1, hw_mca_count);

		if (count == 0)
			errx(0, "no error records found");

		len = sizeof(first);
		if (sysctlbyname(hw_mca_first, &first, &len, NULL, 0) == -1)
			err(1, hw_mca_first);

		len = sizeof(last);
		if (sysctlbyname(hw_mca_last, &last, &len, NULL, 0) == -1)
			err(1, hw_mca_last);

		cpuid = 0;
		error = 0;
		while (count && first <= last) {
			do {
				sprintf(mib, hw_mca_recid, first, cpuid);
				len = 0;
				ch = sysctlbyname(mib, NULL, &len, NULL, 0);
				error = (ch == -1) ? errno : 0;
				if (error != ENOENT)
					break;
				cpuid++;
			} while (cpuid <= HW_MCA_MAX_CPUID);
			if (error == ENOENT && cpuid > HW_MCA_MAX_CPUID) {
				first++;
				cpuid = 0;
				continue;
			}
			if (error)
				errc(1, error, "%s(1)", mib);

			buf = malloc(len);
			if (buf == NULL)
				err(1, "buffer");

			if (sysctlbyname(mib, buf, &len, NULL, 0) == -1)
				err(1, "%s(2)", mib);

			if (fl_dump)
				dump(buf);
			else
				show(buf, mib);

			free(buf);
			count--;
			if (cpuid == HW_MCA_MAX_CPUID) {
				first++;
				cpuid = 0;
			} else
				cpuid++;
		}
	} else {
		fd = open(file, O_RDONLY);
		if (fd == -1)
			err(1, "open(%s)", file);

		len = lseek(fd, 0LL, SEEK_END);
		buf = mmap(NULL, len, PROT_READ, 0U, fd, 0LL);
		if (buf == MAP_FAILED)
			err(1, "mmap(%s)", file);

		showall(buf, len);

		munmap(buf, len);
		close(fd);
	}

	return (0);
}