Exemplo n.º 1
0
static char *
get_oldroot_path (const char *path)
{
  while (*path == '/')
    path++;
  return strconcat ("/oldroot/", path);
}
Exemplo n.º 2
0
/* get a database handle to the alarm db */
EXPORTED sqldb_t *caldav_alarm_open()
{
    /* already running?  Bonus */
    if (refcount) {
        refcount++;
        return my_alarmdb;
    }

    /* we need exclusivity! */
    int r = mboxname_lock("$CALDAVALARMDB", &my_alarmdb_lock, LOCK_EXCLUSIVE);
    if (r) {
        syslog(LOG_ERR, "DBERROR: failed to lock $CALDAVALARMDB");
        return NULL;
    }

    char *dbfilename = strconcat(config_dir, "/caldav_alarm.sqlite3", NULL);
    my_alarmdb = sqldb_open(dbfilename, CMD_CREATE, DBVERSION, upgrade);

    if (!my_alarmdb) {
        syslog(LOG_ERR, "DBERROR: failed to open %s", dbfilename);
        mboxname_release(&my_alarmdb_lock);
    }

    free(dbfilename);
    refcount = 1;
    return my_alarmdb;

}
Exemplo n.º 3
0
void CScriptStorage::flush_log()
{
	string_path			log_file_name;
	strconcat           (sizeof(log_file_name),log_file_name,Core.ApplicationName,"_",Core.UserName,"_lua.log");
	FS.update_path      (log_file_name,"$logs$",log_file_name);
	m_output.save_to	(log_file_name);
}
Exemplo n.º 4
0
void CScriptEngine::process_file_if_exists	(LPCSTR file_name, bool warn_if_not_exist)
{
	u32						string_length = xr_strlen(file_name);
	if (!warn_if_not_exist && no_file_exists(file_name,string_length))
		return;

	string256				S,S1;
	if (m_reload_modules || (*file_name && !namespace_loaded(file_name))) {
		FS.update_path		(S,"$game_scripts$",strconcat(S1,file_name,".script"));
		if (!warn_if_not_exist && !FS.exist(S)) {
#ifdef DEBUG
#	ifndef XRSE_FACTORY_EXPORTS
			if (psAI_Flags.test(aiNilObjectAccess))
#	endif
			{
				print_stack			();
				Msg					("* trying to access variable %s, which doesn't exist, or to load script %s, which doesn't exist too",file_name,S1);
				m_stack_is_ready	= true;
			}
#endif
			add_no_file		(file_name,string_length);
			return;
		}
#ifndef MASTER_GOLD
		Msg					("* loading script %s",S1);
#endif // MASTER_GOLD
		m_reload_modules	= false;
		load_file_into_namespace(S,*file_name ? file_name : "_G");
	}
}
Exemplo n.º 5
0
    virtual void	Execute	(LPCSTR args)	{
        CCC_Token::Execute	(args);
        string_path		_cfg;
        string_path		cmd;

        switch	(*value)	{
        case 0:
            xr_strcpy(_cfg, "rspec_minimum.ltx");
            break;
        case 1:
            xr_strcpy(_cfg, "rspec_low.ltx");
            break;
        case 2:
            xr_strcpy(_cfg, "rspec_default.ltx");
            break;
        case 3:
            xr_strcpy(_cfg, "rspec_high.ltx");
            break;
        case 4:
            xr_strcpy(_cfg, "rspec_extreme.ltx");
            break;
        }
        FS.update_path			(_cfg,"$game_config$",_cfg);
        strconcat				(sizeof(cmd),cmd,"cfg_load", " ", _cfg);
        Console->Execute		(cmd);
    }
Exemplo n.º 6
0
	  virtual void Execute(LPCSTR args) {
		#ifndef	DEBUG
		if (GameID() != GAME_SINGLE) 
		{
			Msg("For this game type Demo Play is disabled.");
			return;
		};
		#endif
		  if (0==g_pGameLevel)
		  {
			  Msg	("! There are no level(s) started");
		  } else {
			  Console->Hide			();
			  string_path			fn;
			  u32		loops	=	0;
			  LPSTR		comma	=	strchr(const_cast<LPSTR>(args),',');
			  if (comma)	{
				  loops			=	atoi	(comma+1);
				  *comma		=	0;	//. :)
			  }
			  strconcat			(sizeof(fn),fn, args, ".xrdemo");
			  FS.update_path	(fn, "$game_saves$", fn);
			  g_pGameLevel->Cameras().AddCamEffector(xr_new<CDemoPlay> (fn, 1.0f, loops));
		  }
	  }
Exemplo n.º 7
0
	virtual void Execute(LPCSTR arguments)
	{
		if (!arguments || !*arguments) {
			Msg					("! no arguments passed");
			return;
		}

		string_path				name;
		string_path				fn;

		if (0==strext(arguments))
			strconcat			(sizeof(name),name,arguments,".ogf");
		else
			strcpy_s			(name,sizeof(name),arguments);

		if (!FS.exist(arguments) && !FS.exist(fn, "$level$", name) && !FS.exist(fn, "$game_meshes$", name)) {
			Msg					("! Cannot find visual \"%s\"",arguments);
			return;
		}

		IRender_Visual			*visual = Render->model_Create(arguments);
		CKinematics				*kinematics = smart_cast<CKinematics*>(visual);
		if (!kinematics) {
			Render->model_Delete(visual);
			Msg					("! Invalid visual type \"%s\" (not a CKinematics)",arguments);
			return;
		}

		Msg						("bones for model \"%s\"",arguments);
		for (u16 i=0, n=kinematics->LL_BoneCount(); i<n; ++i)
			Msg					("%s",*kinematics->LL_GetData(i).name);
		
		Render->model_Delete	(visual);
	}
Exemplo n.º 8
0
EXPORTED int jmapauth_open(struct db **dbptr, int db_flags, const char *fname)
{
    int r = 0;
    char *tofree = NULL;

    assert(dbptr);

    if (!fname) {
        fname = config_getstring(IMAPOPT_JMAPAUTH_DB_PATH);
    }

    /* create db file name */
    if (!fname) {
        tofree = strconcat(config_dir, FNAME_JMAPAUTH, (char*)NULL);
        fname = tofree;
    }

    /* open the database */
    r = cyrusdb_open(DB, fname, db_flags, dbptr);
    if (r) {
        if (r != CYRUSDB_NOTFOUND) {
            syslog(LOG_ERR, "JMAP auth: cannot open db %s: %s",
                    fname, cyrusdb_strerror(r));
        }
        return r;
    }

    free(tofree);
    return r;
}
Exemplo n.º 9
0
/* Create a LDAP URL from DN and FILTER and return it in URL.  We don't
   need the host and port because this will be specified using the
   override options. */
static gpg_error_t
make_url (char **url, const char *dn, const char *filter)
{
  gpg_error_t err;
  char *u_dn, *u_filter;
  char const attrs[] = (USERCERTIFICATE ","
/*                         USERSMIMECERTIFICATE "," */
                        CACERTIFICATE ","
                        X509CACERT );

  *url = NULL;

  u_dn = escape4url (dn);
  if (!u_dn)
      return gpg_error_from_errno (errno);

  u_filter = escape4url (filter);
  if (!u_filter)
    {
      err = gpg_error_from_errno (errno);
      xfree (u_dn);
      return err;
    }

  *url = strconcat ("ldap:///", u_dn, "?", attrs, "?sub?", u_filter, NULL);
  if (!*url)
    err = gpg_error_from_syserror ();
  else
    err = 0;

  xfree (u_dn);
  xfree (u_filter);
  return err;
}
Exemplo n.º 10
0
void CUIStatsListItem::XmlInit(const char *path, CUIXml &uiXml)
{
	CUIXmlInit	xml_init;
//	CUIStatic	*pStatic;
	CUIButton	*pButton;

	string256 buf;
	strconcat(sizeof(buf),buf, path, ":static");

	int tabsCount = uiXml.GetNodesNum(path, 0, "static");

	XML_NODE* tab_node = uiXml.NavigateToNode(path,0);
	uiXml.SetLocalRoot(tab_node);

	for (int i = 0; i < tabsCount; ++i)
	{
		pButton = xr_new<CUIButton>();
		pButton->SetAutoDelete(true);
		xml_init.InitStatic(uiXml, "static", i, pButton);
		pButton->SetTextAlignment(CGameFont::alLeft);
		AttachChild(pButton);
		FieldsVector.push_back(pButton);
	}

	FieldsVector[0]->SetElipsis(CUIStatic::eepEnd, 0);
}
Exemplo n.º 11
0
/* must be called after cyrus_init */
EXPORTED int duplicate_init(const char *fname)
{
    int r = 0;
    char *tofree = NULL;

    if (!fname)
        fname = config_getstring(IMAPOPT_DUPLICATE_DB_PATH);

    /* create db file name */
    if (!fname) {
        tofree = strconcat(config_dir, FNAME_DELIVERDB, (char *)NULL);
        fname = tofree;
    }

    r = cyrusdb_open(DB, fname, CYRUSDB_CREATE, &dupdb);
    if (r != 0) {
        syslog(LOG_ERR, "DBERROR: opening %s: %s", fname,
               cyrusdb_strerror(r));
        goto out;
    }
    duplicate_dbopen = 1;

out:
    free(tofree);

    return r;
}
Exemplo n.º 12
0
EXPORTED void quotadb_open(const char *fname)
{
    int ret;
    char *tofree = NULL;
    int flags = CYRUSDB_CREATE;

    if (!fname)
        fname = config_getstring(IMAPOPT_QUOTA_DB_PATH);

    /* create db file name */
    if (!fname) {
        tofree = strconcat(config_dir, FNAME_QUOTADB, (char *)NULL);
        fname = tofree;
    }

    if (config_getswitch(IMAPOPT_IMPROVED_MBOXLIST_SORT))
        flags |= CYRUSDB_MBOXSORT;

    ret = cyrusdb_open(QDB, fname, flags, &qdb);
    if (ret != 0) {
        syslog(LOG_ERR, "DBERROR: opening %s: %s", fname,
               cyrusdb_strerror(ret));
            /* Exiting TEMPFAIL because Sendmail thinks this
               EC_OSFILE == permanent failure. */
        fatal("can't read quotas file", EC_TEMPFAIL);
    }

    free(tofree);

    quota_dbopen = 1;
}
Exemplo n.º 13
0
/* Build the remote part or the URL from SCHEME, HOST and an optional
   PORT.  Returns an allocated string or NULL on failure and sets
   ERRNO.  */
static char *
make_host_part (const char *scheme, const char *host, unsigned short port)
{
  char portstr[10];
  char *hostname;
  char *hostport;

  /* Map scheme and port.  */
  if (!strcmp (scheme, "hkps") || !strcmp (scheme,"https"))
    {
      scheme = "https";
      strcpy (portstr, "443");
    }
  else /* HKP or HTTP.  */
    {
      scheme = "http";
      strcpy (portstr, "11371");
    }
  if (port)
    snprintf (portstr, sizeof portstr, "%hu", port);
  else
    {
      /*fixme_do_srv_lookup ()*/
    }

  hostname = map_host (host);
  if (!hostname)
    return NULL;

  hostport = strconcat (scheme, "://", hostname, ":", portstr, NULL);
  xfree (hostname);
  return hostport;
}
Exemplo n.º 14
0
static char *
make_fs_dir (const char *root,
             const char *dir,
             mode_t mode)
{
  char *full, *start, *slash;

  while (*dir == '/')
    dir++;

  full = strconcat (root, "/", dir);

  start = full + strlen (root) + 1;

  do
    {
      slash = strchr (start, '/');

      if (slash != NULL)
        *slash = 0;

      if (mkdir (full, mode) < 0 &&
          errno != EEXIST)
        fatal ("mkdir_all %s", full);

      if (slash != NULL)
        {
          *slash = '/';
          start = slash + 1;
        }
    }
  while (slash != NULL);

  return full;
}
Exemplo n.º 15
0
static int
has_conflict (char **dirs, int n_dirs, const char *filename, int except)
{
  char *path;
  int all_dirs = 1;
  int conflict = 0;
  struct stat st;
  int i;

  for (i = 0; i < n_dirs; i++)
    {
      if (dirs[i] == NULL || i == except)
        continue;

      path = strconcat (dirs[i], "/", filename);
      if (lstat (path, &st) < 0)
        continue;

      conflict = 1;
      if (!S_ISDIR (st.st_mode))
        all_dirs = 0;
    }

  if (!conflict)
    return NO_CONFLICTS;

  if (all_dirs)
    return DIR_CONFLICT;

  return NON_DIR_CONFLICT;
}
Exemplo n.º 16
0
void CControlAnimationBase::UpdateAnimCount()
{
    CKinematicsAnimated *skel = smart_cast<CKinematicsAnimated*>(m_object->Visual());

    for (ANIM_ITEM_VECTOR_IT it = m_anim_storage.begin(); it != m_anim_storage.end(); it++)	{
        if (!(*it)) continue;

        // проверить, были ли уже загружены данные
        if ((*it)->count != 0) return;

        string128	s, s_temp;
        u8 count = 0;

        for (int i=0; ; ++i) {
            strconcat	(sizeof(s_temp),s_temp, *((*it)->target_name),itoa(i,s,10));
            LPCSTR		name	= s_temp;
            MotionID	id		= skel->ID_Cycle_Safe(name);

            if (id.valid())  {
                count++;
                AddAnimTranslation(id,name);
            }
            else break;
        }

        if (count != 0) (*it)->count = count;
        else {
            sprintf_s(s, "Error! No animation: %s for monster %s", *((*it)->target_name), *m_object->cName());
            R_ASSERT2(count != 0, s);
        }
    }
}
Exemplo n.º 17
0
void CreateLog			(BOOL nl)
{
    no_log				= nl;
    strconcat			(logFName,Core.ApplicationName,"_",Core.UserName,".log");
    if (FS.path_exist("$logs$"))
        FS.update_path	(logFName,"$logs$",logFName);
    if (!no_log) {
        IWriter *f		= FS.w_open	(logFName);
        if (f==NULL) {
            MessageBox	(NULL,"Can't create log file.","Error",MB_ICONERROR);
            abort();
        }
        FS.w_close		(f);
    }
    LogFile.reserve		(128);

    // Calculating build
    time_t	Time;
    time	(&Time);
    int build=0, mnum=0, dnum, ynum, mcnt;
    char mon[4];
    char buf[128];
    strcpy(buf,__DATE__);
    sscanf(buf,"%s %d %d",mon,&dnum, &ynum);
    for (int i=0; i<12; i++) {
        if (stricmp(month[i],mon)==0) mnum=i;
    }
    for (mcnt=6; mcnt<mnum; mcnt++) build+=day_in_month[mcnt];
    build+=dnum;
    Msg("'%s' build %d, %s\n","xrCore",build+(ynum-1999)*365, __DATE__);
}
Exemplo n.º 18
0
CMotionDef *CControlAnimationBase::get_motion_def(SAnimItem *it, u32 index)
{
    string128			s1,s2;
    CKinematicsAnimated	*skeleton_animated = smart_cast<CKinematicsAnimated*>(m_object->Visual());
    const MotionID		&motion_id = skeleton_animated->ID_Cycle_Safe(strconcat(sizeof(s2),s2,*it->target_name,itoa(index,s1,10)));
    return				(skeleton_animated->LL_GetMotionDef(motion_id));
}
Exemplo n.º 19
0
Arquivo: header.c Projeto: Prajna/mach
void
WriteServerHeader(FILE *file, const statement_t *stats)
{
    register const statement_t *stat;
    const char *protect = strconcat(SubsystemName, "_server_");

    WriteProlog(file, protect);
    for (stat = stats; stat != stNULL; stat = stat->stNext)
	switch (stat->stKind)
	{
	  case skRoutine:
	    WriteServerRoutine(file, stat->stRoutine);
	    break;
	  case skImport:
	  case skSImport:
	    WriteImport(file, stat->stFileName);
	    break;
	  case skUImport:
	    break;
	  default:
	    fatal("WriteServerHeader(): bad statement_kind_t (%d)",
		  (int) stat->stKind);
	}
    WriteEpilog(file, protect);
}
Exemplo n.º 20
0
void CUIScrollBar::Init(float x, float y, float length, bool bIsHorizontal, LPCSTR profile)
{
	string256 _path;
	CUIXml xml_doc;
	R_ASSERT(xml_doc.Init	(CONFIG_PATH, UI_PATH, "scroll_bar.xml"));

	float height = xml_doc.ReadAttribFlt(profile, 0, "height", 16);
    	
	m_bIsHorizontal = bIsHorizontal;
	if(m_bIsHorizontal)
	{
		CUIWindow::Init				(x,y, length, height);

        strconcat					(sizeof(_path),_path, profile, ":left_arrow");
		CUIXmlInit::Init3tButton	(xml_doc, _path, 0, m_DecButton);
		m_DecButton->SetWndPos		(0.0f, 0.0f);

		strconcat					(sizeof(_path),_path, profile, ":right_arrow");
		CUIXmlInit::Init3tButton	(xml_doc, _path, 0, m_IncButton);
		m_IncButton->SetWndPos		(length - m_IncButton->GetWidth(), 0.0f);

		m_ScrollBox->SetHorizontal	();

		strconcat					(sizeof(_path),_path, profile, ":box");
		CUIXmlInit::InitStatic		(xml_doc, _path, 0, m_ScrollBox);
		m_IncButton->SetWndPos		(0.0f, length/2);

		strconcat					(sizeof(_path),_path, profile, ":back:texture");
		LPCSTR texture				= xml_doc.Read(_path, 0, "");
		R_ASSERT					(texture);
		CUITextureMaster::InitTexture(texture, m_StaticBackground);
		m_ScrollWorkArea			= _max(0,iFloor(GetWidth()-2*height));
	}else{
		CUIWindow::Init				(x,y, height, length);

		strconcat					(sizeof(_path),_path, profile, ":up_arrow");
		CUIXmlInit::Init3tButton	(xml_doc, _path, 0, m_DecButton);
		m_DecButton->SetWndPos		(0.0f, 0.0f);

		strconcat					(sizeof(_path),_path, profile, ":down_arrow");
 		CUIXmlInit::Init3tButton	(xml_doc, _path, 0, m_IncButton);
		m_IncButton->SetWndPos		(0.0f, length - height);

		m_ScrollBox->SetVertical	();

		strconcat					(sizeof(_path),_path, profile, ":box_v");
		CUIXmlInit::InitStatic		(xml_doc, _path, 0, m_ScrollBox);		
		strconcat					(sizeof(_path),_path, profile, ":back_v:texture");
		LPCSTR texture				= xml_doc.Read(_path, 0, "");
		R_ASSERT					(texture);

		CUITextureMaster::InitTexture(texture, m_StaticBackground);
		m_ScrollWorkArea			= _max(0,iFloor(GetHeight()-2*height));
	}	

	UpdateScrollBar					();
}
Exemplo n.º 21
0
// calculate the list of players for a given game with geolocation
static char* list_game_with_geolocation(const struct game * g)
{
    char list_game_str[8192] = "";
    int i;
    char* n;
    for (i = 0; i < g->players_number; i++) {
        strconcat(list_game_str, g->players_nick[i], sizeof(list_game_str));
        n = geoloc[g->players_conn[i]];
        if (n != NULL) {
            strconcat(list_game_str, ":", sizeof(list_game_str));
            strconcat(list_game_str, n, sizeof(list_game_str));
        }
        if (i < g->players_number - 1)
            strconcat(list_game_str, ",", sizeof(list_game_str));
    }
    return memdup(list_game_str, strlen(list_game_str) + 1);
}
Exemplo n.º 22
0
void CUIStatsPlayerList::Init(CUIXml& xml_doc, LPCSTR path)
{
	// init window
	CUIXmlInit::InitScrollView	(xml_doc, path, 0, this);
	SetFixedScrollBar			(false);


	m_bStatus_mode				= xml_doc.ReadAttribInt(path,0,"status_mode",0)? true: false;
	m_bSpectator				= xml_doc.ReadAttribInt(path,0,"spectator",0)? true: m_bStatus_mode;
	SetSpectator				(m_bSpectator);

	// init item structure
	int tabsCount				= xml_doc.GetNodesNum(path, 0, "field");
	XML_NODE* tab_node			= xml_doc.NavigateToNode(path,0);
	xml_doc.SetLocalRoot		(tab_node);

	for (int i = 0; i < tabsCount; ++i)
	{
		LPCSTR name 			= xml_doc.ReadAttrib("field",i,"name");
		float width 			= xml_doc.ReadAttribFlt("field",i,"width");

		if (0 == xr_strcmp(name, "artefacts") && GameID() != eGameIDArtefactHunt)
			continue;
		
		AddField				(name,width);
	}
	xml_doc.SetLocalRoot		(xml_doc.GetRoot());
	string256					 _path;
	// init item text params
	CUIXmlInit::InitFont		(xml_doc, strconcat(sizeof(_path),_path, path, ":text_format"), 0, m_i.c, m_i.f);
	m_i.h						= xml_doc.ReadAttribFlt(strconcat(sizeof(_path),_path, path, ":text_format"), 0, "height", 25);

	// init list header
	switch (GameID())
	{
	case eGameIDCaptureTheArtefact:
	case eGameIDArtefactHunt:
	case eGameIDTeamDeathmatch:
		if (!m_bSpectator || m_bStatus_mode)
            InitTeamHeader(xml_doc, path);
	case eGameIDDeathmatch:
		InitHeader(xml_doc, path);
	default:
		break;
	}
}
Exemplo n.º 23
0
/**************************************************
 Create a new item based on the specified template
 return the id of the newly created item
 the returned string must be freed by caller
 return NULL if fails
**************************************************/
char * item_create_from_template(const char * my_template)
{
	char * new_name;
	char * templatename;
	char * newfilename;

	new_name = file_new(ITEM_TABLE,NULL);

	templatename = strconcat(base_directory,"/",ITEM_TEMPLATE_TABLE,"/",my_template,NULL);
	newfilename = strconcat(base_directory,"/",ITEM_TABLE,"/",new_name,NULL);

	file_copy(templatename,newfilename);
	free(newfilename);
	free(templatename);

	return new_name;
}
Exemplo n.º 24
0
/******************************************************
Create a new character based on the specified template
return the id of the newly created character
the returned string MUST BE FREED by caller
return NULL if fails
*******************************************************/
char * character_create_from_template(context_t * ctx,const char * my_template,const char * map, int layer, int x, int y)
{
	char * new_id;
	char * templatename;
	char * fullname;

	new_id = file_new(CHARACTER_TABLE,NULL);

	templatename = strconcat(base_directory,"/",CHARACTER_TEMPLATE_TABLE,"/",my_template,NULL);
	fullname = strconcat(base_directory,"/",CHARACTER_TABLE,"/",new_id,NULL);
	file_copy(templatename,fullname);
	free(templatename);
	free(fullname);

	/* Check if new character is allowed to be created here */
	if(map_check_tile(ctx,new_id,map,layer,x,y) == 0) {
		entry_destroy(CHARACTER_TABLE,new_id);
		file_delete(CHARACTER_TABLE,new_id);
		free(new_id);
		return NULL;
	}

	/* Write position */
	if(entry_write_string(CHARACTER_TABLE,new_id,map,CHARACTER_KEY_MAP,NULL) == RET_NOK ) {
		entry_destroy(CHARACTER_TABLE,new_id);
		file_delete(CHARACTER_TABLE,new_id);
		free(new_id);
		return NULL;
	}

	if(entry_write_int(CHARACTER_TABLE,new_id,x,CHARACTER_KEY_POS_X,NULL) == RET_NOK ) {
		entry_destroy(CHARACTER_TABLE,new_id);
		file_delete(CHARACTER_TABLE,new_id);
		free(new_id);
		return NULL;
	}

	if(entry_write_int(CHARACTER_TABLE,new_id,y,CHARACTER_KEY_POS_Y,NULL) == RET_NOK ) {
		entry_destroy(CHARACTER_TABLE,new_id);
		file_delete(CHARACTER_TABLE,new_id);
		free(new_id);
		return NULL;
	}

	return new_id;
}
Exemplo n.º 25
0
CCommandVar CActorTools::CommandSaveBackup(CCommandVar p1, CCommandVar p2)
{
	string_path 		fn;
    strconcat			(sizeof(fn), fn, Core.UserName, "_backup.object");
    FS.update_path		(fn,"$objects$",fn);
    ExecCommand			(COMMAND_SAVE,xr_string(fn));
    return TRUE;
}
Exemplo n.º 26
0
void CScriptDebugger::Eval(const char* strCode, char* res, int res_sz)
{
	string1024 strCodeFull;
	strCodeFull[0] = 0;
	const char * r = "return  ";
	strconcat(sizeof(strCodeFull),strCodeFull,r,strCode);
	m_lua->Eval(strCodeFull, res, res_sz);
}
Exemplo n.º 27
0
/**
 * addHeader() prepends a header to @msg according to @version
 * @param msg char** to which the header should be prepended
 * @param version int protocol version to use
 * @return int length of message with header
 */
int addHeader(char** msg, int version) {
    if (version == 1155) {
        char header[12];
        int len = 11 + strlen(*msg);
        sprintf(header, "1155~%05i~", len);
        char* oldmsg = *msg;
        *msg = strconcat(header, *msg);
        free(oldmsg);
        return len;
    } else if (version == 1154) {
        char header[] = "1154~";
        char* oldmsg = *msg;
        *msg = strconcat(header, *msg);
        free(oldmsg);
        return strlen(*msg);        
    }
}
Exemplo n.º 28
0
void CStalkerAnimationState::Load				(CKinematicsAnimated *kinematics, LPCSTR base_name)
{
	string256			S;
	m_global.Load		(kinematics,base_name);
	m_torso.Load		(kinematics,strconcat(sizeof(S),S,base_name,"torso_"));
	m_movement.Load		(kinematics,base_name);
	m_in_place->Load	(kinematics,base_name);
}
Exemplo n.º 29
0
void
WriteUserHeader(FILE *file, statement_t *stats)
{
	register statement_t *stat;
    const char *protect = strconcat(SubsystemName, "_user_");

	WriteProlog(file, protect, TRUE, TRUE);
	for (stat = stats; stat != stNULL; stat = stat->stNext)
		switch (stat->stKind)
		{
		case skImport:
		case skUImport:
		case skDImport:
			WriteImport(file, stat->stFileName);
			break;
		case skRoutine:
		case skSImport:
		case skIImport:
			break;
		default:
			fatal("WriteHeader(): bad statement_kind_t (%d)",
				  (int) stat->stKind);
		}
    fprintf(file, "\n#ifdef __BeforeMigUserHeader\n");
	fprintf(file, "__BeforeMigUserHeader\n");
	fprintf(file, "#endif /* __BeforeMigUserHeader */\n");
	fprintf(file, "\n");
	fprintf(file, "#include <sys/cdefs.h>\n");
	fprintf(file, "__BEGIN_DECLS\n");
	fprintf(file, "\n");
	for (stat = stats; stat != stNULL; stat = stat->stNext) {
		if (stat->stKind == skRoutine)
			WriteUserRoutine(file, stat->stRoutine);
	}
	fprintf(file, "\n");
	fprintf(file, "__END_DECLS\n");

	fprintf(file, "\n");
	fprintf(file, "/********************** Caution **************************/\n");
	fprintf(file, "/* The following data types should be used to calculate  */\n");
	fprintf(file, "/* maximum message sizes only. The actual message may be */\n");
	fprintf(file, "/* smaller, and the position of the arguments within the */\n");
	fprintf(file, "/* message layout may vary from what is presented here.  */\n");
	fprintf(file, "/* For example, if any of the arguments are variable-    */\n");
	fprintf(file, "/* sized, and less than the maximum is sent, the data    */\n");
	fprintf(file, "/* will be packed tight in the actual message to reduce  */\n");
	fprintf(file, "/* the presence of holes.                                */\n");
	fprintf(file, "/********************** Caution **************************/\n");
	fprintf(file, "\n");

	WriteRequestTypes(file, stats);
	WriteUserRequestUnion(file, stats);

	WriteReplyTypes(file, stats);
	WriteUserReplyUnion(file, stats);

	WriteEpilog(file, protect, TRUE);
}
Exemplo n.º 30
0
void
more_global(void)
{
  if (SubsystemName == strNULL)
    fatal("no SubSystem declaration");

  if (UserHeaderFileName == strNULL)
    UserHeaderFileName = strconcat(SubsystemName, ".h");
  else if (streql(UserHeaderFileName, "/dev/null"))
    UserHeaderFileName = strNULL;

  if (UserFileName == strNULL)
    UserFileName = strconcat(SubsystemName, "User.c");
  else if (streql(UserFileName, "/dev/null"))
    UserFileName = strNULL;

  if (ServerFileName == strNULL)
    ServerFileName = strconcat(SubsystemName, "Server.c");
  else if (streql(ServerFileName, "/dev/null"))
    ServerFileName = strNULL;

  if (ServerDemux == strNULL)
    ServerDemux = strconcat(SubsystemName, "_server");

  if (ServerImpl == strNULL)
    ServerImpl = strconcat(SubsystemName, "_impl");

  if (ServerSubsys == strNULL) {
    if (ServerPrefix != strNULL)
      ServerSubsys = strconcat(ServerPrefix, SubsystemName);
    else
      ServerSubsys = SubsystemName;
    ServerSubsys = strconcat(ServerSubsys, "_subsystem");
  }
}