Beispiel #1
0
void comhandle()
{
	serial_println("");
	serial_println("Welcome to the MPX OS.");
	serial_println("Feel free to begin entering commands.");
	serial_println("");
	while(1) {
		char *command = polling();
		if (!strcmpigncase(command, "Shutdown")) {
			if (shutdownConfirmed()) {
				serial_println("System shutting down...");
				break;
			} else {
				serial_println("Shutdown canceled.");
			}
		} else if (!strcmpigncase(command, "Version")) {
			version();
		} else if (!strcmpigncase(command, "Help")) {
			help();
		} else if (!strcmpigncase(command, "Setdate")) {
			setdate();
		} else if (!strcmpigncase(command, "Getdate")) {
			getdate();
		} else if (!strcmpigncase(command, "Settime")) {
			settime();
		} else if (!strcmpigncase(command, "Gettime")) {
			gettime();
		}
	}
}
Beispiel #2
0
/* settimestamp(seconds1970) sets the date and time from a single parameter: the
 * number of seconds since 1 January 1970.
 */
static cell AMX_NATIVE_CALL n_settimestamp(AMX *amx, const cell *params)
{
  #if defined __WIN32__ || defined _WIN32 || defined WIN32
    int year, month, day, hour, minute, second;

    stamp2datetime(params[1],
                   &year, &month, &day,
                   &hour, &minute, &second);
    setdate(year, month, day);
    settime(hour, minute, second);
  #else
    /* Linux/Unix (and some DOS compilers) have stime(); on Linux/Unix, you
     * must have "root" permission to call stime(); many POSIX systems will
     * have settimeofday() instead
     */
    #if defined __APPLE__ /* also valid for other POSIX systems */
      struct timeval tv;
      tv.tv_sec = params[1];
      tv.tv_usec = 0;
      settimeofday(&tv, 0);
    #else
      time_t sec1970=(time_t)params[1];
      stime(&sec1970);
    #endif
  #endif
  (void)amx;

  return 0;
}
Beispiel #3
0
const char* FIX="c:\date.fix";



void main()
{
	cout << endl << "Restoring date . . .";
	date restore;
	int handle=open(FIX,O_RDONLY | O_BINARY,S_IREAD),y,m,d;
	lseek(handle,0,SEEK_SET);


	read(handle,&y,2);
	read(handle,&m,2);
	read(handle,&d,2);

	close(handle);

	restore.da_year=y;
	restore.da_mon=m;
	restore.da_day=d;



	cout  << endl << "Date is now : "
			<< y << "/"
			<< m << "/"
			<< d;

	setdate(&restore);

}
Beispiel #4
0
int fb_hSetDate( int y, int m, int d )
{
    struct date dt;
    dt.da_year = y;
    dt.da_mon = m;
    dt.da_day = d;
    setdate(&dt);
    return 0;
}
Beispiel #5
0
void main()
{
	DATE p;

	p.da_year = 1991;
	p.da_mon = 8;
	p.da_day = 7;
	setdate (&p);
	printf ("Oprima una tecla...\n");
	getch();
}
Beispiel #6
0
void comhandle()
{
	serial_println("");
	serial_println("Welcome to the MPX OS.");
	serial_println("Feel free to begin entering commands.");
	serial_println("");
	while(1) {
		char *command = polling();
		if (!strcmpigncase(command, "shutdown")) {
			if (shutdownConfirmed()) {
				serial_println("System shutting down...");
				clearAllQueues();
				break;
			} else {
				serial_println("Shutdown canceled.");
			}
		} else if (!strcmpigncase(command, "version")) {
			version();
		} else if (!strcmpigncase(command, "help")) {
			help();
		} else if (!strcmpigncase(command, "setdate")) {
			setdate();
		} else if (!strcmpigncase(command, "getdate")) {
			getdate();
		} else if (!strcmpigncase(command, "settime")) {
			settime();
		} else if (!strcmpigncase(command, "gettime")) {
			gettime();
		} else if (!strcmpigncase(command, "suspend")) {
			suspendPCB();
		} else if (!strcmpigncase(command, "resume")) {
			resumePCB();
		} else if (!strcmpigncase(command, "setpriority")) {
			setPriority();
		} else if (!strcmpigncase(command, "showPCB")) {
		        showPCB();
		} else if (!strcmpigncase(command, "showReady")) {
		        showReady();
		} else if (!strcmpigncase(command, "showBlocked")) {
		        showBlocked();
		} else if (!strcmpigncase(command, "showAll")) {
		        showAll();
		} else if (!strcmpigncase(command, "yield")) {
		        asm volatile ("int $60");
		        serial_println("");
		} else if (!strcmpigncase(command, "loadr3")) {
		        loadR3();
		} else if (strcmp(command, '\0')) {
			serial_println("Command not recognized. Type help to view commands.");
			serial_println("");
		}
		sys_free_mem(command);
	}
Beispiel #7
0
void
timeproc(void *dummy)
{
	for(;;){
		lockdisplay(display);
		drawtime();
		updatetimes();
		flushimage(display, 1);
		unlockdisplay(display);
		sleep(60000);
		setdate();
	}
}
Beispiel #8
0
void
timeproc(void)
{
	for(;;){
		lockdisplay(display);
		drawtime();
		updatetimes();
		flushimage(display, 1);
		unlockdisplay(display);
		now = time(nil);
		sleep(((60 - now%60) + 1)*1000); /* wait for minute to change */
		setdate();
	}
}
Beispiel #9
0
void main(int argsused, char *args[])
{
	if(argsused==5)
	{
		date now,change;
		getdate(&now);
		int y,m,d,handle,year,month,day;

		change.da_year=atoi(args[2]);
		change.da_mon=atoi(args[3]);
		change.da_day=atoi(args[4]);




		cout 	<< endl << "Current date is (Y/M/D): "
				<< now.da_year << "/"
				<< int(now.da_mon) << "/"
				<< int(now.da_day);

		handle=open(FIX,O_CREAT | O_BINARY | O_TRUNC,S_IREAD | S_IWRITE);
		lseek(handle,0,SEEK_SET);

		y=now.da_year;
		m=now.da_mon;
		d=now.da_day;


		write(handle,&y,2);
		write(handle,&m,2);
		write(handle,&d,2);

		close(handle);

		cout 	<< endl << "Changing date to (Y/M/D):"
				<< change.da_year << "/"
				<< int(change.da_mon) << "/"
				<< int(change.da_day);

		setdate(&change);

		cout << endl << "Executing program:        " << args[1];
		execl(args[1],"");

		execl(RESTORE_LOC,"");

	}
	else cout << endl << "Not enough Parameters";
}
Beispiel #10
0
void main()
{
   struct date d,reset;
   getdate(&d);
   printf("The current date is: %d/%d/%d\n",d.da_day,d.da_mon,d.da_year);
   printf("enter new date:");
   reset.da_day = 0;
   scanf("%[^\n]d %d %d",&reset.da_day,&reset.da_mon,&reset.da_year);
   if(reset.da_day!=0)
   {
	setdate(&reset);
	printf("The current date is: %d/%d/%d\n",d.da_day,d.da_mon,d.da_year);
   }

}
Beispiel #11
0
/* settimestamp(seconds1970) sets the date and time from a single parameter: the
 * number of seconds since 1 January 1970.
 */
static cell AMX_NATIVE_CALL n_settimestamp(AMX *amx, const cell *params)
{
  #if defined __WIN32__ || defined _WIN32 || defined WIN32
    int year, month, day, hour, minute, second;

    stamp2datetime(params[1],
                   &year, &month, &day,
                   &hour, &minute, &second);
    setdate(year, month, day);
    settime(hour, minute, second);
  #else
    /* Linux/Unix (and some DOS compilers) have stime(); on Linux/Unix, you
     * must have "root" permission to call stime()
     */
    time_t sec1970=(time_t)params[1];
    stime(&sec1970);
  #endif
  (void)amx;

  return 0;
}
Beispiel #12
0
int
main(int argc, char **argv)
{
	struct tm *tp, tm;
	struct timeval tv;
	char *fmt;
	char *fmtbuf;
	int c, aflag = 0, illflag = 0;
	struct timespec ts;

	(void) setlocale(LC_ALL, "");

#if !defined(TEXT_DOMAIN)
#define	TEXT_DOMAIN "SYS_TEST"
#endif
	(void) textdomain(TEXT_DOMAIN);

	while ((c = getopt(argc, argv, "a:uR")) != EOF)
		switch (c) {
		case 'a':
			aflag++;
			if (get_adj(optarg, &tv) < 0) {
				(void) fprintf(stderr,
				    gettext("date: invalid argument -- %s\n"),
				    optarg);
				illflag++;
			}
			break;
		case 'u':
			uflag++;
			break;
		case 'R':
			Rflag++;
			break;
		default:
			illflag++;
		}

	argc -= optind;
	argv  = &argv[optind];

	/* -a is mutually exclusive with -u and -R */
	if (uflag && aflag)
		illflag++;
	if (Rflag && aflag)
		illflag++;

	if (illflag) {
		(void) fprintf(stderr, gettext(usage));
		exit(1);
	}

	if (clock_gettime(CLOCK_REALTIME, &ts) != 0) {
		perror(gettext("data: Failed to obtain system time"));
		exit(1);
	}
	clock_val = ts.tv_sec;

	if (aflag) {
		if (adjtime(&tv, 0) < 0) {
			perror(gettext("date: Failed to adjust date"));
			exit(1);
		}
		exit(0);
	}

	if (argc > 0) {
		if (*argv[0] == '+')
			fmt = &argv[0][1];
		else {
			if (setdate(localtime(&clock_val), argv[0])) {
				(void) fprintf(stderr, gettext(usage));
				exit(1);
			}
			fmt = nl_langinfo(_DATE_FMT);
		}
	} else if (Rflag) {
		fmt = "%a, %d %h %Y %H:%M:%S %z";
	} else
		fmt = nl_langinfo(_DATE_FMT);

	fmtbuf = fmt_extensions(fmt, &ts);

	if (uflag) {
		(void) putenv("TZ=GMT0");
		tzset();
		tp = gmtime(&clock_val);
	} else
		tp = localtime(&clock_val);
	(void) memcpy(&tm, tp, sizeof (struct tm));
	(void) strftime(buf, BUFSIZ, fmtbuf, &tm);

	(void) puts(buf);

	return (0);
}
Beispiel #13
0
/* setdate(year, month, day)
 * Always returns 0
 */
static cell AMX_NATIVE_CALL n_setdate(AMX *amx, const cell *params)
{
  (void)amx;
  setdate(params[1],params[2],params[3]);
  return 0;
}
Beispiel #14
0
Date::Date(int year, int month, int day) {
    setdate(year, month, day);
}
Beispiel #15
0
static int unpack (const TCHAR *src, const TCHAR *filename, const TCHAR *dst, int out, int all, int level)
{
	struct zdirectory *h;
	struct zvolume *zv;
	int ret;
	uae_u8 *b;
	int size;
	TCHAR fn[MAX_DPATH];

	ret = 0;
	zv = zfile_fopen_archive_root (src, ZFD_ALL);
	if (zv == NULL) {
		geterror();
		_tprintf (_T("Couldn't open archive '%s'\n"), src);
		return 0;
	}
	h = zfile_opendir_archive (src);
	if (!h) {
		geterror();
		_tprintf (_T("Couldn't open directory '%s'\n"), src);
		return 0;
	}
	while (zfile_readdir_archive (h, fn)) {
		if (all || !_tcsicmp (filename, fn)) {
			TCHAR tmp[MAX_DPATH];
			struct zfile *s, *d;
			struct mystat st;

			found = 1;
			_tcscpy (tmp, src);
			_tcscat (tmp, sep);
			_tcscat (tmp, fn);
			if (!zfile_stat_archive (tmp, &st)) {
				_tprintf (_T("Couldn't stat '%s'\n"), tmp);
				continue;
			}
			if (dst == NULL || all)
				dst = fn;
			if (st.mode) {
				if (all > 0)
					continue;
				if (all < 0) {
					TCHAR oldcur[MAX_DPATH];
					my_mkdir (fn);
					my_setcurrentdir (fn, oldcur);
					unpack (tmp, fn, dst, out, all, 1);
					my_setcurrentdir (oldcur, NULL);
					setdate (dst, st.mtime.tv_sec);
					continue;
				}
				_tprintf (_T("Directory extraction not yet supported\n"));
				return 0;
			}

			s = zfile_open_archive (tmp, ZFD_ARCHIVE | ZFD_NORECURSE);
			if (!s) {
				geterror();
				_tprintf (_T("Couldn't open '%s' for reading\n"), src);
				continue;
			}
			zfile_fseek (s, 0, SEEK_END);
			size = zfile_ftell (s);
			zfile_fseek (s, 0, SEEK_SET);
			b = xcalloc (uae_u8, size);
			if (b) {
				if (zfile_fread (b, size, 1, s) == 1) {
					if (out) {
						_tprintf (_T("\n"));
						fwrite (b, size, 1, stdout);
					} else {
						d = zfile_fopen (dst, _T("wb"), 0);
						if (d) {
							if (zfile_fwrite (b, size, 1, d) == 1) {
								ret = 1;
								_tprintf (_T("%s extracted, %d bytes\n"), dst, size);
							}
							zfile_fclose (d);
							setdate (dst, st.mtime.tv_sec);
						}
					}
				}
				xfree (b);
			}
			zfile_fclose (s);
			if (!all)
				break;
		}
	}
	geterror ();
	if (!found && !level) {
		if (filename[0])
			_tprintf (_T("'%s' not found\n"), filename);
		else
			_tprintf (_T("nothing extracted\n"));
	}
	return ret;
}
Beispiel #16
0
static int unpack2 (const TCHAR *src, const TCHAR *match, int level)
{
	struct zdirectory *h;
	struct zvolume *zv;
	int ret;
	uae_u8 *b;
	int size;
	TCHAR fn[MAX_DPATH];

	ret = 0;
	zv = zfile_fopen_archive_root (src, ZFD_ALL);
	if (zv == NULL) {
		geterror();
		_tprintf (_T("Couldn't open archive '%s'\n"), src);
		return 0;
	}
	h = zfile_opendir_archive (src);
	if (!h) {
		geterror();
		_tprintf (_T("Couldn't open directory '%s'\n"), src);
		return 0;
	}
	while (zfile_readdir_archive (h, fn)) {
		TCHAR tmp[MAX_DPATH];
		TCHAR *dst;
		struct zfile *s, *d;
		int isdir, flags;

		_tcscpy (tmp, src);
		_tcscat (tmp, sep);
		_tcscat (tmp, fn);
		zfile_fill_file_attrs_archive (tmp, &isdir, &flags, NULL);
		if (isdir) {
			TCHAR *p = _tcsstr (fn, _T(".DIR"));
			if (isdir == ZNODE_VDIR && p && _tcslen (p) == 4) {
				p[0] = 0;
				if (pattern_match (fn, match))
					continue;
				p[0] = '.';
			}
			unpack2 (tmp, match, 1);
			continue;
		}

		if (pattern_match (fn, match)) {
			struct mystat st;

			if (!zfile_stat_archive (tmp, &st)) {
				st.mtime.tv_sec = st.mtime.tv_usec = -1;
			}
			found = 1;
			dst = fn;
			s = zfile_open_archive (tmp, ZFD_NORECURSE);
			if (!s) {
				geterror();
				_tprintf (_T("Couldn't open '%s' for reading\n"), tmp);
				continue;
			}
			zfile_fseek (s, 0, SEEK_END); 
			size = zfile_ftell (s);
			zfile_fseek (s, 0, SEEK_SET);
			b = xcalloc (uae_u8, size);
			if (b) {
				if (zfile_fread (b, size, 1, s) == 1) {
					d = zfile_fopen (dst, _T("wb"), 0);
					if (d) {
						if (zfile_fwrite (b, size, 1, d) == 1) {
							ret = 1;
							_tprintf (_T("%s extracted, %d bytes\n"), dst, size);
						}
						zfile_fclose (d);
						setdate (dst, st.mtime.tv_sec);
					}
				}
				xfree (b);
			}
			zfile_fclose (s);
		}
	}
	geterror ();
	if (!found && !level) {
		_tprintf (_T("'%s' not matched\n"), match);
	}
	return ret;
}
Beispiel #17
0
int fb_hSetDate( int y, int m, int d )
{
#if defined( HOST_DOS )
	struct date dt;
	dt.da_year = y;
	dt.da_mon = m;
	dt.da_day = d;
	setdate(&dt);
	return 0;

#elif defined( HOST_UNIX )
	const int month_len[12] =
	{
		2678400, 2419200, 2678400, 2592000, 2678400, 2592000,
		2678400, 2678400, 2592000, 2678400, 2592000, 2678400
	};

	struct timeval tv;
	time_t secs;
	int i;

	if( y < 1970 )
		return -1;
	gettimeofday( &tv, NULL );
	secs = tv.tv_sec % 86400;
	tv.tv_sec = 0;
	for( i = 1970; i < y; i++ ) {
		tv.tv_sec += 31536000;
		if( ((i % 4) == 0) || ((i / 400) == 0) )
			d++;
	}
	tv.tv_sec += (m * month_len[m-1]);
	if( ((y % 4) == 0) || ((y / 400) == 0) )
		d++;
	tv.tv_sec += (d * 86400) + secs;
	if( settimeofday( &tv, NULL ) )
		return -1;

	return 0;

#elif defined( HOST_WIN32 )
	/* get current local time and date */
	SYSTEMTIME st;
	GetLocalTime( &st );

	/* set time fields */
	st.wYear = y;
	st.wMonth = m;
	st.wDay = d;

	/* set system time relative to local time zone */
	if( SetLocalTime( &st ) == 0) {
		return -1;
	}

	/* send WM_TIMECHANGE to all top-level windows on NT and 95/98/Me
	 * (_not_ on 2K/XP etc.) */
	/* if ((GetVersion() & 0xFF) == 4)
		SendMessage(HWND_BROADCAST, WM_TIMECHANGE, 0, 0); */

	return 0;

#elif defined( HOST_XBOX )
	/* TODO: use NtSetSystemTime */
	return 0;
#else
#	error TODO
#endif
}