Пример #1
0
/*
	1. Call STOP service, using as argument the received value for the process ID.
	2. Check the output return code against the expected return code, received as argument.
	3. If service call gave no error, call service GET_PROCESS_STATUS, using as argument the
	   received value for the process ID.
	4. If no error occurred, check that process state is equal to Dormant.
	5. Return a bit structure holding information about any of the following errors:
		a. Expected error code different from the output one.
		b. Process state different from Dormant.
		c. GET_PROCESS_STATUS invocation gave an error.
	6. Output the process status returned from the GET_PROCESS_STATUS service and the return code
	   returned from the STOP service.
*/
struct stop_error_type check_stop(PROCESS_ID_TYPE id, RETURN_CODE_TYPE code){
	struct stop_error_type c_s;
	RETURN_CODE_TYPE retCode;
	PROCESS_STATUS_TYPE status;
	char sal_code[MAX_CAD];

	c_s = initStruct();

	STOP(id, &retCode);
	CHECK_CODE(": STOP", retCode, sal_code);
    printf("%s Process with ID: %d\n", sal_code, id);

	if (code==retCode){
		GET_PROCESS_STATUS(id, &status, &retCode);
		if (retCode==NO_ERROR){
			if (status.PROCESS_STATE != DORMANT){
				c_s.test_state = TRUE;
			}
		}else
			c_s.test_code_get = TRUE;
	}else
		c_s.test_code_exp = TRUE;

	return c_s;
}
Пример #2
0
void initImage (int slices, int dimx, int dimy, metaImage * mImage, int background) {

    int i,j,k;

    initStruct(slices, mImage);

    mImage->dimx = dimx;
    mImage->dimy = dimy;
    mImage->slices = slices;

    p_size *** image = mImage->image;

//     image = calloc (slices, sizeof(p_size **));
    for ( k = 0; k<slices; k++) {
        image[k] = calloc(dimx, sizeof (p_size *));
        for (i = 0; i < dimx; i++) {
            image[k][i] = calloc (dimy, sizeof(p_size ));
            for (j = 0; j<dimy; j++) {
                image[k][i][j] = background;//Rendo lo spazio allocato bianco!! MIN is Black

            }

        }

    }

//	mImage->image = image;

}
Пример #3
0
int main(int argc, char**argv) {
    printf("#################################\n");
    printf("#      DE STIJL PROJECT         #\n");
    printf("#################################\n");

    //signal(SIGTERM, catch_signal);
    //signal(SIGINT, catch_signal);

    /* Avoids memory swapping for this program */
    mlockall(MCL_CURRENT | MCL_FUTURE);
    /* For printing, please use rt_print_auto_init() and rt_printf () in rtdk.h
     * (The Real-Time printing library). rt_printf() is the same as printf()
     * except that it does not leave the primary mode, meaning that it is a
     * cheaper, faster version of printf() that avoids the use of system calls
     * and locks, instead using a local ring buffer per real-time thread along
     * with a process-based non-RT thread that periodically forwards the
     * contents to the output stream. main() must call rt_print_auto_init(1)
     * before any calls to rt_printf(). If you forget this part, you won't see
     * anything printed.
     */
    rt_print_auto_init(1);
    initStruct();
    startTasks();
    pause();
    deleteTasks();

    return 0;
}
Пример #4
0
static PyObject *__pyx_pf_13cython_struct_test_struct(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  myStruct __pyx_v_mst;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("test_struct");
  __pyx_self = __pyx_self;

  /* "cython_struct.pyx":10
 * def test_struct():
 *     cdef myStruct mst
 *     initStruct(&mst)             # <<<<<<<<<<<<<<
 *     showStruct(&mst)
 *     return mst
 */
  initStruct((&__pyx_v_mst));

  /* "cython_struct.pyx":11
 *     cdef myStruct mst
 *     initStruct(&mst)
 *     showStruct(&mst)             # <<<<<<<<<<<<<<
 *     return mst
 * 
 */
  showStruct((&__pyx_v_mst));

  /* "cython_struct.pyx":12
 *     initStruct(&mst)
 *     showStruct(&mst)
 *     return mst             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_convert__to_py_myStruct(__pyx_v_mst); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cython_struct.test_struct", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
Пример #5
0
void Solar_System::Init()
{
	glShadeModel(GL_SMOOTH);

	// using dynamic memory allocation so that i do not have to manually
	// initialize the vectors.  It seems like a cleaner solution.
	// also i just need practice using pointers and dynamic memory
	// allocation
	planetPtr = new planet[num];
	
	//initializez the structures
	for(int i = 0; i < num; i++)
		initStruct(planetPtr[i], i);
}
Пример #6
0
/*  1. Call service.
	2. Check whether the returned error code is different from the expected one.
	3. If no error occurred, call service GET_PROCESS_STATUS, using as argument the received process
	   ID. This process ID MUST be the process ID of the current process but this procedure has no way to
	   guarantee it!
	4. Return structure indicating whether the returned error code was different from the expected
	one.
*/
struct replenish_error_type checkreplenish(PROCESS_ID_TYPE id, SYSTEM_TIME_TYPE budget,
										   RETURN_CODE_TYPE code){
	struct replenish_error_type r_e;
	RETURN_CODE_TYPE retCode;
	PROCESS_STATUS_TYPE status0;

	r_e = initStruct();

	REPLENISH(budget, &retCode);
	if (retCode==code){
		GET_PROCESS_STATUS(id, &status0, &retCode);
		if (retCode!=NO_ERROR){
			r_e.test_status = TRUE;
		}
	}else
		r_e.test_code = TRUE;


	return r_e;
}
Пример #7
0
struct suspend_error_type checksuspend(PROCESS_ID_TYPE id, RETURN_CODE_TYPE code){
	struct suspend_error_type s_e;
	RETURN_CODE_TYPE retCode;
	PROCESS_STATUS_TYPE status;

	s_e = initStruct();

	SUSPEND(id, &retCode);
	if (code!=retCode){
		s_e.test_code_suspend = TRUE;
	}else{
		GET_PROCESS_STATUS(id, &status, &retCode);
		if (retCode!=code){
			s_e.test_code_get = TRUE;
		}

		if (status.PROCESS_STATE != WAITING){
			s_e.test_status = TRUE;
		}
	}

	return s_e;

}
Пример #8
0
logM *logToSystem()
{
	logM * plogM = (logM *)calloc(1, sizeof(logM)); //申请空间将登录的用户信息保存
	initStruct(plogM); //初始化结构体指针

	char userName[100] = { 0 };
	char password[100] = { 0 }; //创建临时变量保存用户登录时的信息
	char allMessge[200] = { 0 };

	int userNameLen = 0;
	int passwordLen = 0;
	int count = 0;
	int icountu = 0;
	int icountp = 0;

	do
	{
		logMenu();
		printf("\t请您先登录:\n");
		printf("------------------------------------------------------------------------");
		printf("\t请输入用户名(仅包含字母、数字或两者组合,用户名位数小于8位):\n");
		//gets(userName);
		fgets(userName, 21, stdin);  //截取输入的20位
		//printf("%d", strlen(userName));
		userName[strlen(userName) - 1] = '\0';
		printf("------------------------------------------------------------------------");
		printf("\n请输入密码(仅包含字母、数字或两者组合):\n");
		fflush(stdin);

		/*char c;
		for (int i = 0; i < 100; i++)
		{
			c = _getch();
			if (c == 13)
			{
				password[i] = '\0';
				break;
			}
			if ((c <= 90 && c >= 65) || (c >= 97 && c <= 122) || (c >= 48 || c <= 57))
			{
				printf("*");
			}
			password[i] = c;
		}*/

		/*char c;
		int n = 0;
		do
		{
		c = _getch();
		if (c != '\n' && c != '\r' && c != 127)
		{
			password[n] = c;
			printf("*");
			n++;
		}
		else if ((c != '\n' || c!= '\r') && c != 127)
		{
		if (n > 0)
		{
			n--;
			printf("\b \b");
		}
		}
		} while ((c != '\n' || c != '\r') &&  c!=127);
		password[n] = '\0';*/

		//判断密码
		judgePasswd(password);
		
		fflush(stdin);

		userNameLen = strlen(userName);
		passwordLen = strlen(password);
		if (userNameLen > 8 || userNameLen <= 0)
		{
			system("cls");
			printf("\n您输入的用户名位数有误!请重新确定\n");

		}
		if (passwordLen > 8 || passwordLen <= 0)
		{
			system("cls");
			printf("\n您输入的密码位数有误!请重新确定\n");
		}
		count++;

		printf("\n%s ", userName);
		printf("%s ", password);
		icountu = travUserMesg(userName);
		icountp = travUserMesg(password);
	
		if (count >= 3)
		{
			printf("您已经输错三次,系统将会在3秒钟后退出!");
			Sleep(3000);
			exit(0);
		}
	} while (userNameLen > 8 || passwordLen > 8 || userNameLen <= 0 || passwordLen <= 0 || icountu != 1 || icountp != 1);


	strcat(allMessge, userName);
	strcat(allMessge, ":");
	strcat(allMessge, password);

	plogM->headFlag[0] = 1;
	memcpy(plogM->userMessage, allMessge, userNameLen+passwordLen + 1);

	return plogM;
}