nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

fnmake.c (1727B)


      1 #include "mxf-send.h"
      2 #include "mxf-send-protos.h"
      3 /* this file is too long ----------------------------------------- FILENAMES */
      4 
      5 stralloc fn = {0};
      6 stralloc fn2 = {0};
      7 char fnmake_strnum[FMT_ULONG];
      8 
      9 /* Daniel, if you're up in my source code and reading this, I want to
     10  * look you straight in the eyes and tell you this:
     11  * All of these procedures, to a letter, should not have used globals.
     12  * Macros should then have been defined to define the default stralloc
     13  * to use in a particular file.
     14  * When it comes to chanaddr, I understand why you'd use a global. That
     15  * makes perfect sense - chanaddr is effectively write-once memory for
     16  * channels.
     17  */
     18 void
     19 fnmake_init()
     20 {
     21 	while (!stralloc_ready(&fn, FMTQFN))
     22 		nomem();
     23 	while (!stralloc_ready(&fn2, FMTQFN))
     24 		nomem();
     25 }
     26 
     27 /* fnmake_*() family of functions.
     28  * All of these functions have a right to expect to be passed ptrs to
     29  * the global fn variables, or to appropriate local ones.
     30  */
     31 
     32 void fnmake_info(unsigned long id, stralloc *fn)
     33 {
     34 	fn->len = fmtqfn(fn->s, "info/", id, 1);
     35 }
     36 void fnmake_todo(unsigned long id, stralloc *fn)
     37 {
     38 	fn->len = fmtqfn(fn->s, "todo/", id, 0);
     39 }
     40 void fnmake_mess(unsigned long id, stralloc *fn)
     41 {
     42 	fn->len = fmtqfn(fn->s, "mess/", id, 1);
     43 }
     44 void fnmake_foop(unsigned long id, stralloc *fn)
     45 {
     46 	fn->len = fmtqfn(fn->s, "foop/", id, 0);
     47 }
     48 void fnmake_split(unsigned long id, stralloc *fn)
     49 {
     50 	fn->len = fmtqfn(fn->s, "", id, 1);
     51 }
     52 /* fnmake_bounce should generally be passed
     53  * fn2, although if you need it in fn, go ahead.
     54  */
     55 void
     56 fnmake_bounce(unsigned long id, stralloc *fn)
     57 {
     58 	fn->len = fmtqfn(fn->s, "bounce/", id, 0);
     59 }
     60 void
     61 fnmake_chanaddr(unsigned long id, int c, stralloc *fn)
     62 {
     63 	fn->len = fmtqfn(fn->s, chanaddr[c], id, 1);
     64 }