• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parse_time函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parse_time函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_time函数的具体用法?C++ parse_time怎么用?C++ parse_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse_time函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: parse_zone_common

static gboolean
parse_zone_common(ParsingData	*data,
                  int		 offset)
{
    ZoneData *zone;
    ZoneLineData zone_line;
    TimeCode time_code;

    zone_line.stdoff_seconds = parse_time(data,
                                          data->fields[ZONE_GMTOFF + offset],
                                          &time_code);
    zone_line.save_seconds = parse_rules_save(data,
                             data->fields[ZONE_RULES_SAVE + offset],
                             &zone_line.rules);

    if(!VzicPureOutput)
    {
        /* We round the UTC offsets to the nearest minute, to be compatible with
           Outlook. This also works with -ve numbers, I think.
           -56 % 60 = -59. -61 % 60 = -1. */
        if(zone_line.stdoff_seconds >= 0)
            zone_line.stdoff_seconds += 30;
        else
            zone_line.stdoff_seconds -= 29;
        zone_line.stdoff_seconds -= zone_line.stdoff_seconds % 60;

        if(zone_line.save_seconds >= 0)
            zone_line.save_seconds += 30;
        else
            zone_line.save_seconds -= 29;
        zone_line.save_seconds -= zone_line.save_seconds % 60;
    }

    zone_line.format = g_strdup(data->fields[ZONE_FORMAT + offset]);

    if(data->num_fields - offset >= 6)
    {
        zone_line.until_set = TRUE;
        zone_line.until_year = parse_year(data,
                                          data->fields[ZONE_UNTIL_YEAR + offset],
                                          FALSE, 0);
        zone_line.until_month = parse_month(data,
                                            data->fields[ZONE_UNTIL_MONTH + offset]);
        zone_line.until_day_code = parse_day(data,
                                             data->fields[ZONE_UNTIL_DAY + offset],
                                             &zone_line.until_day_number,
                                             &zone_line.until_day_weekday);
        zone_line.until_time_seconds = parse_time(data,
                                       data->fields[ZONE_UNTIL_TIME + offset],
                                       &zone_line.until_time_code);

        /* We also want to know the maximum year used in any UNTIL value, so we
           know where to expand all the infinite Rule data to. */
        if(zone_line.until_year != YEAR_MAXIMUM
                && zone_line.until_year != YEAR_MINIMUM)
            data->max_until_year = MAX(data->max_until_year, zone_line.until_year);

    }
    else
    {
        zone_line.until_set = FALSE;
    }

    /* Append it to the last Zone, since that is the one we are currently
       reading. */
    zone = &g_array_index(data->zone_data, ZoneData, data->zone_data->len - 1);
    g_array_append_val(zone->zone_line_data, zone_line);

    return zone_line.until_set;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:70,代码来源:vzic-parse.c


示例2: scontrol_parse_res_options

/*
 * scontrol_parse_res_options   parse options for creating or updating a
                                reservation
 * IN argc - count of arguments
 * IN argv - list of arguments
 * IN msg  - a string to append to any error message
 * OUT resv_msg_ptr - struct holding reservation parameters
 * OUT free_user_str - bool indicating that resv_msg_ptr->users should be freed
 * OUT free_acct_str - bool indicating that resv_msg_ptr->accounts should be
 *		       freed
 * RET 0 on success, -1 on err and prints message
 */
extern int
scontrol_parse_res_options(int argc, char *argv[], const char *msg,
			   resv_desc_msg_t  *resv_msg_ptr,
			   int *free_user_str, int *free_acct_str)
{
	int i;
	int duration = -3;   /* -1 == INFINITE, -2 == error, -3 == not set */

	*free_user_str = 0;
	*free_acct_str = 0;

	for (i=0; i<argc; i++) {
		char *tag = argv[i];
		int taglen = 0;
		char plus_minus = '\0';

		char *val = strchr(argv[i], '=');
		taglen = val - argv[i];

		if (!val && strncasecmp(argv[i], "res", 3) == 0) {
			continue;
		} else if (!val || taglen == 0) {
			exit_code = 1;
			error("Unknown parameter %s.  %s", argv[i], msg);
			return -1;
		}
		if (val[-1] == '+' || val[-1] == '-') {
			plus_minus = val[-1];
			taglen--;
		}
		val++;

		if (strncasecmp(tag, "ReservationName", MAX(taglen, 1)) == 0) {
			resv_msg_ptr->name = val;

		} else if (strncasecmp(tag, "StartTime", MAX(taglen, 1)) == 0){
			time_t  t = parse_time(val, 0);
			if (errno == ESLURM_INVALID_TIME_VALUE) {
				exit_code = 1;
				error("Invalid start time %s.  %s",
				      argv[i], msg);
				return -1;
			}
			resv_msg_ptr->start_time = t;

		} else if (strncasecmp(tag, "EndTime", MAX(taglen, 1)) == 0) {
			time_t  t = parse_time(val, 0);
			if (errno == ESLURM_INVALID_TIME_VALUE) {
				exit_code = 1;
				error("Invalid end time %s.  %s", argv[i],msg);
				return -1;
			}
			resv_msg_ptr->end_time = t;

		} else if (strncasecmp(tag, "Duration", MAX(taglen, 1)) == 0) {
			/* -1 == INFINITE, -2 == error, -3 == not set */
			duration = time_str2mins(val);
			if (duration < 0 && duration != INFINITE) {
				exit_code = 1;
				error("Invalid duration %s.  %s", argv[i],msg);
				return -1;
			}
			resv_msg_ptr->duration = (uint32_t)duration;

		} else if (strncasecmp(tag, "Flags", MAX(taglen, 2)) == 0) {
			uint32_t f;
			if (plus_minus) {
				char *tmp =
					_process_plus_minus(plus_minus, val);
				f = _parse_flags(tmp, msg);
				xfree(tmp);
			} else {
				f = _parse_flags(val, msg);
			}
			if (f == 0xffffffff) {
				return -1;
			} else {
				resv_msg_ptr->flags = f;
			}
		} else if (strncasecmp(tag, "NodeCnt", MAX(taglen,5)) == 0 ||
			   strncasecmp(tag, "NodeCount", MAX(taglen,5)) == 0) {
			char *endptr = NULL, *node_cnt, *tok, *ptrptr = NULL;
			int node_inx = 0;
			node_cnt = xstrdup(val);
			tok = strtok_r(node_cnt, ",", &ptrptr);
			while (tok) {
				xrealloc(resv_msg_ptr->node_cnt,
					 sizeof(uint32_t) * (node_inx + 2));
//.........这里部分代码省略.........
开发者ID:BYUHPC,项目名称:slurm,代码行数:101,代码来源:create_res.c


示例3: main

int
main(int argc, char **argv)
{
    size_t sz;
    size_t buf_sz;
    int i, j;

    for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) {
	char *buf;

	sz = unparse_time(tests[i].val, NULL, 0);
	if  (sz != tests[i].size)
	    errx(1, "sz (%lu) != tests[%d].size (%lu)",
		 (unsigned long)sz, i, (unsigned long)tests[i].size);

	for (buf_sz = 0; buf_sz < tests[i].size + 2; buf_sz++) {

	    buf = rk_test_mem_alloc(RK_TM_OVERRUN, "overrun",
				    NULL, buf_sz);
	    sz = unparse_time(tests[i].val, buf, buf_sz);
	    if (sz != tests[i].size)
		errx(1, "sz (%lu) != tests[%d].size (%lu) with in size %lu",
		     (unsigned long)sz, i,
		     (unsigned long)tests[i].size,
		     (unsigned long)buf_sz);
	    if (buf_sz > 0 && memcmp(buf, tests[i].str, buf_sz - 1) != 0)
		errx(1, "test %i wrong result %s vs %s", i, buf, tests[i].str);
	    if (buf_sz > 0 && buf[buf_sz - 1] != '\0')
		errx(1, "test %i not zero terminated", i);
	    rk_test_mem_free("overrun");

	    buf = rk_test_mem_alloc(RK_TM_UNDERRUN, "underrun",
				    NULL, tests[i].size);
	    sz = unparse_time(tests[i].val, buf, min(buf_sz, tests[i].size));
	    if (sz != tests[i].size)
		errx(1, "sz (%lu) != tests[%d].size (%lu) with insize %lu",
		     (unsigned long)sz, i,
		     (unsigned long)tests[i].size,
		     (unsigned long)buf_sz);
	    if (buf_sz > 0 && strncmp(buf, tests[i].str, min(buf_sz, tests[i].size) - 1) != 0)
		errx(1, "test %i wrong result %s vs %s", i, buf, tests[i].str);
	    if (buf_sz > 0 && buf[min(buf_sz, tests[i].size) - 1] != '\0')
		errx(1, "test %i not zero terminated", i);
	    rk_test_mem_free("underrun");
	}

	buf = rk_test_mem_alloc(RK_TM_OVERRUN, "overrun",
				tests[i].str, tests[i].size + 1);
	j = parse_time(buf, "s");
	if (j != tests[i].val)
	    errx(1, "parse_time failed for test %d", i);
	rk_test_mem_free("overrun");

	buf = rk_test_mem_alloc(RK_TM_UNDERRUN, "underrun",
				tests[i].str, tests[i].size + 1);
	j = parse_time(buf, "s");
	if (j != tests[i].val)
	    errx(1, "parse_time failed for test %d", i);
	rk_test_mem_free("underrun");

    }
    return 0;
}
开发者ID:Henauxg,项目名称:minix,代码行数:63,代码来源:parse_time-test.c


示例4: _process_command


//.........这里部分代码省略.........
			exit_code = 1;
			fprintf (stderr,
				 "too many arguments for keyword:%s\n",
				 argv[0]);
		}
		one_liner = 1;
	} else if (strncasecmp (argv[0], "quiet", MAX(command_len, 4)) == 0) {
		if (argc > 1) {
			exit_code = 1;
			fprintf (stderr, "too many arguments for keyword:%s\n",
				 argv[0]);
		}
		quiet_flag = 1;
	} else if ((strncasecmp (argv[0], "exit", MAX(command_len, 4)) == 0) ||
		   (strncasecmp (argv[0], "\\q", MAX(command_len, 2)) == 0) ||
		   (strncasecmp (argv[0], "quit", MAX(command_len, 4)) == 0)) {
		if (argc > 1) {
			exit_code = 1;
			fprintf (stderr,
				 "too many arguments for keyword:%s\n",
				 argv[0]);
		}
		exit_flag = 1;
	} else if ((strncasecmp (argv[0], "add", MAX(command_len, 3)) == 0) ||
		   (strncasecmp (argv[0], "create",
				 MAX(command_len, 3)) == 0)) {
		_add_it((argc - 1), &argv[1]);
	} else if ((strncasecmp (argv[0], "archive",
				 MAX(command_len, 3)) == 0)) {
		_archive_it((argc - 1), &argv[1]);
	} else if ((strncasecmp (argv[0], "show", MAX(command_len, 3)) == 0) ||
		   (strncasecmp (argv[0], "list", MAX(command_len, 3)) == 0)) {
		_show_it((argc - 1), &argv[1]);
	} else if (!strncasecmp (argv[0], "modify", MAX(command_len, 1))
		   || !strncasecmp (argv[0], "update", MAX(command_len, 1))) {
		_modify_it((argc - 1), &argv[1]);
	} else if ((strncasecmp (argv[0], "delete",
				 MAX(command_len, 3)) == 0) ||
		   (strncasecmp (argv[0], "remove",
				 MAX(command_len, 3)) == 0)) {
		_delete_it((argc - 1), &argv[1]);
	} else if (strncasecmp (argv[0], "verbose", MAX(command_len, 4)) == 0) {
		if (argc > 1) {
			exit_code = 1;
			fprintf (stderr,
				 "too many arguments for %s keyword\n",
				 argv[0]);
		}
		quiet_flag = -1;
	} else if (strncasecmp (argv[0], "readonly",
				MAX(command_len, 4)) == 0) {
		if (argc > 1) {
			exit_code = 1;
			fprintf (stderr,
				 "too many arguments for %s keyword\n",
				 argv[0]);
		}
		readonly_flag = 1;
	} else if (strncasecmp (argv[0], "rollup", MAX(command_len, 2)) == 0) {
		time_t my_start = 0;
		time_t my_end = 0;
		uint16_t archive_data = 0;
		if (argc > 4) {
			exit_code = 1;
			fprintf (stderr,
				 "too many arguments for %s keyword\n",
				 argv[0]);
		}

		if(argc > 1)
			my_start = parse_time(argv[1], 1);
		if(argc > 2)
			my_end = parse_time(argv[2], 1);
		if(argc > 3)
			archive_data = atoi(argv[3]);
		if(acct_storage_g_roll_usage(db_conn, my_start,
					     my_end, archive_data)
		   == SLURM_SUCCESS) {
			if(commit_check("Would you like to commit rollup?")) {
				acct_storage_g_commit(db_conn, 1);
			} else {
				printf(" Rollup Discarded\n");
				acct_storage_g_commit(db_conn, 0);
			}
		}
	} else if (strncasecmp (argv[0], "version", MAX(command_len, 4)) == 0) {
		if (argc > 1) {
			exit_code = 1;
			fprintf (stderr,
				 "too many arguments for %s keyword\n",
				 argv[0]);
		}
		_print_version();
	} else {
		exit_code = 1;
		fprintf (stderr, "invalid keyword: %s\n", argv[0]);
	}

	return 0;
}
开发者ID:VURM,项目名称:slurm,代码行数:101,代码来源:sacctmgr.c


示例5: caltrap_add

void caltrap_add(int nargs, char **args, int nphysargs, struct entry *e)
{
    Date sd, ed;
    Time st, et;
    int i;
    char msg[512], *msgp, *p;
    struct entry ent;

    if (e->length == INVALID_DURATION)
	e->length = 0;

    if (e->period == INVALID_DURATION)
	e->period = 0;

    if (e->type == INVALID_TYPE)
	e->type = T_EVENT;

    if (nargs < 1 || nargs > 4)
	fatalerr_addargno();
    assert(nargs <= nphysargs);

    /*
     * We MUST see a date as the first argument.
     */
    sd = parse_date(args[0]);
    if (sd == INVALID_DATE)
	fatalerr_date(args[0]);

    i = 1;

    /*
     * Now we might see a time.
     */
    st = NO_TIME;
    if (nargs > i) {
	st = parse_time(args[i]);
	if (st != INVALID_TIME)
	    i++;
	else
	    st = NO_TIME;
    }

    /*
     * Now we expect to see a second date or time or both.
     */
    if (nargs > i) {
	ed = parse_date(args[i]);
	if (ed != INVALID_DATE)
	    i++;

	if (nargs > i) {
	    et = parse_time(args[i]);
	    if (et == INVALID_TIME)
		fatalerr_time(args[i]);
	    i++;
	    if (ed == INVALID_DATE) {
		/*
		 * If an end time was specified but no end date, we
		 * assume ed == sd.
		 */
		ed = sd;
	    }
	} else
	    et = 0;

	/*
	 * In this case, we normalise a missing start time to
	 * midnight.
	 */
	if (st == NO_TIME)
	    st = 0;
    } else {
	/*
	 * If there was no end time, choose one appropriately. An
	 * entry specifying just a date as input is taken to last
	 * exactly one day; an entry specifying just a start
	 * date+time is taken to be instantaneous.
	 */
	if (st == NO_TIME) {
	    st = 0;
	    ed = sd + 1;
	    et = 0;
	} else {
	    ed = sd;
	    et = st;
	}
    }

    if (i < nargs)
	fatalerr_extraarg(args[i]);

    msgp = e->description;

    if (isatty(fileno(stdin))) {
	char *dfmt, *tfmt;
	dfmt = format_date_full(sd);
	tfmt = format_time(st);
	printf("New entry will run from %s %s\n", dfmt, tfmt);
	sfree(dfmt);
	sfree(tfmt);
//.........这里部分代码省略.........
开发者ID:rdebath,项目名称:sgt,代码行数:101,代码来源:add.c


示例6: assign_option

static void
assign_option(pgut_option *opt, const char *optarg, pgut_optsrc src)
{
	const char	  *message;

	if (opt == NULL)
	{
		ereport(ERROR,
			(errcode(ERROR_ARGS),
			 errmsg("option is not specified"),
			 errhint("Try \"%s --help\" for more information.", PROGRAM_NAME)));
	}

	if (opt->source > src)
	{
		/* high prior value has been set already. */
		return;
	}
	else if (src >= SOURCE_CMDLINE && opt->source >= src)
	{
		/* duplicated option in command line */
		message = "specified only once";
	}
	else
	{
		/* can be overwritten if non-command line source */
		opt->source = src;

		switch (opt->type)
		{
			case 'b':
			case 'B':
				if (optarg == NULL)
				{
					*((bool *) opt->var) = (opt->type == 'b');
					return;
				}
				else if (parse_bool(optarg, (bool *) opt->var))
				{
					return;
				}
				message = "a boolean";
				break;
			case 'f':
				((pgut_optfn) opt->var)(opt, optarg);
				return;
			case 'i':
				if (parse_int32(optarg, opt->var))
					return;
				message = "a 32bit signed integer";
				break;
			case 'u':
				if (parse_uint32(optarg, opt->var))
					return;
				message = "a 32bit unsigned integer";
				break;
			case 'I':
				if (parse_int64(optarg, opt->var))
					return;
				message = "a 64bit signed integer";
				break;
			case 'U':
				if (parse_uint64(optarg, opt->var))
					return;
				message = "a 64bit unsigned integer";
				break;
			case 's':
				if (opt->source != SOURCE_DEFAULT)
					free(*(char **) opt->var);
				*(char **) opt->var = pgut_strdup(optarg);
				return;
			case 't':
				if (parse_time(optarg, opt->var))
					return;
				message = "a time";
				break;
			case 'y':
			case 'Y':
				if (optarg == NULL)
				{
					*(YesNo *) opt->var = (opt->type == 'y' ? YES : NO);
					return;
				}
				else
				{
					bool	value;
					if (parse_bool(optarg, &value))
					{
						*(YesNo *) opt->var = (value ? YES : NO);
						return;
					}
				}
				message = "a boolean";
				break;
			default:
				ereport(ERROR,
					(errcode(ERROR_ARGS),
					 errmsg("invalid option type: %c", opt->type)));
				return;	/* keep compiler quiet */
		}
//.........这里部分代码省略.........
开发者ID:jamexu98918,项目名称:pg_rman,代码行数:101,代码来源:pgut.c


示例7: _set_cond

static int _set_cond(int *start, int argc, char *argv[],
		     slurmdb_archive_cond_t *arch_cond)
{
	int i;
	int set = 0;
	int end = 0;
	int command_len = 0;
 	uint32_t tmp;
	slurmdb_job_cond_t *job_cond = NULL;

	if (!arch_cond) {
		error("No arch_cond given");
		return -1;
	}
	if (!arch_cond->job_cond)
		arch_cond->job_cond = xmalloc(sizeof(slurmdb_job_cond_t));
	job_cond = arch_cond->job_cond;

	for (i=(*start); i<argc; i++) {
		end = parse_option_end(argv[i]);
		if (!end)
			command_len=strlen(argv[i]);
		else {
			command_len=end-1;
			if (argv[i][end] == '=') {
				end++;
			}
		}

		if (!end && !strncasecmp(argv[i], "where",
					MAX(command_len, 5))) {
			continue;
		} else if (!end && !strncasecmp(argv[i], "events",
					  MAX(command_len, 1))) {
			arch_cond->purge_event |= SLURMDB_PURGE_ARCHIVE;
			set = 1;
		} else if (!end && !strncasecmp(argv[i], "jobs",
					  MAX(command_len, 1))) {
			arch_cond->purge_job |= SLURMDB_PURGE_ARCHIVE;
			set = 1;
		} else if (!end && !strncasecmp(argv[i], "reservations",
					  MAX(command_len, 1))) {
			arch_cond->purge_resv |= SLURMDB_PURGE_ARCHIVE;
			set = 1;
		} else if (!end && !strncasecmp(argv[i], "steps",
					  MAX(command_len, 1))) {
			arch_cond->purge_step |= SLURMDB_PURGE_ARCHIVE;
			set = 1;
		} else if (!end && !strncasecmp(argv[i], "suspend",
					  MAX(command_len, 1))) {
			arch_cond->purge_suspend |= SLURMDB_PURGE_ARCHIVE;
			set = 1;
		} else if (!end
			  || !strncasecmp(argv[i], "Clusters",
					  MAX(command_len, 1))) {
			if (!job_cond->cluster_list)
				job_cond->cluster_list =
					list_create(slurm_destroy_char);
			slurm_addto_char_list(job_cond->cluster_list,
					      argv[i]+end);
			set = 1;
		} else if (!strncasecmp (argv[i], "Accounts",
					 MAX(command_len, 2))) {
			if (!job_cond->acct_list)
				job_cond->acct_list =
					list_create(slurm_destroy_char);
			slurm_addto_char_list(job_cond->acct_list,
					      argv[i]+end);
			set = 1;
		} else if (!strncasecmp (argv[i], "Associations",
					 MAX(command_len, 2))) {
			if (!job_cond->associd_list)
				job_cond->associd_list =
					list_create(slurm_destroy_char);
			slurm_addto_char_list(job_cond->associd_list,
					      argv[i]+end);
			set = 1;
		} else if (!strncasecmp (argv[i], "Directory",
					 MAX(command_len, 2))) {
			arch_cond->archive_dir =
				strip_quotes(argv[i]+end, NULL, 0);
			set = 1;
		} else if (!strncasecmp (argv[i], "End", MAX(command_len, 1))) {
			job_cond->usage_end = parse_time(argv[i]+end, 1);
			set = 1;
		} else if (!strncasecmp (argv[i], "Gid", MAX(command_len, 2))) {
			if (!job_cond->groupid_list)
				job_cond->groupid_list =
					list_create(slurm_destroy_char);
			slurm_addto_char_list(job_cond->groupid_list,
					      argv[i]+end);
			set = 1;
		} else if (!strncasecmp (argv[i], "Jobs",
					 MAX(command_len, 1))) {
			char *end_char = NULL, *start_char = argv[i]+end;
			slurmdb_selected_step_t *selected_step = NULL;
			char *dot = NULL;
			if (!job_cond->step_list)
				job_cond->step_list =
					list_create(slurm_destroy_char);
//.........这里部分代码省略.........
开发者ID:BYUHPC,项目名称:slurm,代码行数:101,代码来源:archive_functions.c


示例8: parse_time

bool changeset_info::is_open_at(const pt::ptime &now) const {
  const pt::ptime closed_at_time = parse_time(closed_at);
  return (closed_at_time > now) && (num_changes < MAX_CHANGESET_ELEMENTS);
}
开发者ID:openstreetmap,项目名称:cgimap,代码行数:4,代码来源:output_formatter.cpp


示例9: parse_date


//.........这里部分代码省略.........
		case 's':
		case 'S':	/* seconds */
			dt += val;
			break;
		case 'd':
		case 'D':	/* days */
			dt += (val * 86400L);
			break;
		case 'w':
		case 'W':	/* weeks */
			dt += (val * 604800L);
			break;
		case 'o':
		case 'O':	/* months */
			T = localtime(&dt);
			T->tm_mon += (int) val;
			i = T->tm_mday;
			goto fixday;
		case 'y':
		case 'Y':	/* years */
			T = localtime(&dt);
			T->tm_year += (int) val;
			i = T->tm_mday;
	fixday:
			dt = mktime(T);
			T = localtime(&dt);
			if (T->tm_mday != i) {
				T->tm_mday = 1;
				dt = mktime(T);
				dt -= (time_t) 86400L;
			}
		default:	/* unknown */
			break;	/* leave untouched */
		}
	} else {
		char           *q, tmp[64];

		/*
		 * Skip past any weekday prefix
		 */
		weekday(&str);
		strlcpy(tmp, str, sizeof(tmp));
		str = tmp;
		T = localtime(&dt);

		/*
		 * See if we can break off any timezone
		 */
		while ((q = strrchr(tmp, ' ')) != NULL) {
			if (strchr("(+-", q[1]) != NULL)
				*q = '\0';
			else {
				int             j = 1;

				while (q[j] && isupper((unsigned char)q[j]))
					++j;
				if (q[j] == '\0')
					*q = '\0';
				else
					break;
			}
		}

		/*
		 * See if there is a time hh:mm[:ss]
		 */
		if ((p = strchr(tmp, ':')) == NULL) {

			/*
			 * No time string involved
			 */
			T->tm_hour = T->tm_min = T->tm_sec = 0;
			parse_datesub(tmp, &T->tm_mday, &T->tm_mon, &T->tm_year);
		} else {
			char            datestr[64], timestr[64];

			/*
			 * Let's chip off the time string
			 */
			if ((q = strpbrk(p, " \t")) != NULL) {	/* Time first? */
				int             l = q - str;

				strlcpy(timestr, str, l + 1);
				strlcpy(datestr, q + 1, sizeof(datestr));
				parse_time(timestr, &T->tm_hour, &T->tm_min, &T->tm_sec);
				parse_datesub(datestr, &T->tm_mday, &T->tm_mon, &T->tm_year);
			} else if ((q = strrchr(tmp, ' ')) != NULL) {	/* Time last */
				int             l = q - tmp;

				strlcpy(timestr, q + 1, sizeof(timestr));
				strlcpy(datestr, tmp, l + 1);
			} else	/* Bail out */
				return dt;
			parse_time(timestr, &T->tm_hour, &T->tm_min, &T->tm_sec);
			parse_datesub(datestr, &T->tm_mday, &T->tm_mon, &T->tm_year);
		}
		dt = mktime(T);
	}
	return dt;
}
开发者ID:JabirTech,项目名称:Source,代码行数:101,代码来源:psdate.c


示例10: main

int
main(int argc, char **argv)
{
    krb5_error_code ret, ret2;
    krb5_context context;
    krb5_auth_context auth_context;
    void *kadm_handle;
    kadm5_server_context *server_context;
    kadm5_config_params conf;
    int master_fd;
    krb5_ccache ccache;
    krb5_principal server;
    char **files;
    int optidx = 0;
    time_t reconnect_min;
    time_t backoff;
    time_t reconnect_max;
    time_t reconnect;
    time_t before = 0;
    int restarter_fd = -1;

    const char *master;

    setprogname(argv[0]);

    if (getarg(args, num_args, argc, argv, &optidx))
	usage(1);

    if (help_flag)
	usage(0);

    if (version_flag) {
	print_version(NULL);
	exit(0);
    }

    if (detach_from_console && daemon_child == -1)
        roken_detach_prep(argc, argv, "--daemon-child");
    rk_pidfile(NULL);

    ret = krb5_init_context(&context);
    if (ret)
	errx (1, "krb5_init_context failed: %d", ret);

    setup_signal();

    if (config_file == NULL) {
	if (asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context)) == -1
	    || config_file == NULL)
	    errx(1, "out of memory");
    }

    ret = krb5_prepend_config_files_default(config_file, &files);
    if (ret)
	krb5_err(context, 1, ret, "getting configuration files");

    ret = krb5_set_config_files(context, files);
    krb5_free_config_files(files);
    if (ret)
	krb5_err(context, 1, ret, "reading configuration files");

    argc -= optidx;
    argv += optidx;

    if (argc != 1)
	usage(1);

    master = argv[0];

    if (status_file == NULL) {
	if (asprintf(&status_file,  "%s/ipropd-slave-status", hdb_db_dir(context)) < 0 || status_file == NULL)
	    krb5_errx(context, 1, "can't allocate status file buffer"); 
    }

    krb5_openlog(context, "ipropd-slave", &log_facility);
    krb5_set_warn_dest(context, log_facility);

    slave_status(context, status_file, "bootstrapping");

    ret = krb5_kt_register(context, &hdb_get_kt_ops);
    if(ret)
	krb5_err(context, 1, ret, "krb5_kt_register");

    time_before_lost = parse_time (server_time_lost,  "s");
    if (time_before_lost < 0)
	krb5_errx (context, 1, "couldn't parse time: %s", server_time_lost);

    slave_status(context, status_file, "getting credentials from keytab/database");

    memset(&conf, 0, sizeof(conf));
    if(realm) {
	conf.mask |= KADM5_CONFIG_REALM;
	conf.realm = realm;
    }
    ret = kadm5_init_with_password_ctx (context,
					KADM5_ADMIN_SERVICE,
					NULL,
					KADM5_ADMIN_SERVICE,
					&conf, 0, 0,
					&kadm_handle);
//.........这里部分代码省略.........
开发者ID:DavidMulder,项目名称:heimdal,代码行数:101,代码来源:ipropd_slave.c


示例11: main

int
main(int argc, char **argv)
{
    krb5_error_code ret;
    krb5_context context;
    krb5_auth_context auth_context;
    void *kadm_handle;
    kadm5_server_context *server_context;
    kadm5_config_params conf;
    int master_fd;
    krb5_ccache ccache;
    krb5_principal server;
    char **files;
    int optidx = 0;
    time_t reconnect_min;
    time_t backoff;
    time_t reconnect_max;
    time_t reconnect;
    time_t before = 0;

    const char *master;

    setprogname(argv[0]);

    if(getarg(args, num_args, argc, argv, &optidx))
	usage(1);

    if(help_flag)
	usage(0);
    if(version_flag) {
	print_version(NULL);
	exit(0);
    }

    ret = krb5_init_context(&context);
    if (ret)
	errx (1, "krb5_init_context failed: %d", ret);

    setup_signal();

    if (config_file == NULL) {
	if (asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context)) == -1
	    || config_file == NULL)
	    errx(1, "out of memory");
    }

    ret = krb5_prepend_config_files_default(config_file, &files);
    if (ret)
	krb5_err(context, 1, ret, "getting configuration files");

    ret = krb5_set_config_files(context, files);
    krb5_free_config_files(files);
    if (ret)
	krb5_err(context, 1, ret, "reading configuration files");

    argc -= optidx;
    argv += optidx;

    if (argc != 1)
	usage(1);

    master = argv[0];

    if (status_file == NULL) {
	if (asprintf(&status_file,  "%s/ipropd-slave-status", hdb_db_dir(context)) < 0 || status_file == NULL)
	    krb5_errx(context, 1, "can't allocate status file buffer"); 
    }

#ifdef SUPPORT_DETACH
    if (detach_from_console){
	int aret = daemon(0, 0);
	if (aret == -1) {
	    /* not much to do if detaching fails... */
	    krb5_err(context, 1, aret, "failed to daemon(3)ise");
	}
    }
#endif
    pidfile (NULL);
    krb5_openlog (context, "ipropd-slave", &log_facility);
    krb5_set_warn_dest(context, log_facility);

    slave_status(context, status_file, "bootstrapping");

    ret = krb5_kt_register(context, &hdb_kt_ops);
    if(ret)
	krb5_err(context, 1, ret, "krb5_kt_register");

    time_before_lost = parse_time (server_time_lost,  "s");
    if (time_before_lost < 0)
	krb5_errx (context, 1, "couldn't parse time: %s", server_time_lost);

    slave_status(context, status_file, "getting credentials from keytab/database");

    memset(&conf, 0, sizeof(conf));
    if(realm) {
	conf.mask |= KADM5_CONFIG_REALM;
	conf.realm = realm;
    }
    ret = kadm5_init_with_password_ctx (context,
					KADM5_ADMIN_SERVICE,
//.........这里部分代码省略.........
开发者ID:hyc,项目名称:heimdal,代码行数:101,代码来源:ipropd_slave.c


示例12: parse_line

static void
parse_line(GSList    **cookies_p,
           const char *line,
           const char *end,
           const char *domain_filter,
           int         port_filter,
           const char *name_filter,
           HippoBrowserKind browser)
{
    const char *p;
    const char *start;
    int field;
    Field fields[N_FIELDS];
    
    // see if it's an empty or comment line
    if (is_empty_line(line, end))
        return;
        
    for (field = 0; field < N_FIELDS; ++field) {
        fields[field].which = field;
        fields[field].text = NULL;
    }
    
    start = line;
    field = 0;
    for (p = line; p <= end; ++p) {
        g_assert(p >= start);
        if (*p == '\t' || p == end) {
            
            if (field >= N_FIELDS) {
                // too many fields on this line, give up
                goto out;
            }
            
            fields[field].text = g_strndup(start, p - start);
            
            start = p + 1;
            ++field;
        }
    }
    
    /* ATTR_VALUE is optional, the other fields are not */
    for (field = 0; field < N_FIELDS; ++field) {
        if (field != ATTR_VALUE && fields[field].text == NULL)
            goto out;
    }    
    
    {
        char *domain;
        int port;
        gboolean all_hosts_match;
        gboolean secure_connection_required;
        GTime timestamp;

        if (!parse_bool(fields[DOMAIN_FLAG].text, &all_hosts_match))
            goto out;
            
        if (!parse_bool(fields[SECURE_FLAG].text, &secure_connection_required))
            goto out;
            
        if (!parse_time(fields[TIMESTAMP].text, &timestamp))
            goto out;

        if (!parse_domain(fields[DOMAIN].text, &domain, &port))
            goto out;
        
        if ((domain_filter == NULL || strcmp(domain_filter, domain) == 0) &&
            (port_filter < 0 || port_filter == port) &&
            (name_filter == NULL || strcmp(name_filter, fields[ATTR_NAME].text) == 0)) {
            HippoCookie *cookie;
            cookie = hippo_cookie_new(browser,
                                      domain, port, all_hosts_match,
                                      fields[PATH].text,
                                      secure_connection_required, timestamp,
                                      fields[ATTR_NAME].text,
                                      fields[ATTR_VALUE].text);
            *cookies_p = g_slist_prepend(*cookies_p, cookie);
        }
                                  
        g_free(domain);
    }
                        
  out:
    for (field = 0; field < N_FIELDS; ++field) {
        g_free(fields[field].text);
    }    
}
开发者ID:manoj-makkuboy,项目名称:magnetism,代码行数:87,代码来源:hippo-cookies.c


示例13: ccache_init_system

static krb5_error_code
ccache_init_system(void)
{
    kcm_ccache ccache;
    krb5_error_code ret;

    if (system_cache_name == NULL)
	system_cache_name = kcm_system_config_get_string("cc_name");

    ret = kcm_ccache_new(kcm_context,
			 system_cache_name ? system_cache_name : "SYSTEM",
			 &ccache);
    if (ret)
	return ret;

    ccache->flags |= KCM_FLAGS_OWNER_IS_SYSTEM;
    ccache->flags |= KCM_FLAGS_USE_KEYTAB;

    ret = parse_owners(ccache);
    if (ret)
	return ret;

    ret = krb5_parse_name(kcm_context, system_principal, &ccache->client);
    if (ret) {
	kcm_release_ccache(kcm_context, ccache);
	return ret;
    }

    if (system_server == NULL)
	system_server = kcm_system_config_get_string("server");

    if (system_server != NULL) {
	ret = krb5_parse_name(kcm_context, system_server, &ccache->server);
	if (ret) {
	    kcm_release_ccache(kcm_context, ccache);
	    return ret;
	}
    }

    if (system_keytab == NULL)
	system_keytab = kcm_system_config_get_string("keytab_name");

    if (system_keytab != NULL) {
	ret = krb5_kt_resolve(kcm_context, system_keytab, &ccache->key.keytab);
    } else {
	ret = krb5_kt_default(kcm_context, &ccache->key.keytab);
    }
    if (ret) {
	kcm_release_ccache(kcm_context, ccache);
	return ret;
    }

    if (renew_life == NULL)
	renew_life = kcm_system_config_get_string("renew_life");

    if (renew_life == NULL)
	renew_life = "1 month";

    if (renew_life != NULL) {
	ccache->renew_life = parse_time(renew_life, "s");
	if (ccache->renew_life < 0) {
	    kcm_release_ccache(kcm_context, ccache);
	    return EINVAL;
	}
    }

    if (ticket_life == NULL)
	ticket_life = kcm_system_config_get_string("ticket_life");

    if (ticket_life != NULL) {
	ccache->tkt_life = parse_time(ticket_life, "s");
	if (ccache->tkt_life < 0) {
	    kcm_release_ccache(kcm_context, ccache);
	    return EINVAL;
	}
    }

    if (system_perms == NULL)
	system_perms = kcm_system_config_get_string("mode");

    if (system_perms != NULL) {
	int mode;

	if (sscanf(system_perms, "%o", &mode) != 1)
	    return EINVAL;

	ccache->mode = mode;
    }

    if (disallow_getting_krbtgt == -1) {
	disallow_getting_krbtgt =
	    krb5_config_get_bool_default(kcm_context, NULL, FALSE, "kcm",
					 "disallow-getting-krbtgt", NULL);
    }

    /* enqueue default actions for credentials cache */
    ret = kcm_ccache_enqueue_default(kcm_context, ccache, NULL);

    kcm_release_ccache(kcm_context, ccache); /* retained by event queue */

//.........这里部分代码省略.........
开发者ID:tombibsd,项目名称:netbsd-src,代码行数:101,代码来源:config.c


示例14: parse_rule_line

static void
parse_rule_line(ParsingData	*data)
{
    GArray *rule_array;
    RuleData rule;
    char *name;
    TimeCode time_code;

    /* All 10 fields must be present. */
    if(data->num_fields != 10)
    {
        fprintf(stderr, "%s:%i: Invalid Rule line - %i fields.\n%s\n",
                data->filename, data->line_number, data->num_fields,
                data->line);
        exit(1);
    }

    name = data->fields[RULE_NAME];

    /* Create the GArray and add it to the hash table if it doesn't already
       exist. */
    rule_array = g_hash_table_lookup(data->rule_data, name);
    if(!rule_array)
    {
        rule_array = g_array_new(FALSE, FALSE, sizeof(RuleData));
        g_hash_table_insert(data->rule_data, g_strdup(name), rule_array);
    }

    rule.from_year = parse_year(data, data->fields[RULE_FROM], FALSE, 0);
    if(rule.from_year == YEAR_MAXIMUM)
    {
        fprintf(stderr, "%s:%i: Invalid Rule FROM value: '%s'\n",
                data->filename, data->line_number, data->fields[RULE_FROM]);
        exit(1);
    }

    rule.to_year = parse_year(data, data->fields[RULE_TO], TRUE,
                              rule.from_year);
    if(rule.to_year == YEAR_MINIMUM)
    {
        fprintf(stderr, "%s:%i: Invalid Rule TO value: %s\n",
                data->filename, data->line_number, data->fields[RULE_TO]);
        exit(1);
    }

    if(!strcmp(data->fields[RULE_TYPE], "-"))
        rule.type = NULL;
    else
    {
        printf("Type: %s\n", data->fields[RULE_TYPE]);
        rule.type = g_strdup(data->fields[RULE_TYPE]);
    }

    rule.in_month = parse_month(data, data->fields[RULE_IN]);
    rule.on_day_code = parse_day(data, data->fields[RULE_ON],
                                 &rule.on_day_number, &rule.on_day_weekday);
    rule.at_time_seconds = parse_time(data, data->fields[RULE_AT],
                                      &rule.at_time_code);
    rule.save_seconds = parse_time(data, data->fields[RULE_SAVE], &time_code);

    if(!strcmp(data->fields[RULE_LETTER_S], "-"))
    {
        rule.letter_s = NULL;
    }
    else
    {
        rule.letter_s = g_strdup(data->fields[RULE_LETTER_S]);
    }

    rule.is_shallow_copy = FALSE;

    g_array_append_val(rule_array, rule);
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:73,代码来源:vzic-parse.c


示例15: parse_options

void parse_options(int argc, char **argv)
{
    int opt;

    if (argc < 2) {
        usage();
        exit(1);
    }

    while ((opt = getopt(argc, argv, "hvkALRDCWBqi:w:s:S:c:o:p:P:")) != -1) {
        switch (opt) {
        case 'h':
            usage();
            exit(0);
        case 'v':
            version();
            exit(0);
        case 'L':
            randomize = 0;
            default_size = 1<<18;
            break;
        case 'R':
            interval = 0;
            deadline = 3000000;
            temp_wsize = 1<<26;
            quiet = 1;
            break;
        case 'D':
            direct = 1;
            break;
        case 'C':
            cached = 1;
            break;
        case 'A':
            async = 1;
            break;
        case 'W':
            write_test++;
            break;
        case 'i':
            interval = parse_time(optarg);
            break;
        case 'w':
            deadline = parse_time(optarg);
            break;
        case 's':
            size = parse_size(optarg);
            break;
        case 'S':
            wsize = parse_offset(optarg);
            break;
        case 'o':
            offset = parse_offset(optarg);
            break;
        case 'p':
            period_request = parse_int(optarg);
            break;
        case 'P':
            period_time = parse_time(optarg);
            break;
        case 'q':
            quiet = 1;
            break;
        case 'B':
            quiet = 1;
            batch_mode = 1;
            break;
        case 'c':
            stop_at_request = parse_int(optarg);
            break;
        case 'k':
            keep_file = 1;
            break;
        case '?':
            usage();
            exit(1);
        }
    }

    if (optind > argc-1)
        errx(1, "no destination specified");
    if (optind < argc-1)
        errx(1, "more than one destination specified");
    path = argv[optind];
}
开发者ID:yksuh,项目名称:ioping,代码行数:85,代码来源:ioping.c


示例16: get_new_tickets


//.........这里部分代码省略.........
	krb5_get_init_creds_opt_set_pac_request(context, opt,
						pac_flag ? TRUE : FALSE);
    if (canonicalize_flag)
	krb5_get_init_creds_opt_set_canonicalize(context, opt, TRUE);
    if (pk_enterprise_flag || enterprise_flag || canonicalize_flag || windows_flag)
	krb5_get_init_creds_opt_set_win2k(context, opt, TRUE);
    if (pk_user_id || ent_user_id || anonymous_flag) {
	ret = krb5_get_init_creds_opt_set_pkinit(context, opt,
						 principal,
						 pk_user_id,
						 pk_x509_anchors,
						 NULL,
						 NULL,
						 pk_use_enckey ? 2 : 0 |
						 anonymous_flag ? 4 : 0,
						 krb5_prompter_posix,
						 NULL,
						 passwd);
	if (ret)
	    krb5_err(context, 1, ret, "krb5_get_init_creds_opt_set_pkinit");
	if (ent_user_id)
	    krb5_get_init_creds_opt_set_pkinit_user_certs(context, opt, ent_user_id);
    }

    if (addrs_flag != -1)
	krb5_get_init_creds_opt_set_addressless(context, opt,
						addrs_flag ? FALSE : TRUE);

    if (renew_life == NULL && renewable_flag)
	renewstr = "1 month";
    if (renew_life)
	renewstr = renew_life;
    if (renewstr) {
	renew = parse_time (renewstr, "s");
	if (renew < 0)
	    errx (1, "unparsable time: %s", renewstr);

	krb5_get_init_creds_opt_set_renew_life (opt, renew);
    }

    if(ticket_life != 0)
	krb5_get_init_creds_opt_set_tkt_life (opt, ticket_life);

    if(start_str) {
	int tmp = parse_time (start_str, "s");
	if (tmp < 0)
	    errx (1, N_("unparsable time: %s", ""), start_str);

	start_time = tmp;
    }

    if(etype_str.num_strings) {
	int i;

	enctype = malloc(etype_str.num_strings * sizeof(*enctype));
	if(enctype == NULL)
	    errx(1, "out of memory");
	for(i = 0; i < etype_str.num_strings; i++) {
	    ret = krb5_string_to_enctype(context,
					 etype_str.strings[i],
					 &enctype[i]);
	    if(ret)
		errx(1, "unrecognized enctype: %s", etype_str.strings[i]);
	}
	krb5_get_init_creds_opt_set_etype_list(opt, enctype,
					       etype_str.num_strings);
开发者ID:lha,项目名称:heimdal,代码行数:67,代码来源:kinit.c


示例17: calculate_midexposure

/*=====================================*/
void
calculate_midexposure(FITSFILE *f, int *year, int *month, int *day,
		      int *hour, int *minute, float *second)

{
  int h, m, h2, m2;
  float s, s2;
  double d1 = 0.0, d2 = 0.0;

  /*  If the DATE-OBS keyword is present, set the date  */
  if (f->is_date_obs) {
    parse_date(f->date_obs, year, month, day);
  }
  else {
    /*  Set date to a default  */
    *year = 2000;
    *month = 1;
    *day = 1;
  }

  /*  For the time od midexposure, first try the easy way: check if */
  /*  UT-CENT keyword is present  */
  if (f->is_ut_cent) {
    parse_time(f->ut_cent, hour, minute, second);
    /* Now, check if a correction of date is needed  */
    if (f->is_ut_start) {
      /*  Read start of exposure  */
      parse_time(f->ut_start, &h, &m, &s);
      if (h > *hour) {
	/* exposure is over midnight, adjust the date */
	incr_date(year, month, day);
      }
    }
    else {
      if (f->is_exposure) {  /*  This situation is already weird:  */
				/*  there is UT-CENT but no UT-START  */
	/*  Nevertheless, we happen to have the EXPOSURE keyword  */
	/*  Convert UT-CENT to seconds and subtract half of exposure  */
	d1 = (double) *hour + (double) *minute / 60.0 + *second / 3600.0 - 
	  f->exposure / 7200.0;
	if (d1 > 0) {  /* Increment date for one day  */
	  incr_date(year, month, day);
	}
      }
    }
  }
  else if (f->is_ut_start) {
    /*  There is no UT-CENT keyword, so we have to calculate it by our own  */
    /*  Fi 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parse_to函数代码示例发布时间:2022-05-30
下一篇:
C++ parse_tag函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap