Esempio n. 1
0
LocInfo* parse_add_locinfov(Parse *p,char *filename, int lineno, char *line, char *tag, char *referrer, char *context_in,va_list args)
{
    char buf[128];
    char *ctxt = context_in;
    LocInfo *l;
    TIMER_START();
    if(ctxt)
    {
        vsnprintf(buf,DIMOF(buf),ctxt,args);
        buf[DIMOF(buf)-1] = 0;
        ctxt = buf;
    }
    
    p->n_locs++;
    l           = ali_push(&p->locs);
    l->tag      = parse_find_add_str(p,tag);
    l->referrer = parse_find_add_str(p,referrer);
    l->context  = parse_find_add_str(p,ctxt);
    l->fname    = parse_find_add_str(p,filename);
    l->lineno   = lineno;
    l->line     = parse_find_add_str(p,line);

    TIMER_END(locinfo_timer);
    return l;
}
/// Function to enable listening to a particular ethernet multicast address.
/// This is a highly non-portable function.
/// I wonder how you do this on BSD or Slowlaris?
FSTATIC gboolean
_enable_mcast_address(const char * addrstring	///<[in] multicast MAC address string suitable for giving to 'ip'
                      ,		     const char * dev		///<[in] ethernet device
                      ,		     gboolean enable)		///<[in] TRUE to enable, FALSE to disable
{
    GSpawnFlags	flags =  G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_SEARCH_PATH;
    gint		exit_status;
    const gchar*	constargv [] =
    {"ip", "maddress", (enable ? "add" : "delete"), addrstring, "dev", dev, NULL};
    gchar*		argv[DIMOF(constargv)];
    unsigned	j;


    if (NULL == addrstring) {
        return FALSE;
    }

    // This is really stupid and annoying - they have the wrong function prototype for g_spawn_sync...
    for (j=0; j < DIMOF(argv); ++j) {
        argv[j] = g_strdup(constargv[j]);
    }

    DEBUGMSG1("Running IP command %s %s %s %s %s %s", argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
    if (!g_spawn_sync(NULL, argv, NULL, flags, NULL, NULL, NULL, NULL, &exit_status, NULL)) {
        exit_status = 300;
    }
    for (j=0; j < DIMOF(argv); ++j) {
        g_free(argv[j]);
        argv[j] = NULL;
    }
    DEBUGMSG1("Previous IP command returned %d", exit_status);
    return exit_status == 0;
}
Esempio n. 3
0
bool CScriptEditView::OnFileSaveAs()
{
	bool bRet = false;

	TCHAR szFilter[256];
	::ZeroMemory( szFilter, DIMOF(szFilter) );
	int nChar = AtlLoadString( IDS_FILE_FILTER, szFilter, DIMOF(szFilter) );

	DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
	CFileDialog dlg( FALSE, _T("*.txt"), m_szFilePath, dwFlags, szFilter );
	if( dlg.DoModal() == IDOK )
	{
		ATLTRACE( _T("File path: %s\n"), dlg.m_ofn.lpstrFile );
		bRet = SaveFile( dlg.m_szFileName );
		if( bRet )
		{
			Init( dlg.m_szFileName, dlg.m_szFileTitle );
		}
		else
		{
			AtlMessageBox(
				WtlGetMainWnd(),
				IDS_WRITE_FILE_FAILED,
				IDR_MAINFRAME,
				MB_OK|MB_ICONERROR
				);
		}
	}

	return bRet;
}
Esempio n. 4
0
/*
 * Dialog_About_Create() [external]
 *
 * Called to create the about dialog. Returns the handle to the
 * dialog created. This handle should only be used to check for
 * errors during creation. Call Dialog_About_GetWindow() to get
 * the handle for later use.
 */
HWND Dialog_About_Create(void)
{
    PROPSHEETPAGE psp[2];
    PROPSHEETHEADER psh;
    int i;

    for (i = 0; i < DIMOF(sps); i++)
    {
        INITSTRUCT(psp[i], TRUE);
        psp[i].hInstance    = g_hInstance;
    }

    psp[0].pszTemplate  = MAKEINTRESOURCE(IDD_ABOUT_GENERAL);
    psp[0].pfnDlgProc   = About_General_DlgProc;

    psp[1].pszTemplate  = MAKEINTRESOURCE(IDD_ABOUT_INFOCREDZ);
    psp[1].pfnDlgProc   = About_InfoCredz_DlgProc;

    INITSTRUCT(psh, TRUE);
    psh.dwFlags         = PSH_PROPSHEETPAGE | PSH_MODELESS | PSH_NOAPPLYNOW;
    psh.hwndParent      = Main_GetWindow();
    psh.hInstance       = Main_GetInstance();
    psh.pszCaption      = String_LoadString(IDS_TITLE_ABOUTDIALOG);
    psh.nPages          = DIMOF(sps);
    psh.ppsp            = (LPCPROPSHEETPAGE)&psp;

    s_hwndDlgAbout = (HWND)PropertySheet(&psh);

    return (s_hwndDlgAbout);
}
Esempio n. 5
0
static int
bind_and_listen(struct addrinfo *addr)
{
    int optval;
    int fd;
    int rc;
    char buffer[256] = { 0, };

    if (addr->ai_family == AF_INET6) {
        struct sockaddr_in6 *addr_in = (struct sockaddr_in6 *)(void*)addr->ai_addr;
        inet_ntop(addr->ai_family, &addr_in->sin6_addr, buffer, DIMOF(buffer));

    } else {
        struct sockaddr_in *addr_in = (struct sockaddr_in *)(void*)addr->ai_addr;
        inet_ntop(addr->ai_family, &addr_in->sin_addr, buffer, DIMOF(buffer));
    }

    crm_trace("Attempting to bind on address %s", buffer);

    fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
    if (fd < 0) {
        return -1;
    }

    /* reuse address */
    optval = 1;
    rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));
    if (rc < 0) {
        crm_perror(LOG_INFO, "Couldn't allow the reuse of local addresses by our remote listener, bind address %s", buffer);
        close(fd);
        return -1;
    }

    if (addr->ai_family == AF_INET6) {
        optval = 0;
        rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval));
        if (rc < 0) {
            crm_perror(LOG_INFO, "Couldn't disable IPV6 only on address %s", buffer);
            close(fd);
            return -1;
        }
    }

    if (bind(fd, addr->ai_addr, addr->ai_addrlen) != 0) {
        close(fd);
        return -1;
    }

    if (listen(fd, 10) == -1) {
        crm_err("Can not start listen on address %s", buffer);
        close(fd);
        return -1;
    }

    crm_notice("Listening on address %s", buffer);

    return fd;
}
Esempio n. 6
0
int abfile_test()
{
	File *fp;
	char tmp[] = "abcdefghijklmnopqrstuvwxyz";
	char tmp2[sizeof(tmp)];
	struct Foo 
	{
		int a;
		char b[16];
	} foos[3] = {
		{1,"one"},
		{2,"two"},
		{3,"three"},
	}, bars[DIMOF(foos)] = {0};
	
	printf("abfile test...");
	fp = abfopen("foo",File_W,FileType_Mem);
	TEST(fp);
	TEST(0==strcmp(fp->fn,"foo"));
	TEST(1 == abfwrite(tmp,sizeof(tmp),1,fp));
	TEST(sizeof(tmp) == abfread(tmp2,1,sizeof(tmp),fp));
	TEST(0==memcmp(tmp,tmp2,sizeof(tmp)));
	ZeroStruct(foos);
	abfclose(fp);

	fp = abfopen("bar",File_RW,FileType_Mem);
	TEST(fp);
	TEST(DIMOF(foos) == abfwrite(foos,sizeof(foos[0]),DIMOF(foos),fp));
	TEST(DIMOF(bars) == abfread(bars,sizeof(bars[0]),DIMOF(bars),fp));
	TEST(0==memcmp(foos,bars,sizeof(foos)));
	ZeroStruct(foos);
	abfclose(fp);

	// read too many
	fp = abfopen("bar",File_RW,FileType_Mem);
	TEST(fp);
	TEST(DIMOF(foos) == abfwrite(foos,sizeof(foos[0]),DIMOF(foos),fp));
	TEST(DIMOF(bars) == abfread(bars,sizeof(bars[0]),DIMOF(bars)+1,fp));
	TEST(0==memcmp(foos,bars,sizeof(foos)));
	ZeroStruct(foos);
	abfclose(fp);

	// read too many 2: a little extra data
	fp = abfopen("bar",File_RW,FileType_Mem);
	TEST(fp);
	TEST(1 == abfwrite(foos,sizeof(foos[0])+1,1,fp));
	TEST(1 == abfread(bars,sizeof(bars[0]),DIMOF(bars)+1,fp));
	TEST(0==memcmp(foos,bars,sizeof(foos)));
	ZeroStruct(foos);
	abfclose(fp);
		 
	printf("done.\n");

	return 0;
}
Esempio n. 7
0
static int
core_uses_pid(void)
{
	const char *	uses_pid_pathnames[] = {PROC_SYS_KERNEL_CORE_PID};
	const char *	corepats_pathnames[] = {PROC_SYS_KERNEL_CORE_PAT};
	const char *	goodpats [] = {"%t", "%p"};
	int		j;


	for (j=0; j < DIMOF(corepats_pathnames); ++j) {
		int	fd;
		char	buf[BUF_MAX];
		int	rc;
		int	k;

		if ((fd = open(corepats_pathnames[j], O_RDONLY)) < 0) {
			continue;
		}
		
		memset(buf, 0, BUF_MAX);
		rc = read(fd, buf, BUF_MAX - 1); /* Ensure it is always NULL terminated */
		close(fd);
		
		for (k=0; rc > 0 && k < DIMOF(goodpats); ++k) {
			if (strstr(buf, goodpats[k]) != NULL) {
				return 1;
			}
		}

		break;
	}
	for (j=0; j < DIMOF(uses_pid_pathnames); ++j) {
		int	fd;
		char	buf[2];
		int	rc;
		if ((fd = open(uses_pid_pathnames[j], O_RDONLY)) < 0) {
			continue;
		}
		rc = read(fd, buf, sizeof(buf));
		close(fd);
		if (rc < 1) {
			continue;
		}
		return (buf[0] == '1');
	}
	setenv(CHECKED_KERNEL_CORE_ENV, "1", TRUE);
	return -1;
}
Esempio n. 8
0
/*
 * This function exists to allow security-sensitive programs
 * to safely take core dumps.  Such programs can't can't call
 * cl_untaint_coredumps() alone - because it might cause a
 * leak of confidential information - as information which should
 * only be known by the "high-privilege" user id will be written
 * into a core dump which is readable by the "low-privilege" user id.
 * This is a bad thing.
 *
 * This function causes this program to call a special signal handler
 * on receipt of any core dumping signal.  This handler then does
 * the following four things on receipt of a core dumping signal:
 *
 *  1)	Set privileges to "maximum" on receipt of a signal
 *  2)	"untaint" themselves with regard to core dumping
 *  3)	set SIG_DFLT for the received signal
 *  4)	Kill themselves with the received core-dumping signal
 *
 * Any process *could* do this to get core dumps, but if your stack
 * is screwed up, then the signal handler might not work.
 * If you're core dumping because of a stack overflow, it certainly won't work.
 *
 * On the other hand, this function may work on some OSes that don't support
 * prctl(2).  This is an untested theory at this time...
 */
void
cl_set_all_coredump_signal_handlers(void)
{
	static const int coresigs [] = {SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV
#ifdef SIGBUS
,	SIGBUS
#endif
#ifdef SIGSYS
,	SIGSYS
#endif
#ifdef SIGTRAP
,	SIGTRAP
#endif
#ifdef SIGXCPU
,	SIGXCPU
#endif
#ifdef SIGXFSZ
,	SIGXFSZ
#endif
};
	int	j;

	for (j=0; j < DIMOF(coresigs); ++j) {
		cl_set_coredump_signal_handler(coresigs[j]);
	}
}
Esempio n. 9
0
LRESULT CScriptEditView::OnFindReplaceCmd( UINT, WPARAM, LPARAM lParam, BOOL& )
{
	CFindReplaceDialog* pDlg = CFindReplaceDialog::GetNotifier(lParam);
	if( pDlg == NULL )
	{
		::MessageBeep( (UINT)-1 );
		return 1;
	}
	ATLASSERT( pDlg == m_pFindDlg );

	if( pDlg->IsTerminating() )
	{
		m_pFindDlg = NULL;
		return 0;
	}

	lstrcpyn( m_fro.StrToFind, pDlg->m_fr.lpstrFindWhat, DIMOF(m_fro.StrToFind) );
	m_fro.bMatchCase = (pDlg->MatchCase() != FALSE);
	m_fro.bWholeWord = (pDlg->MatchWholeWord() != FALSE);

	if( pDlg->FindNext() )
	{
		if( !DoFindText() )
			::MessageBeep( (UINT)-1 );
	}
	else if( pDlg->ReplaceCurrent() )
	{
		long nStart, nEnd;
		GetSel( nStart, nEnd );

		if( nStart != nEnd )
		{
			LPTSTR szFind = (LPTSTR)_alloca( (nEnd - nStart + 1) * sizeof(TCHAR) );
			GetSelText( szFind );
			int nRet;
			if( m_fro.bMatchCase )
				nRet = lstrcmp( szFind, m_fro.StrToFind );
			else
				nRet = lstrcmpi( szFind, m_fro.StrToFind );
			if(nRet == 0)
				ReplaceSel( pDlg->GetReplaceString(), TRUE );
		}

		if( !DoFindText() )
			::MessageBeep( (UINT)-1 );

	}
	else if( pDlg->ReplaceAll() )
	{
		SetRedraw(FALSE);
		CWaitCursor wait;
		while( DoFindText(false) )
			ReplaceSel( pDlg->GetReplaceString(), TRUE );
		SetRedraw( TRUE );
		Invalidate();
		UpdateWindow();
	}

	return 0;
}
Esempio n. 10
0
int
mh_test_is_match(const char *pattern, const char *subject)
{
    int erroroffset;
    int ovector[OVECCOUNT];
    const char *error;
    pcre *re;
    int rc;

    re = pcre_compile(pattern,
                      0,
                      &error,
                      &erroroffset,
                      NULL);
    if (re == NULL) {
        return PCRE_ERROR_NULL;
    }

    rc = pcre_exec(
             re,
             NULL,
             subject,
             strlen(subject),
             0,
             0,
             ovector,
             DIMOF(ovector));

    /* Since we only care about return code for now free the regex */
    pcre_free(re);
    return rc;
}
Esempio n. 11
0
File: xqf-ui.c Progetto: IR4T4/xqf
void clist_set_sort_column (GtkCList *clist, int column, struct clist_def *cldef) {
	if (column == clist->sort_column) {
		if (clist->sort_type == GTK_SORT_DESCENDING) {
			cldef->cols[column].current_sort_mode = ++cldef->cols[column].current_sort_mode%DIMOF(cldef->cols[column].sort_mode);
			if (cldef->cols[column].sort_mode[cldef->cols[column].current_sort_mode] == -1)
				cldef->cols[column].current_sort_mode = 0;
		}

		gtk_clist_set_sort_type (clist, GTK_SORT_DESCENDING + GTK_SORT_ASCENDING - clist->sort_type);
	}
	else {
		cldef->cols[column].current_sort_mode = 0;
		clist_column_set_title (clist, cldef, FALSE);
		gtk_clist_set_sort_column (clist, column);
	}

	debug (3, "%d %hhd", column, cldef->cols[column].current_sort_mode);

	clist_column_set_title (clist, cldef, TRUE);
	gtk_clist_sort (clist);

	if (clist == server_clist) {
		server_clist_selection_visible ();
	}
}
Esempio n. 12
0
int
cib_get_operation_id(const char *op, int *operation)
{
    static GHashTable *operation_hash = NULL;

    if (operation_hash == NULL) {
        int lpc = 0;
        int max_msg_types = DIMOF(cib_server_ops);

        operation_hash = g_hash_table_new_full(crm_str_hash, g_str_equal, NULL, g_hash_destroy_str);
        for (lpc = 1; lpc < max_msg_types; lpc++) {
            /* coverity[returned_null] Ignore */
            int *value = malloc(sizeof(int));

            *value = lpc;
            g_hash_table_insert(operation_hash, (gpointer) cib_server_ops[lpc].operation, value);
        }
    }

    if (op != NULL) {
        int *value = g_hash_table_lookup(operation_hash, op);

        if (value) {
            *operation = *value;
            return pcmk_ok;
        }
    }
    crm_err("Operation %s is not valid", op);
    *operation = -1;
    return -EINVAL;
}
Esempio n. 13
0
xmlNode *
cib_construct_reply(xmlNode * request, xmlNode * output, int rc)
{
    int lpc = 0;
    xmlNode *reply = NULL;
    const char *name = NULL;
    const char *value = NULL;

    const char *names[] = {
        F_CIB_OPERATION,
        F_CIB_CALLID,
        F_CIB_CLIENTID,
        F_CIB_CALLOPTS
    };
    static int max = DIMOF(names);

    crm_trace("Creating a basic reply");
    reply = create_xml_node(NULL, "cib-reply");
    crm_xml_add(reply, F_TYPE, T_CIB);

    for (lpc = 0; lpc < max; lpc++) {
        name = names[lpc];
        value = crm_element_value(request, name);
        crm_xml_add(reply, name, value);
    }

    crm_xml_add_int(reply, F_CIB_RC, rc);

    if (output != NULL) {
        crm_trace("Attaching reply output");
        add_message_xml(reply, F_CIB_CALLDATA, output);
    }
    return reply;
}
Esempio n. 14
0
void
pe_metadata(void)
{
    config_metadata("Policy Engine", "1.0",
                    "Policy Engine Options",
                    "This is a fake resource that details the options that can be configured for the Policy Engine.",
                    pe_opts, DIMOF(pe_opts));
}
Esempio n. 15
0
/// Translate a CDP TLV type into a string.
/// @return pointer to a constant/static string describing the type of this TLV.
const char *
get_cdp_type_string(unsigned cdptype) ///< [in] CDP TLV type
{
	if (cdptype < DIMOF(cdptypenames)) {
		return cdptypenames[cdptype];
	}
        return "UNKNOWN";
}
Esempio n. 16
0
void ShowMessageBoxV(LPCTSTR pMessage, va_list argList)
{
	DECLARE_INIT_TCHAR_ARRAY(szMessage, 1025);
	DECLARE_INIT_TCHAR_ARRAY(szTitle, 256 + 1);

	::wvsprintf(szMessage, pMessage, argList);
	::GetModuleFileName(NULL, szTitle, DIMOF(szTitle));
	HWND hwnd = ::GetActiveWindow();
	::MessageBox(hwnd, szMessage, szTitle, MB_OK | ((NULL == hwnd) ? MB_SERVICE_NOTIFICATION : 0));
}
Esempio n. 17
0
static int 
get_dir_index(const char* directive)
{
	int j;
	for(j=0; j < DIMOF(Directives); j++){
		if (0 == strcasecmp(directive, Directives[j].name)){
			return j;
		}
	}
	return -1;
}
Esempio n. 18
0
/// Close this pcap_listener, and undo listens for multicast addresses
void
close_pcap_listener(pcap_t*	pcapdev		///< Pcap device structure
                    ,		    const char*	dev		///< device that this is opened on
                    ,		    unsigned	listenmask)	///< The 'listenmask' given to create_pcap_listener
{
    unsigned j;
    pcap_close(pcapdev);
    for (j = 0; j < DIMOF(filterinfo); ++j) {
        if (listenmask & filterinfo[j].filterbit && filterinfo[j].mcastaddr) {
            _enable_mcast_address(filterinfo[j].mcastaddr, dev, FALSE);
        }
    }
}
Esempio n. 19
0
void
services_action_free(svc_action_t * op)
{
    unsigned int i;

    if (op == NULL) {
        return;
    }

    if (op->opaque->repeat_timer) {
        g_source_remove(op->opaque->repeat_timer);
    }
    if (op->opaque->stderr_gsource) {
        mainloop_del_fd(op->opaque->stderr_gsource);
        op->opaque->stderr_gsource = NULL;
    }

    if (op->opaque->stdout_gsource) {
        mainloop_del_fd(op->opaque->stdout_gsource);
        op->opaque->stdout_gsource = NULL;
    }

    free(op->id);
    free(op->opaque->exec);

    for (i = 0; i < DIMOF(op->opaque->args); i++) {
        free(op->opaque->args[i]);
    }

    free(op->opaque);
    free(op->rsc);
    free(op->action);

    free(op->standard);
    free(op->agent);
    free(op->provider);

    free(op->stdout_data);
    free(op->stderr_data);

    if (op->params) {
        g_hash_table_destroy(op->params);
        op->params = NULL;
    }

    free(op);
}
Esempio n. 20
0
/**
 * Process a message from client process 
 */
void
recoverymgr_process_msg(recoverymgr_client_t* client, void* Msg,  size_t length)
{
        struct recoverymgr_msg *      	msg = Msg;
        const int               	sz1     = sizeof(msg->msgtype)-1;
        int                     	rc      = EINVAL;
        gboolean                	sendrc  = TRUE;
        int                     	j;


        if (length < sizeof(*msg)) {
                return;
        }

        msg->msgtype[sz1] = EOS;


        if (debug >= DBGDETAIL) {
                cl_log(LOG_DEBUG, "recoverymgr_process_msg: client: 0x%x"
                " type=%s"
                ,       GPOINTER_TO_UINT(client)
                ,       msg->msgtype);
        }
        for (j=0; j < DIMOF(cmds); ++j) {
                if (strcmp(msg->msgtype, cmds[j].msg) == 0) {
                        sendrc = cmds[j].senderrno;

                        if (client->appname == NULL
                        &&      cmds[j].fun != recoverymgr_client_connect) {
                                rc = ESRCH;
                                break;
                        }

                        rc = cmds[j].fun(client, Msg, length);
                }
        }
        if (sendrc) {
                if (debug >= DBGMIN) {
                        cl_log(LOG_DEBUG, "recoverymgr_process_msg: client: 0x%x"
                        " type=%s, rc=%d"
                        ,       GPOINTER_TO_UINT(client)
                        ,       msg->msgtype, rc);
                }
                recoverymgr_putrc(client, rc);
        }
}
Esempio n. 21
0
const char *
prio2str(int priority)
{
	static const char *log_prio[8] = {
		"EMERG",
		"ALERT",
		"CRIT",
		"ERROR",
		"WARN",
		"notice",
		"info",
		"debug"
	};
	int		logpri;

	logpri =  LOG_PRI(priority);

	return (logpri < 0 || logpri >= DIMOF(log_prio)) ?
		"(undef)" : log_prio[logpri];
}
/// Initialize our frame type map.
/// Post-condition:  Every element of 'frametypemap' is initialized with a valid function pointer.
PacketDecoder*
packetdecoder_new(guint objsize, const FrameTypeToFrame* framemap, gint mapsize)
{
	gint		j;
	AssimObj*	baseobj;
	PacketDecoder*	self;
	
	if (objsize < sizeof(PacketDecoder)) {
		objsize = sizeof(PacketDecoder);
	}
	if (NULL == framemap) {
		framemap = _defaultmap;
		mapsize = DIMOF(_defaultmap);
	}

	baseobj = assimobj_new(objsize);
	proj_class_register_subclassed(baseobj, "PacketDecoder");
	self = CASTTOCLASS(PacketDecoder, baseobj);
	

	self->_pfinalize = baseobj->_finalize;
	baseobj->_finalize = _packetdecoder_finalize;
	self->pktdata_to_framesetlist = _pktdata_to_framesetlist;
	self->_maxframetype = 0;
	self->_framemap = framemap;
	self->_framemaplen = mapsize;

	for (j=0; j < self->_framemaplen; ++j) {
		if (self->_framemap[j].frametype > self->_maxframetype) {
			self->_maxframetype = self->_framemap[j].frametype;
		}
	}
	self->_frametypemap = MALLOC0((self->_maxframetype+1)*sizeof(gpointer));
	for (j=0; j <= self->_maxframetype; ++j) {
		self->_frametypemap[j] = unknownframe_tlvconstructor;
	}
	for (j=0; j < self->_framemaplen; ++j) {
		self->_frametypemap[self->_framemap[j].frametype] = self->_framemap[j].constructor;
	}
	return self;
}
Esempio n. 23
0
static  void    CreateProduct( CardImage_t *pCardImage, int dirIndex, int productId, int zoneLow, int zoneHigh, Time_t expiry )
{
    //  Just in case the caller gets it wrong - index should be between 1 and 5 inclusive

    if ( dirIndex < 1 || dirIndex >= DIMOF( pCardImage->pMYKI_TAControl->Directory ) )
    {
        CsErrx( "CreateProduct() Invalid directory index %d", dirIndex );
        return;
    }

    //  Create product

    pCardImage->pMYKI_TAProduct[ dirIndex - 1 ]->ZoneLow                = zoneLow;
    pCardImage->pMYKI_TAProduct[ dirIndex - 1 ]->ZoneHigh               = zoneHigh;
    pCardImage->pMYKI_TAProduct[ dirIndex - 1 ]->EndDateTime            = expiry;

    //  Create directory entry for product

    pCardImage->pMYKI_TAControl->Directory[ dirIndex ].Status           = TAPP_CONTROL_DIRECTORY_STATUS_ACTIVATED;
    pCardImage->pMYKI_TAControl->Directory[ dirIndex ].ProductId        = productId;
    pCardImage->pMYKI_TAControl->Directory[ dirIndex ].SerialNo         = pCardImage->pMYKI_TAControl->NextProductSerialNo++;
}
Esempio n. 24
0
/// Function to handle child timeouts.
/// It implements a very simple, linear state machine...
FSTATIC gboolean
_childprocess_timeout(gpointer childprocess_object)
{
	ChildProcess*	self;
	DEBUGMSG("%s:%d Called from timeout for process with user_data = %p"
	,	__FUNCTION__, __LINE__, childprocess_object);
	self = CASTTOCLASS(ChildProcess, childprocess_object);
	if ((unsigned)(self->child_state) < DIMOF(signalmap)) {
#ifdef WIN32
		TerminateProcess(self->child_pid, -1);
#else
		(void)kill(self->child_pid, signalmap[self->child_state].signal);
#endif
		self->timeoutsrc_id = g_timeout_add_seconds
		(	signalmap[self->child_state].next_timeout
		,	_childprocess_timeout, self);
		self->child_state += 1;
	}else{
		_childprocess_childexit(self->child_pid, 0xffffffff, self);
	}
	return FALSE;
}
Esempio n. 25
0
svc_action_t *
services_action_create_generic(const char *exec, const char *args[])
{
    svc_action_t *op;
    unsigned int cur_arg;

    op = calloc(1, sizeof(*op));
    op->opaque = calloc(1, sizeof(svc_action_private_t));

    op->opaque->exec = strdup(exec);
    op->opaque->args[0] = strdup(exec);

    for (cur_arg = 1; args && args[cur_arg - 1]; cur_arg++) {
        op->opaque->args[cur_arg] = strdup(args[cur_arg - 1]);

        if (cur_arg == DIMOF(op->opaque->args) - 1) {
            crm_err("svc_action_t args list not long enough for '%s' execution request.", exec);
            break;
        }
    }

    return op;
}
Esempio n. 26
0
static gboolean
check_rsc_parameters(resource_t *rsc, node_t *node, crm_data_t *rsc_entry,
		     pe_working_set_t *data_set) 
{
	int attr_lpc = 0;
	gboolean force_restart = FALSE;
	gboolean delete_resource = FALSE;
	
	const char *value = NULL;
	const char *old_value = NULL;
	const char *attr_list[] = {
		XML_ATTR_TYPE, 
		XML_AGENT_ATTR_CLASS,
 		XML_AGENT_ATTR_PROVIDER
	};

	for(; attr_lpc < DIMOF(attr_list); attr_lpc++) {
		value = crm_element_value(rsc->xml, attr_list[attr_lpc]);
		old_value = crm_element_value(rsc_entry, attr_list[attr_lpc]);
		if(value == old_value /* ie. NULL */
		   || crm_str_eq(value, old_value, TRUE)) {
			continue;
		}
		
		force_restart = TRUE;
		crm_notice("Forcing restart of %s on %s, %s changed: %s -> %s",
			   rsc->id, node->details->uname, attr_list[attr_lpc],
			   crm_str(old_value), crm_str(value));
	}
	if(force_restart) {
		/* make sure the restart happens */
		stop_action(rsc, node, FALSE);
		set_bit(rsc->flags, pe_rsc_start_pending);
		delete_resource = TRUE;
	}
	return delete_resource;
}
Esempio n. 27
0
bool CScriptEditView::QueryClose()
{
	if( !GetModify() )
		return true;

	TCHAR szFmt[32];
	AtlLoadString( IDS_SAVE_MODIFIED, szFmt, DIMOF(szFmt) );
	TCHAR szBuff[MAX_PATH + 40];
	wsprintf( szBuff, szFmt, m_szFileName );
	int nRet = AtlMessageBox(
		WtlGetMainWnd(),
		szBuff,
		IDR_MAINFRAME,
		MB_YESNOCANCEL | MB_ICONEXCLAMATION
		);

	if(nRet == IDCANCEL)
		return false;

	if(nRet == IDYES)
		return OnFileSave();

	return true;
}
Esempio n. 28
0
const char *
pe_pref(GHashTable * options, const char *name)
{
    return get_cluster_pref(options, pe_opts, DIMOF(pe_opts), name);
}
Esempio n. 29
0
void
verify_pe_options(GHashTable * options)
{
    verify_all_options(options, pe_opts, DIMOF(pe_opts));
}
Esempio n. 30
0
xmlNode *
cib_msg_copy(xmlNode * msg, gboolean with_data)
{
    int lpc = 0;
    const char *field = NULL;
    const char *value = NULL;
    xmlNode *value_struct = NULL;

    static const char *field_list[] = {
        F_XML_TAGNAME,
        F_TYPE,
        F_CIB_CLIENTID,
        F_CIB_CALLOPTS,
        F_CIB_CALLID,
        F_CIB_OPERATION,
        F_CIB_ISREPLY,
        F_CIB_SECTION,
        F_CIB_HOST,
        F_CIB_RC,
        F_CIB_DELEGATED,
        F_CIB_OBJID,
        F_CIB_OBJTYPE,
        F_CIB_EXISTING,
        F_CIB_SEENCOUNT,
        F_CIB_TIMEOUT,
        F_CIB_CALLBACK_TOKEN,
        F_CIB_GLOBAL_UPDATE,
        F_CIB_CLIENTNAME,
#if ENABLE_ACL
        F_CIB_USER,
#endif
        F_CIB_NOTIFY_TYPE,
        F_CIB_NOTIFY_ACTIVATE
    };

    static const char *data_list[] = {
        F_CIB_CALLDATA,
        F_CIB_UPDATE,
        F_CIB_UPDATE_RESULT
    };

    xmlNode *copy = create_xml_node(NULL, "copy");

    CRM_ASSERT(copy != NULL);

    for (lpc = 0; lpc < DIMOF(field_list); lpc++) {
        field = field_list[lpc];
        value = crm_element_value(msg, field);
        if (value != NULL) {
            crm_xml_add(copy, field, value);
        }
    }
    for (lpc = 0; with_data && lpc < DIMOF(data_list); lpc++) {
        field = data_list[lpc];
        value_struct = get_message_xml(msg, field);
        if (value_struct != NULL) {
            add_message_xml(copy, field, value_struct);
        }
    }

    return copy;
}