예제 #1
0
void php_ds_register_queue()
{
    zend_class_entry ce;

    zend_function_entry methods[] = {
        PHP_DS_ME(Queue, __construct)
        PHP_DS_ME(Queue, allocate)
        PHP_DS_ME(Queue, capacity)
        PHP_DS_ME(Queue, peek)
        PHP_DS_ME(Queue, pop)
        PHP_DS_ME(Queue, push)
        PHP_DS_ME(Queue, pushAll)

        PHP_DS_ME_LIST(Queue)
        PHP_FE_END
    };

    INIT_CLASS_ENTRY(ce, PHP_DS_NS(Queue), methods);

    php_ds_queue_ce = zend_register_internal_class(&ce);
    php_ds_queue_ce->ce_flags      |= ZEND_ACC_FINAL;
    php_ds_queue_ce->create_object  = php_ds_queue_create_object;
    php_ds_queue_ce->get_iterator   = php_ds_queue_get_iterator;
    php_ds_queue_ce->serialize      = php_ds_queue_serialize;
    php_ds_queue_ce->unserialize    = php_ds_queue_unserialize;

    zend_declare_class_constant_long(php_ds_queue_ce, STR_AND_LEN("MIN_CAPACITY"), DS_DEQUE_MIN_CAPACITY);
    zend_class_implements(php_ds_queue_ce, 1, collection_ce);

    php_ds_register_queue_handlers();
}
예제 #2
0
void initproctitle (int argc, char **argv)
{
        int i;
        char **envp = environ;

        if (argc) {
            prog_len= strlen(argv[0]);
            prog_str= strdup(argv[0]);
            if (argc > 1 ) {
                for(i = 1; i < argc; i++) {
                    args_len += strlen(argv[i]);
                    args_len++;
                }
                args_str= (char *) malloc(args_len);
                args_len= 0;
                for(i = 1; i < argc; i++) {
                    int l= strlen(argv[i]);
                    memcpy(args_str + args_len, argv[i], l);
                    args_len += l;
                    args_str[args_len++]=' ';
                }
                args_len--;
                args_str[args_len]= 0;
            } else {
                args_str= "";
                args_len= 0;
            }
        } else {
            prog_str= STR_AND_LEN("relay",prog_len);
        }
        /*
        printf("prog_str: '%*s' args_str: '%*s'\n", prog_len, prog_str, args_len, args_str);
        */

        /*
         * Move the environment so we can reuse the memory.
         * (Code borrowed from sendmail.)
         * WARNING: ugly assumptions on memory layout here;
         *          if this ever causes problems, #undef DO_PS_FIDDLING
         */
        for (i = 0; envp[i] != NULL; i++)
                continue;

        environ = (char **) malloc(sizeof(char *) * (i + 1));
        if (environ == NULL)
                return;

        for (i = 0; envp[i] != NULL; i++)
                if ((environ[i] = strdup(envp[i])) == NULL)
                        return;
        environ[i] = NULL;

        argv0 = argv;
        if (i > 0)
                argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0];
        else
                argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0];
}
예제 #3
0
void	dse_dmp(void)
{
	boolean_t	dmp_res, glo_present, zwr_present;

	patch_fdmp_recs = 0;
	glo_present = (CLI_PRESENT == cli_present("GLO"));
	zwr_present = (CLI_PRESENT == cli_present("ZWR"));
	if (glo_present || zwr_present)
	{
		if (CLOSED_FMT == dse_dmp_format)
		{
			util_out_print("Error:  must open an output file before dump.", TRUE);
			return;
		}
		if (gtm_utf8_mode && (GLO_FMT == glo_present))
		{
			util_out_print("Error:  GLO format is not supported in UTF-8 mode. Use ZWR format.", TRUE);
			return;
		}
		if (OPEN_FMT == dse_dmp_format)
		{
			dse_dmp_format = (glo_present ? GLO_FMT : ZWR_FMT);
			if (!gtm_utf8_mode)
				dse_fdmp_output(LIT_AND_LEN("; DSE EXTRACT"));
			else
				dse_fdmp_output(LIT_AND_LEN("; DSE EXTRACT UTF-8"));
			dse_fdmp_output(STR_AND_LEN(format_label[dse_dmp_format]));
		} else if ((glo_present ? GLO_FMT : ZWR_FMT) != dse_dmp_format)
		{
			util_out_print("Error:  current output file already contains !AD records.", TRUE,
					LEN_AND_STR(&format_label[dse_dmp_format][MESS_OFF]));
			return;
		}
		patch_is_fdmp = TRUE;
		ESTABLISH(dse_dmp_handler);
	} else
		patch_is_fdmp = FALSE;
	if (CLI_PRESENT == cli_present("RECORD") || CLI_PRESENT == cli_present("OFFSET"))
		dmp_res = dse_r_dmp();
	else
		dmp_res = dse_b_dmp();
	if (patch_is_fdmp)
	{
		REVERT;
		if (dmp_res)
			util_out_print("!UL !AD records written.!/", TRUE, patch_fdmp_recs,
					LEN_AND_STR(&format_label[dse_dmp_format][MESS_OFF]));
	}
	return;
}
예제 #4
0
void register_vector()
{
    zend_class_entry ce;

    zend_function_entry methods[] = {
        SEQUENCE_ME_LIST(Vector)
        COLLECTION_ME_LIST(Vector)
        PHP_FE_END
    };

    INIT_CLASS_ENTRY(ce, DS_NS(Vector), methods);

    vector_ce = zend_register_internal_class(&ce);
    vector_ce->ce_flags      |= ZEND_ACC_FINAL;
    vector_ce->create_object  = vector_create_object;
    vector_ce->get_iterator   = vector_get_iterator;
    vector_ce->serialize      = vector_serialize;
    vector_ce->unserialize    = vector_unserialize;

    zend_declare_class_constant_long(vector_ce, STR_AND_LEN("MIN_CAPACITY"), VECTOR_MIN_CAPACITY);

    zend_class_implements(vector_ce, 1, sequence_ce);
    register_vector_handlers();
}
예제 #5
0
void	util_out_print_vaparm(caddr_t message, int flush, va_list var, int faocnt)
{
	char	fmt_buff[OUT_BUFF_SIZE];
	caddr_t	fmtc;
	int	rc;

	/*
	 * Note: this function checks for EINTR on FPRINTF. This check should not be
	 * converted to an EINTR wrapper macro because of the variable number of args used
	 * by fprintf.
	 */

	if (util_outptr == NULL)
		util_outptr = util_outbuff;

	if (message != NULL)
		util_outptr = util_format(message, var, util_outptr, OUT_BUFF_SIZE - (util_outptr - util_outbuff) - 2, faocnt);

	switch (flush)
	{
		case NOFLUSH:
			break;

		case RESET:
			break;

		case FLUSH:
			*util_outptr++ = '\n';
		case OPER:
		case SPRINT:
			/******************************************************************************************************
			   For all three of these actions we need to do some output buffer translation. In all cases a '%'
			   is translated to the escape version '%%'. For OPER and SPRINT, we also translate '\n' to a ', '
			   since some syslog() implementations (like Tru64) stop processing the passed message on a newline.
			*******************************************************************************************************/
			*util_outptr = '\0';
			for (util_outptr = util_outbuff, fmtc = fmt_buff;  0 != *util_outptr; )
			{
				if ('%' == *util_outptr)
				{
					*fmtc++ = '%';	/* escape for '%' */
					*fmtc++ = '%';
					util_outptr++;
				} else if ('\n' == *util_outptr && (OPER == flush || SPRINT == flush))
				{
					*fmtc++ = ',';
					*fmtc++ = ' ';
					util_outptr++;
				} else
					*fmtc++ = *util_outptr++;
			}
			*fmtc++ = '\0';
			switch (flush)
			{
				case FLUSH:
					do
					{
						rc = FPRINTF(stderr, fmt_buff);
					} while (-1 == rc && EINTR == errno);
					break;
				case OPER:
					util_out_send_oper(STR_AND_LEN(fmt_buff));
					break;
				case SPRINT:
					memcpy(util_outbuff, fmt_buff, fmtc - fmt_buff);
					break;
			}
			break;
		default:
			assert(FALSE);
	}
	switch (flush)
	{
		case NOFLUSH:
			break;

		case FLUSH:
		case RESET:
		case OPER:
		case SPRINT:
			/* Reset buffer information.  */
			util_outptr = util_outbuff;
			break;
	}

}