Example #1
0
bool NOSAPI_init() {
#define setapi(x) {\
    extern NOSAPI_t N_OSAPI_##x;\
    N_OSAPI = N_OSAPI_##x;\
    Ndebug("Detected "#x);\
}
#if defined(NPORTING_LINUX)
    setapi(Linux);
#elif defined(NPORTING_WINDOWS)
    setapi(Windows);
#else
    Nerror("Failed to detect your OS!");
    return false;
#endif

    return N_OSAPI.init();
}
Example #2
0
bool WL_init() {
    _WL_display.running = true;

    // Initialize wayland
    _WL_display.display = wl_display_connect(NULL);

    if (!_WL_display.display) {
        Nerror("Can't connect to display (WL)");
        return false;
    }

    // Initialize events
    NWMan_events_init();

    // Initialize registry
    _WL_display.registry = wl_display_get_registry(_WL_display.display);
    wl_registry_add_listener(_WL_display.registry, &_WL_registry_listener, NULL);

    // Sync
    wl_display_dispatch(_WL_display.display);

    return true;
}
Example #3
0
File: init.c Project: LinuxCSA/CSA
/*
 *	init_irix() - initialize the IRIX format argument list.
 */
static	int
init_irix(int argc, char **argv)
{
	int	c;
	char	*optstring = "a:D:g:j:p:u:M:n:cdefhJlmorst";

	/*  Process options. */
	while ((c = getopt(argc, argv, optstring)) != EOF) {
		switch (c) {

	 	/*  Process the report selection options. */
		case 'c':		/* command report */
			c_opt++;
			break;
		case 'f':		/* command flow report */
			f_opt++;
			break;
		case 'o':		/* other command report */
			o_opt++;
			break;
		case 's':		/* summary report */
			s_opt++;
			break;

	 	/*  Process the record selection options. */
		case 'a':		/* select by array session ID */
			a_opt++;
			sscanf(optarg, "%llx", &s_ash);
			break;

		case 'g':		/* select by group ID */
			g_opt++;
			if (optarg[0] >= '0' && optarg[0] <= '9') {
				sscanf(optarg, "%d", &s_gid);

			} else {	/* ASCII */
				if ((s_gid = name_to_gid(optarg)) == -1) {
					acct_err(ACCT_ABORT,
					       _("An unknown Group name '%s' was given on the -g parameter."),
						optarg);
				}
			}
			break;

		case 'j':		/* select by job ID */
			j_opt++;
			sscanf(optarg, "%llx", &s_jid);
			break;

		case 'M':			/* select by positioning */
			M_opt++;
			if ((M_optargc = getoptlst(optarg, &M_optargv))
					== -1) {
				acct_err(ACCT_ABORT,
				       _("An error was returned from routine '%s' for the (-%s) option '%s'."),
					"getoptlst()",
					"M", optarg);
			}
			break;

		case 'n':		/* select by command names */
			n_opt++;
			if ((n_optargc = getoptlst(optarg, &n_optargv))
					== -1) {
				acct_err(ACCT_ABORT,
				       _("An error was returned from routine '%s' for the (-%s) option '%s'."),
					"getoptlst()",
					"n", optarg);
			}
			names = getnames(n_optargc, n_optargv);
			free(n_optargv);
			break;

		case 'p':		/* select by project ID */
			p_opt++;
			if (optarg[0] >= '0' && optarg[0] <= '9') {
				sscanf(optarg, "%lld", &s_prid);

			} else {	/* ASCII */
				if ((s_prid = name_to_prid(optarg)) == -1) {
					acct_err(ACCT_ABORT,
					       _("An unknown Project name '%s' was given on the -p parameter."),
						optarg);
				}
			}
			break;

		case 'u':		/* select by user ID */
			u_opt++;
			if (optarg[0] >= '0' && optarg[0] <= '9') {
				sscanf(optarg, "%d", &s_uid); /* numeric */

			} else {	/* ASCII */
				if ((s_uid = name_to_uid(optarg)) == -1) {
					acct_err(ACCT_ABORT,
					       _("An unknown User name '%s' was given on the -u parameter."),
						optarg);
				}
			}
			break;

	 	/*  Process the report modification options. */
		case 'd':		/* daemon report */
			d_opt++;
			break;
		case 'e':		/* extended summary report */
			e_opt++;
			break;
		case 'h':		/* hiwater report */
			h_opt++;
			break;
		case 'J':
			J_opt++;	/* select all special pacct */
			break;
		case 'l':		/* long report (-{B c f} only) */
			l_opt++;
			break;

	 	/*  Process the remaining options. */
		case 'D':		/* debug option */
			D_opt++;
			db_flag = atoi(optarg);
			if ((db_flag < 1) || (db_flag > 4)) {
				acct_err(ACCT_FATAL,
				       _("The (-%s) option's argument, '%s', is invalid."),
					"D", optarg);
				Nerror("Option -D valid values are 1 to 4\n");
				usage();
			}
			Ndebug("Debugging option set to level %d\n", db_flag);
			break;
		case 'm':		/* mark position */
			m_opt++;
			break;
		case 'r':		/* raw mode */
			r_opt++;
			break;
		case 't':		/* terminate job accounting */
			t_opt++;
			break;

		default:
			usage();
		}
	}

	/*  Verify the selected options - must be used with report options. */
	if (!c_opt && !f_opt && !o_opt && !s_opt){
		if (a_opt) {
		    acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			 "a", "{c f o s}");
		}
		if (g_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "g", "{c f o s}");
                }
		if (j_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "j", "{c f o s}");
                }
		if (n_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "n", "{c f o s}");
                }
		if (p_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "p", "{c f o s}");
                }
		if (u_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "u", "{c f o s}");
                }
		if (d_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "d", "{c f o s}");
                }
		if (r_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "r", "{c f o s}");
                }

	/*  and -m is NOT used with the report options. */
	} else if (m_opt) {
	    acct_err(ACCT_ABORT,
		_("The (-%s) option cannot be selected when issuing a report."),
			"m");
	}

	/*  Insure -m is NOT with t. */
	if (t_opt && m_opt) {
		acct_err(ACCT_ABORT,
		   _("The (-%s) and the (-%s) options are mutually exclusive."),
			"m", "t");
	}

	/*  Insure -o is NOT with c. */
	if (o_opt && c_opt) {
		acct_err(ACCT_ABORT,
		   _("The (-%s) and the (-%s) options are mutually exclusive."),
			"o", "c");
	}

	/*  Insure -e is with {s}. */
	if (e_opt && !(s_opt) ) {
		acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			"e", "s");
	}

	/*  Insure -h is with l and c. */
	if (h_opt && !(c_opt && l_opt)) {
		acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			"h", "c and l");
	}

	/*  Insure -l is with -{ c f} */
	if (l_opt && !(c_opt || f_opt)) {
		acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			"l", "{c f}");
	}

	/*  Insure -M is with -{c}. */
	if (M_opt && !c_opt) {
		acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			"M", "c");
	}

	return(0);
}
Example #4
0
/*
 *	process_wm() - process workload management daemon record.
 */
int process_wm(int fd, int findex)
{
	static	int	tso_flag = 0;
	static	time_t	lasttime = 0;
	time_t	btime;

/*
 *	Check the record time information against the uptime info.
 */
	btime = acctent.wmbs->time;
	if (lasttime) {
		if (lasttime > btime) {
			/*
			 *	If time stamps are out of order, keep on going.
			 *	Assume that the records belong in the current
			 *	or later up periods.
			 */
			if (!tso_flag) {
				tso_flag++;
				acct_err(ACCT_WARN,
				  _("The %s records were out of time order in file '%s%d'\n   near offset %lld due to a date change or an invalid file."),
					 "workload management", pacct,
					 findex, Pacct_offset);
			}
		}
	} else {
		if (btime < uptime[0].up_start) {
		    if (btime < EARLY_FUDGE) {
			char btime_str[26];
			time_t	time = EARLY_FUDGE;

			strcpy(btime_str, ctime(&btime));
			Nerror("REC_WKMG: EARLY_FUDGE error (%d - %24.24s) ",
			       btime, btime_str);
			Nerror("< (%d - %24.24s)\n", time, ctime(&time));

			acct_err(ACCT_WARN,
				_("An earlier than expected time stamp was discovered in the file '%s%d' near offset (%lld).  Examine the data set."),
				pacct, findex, Pacct_offset);
			if (i_opt) {
				acct_err(ACCT_INFO,
					_("The record was ignored."));
				if (db_flag > 2) {
					Dump_rec(acctent.wmbs,
						 sizeof(struct wkmgmtbs));
				}
				return(RC_BAD);
			}
		    }
		    if (upind != 0) {
				if (db_flag > 2) {
					Dump_rec(acctent.wmbs,
						 sizeof(struct wkmgmtbs));
				}
				acct_err(ACCT_ABORT,
				  _("An earlier than expected time stamp was discovered in the file '%s%d' near offset (%lld).  Examine the data set."),
					 pacct, findex, Pacct_offset);
		    } else {
				Shift_uptime(REC_WKMG, pacct, findex);
		    }
		}
	}

	lasttime = btime;
	while (uptime[upind].up_stop < btime) {
		if (db_flag > 3) {
			Ndebug("process_wm(4): Past stop time(%d) going to "
			       "next workload management uptime(%d) - %s%d.\n",
			       uptime[upind].up_stop, upind+1, pacct, findex);
		}
		upind++;
		if (upind > upIndex) {
			break;
		}
	}
	cur_findex = findex;

/*
 *	Process the workload management records - consolidate all associated
 *	data.  Since there aren't valid jids in some of the workload
 *	management daemon records, don't attach the consolidated record to a
 *	segment now.  This will be done later by a call to add_segs_wm() after
 *	all of the pacct records have been processed.  The workload management
 *	consolidated records at that time have accurate information.
 */
	prc_wm(acctent.wmbs);

	return(RC_GOOD);
}
Example #5
0
/*
 *	main() - main program including parameter processing and main loop.
 */
main(int argc, char **argv)
{
	char		ch;
	int		c;
	extern char	*optarg;

	Prg_name = argv[0];
	while((c = getopt(argc, argv, "AD:P:Rrs:")) != EOF) {
		ch = (char)c;

		switch(ch) {

		case 'A':		/* ask option */
			r_opt = A_opt = TRUE;
			break;

		case 'D':		/* debug level option */
			db_flag = atoi(optarg);
			if ((db_flag < 0) || (db_flag > 2)) {
				acct_err(ACCT_FATAL,
				       _("The (-%s) option's argument, '%s', is invalid."),
					"D", optarg);
				Nerror("Option -D valid values are 1 and 2\n");
				usage();
			}
				
			setvbuf(stderr, NULL, _IONBF, 0);
			Ndebug("Debugging option set to level %d.\n", db_flag);
			break;
		case 'P':
			pacct0 = optarg;
			break;

		case 'R':		/* report, no recycle option */
			R_opt = 1;
		case 'r':		/* report option */
			r_opt = 1;
			break;

		case 's':		/* sorted pacct file */
			spacct = optarg;
			break;

		default:
			acct_err(ACCT_FATAL,
			       _("An unknown option '%c' was specified."),
				optopt);
			usage();

		}		/* end of switch(ch) */
	}		/* end of while(getopt) */

	if  (A_opt) {
		FILE *in = stdin;               /* input file */
		int	iactive;

		iactive = isatty(fileno(in));
		if  (!iactive) {
			acct_err(ACCT_WARN,
			       _("The (-%s) option is only valid in interactive mode."),
				"A");
		}

		if (R_opt) {
			acct_err(ACCT_FATAL,
			       _("The (-%s) and the (-%s) options are mutually exclusive."),
				"A", "R");
			usage();
		}
	}

	strcpy(path, pacct0);
	strcat(path, "0");	
	pacct0 = path;

	/*  Open the accounting files. */
	if (db_flag > 0) {
		Ndebug("main(1): Open accounting files.\n");
	}

	if ((sfd = openacct(spacct, "r")) < 0) {
		acct_perr(ACCT_ABORT, errno,
			_("An error occurred during the opening of file '%s'."),
			spacct);
	}

	if ((pfd0 = openacct(pacct0, "w")) < 0) {
		acct_perr(ACCT_ABORT, errno,
			_("An error occurred during the opening of file '%s'."),
			pacct0);
	}

	/*  Process the spacct file. */
	get_uptimes();
	scan_spacct();

	closeacct(pfd0);

	if (db_flag > 0) {
		fprintf(stdout, " file '%s' uptimes (%d), jobs(%d)\n",
			spacct, total_uptimes, total_jobs);
		fprintf(stdout, " file '%s' uptimes (%d), jobs(%d)\n",
			pacct0, saved_uptimes, saved_jobs);
	}

	exit(0);
}