home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------*/
- /* */
- /* Module Name: AMAXGEN.C */
- /* Program Name: AMAX */
- /* Revision: 2.xx */
- /* Purpose: General Routines Module */
- /* Programmer: Alan D. Bryant */
- /* */
- /* Copyright (C) 1988, 89, 90, 92 Alan D. Bryant, All Rights Reserved. */
- /* */
- /* NOTICE: This source code is copyrighted material. You are granted a */
- /* limited license to use and distribute the code. The complete text of */
- /* the license can be found in the document LICENSE.DOC which accompanies */
- /* this source code, or can be obtained directly from the author. */
- /* */
- /* Inquiries regarding this package should be directed to: */
- /* */
- /* AMAX */
- /* Alan D. Bryant */
- /* P. O. Box 101612 */
- /* Denver, CO 80250 */
- /* USA */
- /* */
- /*---------------------------------------------------------------------------*/
-
- #include <stdio.h>
- #include <dos.h>
- #include <dir.h>
- #include <sys\stat.h>
- #include <alloc.h>
- #include <time.h>
- #include "amax.h"
-
-
- void cls();
- void minicls();
- void bottomcls(int);
- char check_backslash(char *);
- void newzone(int);
- void add_parse(char *, int *, int *, int *, int *);
- void display_time(char);
-
-
- extern char usecolor;
-
- void cls()
- {
- if (! direct) {
- if (usecolor) printf("\x1B[0;44m");
- printf("\x1B[0H\x1B[2J");
- }
- else {
- if (usecolor) textattr(23);
- clrscr();
- }
- }
-
- void minicls()
- {
- int x;
-
- for (x = 2; x < 24; x++) {
- cursor(x, 0);
- if (! direct) printf("\x1B[K");
- else clreol();
- }
- }
-
-
- void bottomcls(int line)
- {
- int x;
-
- for (x = line; x < 24; x++) {
- cursor(x, 0);
- if (! direct) printf("\x1B[K");
- else clreol();
- }
- }
-
-
- /* validation suite for path strings.... */
-
- char check_backslash(char *string)
- {
- char test[150];
- strcpy(test, string);
- if (string[strlen(string) - 1] != 0x5C) {
- return 0;
- }
- return 1;
-
- }
-
- void newzone(int new_zone) {
-
- char intermediate[10];
- char temp[150];
- int done;
- int result;
- struct ffblk ffblk;
-
- strcpy(outbound, orig_outbound);
- zone_num = new_zone;
-
- if (new_zone == 0) zone_num = our_zone;
- if (zone_num == our_zone) return;
- if (new_zone > 4095 || new_zone < 1) return;
-
- outbound[strlen(outbound) - 1] = 0x00;
-
- sprintf(intermediate, "%03x", zone_num);
- strcat(outbound, ".");
- strcat(outbound, intermediate);
- strcat(outbound, "\\");
-
- strcpy(temp, outbound);
- temp[strlen(temp) - 1] = 0x00;
-
- done = findfirst(temp, &ffblk, FA_DIREC);
- if (done) {
- result = mkdir(temp);
- if (result) {
- output("Error creating new directory. ");
- output(reterror());
- output(" Press any key...");
- getch();
- }
- }
-
- }
-
-
-
-
-
-
- void add_parse(char *address, int *ret_zone, int *ret_net, int *ret_node, int *ret_point)
- {
- int x = 0;
- int y = 0;
-
- char int_zone[10] = "";
- char int_net[10] = "";
- char int_node[10] = "";
- char int_point[10] = "";
-
- *ret_zone = 0;
- *ret_net = 0;
- *ret_node = 0;
- *ret_point = 0;
-
- /* parse out the zone */
-
- if (strchr(address, ':')) {
- while (address[x] != ':' && x != strlen(address)) {
- int_zone[x] = address[x];
- ++x;
- }
- int_zone[x] = 0x00;
-
- ++x;
- }
- y = 0;
-
- while (address[x] != '/' && x != strlen(address)) {
- int_net[y] = address[x];
- ++x;
- ++y;
- }
- int_net[y] = 0x00;
- ++x;
-
- y = 0;
-
- while (address[x] != '.' && x != strlen(address)) {
- int_node[y] = address[x];
- ++x;
- ++y;
- }
- int_node[y] = 0x00;
- ++x;
-
- y = 0;
-
- while (x < strlen(address)) {
- int_point[y] = address[x];
- ++x;
- ++y;
- }
- if (int_point[0]) int_point[y] = 0x00;
- else int_point[0] = 0x00;
-
- if (int_zone[0]) *ret_zone = atoi(int_zone);
- if (int_net[0]) *ret_net = atoi(int_net);
- if (int_node[0]) *ret_node = atoi(int_node);
- if (int_point[0]) *ret_point = atoi(int_point);
-
- }
-
-
- void display_time(char full)
- {
- char *str_now;
- time_t secs_now;
- static time_t time_then;
- char week[5];
- char month[5];
- char day[5];
- char times[10];
- char year[5];
- char new[30];
-
- time(&secs_now);
- str_now = (char *) ctime(&secs_now);
- sscanf(str_now, "%s %s %s %s %s", week, month, day, times, year);
- if (full) {
- sprintf(new, "%s., %s. %s, %s %s", week, month, day, year, times);
- cursor(0, 50);
- output(new);
- time_then = secs_now;
- }
- if ((! full) && (time_then != secs_now)) {
- sprintf(new, "%s", times);
- cursor(0, 70);
- output(new);
- time_then = secs_now;
- }
- }
-
-
-
-