コード例 #1
0
static void _up_assert(int errorcode)
{
  /* Are we in an interrupt handler or the idle task? */

  if (g_irqtos || ((FAR struct tcb_s*)g_readytorun.head)->pid == 0)
    {
       (void)irqsave();
        for (;;)
          {
#ifdef CONFIG_ARCH_LEDS
            board_led_on(LED_PANIC);
            up_delay(250);
            board_led_off(LED_PANIC);
            up_delay(250);
#endif
          }
    }
  else
    {
      exit(errorcode);
    }
}
コード例 #2
0
ファイル: upload.c プロジェクト: jungsagacity/ftp
void log_checktask(char * name,char * a)
{
	struct tm *t;
	char * curtime;
	int k;
	t=gettime();
	curtime=getchartime();
	int year=t->tm_year+1900;
	int month=t->tm_mon+1;
	char logdir[CHECKTASK_LOG_PATH_SIZE];
	sprintf(logdir,"%s%04d%02d%s",CHECKTASK_LOG_PATH,year,month,CHECKTASK_LOG_TYPE);
	FILE *fp;
	fp=fopen(logdir,"a+");
	if(fp==NULL)
	 exit(1);
	fprintf(fp,"%s\t%s\t%s\n",a,name,curtime);
//	fprintf(fp,"%s\n",a);
	fclose(fp);
	up_delay();
}
コード例 #3
0
ファイル: upload.c プロジェクト: jungsagacity/ftp
static void _inotify_event_handler(struct inotify_event *event)
{
	/* Perform event dependent handler routines */
	/* The mask is the magic that tells us what file operation occurred */
    if(strstr(event->name,UNIX_Z)==0)
    {
        /*File was closed */
        if(event->mask & IN_CLOSE_WRITE)
        {
            #ifdef DEBUG
            printf("wd:%d",event->wd);
            printf("IN_CLOSE_WRITE\n");
            printf("event->name: %s\n", event->name);
            #endif

            char command[COMMAND_SIZE]={0};
            FILE *pf;
            //get the command to compress the file with unix.z
            if(event->wd==1)
                sprintf(command,"compress -f %s%s",uploadPath->BDLocalPathPrefix,event->name);
            else
                sprintf(command,"compress -f %s%s",uploadPath->GNSSLocalPathPrefix,event->name);
            //execute the command of compression
            if((pf=popen(command,"r"))==NULL)
            {
                //compression failed
                #ifdef _DEBUG
                perror("压缩失败");
                #endif
            }
            pclose(pf);
            up_delay();

        }

        /* File was deleted means the compression is over*/
        if(event->mask & IN_DELETE)
        {
            #ifdef DEBUG
            printf("IN_DELETE\n");
            printf("event->name: %s\n", event->name);
            #endif
            int type = event-> wd;
            char name[STD_FILENAME_SIZE]="0";
            strcpy(name,event->name);
            if(nodeIsExist(name,type)==1)
            {
                char * dir;
                UploadNode *p0;
                p0=(UploadNode *)malloc(sizeof(UploadNode));

                int len1 = strlen(name)+strlen(UNIX_Z)+1;
                p0->filename=(char *)malloc(len1);
                memset(p0->filename,0, len1);
                sprintf(p0->filename,"%s%s",name,UNIX_Z);
                printf("filename:%s\n",p0->filename);
                //move the file to the backup folder

                dir = (char *)malloc(10);
                memset(dir,0,10);

                //move the file to the backup folder
                copyfile(p0->filename,type,dir);

                //BEIDOU
                if(type==1)
                {
                    int len2=strlen(uploadPath->BDLocalPathPrefix)+1;
                    p0->analysisCenterPath=(char *)malloc(len2);
                    memset(p0->analysisCenterPath,0, len2);
                    strcpy(p0->analysisCenterPath,uploadPath->BDLocalPathPrefix);

                    int len3 = strlen(uploadPath->BDRemotePathPrefix)+strlen(dir)+strlen(PATH_SUFFIX)+1;
                    p0->productCenterPath=(char *)malloc(len3);
                    memset(p0->productCenterPath,0, len3);
                    sprintf(p0->productCenterPath,"%s%s%s",uploadPath->BDRemotePathPrefix,dir,PATH_SUFFIX);
                }
                //GNSS
                else
                {
                    int len2=strlen(uploadPath->GNSSLocalPathPrefix)+1;
                    p0->analysisCenterPath=(char *)malloc(len2);
                    memset(p0->analysisCenterPath,0, len2);
                    strcpy(p0->analysisCenterPath,uploadPath->GNSSLocalPathPrefix);

                    int len3 = strlen(uploadPath->GNSSRemotePathPrefix)+strlen(dir)+strlen(PATH_SUFFIX)+1;
                    p0->productCenterPath=(char *)malloc(len3);
                    memset(p0->productCenterPath,0, len3);
                    sprintf(p0->productCenterPath,"%s%s%s",uploadPath->GNSSRemotePathPrefix,dir,PATH_SUFFIX);
                }



                p0->state=UPLOAD_FILE_EXIST;
                p0->type = type;
                p0->server=fs->next;
                #ifdef DEBUG
                printf("filename:%s\n",p0->filename);
                printf("传入:%s\n",p0->filename);
                log_checktask(p0->filename,"文件创建");
                #endif
                //create a new node
                insertlist(p0);
            }



    }

    }
}
コード例 #4
0
ファイル: upload.c プロジェクト: jungsagacity/ftp
void copyfile(char * filename,int type,char * dir)
{
	//char * filename = p0->filename;
	char * current_path;
	char * backup_path;
	char * filepath;
    char command[COMMAND_SIZE] = {0};

    #ifdef DEBUG
	printf("filename:%s\n",filename);
	#endif

	//the file is named after BD week, from the third to the sixth
	if((strstr(filename,"isa")==0)&&(strstr(filename,"dcb")==0))
	{
		strncpy(dir, filename+3, 4);
		#ifdef DEBUG
        printf("if\n");
		printf("%s\n",dir);
		#endif
	}
	//the file is named after year and month, from the third to the eighth
	else
	{
		strncpy(dir,filename+3,6);
		#ifdef DEBUG
		printf("else\n");
		printf("%s\n",dir);
		#endif
	}

    //the file is in the BD folder
    if(type==1)
	{
        current_path=uploadPath->BDLocalPathPrefix;
        backup_path=uploadPath->BDLocalPathPrefixBak;
	}
	//the file is in the GNSS folder
	else
	{
        current_path=uploadPath->GNSSLocalPathPrefix;
        backup_path=uploadPath->GNSSLocalPathPrefixBak;
	}

	int lenth = strlen(backup_path)+strlen(dir)+strlen(PATH_SUFFIX)+1;
	filepath = (char * )malloc(lenth);
	memset(filepath,0,lenth);
	sprintf(filepath,"%s%s%s",backup_path,dir,PATH_SUFFIX);

	#ifdef DEBUG
	printf("filepath:%s\n",filepath);
	#endif

	if(fileIsExist(filepath)==0)
    {

        sprintf(command,"cp %s%s %s%s",current_path,filename,backup_path,dir);

        #ifdef DEBUG
        printf("command:%s\n",command);
        #endif

        FILE *pf;
        if((pf=popen(command,"r"))==NULL)
        {
            //move failed
            #ifdef _DEBUG
            perror("移动失败");
            #endif
        }
        pclose(pf);
        up_delay();
    }

    free(filepath);
}