예제 #1
0
파일: swan_ts.c 프로젝트: FuangCao/cavan
int swan_ts_open_misc_device(const char *devpath, int flags)
{
	int fd;

	if (devpath) {
		fd = try_to_open(flags, devpath, SWAN_TS_MISC_DEVICE, SWAN_TS_PROC_DEVICE, NULL);
	} else {
		fd = try_to_open(flags, SWAN_TS_MISC_DEVICE, SWAN_TS_PROC_DEVICE, NULL);
	}

	if (fd < 0) {
		pr_red_info("Open misc device failed");
	}

	return fd;
}
예제 #2
0
/* This is meant to find and open files for reading, possibly piping
	 them through a decompressor. */
FILE *open_file(const char *name, int decompress, int noise_mode)
	{
	FILE *fp;
	PathList *plp=pathlist;
	int l;

	if (!name || !(*name))
		{
		ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Attempted to open nameless file.");
		return 0;
		}

	/* First try the given name */

	strncpy(current_filename, name, 1023);
	current_filename[1023]='\0';

	ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Trying to open %s", current_filename);
	if ((fp=try_to_open(current_filename, decompress, noise_mode)))
		return fp;

#ifdef ENOENT
	if (noise_mode && (errno != ENOENT))
		{
		ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", 
		 current_filename, strerror(errno));
		return 0;
		}
#endif
	
#ifndef __WIN32__
	if (name[0] != PATH_SEP)
#else
	if (name[0] != '\\' && name[0] != '/' && name[1] != ':')
#endif
		while (plp)	/* Try along the path then */
			{
	*current_filename=0;
	l=static_cast<int>(strlen(plp->path));
	if(l)
		{
		strcpy(current_filename, plp->path);
#ifndef __WIN32__
		if(current_filename[l-1]!=PATH_SEP)
#else
		if(current_filename[l-1]!='\\' && current_filename[l-1]!='/')
#endif
			strcat(current_filename, PATH_STRING);
		}
	strcat(current_filename, name);
	ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Trying to open %s", current_filename);
	if ((fp=try_to_open(current_filename, decompress, noise_mode)))
		return fp;
#ifdef ENOENT
	if (noise_mode && (errno != ENOENT))
		{
		ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", 
		 current_filename, strerror(errno));
		return 0;
		}
#endif
	plp=plp->next;
			}
	
	/* Nothing could be opened. */

	*current_filename=0;
	
	if (noise_mode>=2)
		ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", name, strerror(errno));
	
	return 0;
	}
예제 #3
0
/* This is meant to find and open files for reading, possibly piping
   them through a decompressor. */
FILE *open_file(const char *name, int decompress, int noise_mode)
{
  FILE *fp;
  PathList *plp;
  int l;

  if (!name || !(*name))
    {
      ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Attempted to open nameless file.");
      return 0;
    }

  if (pathlist==NULL) {
    if(customPath[0]!='\0') {
        add_to_pathlist(customPath); }
    /* Generate path list */
#ifdef DEFAULT_PATH
    add_to_pathlist(DEFAULT_PATH);
#endif
#ifdef DEFAULT_PATH1
    add_to_pathlist(DEFAULT_PATH1);
#endif
#ifdef DEFAULT_PATH2
    add_to_pathlist(DEFAULT_PATH2);
#endif
#ifdef DEFAULT_PATH3
    add_to_pathlist(DEFAULT_PATH3);
#endif
  }

  /* First try the given name */

  strncpy(current_filename, name, PATH_MAX - 1);
  current_filename[PATH_MAX - 1]='\0';

  ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Trying to open %s", current_filename);
  if ((fp=try_to_open(current_filename, decompress, noise_mode)))
    return fp;

#ifdef ENOENT
  if (noise_mode && (errno != ENOENT))
    {
      ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", 
	   current_filename, strerror(errno));
      return 0;
    }
#endif

  plp=pathlist;
  if (name[0] != PATH_SEP)
    while (plp)  /* Try along the path then */
      {
	*current_filename=0;
	l=strlen(plp->path);
	if(l)
	  {
	    strcpy(current_filename, plp->path);
	    if(current_filename[l-1]!=PATH_SEP)
	      strcat(current_filename, PATH_STRING);
	  }
	strcat(current_filename, name);
	ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Trying to open %s", current_filename);
	if ((fp=try_to_open(current_filename, decompress, noise_mode)))
	  return fp;
#ifdef ENOENT
	if (noise_mode && (errno != ENOENT))
	  {
	    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", 
		 current_filename, strerror(errno));
	    return 0;
	  }
#endif
	plp=plp->next;
      }
  
  /* Nothing could be opened. */

  *current_filename=0;
  
  if (noise_mode>=2)
    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", name, strerror(errno));
  
  return 0;
}
예제 #4
0
/* This is meant to find and open files for reading, possibly piping
   them through a decompressor. */
struct timidity_file *open_file(char *name, int decompress, int noise_mode)
{
  struct timidity_file *tf;
  PathList *plp=pathlist;
  int l;

  open_file_noise_mode = noise_mode;
  if (!name || !(*name))
    {
      if(noise_mode)
        ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Attempted to open nameless file.");
      return 0;
    }

  /* First try the given name */
  strncpy(current_filename, url_unexpand_home_dir(name), 1023);
  current_filename[1023]='\0';

  if(noise_mode)
    ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Trying to open %s", current_filename);
  if ((tf=try_to_open(current_filename, decompress)))
    return tf;

#ifdef __MACOS__
  if(errno)
#else
  if(errno && errno != ENOENT)
#endif
    {
	if(noise_mode)
	    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s",
		      current_filename, strerror(errno));
	return 0;
    }

  if (!IS_PATH_SEP(name[0]) && !is_url_prefix(name))
    while (plp)  /* Try along the path then */
      {
	*current_filename=0;
	l=strlen(plp->path);
	if(l)
	  {
	    strcpy(current_filename, plp->path);
	    if(!IS_PATH_SEP(current_filename[l-1]) &&
	       current_filename[l-1] != '#' &&
	       name[0] != '#')
		strcat(current_filename, PATH_STRING);
	  }
	strcat(current_filename, name);
	if(noise_mode)
	    ctl->cmsg(CMSG_INFO, VERB_DEBUG,
		      "Trying to open %s", current_filename);
	if ((tf=try_to_open(current_filename, decompress)))
	  return tf;
#ifdef __MACOS__
	if(errno)
#else
	if(errno && errno != ENOENT)
#endif
	{
	    if(noise_mode)
		ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s",
			  current_filename, strerror(errno));
	    return 0;
	  }
	plp=plp->next;
      }

  /* Nothing could be opened. */

  *current_filename=0;

  if (noise_mode>=2)
      ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", name,
		errno ? strerror(errno) : "Can't open file");

  return 0;
}
예제 #5
0
int ManageCamera::init_camera_from_DB()
{
	uint32 ID = 0;
	string rtspurl;
	uint8  num= 0;

	int iRet = -1;
	vector<int> camID;
	DBCAMERACONFI Caminfo;
	DBCAMERAFUNCPARAM Camfuncparam;

	ST_VDCS_VIDEO_PUSH_CAM  t_addCam;
	T_VDCS_VIDEO_CAMERA_PARAM t_varParam;
	vector <VIDEO_DRAW>   pkg;
	
	CDataInfo.getAllCameraConfigID(NULL,camID);

	if(camID.size() > 0){
		for(num = 0; num < camID.size() ; num++ )
		{	
			ID = (uint32)camID[num];
			CDataInfo.getCameraConfig(camID[num],&Caminfo); 
			iRet = try_to_open(Caminfo.ip,Caminfo.CamUrl);
			if(iRet < 0)
			{
				m_log.Add("%s(%d),DB have  camera  %s cant open!" ,DEBUGARGS ,Caminfo.ip);
				continue;
			}
			SingleCamPtr camptr =  SingleCamPtr(new SingleCamera(this,ID));
			WriteLock writelock_(m_SinCamListMutex_);
			m_SinCamList.push_front(camptr);
			writelock_.unlock();
			fill_push_cam(&Caminfo,&t_addCam);

			camptr->set_camera_fix_param(t_addCam);

		    iRet = CDataInfo.getCameraAlarmInfo(camID[num],&Camfuncparam);		
			if(iRet < 0)
			{
				m_log.Add("%s(%d),DB get Camera no AlarmInfo  !" ,DEBUGARGS);
				continue;
			}

			if(Camfuncparam.AnalyzeNUM == 1)
			{
				pkg.clear();
				memset(&t_varParam , 0 ,sizeof(T_VDCS_VIDEO_CAMERA_PARAM));
				fill_var_param(&Camfuncparam,&t_varParam,pkg,1);				
				camptr->reset_camera_var_param_from_db(&t_varParam,pkg,1);
			}
			else if(Camfuncparam.AnalyzeNUM == 2)
			{
				pkg.clear();
				memset(&t_varParam , 0 ,sizeof(T_VDCS_VIDEO_CAMERA_PARAM));
				fill_var_param(&Camfuncparam,&t_varParam,pkg,1);
				camptr->reset_camera_var_param_from_db(&t_varParam,pkg,1);
				
				pkg.clear();
				memset(&t_varParam , 0 ,sizeof(T_VDCS_VIDEO_CAMERA_PARAM));
				fill_var_param(&Camfuncparam,&t_varParam,pkg,2);
				camptr->reset_camera_var_param_from_db(&t_varParam,pkg,2);
			}
			else
			{
				m_log.Add("%s(%d),DB have wrong  camera AnalyzeNUM %d !" ,DEBUGARGS,Camfuncparam.AnalyzeNUM);
			}
			erase_id_from_CamIDList(ID);
			m_CamList.add_cam_list(Caminfo.CamUrl, ID);	
		 }
		return 0;
	}
	m_log.Add("%s(%d),DB have no camera!" ,DEBUGARGS);

	return -1;
}