Пример #1
0
void tab_print(int tab[], int size, int dir)
{
	static int act=0;
	if(act>=size||act<0)
	{
		return;
	};
	int current=dir>=0?act:size-act-1;
	printf("tab[%d]=%d\n",current,tab[current]);
	act++;
	tab_print(tab,size,dir);
};
Пример #2
0
static inline void json_print(JSONNode * node, unsigned int tab)
{
    const char *name = json_node_get_name(node);
    if (name == NULL) {
        name = "NULL";
    }
    tab_print(tab);
    if (json_node_is_string(node)) {
        printf("%s=%s\n", name, json_string_get(node));
    } else if (json_node_is_false(node)) {
        printf("%s=FALSE\n", name);
    } else if (json_node_is_true(node)) {
        printf("%s=TRUE\n", name);
    } else if (json_node_is_int(node)) {
        printf("%s=%ld\n", name, json_int_get(node));
    } else if (json_node_is_float(node)) {
        printf("%s=%g\n", name, json_float_get(node));
    } else if (json_node_is_object(node) || json_node_is_array(node)) {
        JList *children = json_node_get_children(node);
        if (json_node_is_array(node)) {
            printf("%s=[\n", name);
        } else {
            printf("%s={\n", name);
        }
        while (children) {
            JSONNode *child = (JSONNode *) j_list_data(children);
            json_print(child, tab + 1);
            children = j_list_next(children);
        }
        tab_print(tab);
        if (json_node_is_array(node)) {
            printf("]\n");
        } else {
            printf("}\n");
        }
    } else {
        printf("%s=NULL\n", name);
    }
}
Пример #3
0
int main()
{
	srand(time(NULL));
	const int SIZE=10;
	int tab[SIZE];
	int x=0;
	for(x=0;x<SIZE;x++)
	{
		tab[x]=rand()%24+34;
//		printf("%d\n",tab[x]);
	};
	for(x=0;x<SIZE;x++)
	{
		printf("tab[%d]=%d\n",x,tab[x]);
	};
	printf("rekurencyjnie: \n");
	tab_print(tab,SIZE,1);
	return 0;
};
Пример #4
0
static void load_crontabs(void)
/* Load all the crontabs we like to run.  We didn't bother to make a list in
 * an array or something, this is too system specific to make nice.
 */
{
	DIR *spool;
#if __minix_vmd
	FILE *pkgs;
#endif

	tab_parse("/usr/lib/crontab", nil);
	tab_parse("/usr/local/lib/crontab", nil);
	tab_parse("/var/lib/crontab", nil);

#if __minix_vmd
	if ((pkgs= fopen("/usr/lib/packages", "r")) != nil) {
		char name[NAME_MAX+1];
		char *np;
		int c;
		char tab[sizeof("/var/opt//lib/crontab") + NAME_MAX];

		while ((c= fgetc(pkgs)) != EOF) {
			np= name;
			while (c != EOF && c != '/' && c != '\n') {
				if (np < name+NAME_MAX) *np++ = c;
				c= fgetc(pkgs);
			}
			*np= 0;
			while (c != EOF && c != '\n') c= fgetc(pkgs);

			if (name[0] == 0) continue;	/* ? */

			strcpy(tab, "/var/opt/");
			strcat(tab, name);
			strcat(tab, "/lib/crontab");
			tab_parse(tab, nil);
		}
		if (ferror(pkgs)) {
			log(LOG_CRIT, "/usr/lib/packages: %s\n",
							strerror(errno));
		}
		fclose(pkgs);
	} else {
		if (errno != ENOENT) {
			log(LOG_ERR, "/usr/lib/packages: %s\n",
							strerror(errno));
		}
	}
#endif /* Minix-vmd */

	if ((spool= opendir("/usr/spool/crontabs")) != nil) {
		struct dirent *entry;
		char tab[sizeof("/usr/spool/crontabs/") + NAME_MAX];

		while ((entry= readdir(spool)) != nil) {
			if (entry->d_name[0] == '.') continue;

			strcpy(tab, "/usr/spool/crontabs/");
			strcat(tab, entry->d_name);
			tab_parse(tab, entry->d_name);
		}
		closedir(spool);
	}

	/* Find the first to be executed AT job. */
	tab_find_atjob("/usr/spool/at");

	tab_purge();
	if (debug >= 2) {
		tab_print(stderr);
		fprintf(stderr, "%lu memory chunks in use\n",
			(unsigned long) alloc_count);
	}
}