Example #1
0
int rmd_rtspsvr_start()
{
	int lsnport, max_clients;

	if (getcfg(cfg_file, "rtsp_port", &lsnport, GETCFG_INT32) != 0)
		lsnport = RTSP_PORT;
	if (getcfg(cfg_file, "max_clients", &max_clients, GETCFG_INT32) != 0)
		max_clients = DEFAULT_CLIENTS;
	syslog(LOG_INFO, "max clients: %d", max_clients);

	return rtspsvr_start(lsnport, max_clients, &callback);
}
Example #2
0
JNIEXPORT void JNICALL Java_vit01_timeleft_MainActivity_resources_1init() {
	getcfg();
	// дневное timestamp-смещение первого урока
	start_lessons_offset=start_lessons[0]*3600+start_lessons[1]*60;

	count_timekeys=count_lessons*2;
	timekeys=(time_t*)malloc(count_timekeys*sizeof(time_t));

	for (i=0; i<count_timekeys; i++) {
		timekeys[i]=start_lessons_offset;
		timekeys[i]+=lesson_length*(i/2)*60;

		isbreak=i%2;
		
		numbreak=i/2; // номер текущей перемены

		for (a=0; a<numbreak; a++) {
			if (a>=BREAKS_MAX_INDEX) {
				timekeys[i]+=default_break*60;
			} else {
				timekeys[i]+=breaks_in_minutes[a]*60;
			}
		}

		if (isbreak) { // если эта метка - перемена, то прибавляем время 1 урока, чтобы уравняться
			timekeys[i]+=lesson_length*60;
		}
	}
}
Example #3
0
static int add_drivers()
{
	int size;
	int n = 0;

	/* initialize hash table */
	if (getcfg(cfg_file, "device_driver_table_size", &size, 
				GETCFG_INT32) != 0)
		size = DRIVER_TABLE_SIZE;
	driver_table = hash_init(size, hash_func_driver);
	if (driver_table == NULL)
		return -1;

	/* load device drivers into hash table */
	char path[PATH_MAX], prefix[32];
	getcfg(cfg_file, "device_lib_path", path, GETCFG_STR);
	getcfg(cfg_file, "device_lib_name_prefix", prefix, GETCFG_STR);

	char *names = lookup_so(path, prefix);
	if (names == NULL) {
		syslog(LOG_ERR, "nono driver found");
		return -1;
	}

	buf_t *pb = openbuf(names, strlen(names));
	if (pb == NULL) {
		free(names);
		return -1;
	}

	char *line;
	while ((line = readbuf(pb, "\n")) != NULL) {
		if (add_driver(line) == 0)
			n++;
	}
	closebuf(pb);
	free(names);

	if (n == 0) {
		syslog(LOG_ERR, "none driver loaded");
		return -1;
	}

	return 0;
}
Example #4
0
static int add_devices()
{
	FILE *fp;
	char file[PATH_MAX], name[128], path[PATH_MAX], line[PATH_MAX];
	driver_t *driver;
	device_t *device;

	if (getcfg(cfg_file, "device_cfg_file", name, GETCFG_STR) != 0) {
		syslog(LOG_INFO, "can't get device cfg file info");
		return -1;
	}

	if (getrpath(path, sizeof(path)) == -1)
		snprintf(path, sizeof(path), ".");
	snprintf(file, sizeof(file), "%s/%s", path, name);

	if ((fp = fopen(file, "r")) == NULL)
		return -1;

	device_cfg_t cfg;
	int n;
	while (fgets(line, sizeof(line), fp) != NULL) {
		if (line[0] == '#' || line[0] == '/' || strlen(line) == 1)
			continue;

		n = sscanf(line, "%d;%d;%[^;];%d;%[^;];%[^;];%d;%[^;];"
				"%d;%[^;];%d;%[^;];%[^;];%d;%d;",
				&cfg.type,
				&cfg.id,
				cfg.ip,
				&cfg.port,
				cfg.user,
				cfg.pwd,
				&cfg.channel_num,
				cfg.rec,
				&cfg.storage_device_type,
				cfg.storage_ip,
				&cfg.storage_port,
				cfg.storage_user,
				cfg.storage_pwd,
				&cfg.storage_disk,
				&cfg.baud_rate);
		if (n != 15)
			continue;

		driver = rmd_devmgr_get_driver(cfg.type);
		if (driver == NULL)
			continue;

		device = add_device(&cfg, driver);
		if (device == NULL)
			continue;
		add_channels(&cfg, driver, device);
	}
	fclose(fp);
	return 0;
}
Example #5
0
int
main(int av, char** ac)
{
    ndb_init();
    debug("start");
    hostname = "ndb-srv7";
    if (Ndb_getInAddr(&hostaddr.sin_addr, hostname) != 0) {
	fatal("hostname %s lookup failed", hostname);
    }
    localcfgfile = "Ndb.cfg";
    initcfgfile = "config.txt";
    getcfg();
    start();
    debug("done");
    return 0;
}
Example #6
0
int main()
{
 DIR *ld; // папка с файлами транзакций
 struct dirent *tf;
 FILE *tr;
 long long i,lcp=-1,mtn=0x7fffffffffffffff; // минимальный номер транзакций из последовательности
 int tt;

 if(getcfg()!=0) { printf("2 Ошибка при чтении файла настроек\n"); return 1; }
 if(chdir(cfg.log_path)!=0) { printf("2 Папка журнала не найдена\n"); return 1; };

// найдем транзакцию с минимальным номером
 ld=opendir(".");
 while((tf=readdir(ld))!=NULL) 
 {
  if(tf->d_name[0]!='.') 
   { sscanf(tf->d_name,"%Ld",&i); if(i<mtn) mtn=i; }
 }
 closedir(ld);

 if(mtn!=0x7fffffffffffffff)
 {
// найдем последнюю контрольную точку
  i=mtn; sprintf(ftn,"%018Ld",i);
  while((tr=fopen(ftn,"rb"))!=NULL)
  {
   fread(&tt,sizeof(tt),1,tr); if(tt==TR_CPOINT) lcp=i;
   fclose(tr); i++; sprintf(ftn,"%018Ld",i);
  }

// удалим все транзакции после контрольной точки
  i=lcp+1; sprintf(ftn,"%018Ld",i);
  while(access(ftn,0)==0) { remove(ftn); i++; sprintf(ftn,"%018Ld",i); }

// обработаем все транзакции и очистим журнал
  for(i=mtn;i<=lcp;i++) tr_process(i);
 }

 mtn=0; lcp=-1;
 for(i=0;i<0x7fffffffffffffff;i++)
 {
  sprintf(ftn,"%018Ld",i); while(access(ftn,0)!=0) sleep(1);
  tt=tr_type(); if(tt==TR_CPOINT) lcp=i;
  for(;mtn<=lcp;mtn++) tr_process(mtn);
 }
 return 0;
}
Example #7
0
int rmd_uds_start()
{
	if (getcfg(cfg_file, "unix_domain_path", unix_domain_path, 
				GETCFG_STR) != 0) {
		syslog(LOG_ERR, "get UNIX domain sock path error");
		return -1;
	}

	uds_sock = uudpsock(unix_domain_path, &uds_addr);

	rmd_uds_sendmsg(RMD_RESTART, strlen(RMD_RESTART));

	if (uds_sock == -1)
		return -1;

	return 0;
}
Example #8
0
int xdrs2app_start(int mode)
{
	pthread_t tid;

	handle_mode = mode;
	if (getcfg() != 0)
		return -1;

	app_pkt.hdr.sync = htons(PKT_HDR_SYNC);
	app_pkt.hdr.type = PKT_TYPE_XDR;
	app_pkt.xdr_type = PKT_SINGLE_XDR;

	if (pthread_create(&tid, NULL, keepalive_thread, NULL) != 0) {
		syslog(LOG_ERR, "create xdrs2app keepalive_thread failed.");
		return -1;
	}
	pthread_detach(tid);
	return 0;
}
Example #9
0
static void set_report_rec_stat()
{
	getcfg(cfg_file, "report_rec_stat", &report_rec_stat, GETCFG_INT32);
}