home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / HSRC_117.ZIP / HEADMISC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-08  |  4.7 KB  |  276 lines

  1. /* Miscellaneous functions */
  2.  
  3. #include "msgg.h"
  4. #include "twindow.h"
  5. #include "keys.h"
  6. #include "headedit.h"
  7.  
  8.  
  9.  
  10. char pascal isitme (char which) {
  11.  
  12.     register word x;
  13.     char check1[36];
  14.     char check3[36];
  15.  
  16.     if (!which) strcpy(check3,rstrip(msg.to));
  17.     else strcpy(check3,rstrip(msg2.to));
  18.     if (userno==1 && !stricmp(check3,"SYSOP")) return 1;
  19.     if (noalias) {
  20.         for (x=0;x<noalias;x++) {
  21.             strcpy(check1,rstrip(alias[x]));
  22.             if (!stricmp(check1,check3)) return 1;
  23.         }
  24.     }
  25.     return 0;
  26. }
  27.  
  28.  
  29.  
  30. word pascal check_area (word tempno) {
  31.  
  32.  struct ffblk f;
  33.  
  34.  sprintf(filename,"%sXDATA.%03x",path,tempno);
  35.  sprintf(textname,"%sXTEXT.%03x",path,tempno);
  36.  
  37.  if (findfirst(filename,&f,0)) {
  38.   sprintf(filename," No messages in area #%u ",tempno);
  39.   any_message(filename);
  40.   return 0;
  41.  }
  42.  
  43.  tempno=(word)(f.ff_fsize/(long)sizeof(struct _xmsg));
  44.  if (f.ff_fsize<(long)sizeof(struct _xmsg) || findfirst(textname,&f,0)){
  45.     sprintf(filename," No messages in area #%u ",tempno);
  46.     any_message(filename);
  47.     return 0;
  48.  }
  49.  return tempno;
  50. }
  51.  
  52.  
  53.  
  54. char * pascal rstrip (char *a) {
  55.  
  56.   register int x;
  57.  
  58.   x=strlen(a);
  59.   while (x && a && a[x-1]==' ') a[--x]=0;
  60.   return a;
  61. }
  62.  
  63.  
  64.  
  65. char * pascal lstrip (char *a) {
  66.  
  67.   register int x;
  68.  
  69.   x=strlen(a);
  70.   while (x && *a==' ') memmove (a,(a+1),x--);
  71.   return (a);
  72. }
  73.  
  74.  
  75. char * pascal stripcr (char *a) {
  76.  
  77.   register int x;
  78.  
  79.   x=strlen(a);
  80.   while (x && (a[x-1]=='\n' || a[x-1]=='\r')) a[--x]=0;
  81.   return a;
  82. }
  83.  
  84.  
  85.  
  86.  
  87. int charlimit (char *bf,int key) {
  88.  
  89.   if (atoi(bf)<1 or atoi(bf)>255) {
  90.     error_message(" 1-255! ");
  91.     return ERROR;
  92.   }
  93.   return 0;
  94.  
  95. }
  96.  
  97.  
  98. int messlimit (char *bf,int key) {
  99.  
  100.   char s[78];
  101.  
  102.   if (atol(bf)<1L or atol(bf)>(long)nomess) {
  103.     sprintf(s," Try keeping it between 1 and %u ",nomess);
  104.     error_message(s);
  105.     return ERROR;
  106.   }
  107.   return 0;
  108.  
  109. }
  110.  
  111.  
  112.  
  113. char * pascal fidodate (void) {
  114.  
  115.  char months[12][4]={
  116.     "Jan",
  117.     "Feb",
  118.     "Mar",
  119.     "Apr",
  120.     "May",
  121.     "Jun",
  122.     "Jul",
  123.     "Aug",
  124.     "Sep",
  125.     "Oct",
  126.     "Nov",
  127.     "Dec"
  128.  };
  129.  static char fdate[20];
  130.  struct date dos_date;
  131.  struct time dos_time;
  132.  
  133. /* 26 Jul 89  06:23:47 */
  134.  
  135.  getdate(&dos_date);
  136.  gettime(&dos_time);
  137.  
  138.  sprintf(fdate,"%02hu %s %02d  %02hu:%02hu:%02hu",dos_date.da_day,months[dos_date.da_mon-1],dos_date.da_year%100,dos_time.ti_hour,dos_time.ti_min,dos_time.ti_sec);
  139.  return(fdate);
  140. }
  141.  
  142.  
  143. char * pascal saydate (struct date *a) {
  144.  
  145. static char xdate[11];
  146.  
  147.  sprintf(xdate,"%02hu/%02hu/%04u",a->da_mon,a->da_day,a->da_year);
  148.  return(xdate);
  149. }
  150.  
  151.  
  152.  
  153. char * pascal saytime (struct time *a) {
  154.  
  155. static char xtime[9];
  156.  
  157.  sprintf(xtime,"%02u:%02u:%02u",a->ti_hour,a->ti_min,a->ti_sec);
  158.  return(xtime);
  159. }
  160.  
  161.  
  162.  
  163.  
  164. void pascal left(char *a,char *b,int x) {
  165.  
  166.   int i=0;
  167.   x = (x <= strlen(b)) ? x : strlen(b);
  168.   while (i++ < x) *a++ = *b++;
  169.   *a = '\0';
  170.  
  171. }
  172.  
  173.  
  174.  
  175. void pascal strip_seenbys (char *hold) {
  176.  
  177.     char *path=NULL;
  178.     char *seenby=NULL;
  179.     char *origin=NULL;
  180.     char *p;
  181.  
  182.         origin=strstr(hold,"\r * Origin:");
  183.         if (origin) {
  184.             while((p=strstr(&origin[1],"\r * Origin:"))) origin=p;
  185.             path=strstr(origin,"\r\01PATH:");
  186.             seenby=strstr(origin,"\rSEEN-BY:");
  187.             if (!seenby) seenby=strstr(origin,"\r\01SEEN-BY:");
  188.             if (!path) if (seenby) *seenby=0;
  189.             if (seenby && path) memmove (seenby,path,strlen(path)+1);
  190.         }
  191. }
  192.  
  193.  
  194.  
  195. int yesorno (char *bf,int key) {
  196.  
  197.   if (*bf!='Y' && *bf!='N') {
  198.     error_message(" Y or N! ");
  199.     return ERROR;
  200.   }
  201.   return 0;
  202.  
  203. }
  204.  
  205.  
  206.  
  207. int noblank (char *bf,int key) {
  208.  
  209.   if (!strcspn(bf," ")) {
  210.     error_message("Don't blank this field.");
  211.     return ERROR;
  212.   }
  213.   return 0;
  214. }
  215.  
  216.  
  217. int cdecl break_handler (void) {
  218.  
  219.   clrr();
  220.   return 0;
  221.  
  222. }
  223.  
  224.  
  225.  
  226. int lessthan256 (char *bf,int key) {
  227.  
  228.    if(atoi(bf)>255 || atoi(bf)<0) {
  229.         error_message(" 0 to 255! ");
  230.         return ERROR;
  231.    }
  232.    return 0;
  233. }
  234.  
  235.  
  236.  
  237. char * pascal quick_attr (void) {
  238.  
  239.     word register x;
  240.     word temp;
  241.     static char attrstring[52];
  242.  
  243.     strcpy(attrstring,"Std->[");
  244.     for (x=0;x<16;x++) {
  245.        temp=1;
  246.        temp=temp<<x;
  247.        (msg.attr & temp) ? strcat(attrstring,"X") : strcat (attrstring,"-");
  248.     }
  249.     strcat(attrstring,"]  Extra->[");
  250.     for (x=0;x<16;x++) {
  251.        temp=1;
  252.        temp=temp<<x;
  253.        (msg.m_attr & temp) ? strcat(attrstring,"X") : strcat (attrstring,"-");
  254.     }
  255.     strcat(attrstring,"]");
  256.     return attrstring;
  257. }
  258.  
  259.  
  260.  
  261. char * pascal area_attr (void) {
  262.  
  263.     word register x;
  264.     word temp;
  265.     static char attrstring[22];
  266.  
  267.     strcpy(attrstring,"[");
  268.     for (x=0;x<16;x++) {
  269.        temp=1;
  270.        temp=temp<<x;
  271.        (currarea->attr & temp) ? strcat(attrstring,"X") : strcat (attrstring,"-");
  272.     }
  273.     strcat(attrstring,"]");
  274.     return attrstring;
  275. }
  276.