# 2.11BSD#431 - /usr/src/local/welcome/welcome.c

##### Functions

    main              X

##### Variables

    days              X
    ldvec             X
    mons              X
    ttime             X

       1: #include <stdio.h>
       2: #include <sys/param.h>
       3: #include <sys/sysctl.h>
       4: #include "./cpu.h"
       5:
       6: double ldvec[3];
       7:
       8: char *days[] = { "Sunday", "Monday", "Tuesday", "Wednesday",
       9:          "Thursday", "Friday", "Saturday" };
      10:
      11: char *mons[] = { "January", "February", "March", "April",
      12:          "May", "June", "July", "August",
      13:          "September", "October", "November", "December" };
      14:
      15: char *ttime[] = { "morning ", "afternoon ", "evening ", "night " };
      16:
      17: main()
      18: {
      19:     register struct tm *det;
      20:     size_t size;
      21:     int a, b, x, y, mib[2];
      22:     long secs;
      23:     char    bot[100], *foo, goo[50], ap;
      24:     char    machine[64], model[64], ostype[64];
      25:
      26:     time(&secs);
      27:     (void)getloadavg(ldvec, 3);
      28:
      29:     mib[0] = CTL_HW;
      30:     mib[1] = HW_MACHINE;
      31:     size = sizeof (machine);
      32:     if  (sysctl(mib, 2, machine, &size, NULL, 0) < 0)
      33:         {
      34:         printf("Can't get machine type\n");
      35:         strcpy(machine, "?");
      36:         }
      37:     mib[0] = CTL_HW;
      38:     mib[1] = HW_MODEL;
      39:     size = sizeof (model);
      40:     if  (sysctl(mib, 2, model, &size, NULL, 0) < 0)
      41:         {
      42:         printf("Can't get cpu type\n");
      43:         strcpy(model, "?");
      44:         }
      45:     mib[0] = CTL_KERN;
      46:     mib[1] = KERN_OSTYPE;
      47:     size = sizeof (ostype);
      48:     if  (sysctl(mib, 2, ostype, &size, NULL, 0) < 0)
      49:         {
      50:         printf("Can't get ostype\n");
      51:         strcpy(ostype, "?");
      52:         }
      53:
      54:     ap = "AP"[(det = localtime(&secs))->tm_hour >= 12];
      55:     if (det->tm_hour >= 0 && det->tm_hour < 12)
      56:         foo = ttime[0];
      57:     else if (det->tm_hour > 11 && det->tm_hour < 18)
      58:         foo = ttime[1];
      59:     else if (det->tm_hour > 17 && det->tm_hour < 24)
      60:         foo = ttime[2];
      61:     if ((det->tm_hour %= 12) == 0)
      62:         det->tm_hour = 12;
      63:     fflush(stdout);
      64:     printf("\033[2J\033(0\033)0\033[m");
      65:     printf("\033[3;11H\033(B\033)B   Load Average\033(0\033)0");
      66:     printf("\033[4;11Hlqqqqqqqqqqqqqqqqk");
      67:     printf("\033[5;11Hx                x");
      68:     printf("\033[6;11Hmqqqqqqqqqqqqqqwqj");
      69:     printf("\033[5;13H%.02f %.02f %.02f", ldvec[0], ldvec[1], ldvec[2]);
      70:     printf("\033[7;16Hlqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
      71: #ifdef  TTY
      72:     printf("\033[3;51H\033(B\033)BTTY Name\033(0\033)0");
      73:     printf("\033[4;46Hlqqqqqqqqqqqqqqqqk");
      74:     printf("\033[5;46Hx                x");
      75:     printf("\033[6;46Hmqwqqqqqqqqqqqqqqj");
      76:     printf("\033[5;50H\033(B\033)B%s\033(0\033)0",ttyname(ttyslot(0)));
      77:     printf("\033[7;16Hlqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqvqqqqqqqqk");
      78: #else   TTY
      79:     printf("\033[7;16Hlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
      80: #endif	TTY
      81:     printf("\033[8;16Hx                                        x");
      82:     printf("\033[9;13Hlqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvqqk");
      83:     printf("\033[10;10Hlqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvqqk");
      84:     printf("\033[11;10Hx\033[11;63Hx\033[12;10Hx\033[12;63Hx\033[13;10Hx\033[13;63Hx");
      85:     printf("\033[14;10Hmqqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqqj");
      86:     printf("\033[15;13Hmqqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqqj");
      87:     printf("\033[16;16Hx                                        x");
      88:     printf("\033[17;16Hmqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj");
      89:     printf("\033(B\033)B");
      90: #ifdef  LIGHT
      91:     printf("\033[11;13H\033[7m                                                ");
      92: #endif  LIGHT
      93:     printf("\033[11;13H    Good %s%s,", foo, getenv("USER"));
      94:     gethostname(goo, sizeof(goo));
      95: #ifdef  LIGHT
      96:     printf("\033[12;13H\033[7m                                                ");
      97:     printf("\033[12;13H\033[7m        You have connected to %s", goo);
      98: #else   LIGHT
      99:     printf("\033[12;13H        You have connected to %s", goo);
     100: #endif
     101: #ifdef  LIGHT
     102:     printf("\033[13;13H\033[7m                                                ");
     103: #endif  LIGHT
     104:     printf("\033[m");
     105: #ifdef  LIGHT
     106:     printf("\033[13;13H\033[7m       A %s/%s running %s",
     107: #else
     108:     printf("\033[13;13H       A %s/%s running %s",
     109: #endif
     110:         machine, model, ostype);
     111:
     112: #ifdef  UVERS
     113:     fp = fopen("/etc/motd", "r");
     114:     fscanf(fp, "%s%s", poo, doo);
     115:     printf(" V%c.%c", doo[1], doo[3]);
     116:     fclose(fp);
     117:     unlink("/tmp/foo");
     118: #endif	UVERS
     119: #ifdef  LIGHT
     120:     printf("\033[8;18H                                      ");
     121:     printf("\033[16;18H                                      ");
     122: #endif	LIGHT
     123:     x = 40 - (strlen(days[det->tm_wday]) / 2);
     124:     y = (69 - x);
     125:     printf("\033[8;%dH%s", y, days[det->tm_wday]);
     126:     sprintf(bot, "%s %d, 19%d %d:%02d %cM", mons[det->tm_mon],
     127:             det->tm_mday, det->tm_year, det->tm_hour,
     128:         det->tm_min, ap);
     129:     a = 40 -(strlen(bot) / 2);
     130:     b = (54 - a);
     131:     printf("\033[m");
     132: #ifdef LIGHT
     133:     printf("\033[7m");
     134: #endif LIGHT
     135:     printf("\033[16;%dH%s", b, bot);
     136:     printf("\033[23;1H");
     137:     printf("\033[m");
     138:     exit(0);
     139: }

#### Defined functions

main defined in line 17; never used

#### Defined variables

days defined in line 8; used 2 times

- in line 123-125(2)

ldvec defined in line 6; used 4 times

- in line 27, 69(3)

mons defined in line 11; used 1 times

- in line 126

ttime defined in line 15; used 3 times

- in line 56-60(3)

Last modified: 1995-02-05 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1636 |