github.com/256dpi/max-go@v0.7.0/lib/max/ext_proto.h (about)

     1  /* ext_proto.h -- prototypes for MAX external methods */
     2  /* copyright 1996 Opcode/IRCAM */
     3  #ifndef _EXT_PROTO_H_
     4  #define _EXT_PROTO_H_
     5  
     6  #include "ext_prefix.h"
     7  #include "ext_mess.h"
     8  
     9  #ifdef WIN_VERSION
    10  #include "ext_proto_win.h"
    11  #endif
    12  
    13  BEGIN_USING_C_LINKAGE
    14  
    15  // object/class functions
    16  
    17  /**	Use the setup() function to initialize your class by informing Max of its size, 
    18  	the name of your functions that create and destroy instances, 
    19  	and the types of arguments passed to the instance creation function.
    20  	
    21  	@ingroup class_old
    22  			
    23  	@param	ident		A global variable in your code that points to the initialized class.
    24  	@param	makefun		Your instance creation function. 
    25  	@param	freefun		Your instance free function (see Chapter 7). 
    26  	@param	size		The size of your objects data structure in bytes. 
    27  						Usually you use the C sizeof operator here. 
    28  	@param	menufun		No longer used.  You should pass NULL for this parameter.
    29  	@param	type		The first of a list of arguments passed to makefun when an object is created.
    30  	@param	...			Any additional arguments passed to makefun when an object is created.
    31  						Together with the type parameter, this creates a standard Max type list 
    32  						as enumerated in #e_max_atomtypes.
    33  						The final argument of the type list should be a 0.
    34  	@see @ref chapter_anatomy
    35  */
    36  C74_DEPRECATED ( void setup(t_messlist **ident, method makefun, method freefun, t_getbytes_size size, method menufun, short type, ...) )	;
    37  
    38  
    39  /**	Use addmess() to bind a function to a message other than the standard ones 
    40  	covered by addbang(), addint(), etc.
    41  	
    42  	@ingroup class_old
    43  	@param	f 		Function you want to be the method. 
    44  	@param	s 		C string defining the message. 
    45  	@param	type	The first of one or more integers from #e_max_atomtypes specifying the arguments to the message.
    46  	@param	...		Any additional types from #e_max_atomtypes for additonal arguments.
    47  	@see @ref chapter_anatomy
    48  */
    49  C74_DEPRECATED ( void addmess(method f, char *s, short type, ...) ); 
    50  
    51  
    52  /**
    53  	Used to bind a function to the common triggering message bang. 
    54  
    55  	@ingroup class_old
    56  	@param	f	Function to be the bang method. 
    57  */
    58  C74_DEPRECATED ( void addbang(method f) );
    59  
    60  
    61  /**
    62  	Use addint() to bind a function to the int message received in the leftmost inlet.
    63  	@ingroup class_old
    64  	@param	f Function to be the int method.
    65  */
    66  C74_DEPRECATED ( void addint(method f) );
    67  
    68  
    69  /**
    70  	Use addfloat() to bind a function to the float message received in the leftmost inlet.
    71  	@ingroup class_old
    72  	@param	f Function to be the int method.
    73  */
    74  C74_DEPRECATED ( void addfloat(method f) );
    75  
    76  
    77  /**
    78  	Use addinx() to bind a function to a int message that will be received in 
    79  		an inlet other than the leftmost one. 
    80  
    81  	@ingroup class_old
    82  	@param	f	Function to be the int method. 
    83   	@param	n	Number of the inlet connected to this method. 
    84  				1 is the first inlet to the right of the left inlet. 
    85  
    86  	@remark	This correspondence between inlet locations and messages is not 
    87  			automatic, but it is strongly suggested that you follow existing practice. 
    88  			You must set the correspondence up when creating an object of your 
    89  			class with proper use of intin and floatin in your instance creation 
    90  			function @ref chapter_anatomy_object_new. 
    91  */
    92  C74_DEPRECATED ( void addinx(method f, short n) );
    93  
    94  
    95  /**
    96  	Use addftx() to bind a function to a float message that will be received in 
    97  		an inlet other than the leftmost one. 
    98  
    99  	@ingroup class_old
   100  	@param	f	Function to be the float method. 
   101  	@param	n	Number of the inlet connected to this method. 
   102  				1 is the first inlet to the right of the left inlet. 
   103  
   104  	@remark	This correspondence between inlet locations and messages is not 
   105  			automatic, but it is strongly suggested that you follow existing practice. 
   106  			You must set the correspondence up when creating an object of your 
   107  			class with proper use of intin and floatin in your instance creation 
   108  			function @ref chapter_anatomy_object_new. 
   109  */
   110  C74_DEPRECATED ( void addftx(method f, short n) );
   111  
   112  
   113  /**
   114  	Use newobject to allocate the space for an instance of your class and 
   115  	initialize its object header. 
   116  
   117  	@ingroup class_old
   118  	@param	maxclass	The global class variable initialized in your main routine by the setup function. 
   119  	@return 			A pointer to the new instance.
   120  	
   121  	@remark				You call newobject() when creating an instance of your class in your 
   122  						creation function. newobject allocates the proper amount of memory 
   123  						for an object of your class and installs a pointer to your class in the 
   124  						object, so that it can respond with your class's methods if it receives a 
   125  						message.
   126  */
   127  C74_DEPRECATED ( void *newobject(void *maxclass) );
   128  
   129  
   130  /**
   131  	Release the memory used by a Max object.
   132  	freeobject() calls an object's free function, if any, then disposes the 
   133  	memory used by the object itself. freeobject() should be used on any 
   134  	instance of a standard Max object data structure, with the exception of 
   135  	Qelems and Atombufs. Clocks, Binbufs, Proxies, Exprs, etc. should be freed with freeobject().
   136  	
   137  	@ingroup	class_old
   138  	@param		op	The object instance pointer to free.
   139  	
   140  	@remark		This function can be replaced by the use of object_free().
   141  				Unlike freeobject(), object_free() checkes to make sure the pointer is 
   142  				not NULL before trying to free it.
   143  	
   144  	@see newobject()
   145  	@see object_free()
   146  */
   147  void freeobject(void *op);
   148  
   149  
   150  /** Make a new instance of an existing Max class.
   151  	@ingroup class_old
   152  	
   153  	@param s	className Symbol specifying the name of the class of the instance to be created. 
   154  	@param argc	Count of arguments in argv. 
   155  	@param argv	Array of t_atoms; arguments to the class's instance creation function. 
   156  
   157  	@return 	A pointer to the created object, or 0 if the class 
   158  				didn't exist or there was another type of error in creating the instance. 
   159  	
   160  	@remark This function creates a new instance of the specified class. Using 
   161  	newinstance is equivalent to typing something in a New Object box 
   162  	when using Max. The difference is that no object box is created in any 
   163  	Patcher window, and you can send messages to the object directly 
   164  	without connecting any patch cords. The messages can either be type- 
   165  	checked (using typedmess) or non-type-checked (using the members 
   166  	of the getfn family).
   167  	
   168  	This function is useful for taking advantage of other already-defined 
   169  	objects that you would like to use 'privately' in your object, such as 
   170  	tables. See the source code for the coll object for an example of using a 
   171  	privately defined class. 
   172  */
   173  void *newinstance(t_symbol *s, short argc, t_atom *argv);
   174  
   175  
   176  /**
   177  	@ingroup class_old
   178  */
   179  C74_DEPRECATED (void finder_addclass(char *category, char *classString));
   180  
   181  
   182  /**
   183  	Use the alias function to allow users to refer to your object by a 
   184  	name other than that of your shared library.
   185  
   186  	@ingroup class_old
   187  	@param	name	An alternative name for the user to use to make an object of your class. 
   188  */
   189  C74_DEPRECATED (void alias(char *name) );
   190  
   191  
   192  /**
   193  	@ingroup class_old
   194  */
   195  void class_noinlet(t_messlist *m);
   196  
   197  
   198  /**
   199  	Use class_setname() to associate you object's name with it's filename 
   200  	on disk. 
   201  
   202  	@ingroup class_old
   203  	@param	obname		A character string with the name of your object class as it appears in Max. 
   204  	@param	filename	A character string with the name of your external's file as it appears on disk. 
   205  */
   206  void class_setname(char *obname, char *filename);
   207  
   208  
   209  short force_install(char *classname);
   210  void loader_setpath(t_fourcc type, short path);
   211  
   212  
   213  
   214  // memory functions
   215  
   216  /**
   217  	Allocate small amounts of non-relocatable memory. 
   218  	As of Max 5 it is unified with sysmem_newptr(), which is the preferred method for allocating memory.
   219  	@ingroup memory
   220  	@param	size	The size to allocate in bytes (up to 32767 bytes).
   221  	@return			A pointer to the allocated memory.
   222  */
   223  char *getbytes(t_getbytes_size size);
   224  
   225  
   226  /**
   227  	Free memory allocated with getbytes().
   228  	As of Max 5 it is unified with sysmem_newptr(), which is the preferred method for allocating memory.
   229  	@ingroup memory
   230  	@param	b		A pointer to the block of memory previously allocated that you want to free.
   231  	@param	size	The size the block specified (as parameter b) in bytes.
   232  */
   233  void freebytes(void *b, t_getbytes_size size);
   234  
   235  
   236  /**
   237  	Use getbytes16() to allocate small amounts of non-relocatable 
   238  	memory that is aligned on a 16-byte boundary for use with vector optimization.
   239  	@ingroup memory
   240  	@param	size	The size to allocate in bytes (up to 32767 bytes).
   241  	@return			A pointer to the allocated memory.
   242  	
   243  	@remark		getbytes16() is identical to getbytes except that it returns memory 
   244  				that is aligned to a 16-byte boundary. This allows you to allocate 
   245  				storage for vector-optimized memory at interrupt level. Note that any 
   246  				memory allocated with getbytes16() must be freed with 
   247  				freebytes16(), not freebytes().
   248  */
   249  char *getbytes16(t_getbytes_size size);
   250  
   251  
   252  /**
   253  	Free memory allocated with getbytes16().
   254  	As of Max 5 it is unified with sysmem_newptr(), which is the preferred method for allocating memory.
   255  	@ingroup memory
   256  	@param	mem		A pointer to the block of memory previously allocated that you want to free.
   257  	@param	size	The size the block specified (as parameter b) in bytes.
   258  	
   259  	@remark		Note that freebytes16() will cause memory corruption if you pass it 
   260  				memory that was allocated with getbytes(). Use it only with memory 
   261  				allocated with getbytes16().
   262  */
   263  void freebytes16(char *mem, t_getbytes_size size);
   264  
   265  
   266  /**
   267  	Allocate relocatable memory. Deprecated, use sysmem_newhandle instead
   268  	
   269  	@ingroup memory
   270  	@param	size	The size to allocate in bytes.
   271  	@return			The allocated handle.
   272  	@see			sysmem_newhandle()
   273  */
   274  C74_DEPRECATED (char **newhandle(long size));
   275  
   276  
   277  /**
   278  	Change the size of a handle. Deprecated, use sysmem_resizehandle instead
   279  	
   280  	@ingroup memory
   281  	@param	h		The handle to resize.
   282  	@param	size	The new size to allocate in bytes.
   283  	@return			Ignored.
   284  	@see			sysmem_resizehandle()
   285  */
   286  C74_DEPRECATED (short growhandle(void *h, long size));
   287  
   288  
   289  /**
   290  	Free the memory used by a handle you no longer need. Deprecated, use sysmem_freehandle instead
   291  	
   292  	@ingroup memory
   293  	@param	h		The handle to dispose.
   294  	@see			sysmem_freehandle()
   295  */
   296  C74_DEPRECATED (void disposhandle(char **h));
   297  
   298  #ifdef MM_UNIFIED // sysmem and getbytes are unified
   299  #define getbytes(size) ((char *)sysmem_newptr((t_ptr_size)(size)))
   300  #define freebytes(p,size) sysmem_freeptr((char *)(p))
   301  #endif
   302  
   303  // symbol/string/text/error functions
   304  
   305  #ifndef gensym
   306  /**
   307  	Given a C-string, fetch the matching #t_symbol pointer from the symbol table,
   308  	generating the symbol if neccessary.
   309  
   310  	@ingroup symbol
   311  	@param	s	A C-string to be looked up in Max's symbol table.
   312  	@return		A pointer to the #t_symbol in the symbol table.
   313  */
   314  t_symbol *gensym(C74_CONST char *s);
   315  #endif
   316  
   317  /**
   318   Given a C-string, fetch the matching #t_symbol pointer from the symbol table,
   319   generating and translating the symbol if neccessary.
   320   
   321   @ingroup symbol
   322   @param	s		A C-string to be looked up in Max's symbol table and then translated
   323   @return		A pointer to the #t_symbol in the symbol table.
   324   */
   325  
   326  #ifdef NO_TRANSLATION_SUPPORT
   327  #define gensym_tr gensym
   328  #else
   329  t_symbol *gensym_tr(const char *s);
   330  #endif
   331  
   332  // other translation stuff, to be documented...
   333  	
   334  #ifdef NO_TRANSLATION_SUPPORT
   335  #define str_tr(s) (s)
   336  #define symbol_tr(s) (s)
   337  #define sprintf_tr snprintf
   338  #else
   339  char *str_tr(const char *s);
   340  t_symbol *symbol_tr(t_symbol *s);
   341  int sprintf_tr(char *d, const char *fmt, ...);
   342  #endif
   343  
   344  char *mayquote(char *s);
   345  	
   346  short advise(const char *s, ...);
   347  short advise_explain(const char *note, const char *explanation, const char *b1, const char *b2, const char *b3);
   348  
   349  /**
   350  	Print text to the Max window, linked to an instance of your object,
   351  	and flagged as an error (highlighted with a red background), 
   352  	and grab the user's attention by displaying a banner in the patcher window.
   353  	
   354  	This function should be used exceedingly sparingly, with preference given to 
   355  	object_error() when a problem occurs.
   356  		
   357  	@ingroup console
   358  	@param	x		A pointer to your object.
   359  	@param	s		A C-string containing text and printf-like codes 
   360  					specifying the sizes and formatting of the additional arguments.
   361  	@param	...		Arguments of any type that correspond to the format codes in fmtString.
   362  			
   363  	@see object_post()
   364  	@see object_error()
   365  */
   366  void object_error_obtrusive(t_object *x, C74_CONST char *s, ...);
   367  
   368  
   369  long jdialog_showtext(const char *prompt, const char *deftext, long flags, const char **text);
   370  
   371  
   372  // inlet/outlet functions
   373  
   374  /**
   375  	Use inlet_new() to create an inlet that can receive a specific message or any message. 
   376  
   377  	@ingroup inout
   378  	@param	x	Your object. 
   379  	@param	s	Character string of the message, or NULL to receive any message.
   380  	@return		A pointer to the new inlet.
   381  
   382  	@remark		inlet_new() ceates a general purpose inlet. 
   383  				You can use it in circumstances where you would like special messages to be received in 
   384  				inlets other than the leftmost one. 
   385  				To create an inlet that receives a particular message, pass the message's 
   386  				character string. For example, to create an inlet that receives only bang 
   387  				messages, do the following
   388  	@code
   389  	inlet_new (myObject,"bang"); 
   390  	@endcode
   391  
   392  	@remark		To create an inlet that can receive any message, pass NULL for msg
   393  	@code
   394  	inlet_new (myObject, NULL); 
   395  	@endcode
   396  
   397  	@remark		Proxies are an alternative method for general-purpose inlets that have 
   398  				a number of advantages. If you create multiple inlets as shown above, 
   399  				there would be no way to figure out which inlet received a message. See 
   400  				the discussion in @ref chapter_inout_proxies. 
   401  */
   402  void *inlet_new(void *x, C74_CONST char *s);
   403  
   404  /**
   405  	Use intin() to create an inlet typed to receive only integers. 
   406  
   407  	@ingroup inout
   408  	@param	x	Your object. 
   409  	@param	n	Location of the inlet from 1 to 9. 1 is immediately to the right of the leftmost inlet. 
   410  	@return		A pointer to the new inlet.
   411  	
   412  	@remark		intin creates integer inlets. 
   413  				It takes a pointer to your newly created object and an integer n, from 1 to 9. 
   414  				The number specifies the message 
   415  				type you'll get, so you can distinguish one inlet from another. For 
   416  				example, an integer sent in inlet 1 will be of message type in1 and a 
   417  				floating point number sent in inlet 4 will be of type ft4. You use 
   418  				addinx() and addftx() to add methods to respond to these messages.
   419  				
   420  				The order you create additional inlets is important. If you want the 
   421  				rightmost inlet to be the have the highest number in- or ft- message 
   422  				(which is usually the case), you should create the highest number 
   423  				message inlet first. 
   424  */
   425  void *intin(void *x, short n);
   426  
   427  
   428  /**
   429  	Use floatin() to create an inlet typed to receive only floats. 
   430  
   431  	@ingroup inout
   432  	@param	x	Your object. 
   433  	@param	n	Location of the inlet from 1 to 9. 1 is immediately to the right of the leftmost inlet. 
   434  	@return		A pointer to the new inlet.
   435  */
   436  void *floatin(void *x, short n);
   437  
   438  
   439  // for dynamic inlets
   440  void *inlet_append(t_object *op, void *who, t_symbol *s1, t_symbol *s2);
   441  void *inlet_insert_after(t_object *op,void *who, t_symbol *s1, t_symbol *s2, void *previous_inlet);
   442  void inlet_delete(void *x);
   443  void *inlet_nth(t_object *x, long n);
   444  long inlet_count(t_object *x);
   445  	
   446  
   447  /**
   448  	Use outlet_new() to create an outlet that can send a specific non-standard message, or any message.
   449  
   450  	@ingroup	inout
   451  	@param	x	Your object.
   452  	@param	s	A C-string specifying the message that will be sent out this outlet, 
   453  				or NULL to indicate the outlet will be used to send various messages.
   454  				The advantage of this kind of outlet's flexibility is balanced by the fact that 
   455  				Max must perform a message-lookup in real-time for every message sent through it, 
   456  				rather than when a patch is being constructed, as is true for other types of outlets. 
   457  				Patchers execute faster when outlets are typed, since the message 
   458  				lookup can be done before the program executes.
   459  	@return		A pointer to the new outlet.
   460  */
   461  void *outlet_new(void *x, C74_CONST char *s);
   462  
   463  
   464  // for dynamic outlets
   465  void *outlet_append(t_object *op, t_symbol *s1, t_symbol *s2);
   466  void *outlet_insert_after(t_object *op, t_symbol *s1, t_symbol *s2, void *previous_outlet);
   467  void outlet_delete(void *x);
   468  long outlet_count(t_object *x);
   469  void *outlet_nth(t_object *x, long n);
   470  
   471  	
   472  /**
   473  	Use bangout() to create an outlet that will always send the bang message. 
   474  
   475  	@ingroup	inout
   476  	@param	x	Your object.
   477  	@return		A pointer to the new outlet.
   478  
   479  	@remark		You can send a bang message out a general purpose outlet, but creating 
   480  				an outlet using bangout() allows Max to type-check the connection a 
   481  				user might make and refuse to connect the outlet to any object that 
   482  				cannot receive a bang message. bangout() returns the created outlet. 
   483  */
   484  void *bangout(void *x);
   485  
   486  
   487  /**
   488  	Use intout() to create an outlet that will always send the int message. 
   489  
   490  	@ingroup	inout
   491  	@param	x	Your object.
   492  	@return		A pointer to the new outlet.
   493  
   494  	@remark		You can send a bang message out a general purpose outlet, but creating 
   495  				an outlet using bangout() allows Max to type-check the connection a 
   496  				user might make and refuse to connect the outlet to any object that 
   497  				cannot receive a bang message. bangout() returns the created outlet. 
   498  */
   499  void *intout(void *x);
   500  
   501  
   502  /**
   503  	Use floatout() to create an outlet that will always send the float message. 
   504  
   505  	@ingroup	inout
   506  	@param	x	Your object.
   507  	@return		A pointer to the new outlet.
   508  */
   509  void *floatout(void *x);
   510  
   511  
   512  /**
   513  	Use listout() to create an outlet that will always send the list message. 
   514  	@ingroup	inout
   515  	@param	x	Your object.
   516  	@return		A pointer to the new outlet.
   517  */
   518  void *listout(void *x);
   519  
   520  
   521  /**
   522  	Use outlet_bang() to send a bang message out an outlet. 
   523  
   524  	@ingroup inout
   525  	@param	o	Outlet that will send the message.
   526  	@return		Returns 0 if a stack overflow occurred, otherwise returns 1.
   527  */
   528  void *outlet_bang(t_outlet *x);
   529  
   530  
   531  /**
   532  	Use outlet_int() to send an int message out an outlet. 
   533  
   534  	@ingroup inout
   535  	@param	o	Outlet that will send the message.
   536  	@param	n	Integer value to send.
   537  	@return		Returns 0 if a stack overflow occurred, otherwise returns 1.
   538  */
   539  #ifndef outlet_int
   540  void *outlet_int(t_outlet *x, t_atom_long n);
   541  #endif
   542  
   543  
   544  /**
   545  	Use outlet_float() to send a float message out an outlet. 
   546  
   547  	@ingroup inout
   548  	@param	o	Outlet that will send the message.
   549  	@param	f	Float value to send.
   550  	@return		Returns 0 if a stack overflow occurred, otherwise returns 1.
   551  */
   552  #ifndef outlet_float
   553  void *outlet_float(t_outlet *x, double f);
   554  #endif
   555  
   556  
   557  /**
   558  	Use outlet_list() to send a list message out an outlet. 
   559  
   560  	@ingroup inout
   561  	@param	o		Outlet that will send the message.
   562  	@param	s		Should be NULL, but can be the _sym_list.
   563  	@param	ac		Number of elements in the list in argv. 
   564  	@param	av		Atoms constituting the list. 
   565  	@return			Returns 0 if a stack overflow occurred, otherwise returns 1.
   566  	
   567  	@remark			outlet_list() sends the list specified by argv and argc out the 
   568  					specified outlet. The outlet must have been created with listout or 
   569  					outlet_new in your object creation function (see above). You create 
   570  					the list as an array of Atoms, but the first item in the list must be an 
   571  					integer or float.
   572  					
   573  					Here's an example of sending a list of three numbers. 
   574  	@code
   575  	t_atom myList[3]; 
   576  	long theNumbers[3]; 
   577  	short i; 
   578  	
   579  	theNumbers[0] = 23; 
   580  	theNumbers[1] = 12; 
   581  	theNumbers[2] = 5;
   582  	for (i=0; i < 3; i++) { 
   583  		atom_setlong(myList+i,theNumbers[i]);
   584  	} 
   585  	outlet_list(myOutlet,0L,3,&myList); 
   586  	@endcode
   587  
   588  	@remark			It's not a good idea to pass large lists to outlet_list that are 
   589  					comprised of local (automatic) variables. If the list is small, as in the 
   590  					above example, there's no problem. If your object will regularly send 
   591  					lists, it might make sense to keep an array of t_atoms inside your 
   592  					object's data structure.	
   593  */
   594  #ifndef outlet_list
   595  void *outlet_list(t_outlet *x, t_symbol *s, short ac, t_atom *av);
   596  #endif
   597  
   598  
   599  /**
   600  	Use outlet_anything() to send any message out an outlet. 
   601  
   602  	@ingroup inout
   603  	@param	o		Outlet that will send the message.
   604  	@param	s		The message selector #t_symbol*. 
   605  	@param	ac		Number of elements in the list in argv. 
   606  	@param	av		Atoms constituting the list. 
   607  	@return			Returns 0 if a stack overflow occurred, otherwise returns 1.
   608  	
   609  	@remark			This function lets you send an arbitrary message out an outlet. 
   610  					Here are a couple of examples of its use.
   611  					
   612  					First, here's a hard way to send the bang message (see outlet_bang() for an easier way):
   613  	@code
   614  	outlet_anything(myOutlet, gensym("bang"), 0, NIL); 
   615  	@endcode
   616  	
   617  	@remark			And here's an even harder way to send a single integer (instead of using outlet_int()).
   618  	@code
   619  	t_atom myNumber; 
   620  
   621  	atom_setlong(&myNumber, 432);
   622  	outlet_anything(myOutlet, gensym("int"), 1, &myNumber);
   623  	@endcode
   624  
   625  	@remark			Notice that outlet_anything() expects the message argument as a 
   626  					#t_symbol*, so you must use gensym() on a character string. 
   627  				
   628  					If you'll be sending the same message a lot, you might call gensym() on the message string at 
   629  					initialization time and store the result in a global variable to save the 
   630  					(significant) overhead of calling gensym() every time you want to send a 
   631  					message.
   632  					
   633  					Also, do not send lists using outlet_anything() with list as 
   634  					the selector argument. Use the outlet_list() function instead. 
   635  */
   636  #ifndef outlet_anything
   637  void *outlet_anything(t_outlet *x, t_symbol *s, short ac, t_atom *av);
   638  #endif
   639  
   640  
   641  void *inlet4(void *x, void *w, char *s, char *s1);
   642  
   643  
   644  void inlet_to(t_inlet *x, void *w);
   645  
   646  
   647  short outlet_add(t_outlet *x, t_inlet *ip);
   648  
   649  
   650  void outlet_rm(t_outlet *x, t_inlet *ip);
   651  
   652  
   653  void outlet_atoms(void *out, short argc, t_atom *argv);
   654  
   655  
   656  
   657  
   658  // clock functions
   659  
   660  /**
   661  	Create a new Clock object. 
   662  	Normally, clock_new() is called in your instance creation 
   663  	function—and it cannot be called from a thread other than the main thread. 
   664  	To get rid of a clock object you created, use freeobject().
   665  
   666  	@ingroup clocks
   667  	@param	obj		Argument that will be passed to clock function fn when it is called. 
   668  					This will almost always be a pointer to your object.
   669  	@param	fn		Function to be called when the clock goes off, 
   670  					declared to take a single argument as shown in @ref clocks_using_clocks.
   671  	@return			A pointer to a newly created Clock object.
   672  */
   673  t_clock *clock_new(void *obj, method fn);
   674  
   675  t_clock *clock_new_withscheduler(void *obj, method fn, t_scheduler *s);
   676  
   677  void clock_set(t_clock *x, long when);
   678  
   679  /**
   680  	Schedule the execution of a Clock.
   681  	clock_delay() sets a clock to go off at a certain number of 
   682  	milliseconds from the current logical time.
   683  
   684  	@ingroup clocks
   685  	@param	x		Clock to schedule. 
   686  	@param	n		Delay, in milliseconds, before the Clock will execute.
   687  	@see	clock_fdelay()
   688  */
   689  void clock_delay(t_clock *x, long n);
   690  
   691  
   692  /**
   693  	Cancel the scheduled execution of a Clock. 
   694  	clock_unset() will do nothing (and not complain) if the Clock passed 
   695  	to it has not been set.
   696  		
   697  	@ingroup clocks
   698  	@param	x		Clock to cancel. 
   699  */
   700  void clock_unset(t_clock *x);
   701  
   702  
   703  /**
   704  	Schedule the execution of a Clock using a floating-point argument.
   705  	clock_delay() sets a clock to go off at a certain number of 
   706  	milliseconds from the current logical time.
   707  
   708  	@ingroup clocks
   709  	@param	c		Clock to schedule. 
   710  	@param	time	Delay, in milliseconds, before the Clock will execute.
   711  	@see	clock_delay()
   712  */
   713  void clock_fset(t_clock *x, double when);
   714  void clock_fset2(t_clock *x, double when, double offset);
   715  void clock_fdelay(t_clock *x, double f);
   716  void clock_fdelay2(t_clock *x, double delay, double offset);
   717  
   718  /**
   719  	Find out the current logical time of the scheduler in milliseconds
   720  	as a floating-point number.
   721  
   722  	@ingroup clocks
   723  	@param	time	Returns the current time.
   724  	@see	gettime()
   725  	@see	setclock_getftime()
   726  	@see	setclock_gettime()
   727  */
   728  void clock_getftime(double *time);
   729  
   730  
   731  /** Schedule a Clock on a scheduler. 
   732  	Schedules the Clock c to execute at time units after the current 
   733  	time. If scheduler x is 0 or does not point to a setclock object, the 
   734  	internal millisecond scheduler is used. Otherwise c is scheduled on 
   735  	the setclock object's list of Clocks. The Clock should be created with 
   736  	clock_new(), the same as for a Clock passed to clock_delay().
   737  
   738  	@ingroup clocks
   739  	@param	x		A setclock object to be used for scheduling this clock.
   740  	@param	c		Clock object containing the function to be executed.
   741  	@param	time	Time delay (in the units of the Setclock) from the 
   742  					current time when the Clock will be executed.
   743  	@see	@ref 	setclock
   744  	@see			setclock_fdelay()
   745  */
   746  void setclock_delay(t_setclock *x, t_clock *c, long when);
   747  
   748  /** Remove a Clock from a scheduler.
   749  	This function unschedules the Clock c in the list of Clocks in the 
   750  	setclock object x, or the internal millisecond scheduler if scheduler is 0.
   751  
   752  	@ingroup clocks
   753  	@param	x		The setclock object that was used to schedule this clock. 
   754  					If 0, the clock is unscheduled from the internal millisecond scheduler.
   755  	@param	c		Clock object to be removed from the scheduler.
   756  	@see	@ref	setclock
   757  */
   758  void setclock_unset(t_setclock *x, t_clock *c);
   759  
   760  /** Find out the current time value of a setclock object.
   761  	@ingroup clocks
   762  	@param	x		A setclock object. 
   763  	@return			Returns the current time value of the setclock object scheduler. 
   764  					If scheduler is 0, setclock_gettime is equivalent to the function 
   765  					gettime that returns the current value of the internal millisecond clock.
   766  	@see	@ref	setclock
   767  	@see			setclock_getftime()
   768  */
   769  long setclock_gettime(t_setclock *x);
   770  
   771  /**	Schedule a Clock on a scheduler, using a floating-point time argument.
   772  	@ingroup clocks
   773  	@param	s		A setclock object to be used for scheduling this clock.
   774  	@param	c		Clock object containing the function to be executed.
   775  	@param	time	Time delay (in the units of the Setclock) from the 
   776  					current time when the Clock will be executed.
   777  	@see	@ref	setclock
   778  	@see			setclock_delay()
   779  */
   780  void setclock_fdelay(t_setclock *x, t_clock *c, double f);
   781  
   782  /** Find out the current time value of a setclock object in floating-point milliseconds.
   783  	@ingroup clocks
   784  	@param	s		A setclock object.
   785  	@param	time	The current time in milliseconds. 
   786  	@see	@ref	setclock
   787  	@see			setclock_gettime()
   788  */
   789  void setclock_getftime(t_setclock *x, double *time);
   790  
   791  // real-time
   792  
   793  /**
   794  	While most Max timing references "logical" time derived from Max's millisecond scheduler, 
   795  	time values produced by the systimer_gettime() are referenced from the CPU clock and can be used 
   796  	to time real world events with microsecond precision.
   797  	
   798  	The standard 'cpuclock' external in Max is a simple wrapper around this function.
   799  	
   800  	@ingroup	clocks
   801  	@return		Returns the current real-world time.
   802  */
   803  double systimer_gettime(void);
   804  
   805  
   806  // scheduler functions
   807  
   808  /**
   809  	Find out the current logical time of the scheduler in milliseconds.
   810  	
   811  	@ingroup	clocks
   812  	@return		Returns the current time.
   813  	@see		clock_getftime()
   814  */
   815  long gettime(void);
   816  long getschedtime(void);
   817  long getexttime(void);
   818  short sched_isinpoll(void);
   819  short sched_isinqueue(void);
   820  
   821  /**
   822  	Find the correct scheduler for the object and return the current time in milliseconds.
   823  	
   824  	@ingroup	clocks
   825  	@return		Returns the current time.
   826  	@see		clock_getftime()
   827   */
   828  
   829  double gettime_forobject(t_object *x);
   830  
   831  /**
   832  	Cause a function to be executed at the timer level at some time in the future.
   833  
   834  	@ingroup	threading
   835  	@param		ob		First argument passed to the function fun when it executes.
   836  	@param		fun		Function to be called, see below for how it should be declared.
   837  	@param		when	The logical time that the function fun will be executed.
   838  	@param		sym		Second argument passed to the function fun when it executes.
   839  	@param		argc	Count of arguments in argv. argc is also the third argument passed to the function fun when it executes.
   840  	@param		argv	Array containing a variable number of #t_atom function arguments. 
   841  						If this argument is non-zero, defer allocates memory to make a copy of the arguments 
   842  						(according to the size passed in argc) 
   843  						and passes the copied array to the function fun when it executes as the fourth argument.
   844  
   845  	@remark				schedule() calls a function at some time in the future. Unlike defer(), 
   846  						the function is called in the scheduling loop when logical time is equal 
   847  						to the specified value when. This means that the function could be 
   848  						called at interrupt level, so it should follow the usual restrictions on
   849  						interrupt-level conduct. The function fun passed to schedule should 
   850  						be declared as follows: 
   851  	
   852  	@code					
   853  	void myobject_do (myObject *client, t_symbol *s, short argc, t_atom *argv); 
   854  	@endcode
   855  	
   856  	@remark				One use of schedule() is as an alternative to using the lockout flag. 	
   857  
   858  	@see		defer()
   859  */
   860  void schedule(void *ob, method fun, long when, t_symbol *sym, short argc, t_atom *argv);
   861  void schedulef(void *ob, method fun, double when, t_symbol *sym, short argc, t_atom *argv);
   862  
   863  /**	Create a new local scheduler.
   864  	@ingroup		clocks
   865  	@return			A pointer to the newly created scheduler.
   866  	@see	@ref	creating_schedulers
   867  */
   868  t_scheduler *scheduler_new(void);
   869  
   870  
   871  /**	Make a scheduler current, so that future related calls (such as 
   872  	clock_delay()) will affect the appropriate scheduler. 
   873  
   874  	@ingroup		clocks
   875  	@param	x		The scheduler to make current.
   876  	@return			This routine returns a pointer to the previously current scheduler, 
   877  					saved and restored when local scheduling is complete.
   878  	@see	@ref	creating_schedulers
   879  */
   880  t_scheduler *scheduler_set(t_scheduler *x);
   881  
   882  /**	Get the currently set scheduler. 
   883  
   884  	@ingroup		clocks
   885  	@return			This routine returns a pointer to the current scheduler, 
   886  	@see	@ref	creating_schedulers
   887  */
   888  t_scheduler *scheduler_get(void);
   889  
   890  /**	Get the scheduler associated with a given object, if any. 
   891  
   892  	@ingroup		clocks
   893  	@param o		The object who's scheduler is to be returned.
   894  	@return			This routine returns a pointer to the scheduler or the passed in object, 
   895  	@see	@ref	creating_schedulers
   896  */
   897  t_scheduler *scheduler_fromobject(t_object *obj);
   898  
   899  /** Run scheduler events to a selected time.
   900  	@ingroup		clocks
   901  	@param	x		The scheduler to advance.
   902  	@param	until	The ending time for this run (in milliseconds). 
   903  	@see	@ref	creating_schedulers
   904  */
   905  void scheduler_run(t_scheduler *x, double until);
   906  
   907  
   908  /** Set the current time of the scheduler. 
   909  	@ingroup		clocks
   910  	@param	x		The scheduler to set.
   911  	@param	time	The new current time for the selected scheduler (in milliseconds). 
   912  	@see	@ref	creating_schedulers
   913  */
   914  void scheduler_settime(t_scheduler *x, double time);
   915  
   916  
   917  /** Retrieve the current time of the selected scheduler.
   918  	@ingroup		clocks
   919  	@param	x		The scheduler to query.
   920  	@param	time	The current time of the selected scheduler.
   921  	@see	@ref	creating_schedulers
   922  */
   923  void scheduler_gettime(t_scheduler *x, double *time);
   924  
   925  /** Shift scheduler's current time and run time for all pending clock.
   926      Could be used to change scheduler's time reference without impacting current clocks.
   927  	@ingroup		clocks
   928  	@param	x		The scheduler to affect.
   929  	@param	amount	Number of milliseconds to shift by.
   930  	@see	@ref	creating_schedulers
   931  */
   932  void scheduler_shift(t_scheduler *x, double amount);
   933  
   934  /**
   935  	Cause a function to be executed at the timer level at some time in the future specified by a delay offset.
   936  
   937  	@ingroup	threading
   938  	@param		ob		First argument passed to the function fun when it executes.
   939  	@param		fun		Function to be called, see below for how it should be declared.
   940  	@param		delay	The delay from the current time before the function will be executed.
   941  	@param		sym		Second argument passed to the function fun when it executes.
   942  	@param		argc	Count of arguments in argv. argc is also the third argument passed to the function fun when it executes.
   943  	@param		argv	Array containing a variable number of #t_atom function arguments. 
   944  						If this argument is non-zero, schedule_delay() allocates memory to make a copy of the arguments 
   945  						(according to the size passed in argc) 
   946  						and passes the copied array to the function fun when it executes as the fourth argument.
   947  
   948  	@remark				schedule_delay() is similar to schedule() but allows you to specify the 
   949  						time as a delay rather than a specific logical time. 
   950  
   951  	@code
   952  	void myobject_click (t_myobject *x, Point pt, short modifiers) 
   953  	{ 
   954  		t_atom a[1]; 
   955  		a[0].a_type = A_LONG; 
   956  		a[0].a_w.w_long = Random(); 
   957  		schedule_delay(x, myobject_sched, 0 ,0, 1, a); 
   958  	} 
   959  
   960  	void myobject_sched (t_myobject *x, t_symbol *s, short ac, t_atom *av) 
   961  	{ 
   962  		outlet_int(x->m_out,av->a_w.w_long); 
   963  	} 
   964  	@endcode
   965  
   966  	@see schedule()
   967  */
   968  void schedule_delay(void *ob, method fun, long delay, t_symbol *sym, short argc, t_atom *argv);
   969  void schedule_fdelay(void *ob, method fun, double delay, t_symbol *sym, short argc, t_atom *argv);
   970  void schedule_defer(void *ob, method fun, long delay, t_symbol *sym, short argc, t_atom *arv);
   971  void schedule_fdefer(void *ob, method fun, double delay, t_symbol *sym, short argc, t_atom *arv);
   972  short lockout_set(short);
   973  
   974  /**
   975  	Determine whether your code is executing in the Max scheduler thread.
   976  	
   977  	@ingroup	threading
   978  	@return		This function returns non-zero if you are within Max's scheduler thread, zero otherwise. 
   979  				Note that if your code sets up other types of interrupt-level callbacks, 
   980  				such as for other types of device drivers used in asynchronous mode, isr will return false.
   981  */
   982  long isr(void);
   983  
   984  // queue functions
   985  
   986  /**
   987  	Create a new Qelem.
   988  	The created Qelem will need to be freed using qelem_free(), do not use freeobject().
   989  	
   990  	@ingroup qelems
   991  	@param	obj	Argument to be passed to function fun when the Qelem executes. 
   992  				Normally a pointer to your object.
   993  	@param	fn	Function to execute.
   994  	@return		A pointer to a Qelem instance.  
   995  				You need to store this value to pass to qelem_set().
   996  	
   997  	@remark		Any kind of drawing or calling of Macintosh Toolbox routines that 
   998  				allocate or purge memory should be done in a Qelem function. 
   999  */
  1000  void *qelem_new(void *obj, method fn);
  1001  
  1002  
  1003  /**
  1004  	Cause a Qelem to execute. 
  1005  
  1006  	@ingroup qelems
  1007  	@param	q	The Qelem whose function will be executed in the main thread.
  1008  	
  1009  	@remark		The key behavior of qelem_set() is this: if the Qelem object has already 
  1010  				been set, it will not be set again. (If this is not what you want, see 
  1011  				defer().) This is useful if you want to redraw the state of some 
  1012  				data when it changes, but not in response to changes that occur faster 
  1013  				than can be drawn. A Qelem object is unset after its queue function has 
  1014  				been called.
  1015  */
  1016  void qelem_set(t_qelem *x);
  1017  
  1018  
  1019  /**
  1020  	Cancel a Qelem's execution. 
  1021  	If the Qelem's function is set to be called, qelem_unset() will stop it 
  1022  	from being called. Otherwise, qelem_unset() does nothing.
  1023  
  1024  	@ingroup qelems
  1025  	@param	q	The Qelem whose execution you wish to cancel.
  1026  */
  1027  void qelem_unset(t_qelem *x);
  1028  
  1029  
  1030  /**
  1031  	Free a Qelem object created with qelem_new().
  1032   	Typically this will be in your object's free funtion. 
  1033  
  1034  	@ingroup qelems
  1035  	@param	x	The Qelem to destroy.
  1036  */
  1037  void qelem_free(t_qelem *x);
  1038  
  1039  
  1040  /**
  1041  	Cause a Qelem to execute with a higher priority.
  1042  	This function is identical to qelem_set(), except that the Qelem's 
  1043  	function is placed at the front of the list of routines to execute in the 
  1044  	main thread instead of the back. Be polite and only use 
  1045  	qelem_front() only for special time-critical applications.
  1046  		
  1047  	@ingroup qelems
  1048  	@param	x	The Qelem whose function will be executed in the main thread.
  1049  */
  1050  void qelem_front(t_qelem *x);
  1051  
  1052  
  1053  /**
  1054  	Defer execution of a function to the main thread if (and only if) 
  1055  	your function is executing in the scheduler thread.
  1056  	
  1057  	@ingroup	threading
  1058  	@param		ob		First argument passed to the function fun when it executes.
  1059  	@param		fn		Function to be called, see below for how it should be declared.
  1060  	@param		sym		Second argument passed to the function fun when it executes.
  1061  	@param		argc	Count of arguments in argv. argc is also the third argument passed to the function fun when it executes.
  1062  	@param		argv	Array containing a variable number of #t_atom function arguments. 
  1063  						If this argument is non-zero, defer allocates memory to make a copy of the arguments 
  1064  						(according to the size passed in argc) 
  1065  						and passes the copied array to the function fun when it executes as the fourth argument.
  1066  	@return		Return values is for internal Cycling '74 use only.
  1067  	
  1068  	@remark		This function uses the isr() routine to determine whether you're at the 
  1069  				Max timer interrupt level (in the scheduler thread). 
  1070  				If so, defer() creates a Qelem (see @ref qelems), calls 
  1071  				qelem_front(), and its queue function calls the function fn you 
  1072  				passed with the specified arguments. 
  1073  				If you're not in the scheduler thread, the function is executed immediately with the 
  1074  				arguments. Note that this implies that defer() is not appropriate for 
  1075  				using in situations such as Device or File manager I/0 completion routines. 
  1076  				The defer_low() function is appropriate however, because it always defers. 
  1077  
  1078  				The deferred function should be declared as follows:
  1079  	@code
  1080  	void myobject_do (myObject *client, t_symbol *s, short argc, t_atom *argv);
  1081  	@endcode
  1082  	
  1083  	@see		defer_low()
  1084  */
  1085  void *defer(void *ob,method fn,t_symbol *sym,short argc,t_atom *argv);
  1086  
  1087  
  1088  /**
  1089  	Defer execution of a function to the back of the queue on the main thread.
  1090  
  1091  	@ingroup	threading
  1092  	@param		ob		First argument passed to the function fun when it executes.
  1093  	@param		fn		Function to be called, see below for how it should be declared.
  1094  	@param		sym		Second argument passed to the function fun when it executes.
  1095  	@param		argc	Count of arguments in argv. argc is also the third argument passed to the function fun when it executes.
  1096  	@param		argv	Array containing a variable number of #t_atom function arguments. 
  1097  						If this argument is non-zero, defer allocates memory to make a copy of the arguments 
  1098  						(according to the size passed in argc) 
  1099  						and passes the copied array to the function fun when it executes as the fourth argument.
  1100  	@return		Return values is for internal Cycling '74 use only.
  1101  
  1102  	@remark		defer_low() always defers a call to the function fun whether you are already 
  1103  				in the main thread or not, and uses qelem_set(), not qelem_front(). This 
  1104  				function is recommended for responding to messages that will cause 
  1105  				your object to open a dialog box, such as read and write. 
  1106  
  1107  				The deferred function should be declared as follows:
  1108  	@code
  1109  	void myobject_do (myObject *client, t_symbol *s, short argc, t_atom *argv);
  1110  	@endcode
  1111  
  1112  	@see		defer()
  1113  */
  1114  void *defer_low(void *ob,method fn,t_symbol *sym,short argc,t_atom *argv);
  1115  
  1116  void *defer_medium(void *ob, method fn, t_symbol *sym, short argc, t_atom *argv);
  1117  
  1118  void *defer_front(void *ob, method fn, t_symbol *sym, short argc, t_atom *argv);
  1119  
  1120  // private
  1121  void *defer_sys_low(void *ob,method fn,t_symbol *sym,short argc,t_atom *argv);
  1122  
  1123  
  1124  
  1125  // binbuf functions
  1126  
  1127  /**
  1128  	Use binbuf_new() to create and initialize a Binbuf.
  1129  	@ingroup	binbuf
  1130  	@return		Returns a new binbuf if successful, otherwise NULL.
  1131  */
  1132  void *binbuf_new(void);
  1133  
  1134  
  1135  /**
  1136  	Use binbuf_vinsert() to append a Max message to a Binbuf adding a semicolon.
  1137  	@ingroup binbuf
  1138  	
  1139  	@param	x		Binbuf containing the desired t_atom. 
  1140  	@param	fmt		A C-string containing one or more letters corresponding to the types of each element of the message. 
  1141  					s for #t_symbol*, l for long, or f for float.
  1142  	@param	...		Elements of the message, passed directly to the function as Symbols, longs, or floats.
  1143  	
  1144  	@remark	binbuf_vinsert() works somewhat like a printf() for Binbufs. It 
  1145  	allows you to pass a number of arguments of different types and insert 
  1146  	them into a Binbuf. The entire message will then be terminated with a 
  1147  	semicolon. Only 16 items can be passed to binbuf_vinsert(). 
  1148  	
  1149  	The example below shows the implementation of a normal object's 
  1150  	save method. The save method requires that you build a message that 
  1151  	begins with #N (the new object) , followed by the name of your object 
  1152  	(in this case, represented by the #t_symbol myobject), followed by any 
  1153  	arguments your instance creation function requires. In this example, 
  1154  	we save the values of two fields m_val1 and m_val2 defined as longs. 
  1155  	
  1156  	@code
  1157  	void myobject_save (myObject *x, Binbuf *dstBuf) 
  1158  	{ 
  1159  		binbuf_vinsert(dstBuf, "ssll", gensym("#N"), 
  1160  			gensym("myobject"), 
  1161  			x->m_val1, x->m_val2); 
  1162  	}
  1163  	@endcode
  1164  	
  1165  	Suppose that such an object had written this data into a file. If you 
  1166  	opened the file as text, you would see the following: 
  1167  	
  1168  	@code
  1169  	#N myobject 10 20; 
  1170  	#P newobj 218 82 30 myobject; 
  1171  	@endcode
  1172  	
  1173  	The first line will result in a new myobject object to be created; the 
  1174  	creation function receives the arguments 10 and 20. The second line 
  1175  	contains the text of the object box. The newobj message to a patcher 
  1176  	creates the object box user interface object and attaches it to the 
  1177  	previously created myobject object. Normally, the newex message is 
  1178  	used. This causes the object to be created using the arguments that 
  1179  	were typed into the object box.
  1180  */
  1181  void binbuf_vinsert(void *x, char *fmt, ...);
  1182  
  1183  
  1184  /**
  1185  	Use binbuf_insert() to append a Max message to a Binbuf adding a semicolon.
  1186  	@ingroup binbuf
  1187  	
  1188  	@param	x		Binbuf to receive the items. 
  1189  	@param	s		Ignored. Pass NULL.
  1190  	@param	argc	Count of items in the argv array. 
  1191  	@param	argv	Array of t_atoms to add to the Binbuf. 
  1192  	
  1193  	@remark	You'll use binbuf_insert() instead of binbuf_append() if you were 
  1194  	saving your object into a Binbuf and wanted a semicolon at the end. If 
  1195  	the message is part of a file that will later be evaluated, such as a 
  1196  	Patcher file, the first argument argv[0] will be the receiver of the 
  1197  	message and must be a Symbol. binbuf_vinsert() is 
  1198  	easier to use than binbuf_insert(), since you don't have to format 
  1199  	your data into an array of Atoms first. 
  1200  	
  1201  	binbuf_insert() will also convert the t_symbols #1 through #9 into 
  1202  	$1 through $9. This is used for saving patcher files that take 
  1203  	arguments; you will probably never save these symbols as part of 
  1204  	anything you are doing.
  1205  */
  1206  void binbuf_insert(t_binbuf *x, t_symbol *s, short argc, t_atom *argv);
  1207  
  1208  
  1209  /**
  1210  	Use binbuf_eval to evaluate a Max message in a Binbuf, passing it arguments.
  1211  	binbuf_eval() is an advanced function that evaluates the message in a 
  1212  	Binbuf with arguments in argv, and sends it to receiver.
  1213  					
  1214  	@ingroup binbuf
  1215  	@param	x	Binbuf containing the message.
  1216  	@param	ac	Count of items in the argv array.
  1217  	@param	av	Array of t_atoms as the arguments to the message. 
  1218  	@param	to	Receiver of the message. 
  1219  
  1220  	@return		The result of sending the message.
  1221  */
  1222  void *binbuf_eval(t_binbuf *x, short ac, t_atom *av, void *to);
  1223  
  1224  
  1225  /**
  1226  	Use binbuf_getatom to retrieve a single t_atom from a Binbuf.
  1227  	
  1228  	@ingroup binbuf
  1229  	@param	x	Binbuf containing the desired #t_atom. 
  1230  	@param	p1	Offset into the Binbuf's array of types. Modified to point to the next #t_atom.
  1231  	@param	p2	Offset into the Binbuf's array of data. Modified to point to the next #t_atom.
  1232  	@param	ap	Location of a #t_atom where the retrieved data will be placed.
  1233  	
  1234  	@return		1 if there were no t_atoms at the specified offsets, 
  1235  				0 if there's a legitimate t_atom returned in result.
  1236  				
  1237  	@remark		To get the first t_atom, set both typeOffset and stuffOffset to 0.
  1238  				Here's an example of getting all the items in a Binbuf: 
  1239  	@code
  1240  	t_atom holder; 
  1241  	long to, so; 
  1242  	
  1243  	to = 0; 
  1244  	so = 0; 
  1245  	while (!binbuf_getatom(x, &to, &so, &holder)){
  1246  		// do something with the t_atom
  1247  	}
  1248  	@endcode
  1249  */
  1250  short binbuf_getatom(t_binbuf *x, long *p1, long *p2, t_atom *ap);
  1251  
  1252  /**
  1253  	Use binbuf_text() to convert a text handle to a Binbuf.
  1254  	binbuf_text() parses the text in the handle srcText and converts it 
  1255  	into binary format. Use it to evaluate a text file or text line entry into a 
  1256  	Binbuf.
  1257  	
  1258  	@ingroup binbuf
  1259  	@param	x		Binbuf to contain the converted text. 
  1260  					It must have already been created with binbuf_new. 
  1261  					Its previous contents are destroyed.
  1262  	@param	srcText	Handle to the text to be converted. It need not be terminated with a 0.
  1263  	@param	n		Number of characters in the text. 
  1264  	@return			If binbuf_text encounters an error during its operation, 
  1265  					a non-zero result is returned, otherwise it returns 0.
  1266  	
  1267  	@remark			Note: Commas, symbols containing a dollar sign followed by a number 
  1268  					1-9, and semicolons are identified by special pseudo-type constants for 
  1269  					you when your text is binbuf-ized. 
  1270  					
  1271  					The following constants in the a_type field of Atoms returned by 
  1272  					binbuf_getAtom identify the special symbols #A_SEMI, 
  1273  					#A_COMMA, and #A_DOLLAR. 
  1274  					
  1275  					For a #t_atom of the pseudo-type #A_DOLLAR, the a_w.w_long field of 
  1276  					the #t_atom contains the number after the dollar sign in the original 
  1277  					text or symbol. 
  1278  					
  1279  					Using these pseudo-types may be helpful in separating 'sentences' and 
  1280  					'phrases' in the input language you design. For example, the old pop-up 
  1281  					umenu object allowed users to have spaces in between words by requiring 
  1282  					the menu items be separated by commas. It's reasonably easy, using 
  1283  					binbuf_getatom(), to find the commas in a Binbuf in order to 
  1284  					determine the beginning of a new item when reading the atomized text 
  1285  					to be displayed in the menu.
  1286  					 
  1287  					If you want to use a literal comma or semicolon in a symbol, precede it 
  1288  					with a backslash (\\) character. The backslash character can be included 
  1289  					by using two backslashes in a row.
  1290  */
  1291  short binbuf_text(t_binbuf *x, char **srcText, long n);
  1292  
  1293  
  1294  /**
  1295  	Use binbuf_totext() to convert a Binbuf into a text handle.
  1296  	binbuf_totext() converts a Binbuf into text and places it in a handle. 
  1297  	Backslashes are added to protect literal commas and semicolons 
  1298  	contained in symbols. The pseudo-types are converted into commas, 
  1299  	semicolons, or dollar-sign and number, without backslashes preceding 
  1300  	them. binbuf_text can read the output of binbuf_totext and 
  1301  	make the same Binbuf.
  1302  		
  1303  	@ingroup binbuf
  1304  	@param	x		Binbuf with data to convert to text.
  1305  	@param	dstText	Pre-existing handle where the text will be placed. 
  1306  					dstText will be resized to accomodate the text. 
  1307  	@param	sizep	Where binbuf_totext() returns the number of characters in the converted text handle.
  1308  	@return			If binbuf_totext runs out of memory during its operation, it returns a non-zero result, 
  1309  					otherwise it returns 0.
  1310  */
  1311  short binbuf_totext(t_binbuf *x, char **dstText, t_ptr_size *sizep);
  1312  
  1313  
  1314  /**
  1315  	Use binbuf_set() to change the entire contents of a Binbuf. 
  1316  	The previous contents of the Binbuf are destroyed.
  1317  
  1318  	@ingroup binbuf
  1319  	@param	x		Binbuf to receive the items.
  1320  	@param	s		Ignored. Pass NULL.
  1321  	@param	argc	Count of items in the argv array.
  1322  	@param	argv	Array of t_atoms to put in the Binbuf.
  1323  */
  1324  void binbuf_set(t_binbuf *x, t_symbol *s, short argc, t_atom *argv);
  1325  
  1326  
  1327  /**
  1328  	Use binbuf_append to append t_atoms to a Binbuf without modifying them.
  1329  	@ingroup binbuf
  1330  	@param	x		Binbuf to receive the items.
  1331  	@param	s		Ignored.  Pass NULL.
  1332  	@param	argc	Count of items in the argv array.
  1333  	@param	argv	Array of atoms to add to the Binbuf.
  1334  */
  1335  void binbuf_append(t_binbuf *x, t_symbol *s, short argc, t_atom *argv);
  1336  
  1337  C74_DEPRECATED ( short binbuf_read(t_binbuf *x, const char *name, short volume, short binary) );
  1338  C74_DEPRECATED ( short binbuf_write(t_binbuf *x, char *fn, short vol, short binary) );
  1339  
  1340  void binbuf_delete(t_binbuf *x, long fromType, long toType, long fromData, long toData);
  1341  short binbuf_addtext(t_binbuf *x, char **text, long n);
  1342  
  1343  
  1344  /**
  1345  	Use readatom() to read a single t_atom from a text buffer.
  1346  	@ingroup		binbuf
  1347  	@param	outstr	C-string of 256 characters that will receive the next text item read from the buffer.
  1348  	@param	text	Handle to the text buffer to be read.
  1349  	@param	n		Starts at 0, and is modified by readatom to point to the next item in the text buffer. 
  1350  	@param	e		Number of characters in text.
  1351  	@param	ap		Where the resulting t_atom read from the text buffer is placed.
  1352  	@return			readatom() returns non-zero if there is more text to read, 
  1353  					and zero if it has reached the end of the text. 
  1354  					Note that this return value has the opposite logic from that of binbuf_getatom().
  1355  	
  1356  	@remark			This function provides access to the low-level Max text evaluator used 
  1357  					by binbuf_text(). It is designed to operate on a handle of characters 
  1358  					(text) and called in a loop, as in the example shown below.
  1359  	@code
  1360  	long index = 0; 
  1361  	t_atom dst; 
  1362  	char outstr[256]; 
  1363  	
  1364  	while (readatom(outstr,textHandle,&index,textLength,&dst)) 
  1365  	{ 
  1366  		// do something with the resulting t_atom
  1367  	} 
  1368  	@endcode
  1369  	
  1370  	@remark			An alternative to using readatom is to turn your text into a Binbuf 
  1371  					using binbuf_text(), then call binbuf_getatom() in a loop.
  1372  */
  1373  short readatom(char *outstr, char **text, long *n, long e, t_atom *ap);
  1374  short readatom_flags(char *outstr, char **text, long *n, long e, t_atom *ap, long flags);
  1375  char *atom_string(t_atom *a);
  1376  
  1377  // message functions
  1378  
  1379  /**	Send a typed message directly to a Max object.
  1380  	@ingroup class_old
  1381  	
  1382  	@param op	Max object that will receive the message. 
  1383  	@param msg	The message selector. 
  1384  	@param argc	Count of message arguments in argv. 
  1385  	@param argp	Array of t_atoms; the message arguments. 
  1386  	@return		If the receiver object can respond to the message, 
  1387  				typedmess() returns the result. Otherwise, an error message will be 
  1388  				seen in the Max window and 0 will be returned.
  1389  	
  1390  	@remark	typedmess sends a message to a Max object (receiver) a message 
  1391  		with arguments. Note that the message 
  1392  		must be a #t_symbol, not a character string, so you must call gensym 
  1393  		on a string before passing it to typedmess. Also, note that untyped 
  1394  		messages defined for classes with the argument list #A_CANT cannot be 
  1395  		sent using typedmess. You must use getfn() etc. instead. 
  1396  		
  1397  		Example: 
  1398  	@code
  1399  	//If you want to send a bang message to the object bang_me… 
  1400  	void *bangResult; 
  1401  	bangResult = typedmess(bang_me,gensym("bang"),0,0L);
  1402  	@endcode
  1403  */
  1404  void *typedmess(t_object *op, t_symbol *msg, short argc, t_atom *argp);
  1405  
  1406  
  1407  /** Use getfn() to send an untyped message to a Max object with error checking.
  1408  	@ingroup class_old
  1409  	
  1410  	@param op	Receiver of the message.
  1411  	@param msg	Message selector.
  1412  	@return		getfn returns a pointer to the method bound to the message selector 
  1413  				msg in the receiver's message list. It returns 0 and prints an error 
  1414  				message in Max Window if the method can't be found.
  1415  */
  1416  method getfn(t_object *op, t_symbol *msg);
  1417  
  1418  
  1419  /** Use egetfn() to send an untyped message to a Max object that always works.
  1420  	@ingroup class_old
  1421  	
  1422  	@param op	Receiver of the message.
  1423  	@param msg	Message selector.
  1424  	@return		egetfn returns a pointer to the method bound to the message selector 
  1425  				msg in the receiver's message list. If the method can't be found, a 
  1426  				pointer to a do-nothing function is returned.
  1427  */
  1428  method egetfn(t_object *op, t_symbol *msg);
  1429  
  1430  
  1431  /** Use zgetfn() to send an untyped message to a Max object without error checking.
  1432  	@ingroup class_old
  1433  	
  1434  	@param op	Receiver of the message.
  1435  	@param msg	Message selector.
  1436  	@return		zgetfn returns a pointer to the method bound to the message selector 
  1437  				msg in the receiver's message list. It returns 0 but doesn't print an 
  1438  				error message in Max Window if the method can't be found.
  1439  */
  1440  method zgetfn(t_object *op, t_symbol *msg);
  1441  
  1442  
  1443  void patcher_eachdo(t_intmethod fun, void *arg);	// this one is still legit
  1444  void loadbang_suspend(void);  // used by poly~ on windows
  1445  void loadbang_resume(void);  // used by poly~ on windows
  1446  char noloadbangdisable_get(void);
  1447  
  1448  // table functions
  1449  
  1450  /**	Get a handle to the data in a named table object.
  1451  	@ingroup tables
  1452  	
  1453  	@param s	Symbol containing the name of the table object to find.
  1454  	@param hp	Address of a handle where the table's data will be returned if the named table object is found.
  1455  	@param sp	Number of elements in the table (its size in longs). 
  1456  	@return		If no table object is associated with the symbol tableName, table_get() returns a non-zero result.
  1457  	
  1458  	@remark		table_get searches for a table associated with the t_symbol 
  1459  				tableName. If one is found, a Handle to its elements (stored as an 
  1460  				array of long integers) is returned and the function returns 0. 
  1461  				Never count on a table to exist across calls to 
  1462  				one of your methods. Call table_get and check the result each time 
  1463  				you wish to use a table. 
  1464  	
  1465  				Here is an example of retrieving the 40th element of a table: 
  1466  	@code
  1467  	long **storage,size,value; 
  1468  	if (!table_get(gensym("somename"),&storage,&size)) { 
  1469  		if (size > 40) 
  1470  			value = *((*storage)+40); 
  1471  	}
  1472  	@endcode
  1473  */
  1474  short table_get(t_symbol *s, long ***hp, long *sp);
  1475  
  1476  
  1477  /**	Mark a table object as having changed data.
  1478  	@ingroup tables
  1479  	@param s	Symbol containing the name of a table object.
  1480  	@return		If no table is associated with tableName, table_dirty returns a non-zero result.
  1481  */
  1482  short table_dirty(t_symbol *s);
  1483  
  1484  
  1485  // file functions
  1486  
  1487  /** Load a data file into a handle.
  1488  	This is a low-level routine used for reading text and data files. You 
  1489  		specify the file's name and Path ID, as well as a pointer to a Handle.
  1490  
  1491  	@ingroup loading_max_files
  1492  	@param	name	Name of the patcher file to load. 
  1493  	@param	volume	Path ID specifying the location of the file.
  1494  	@param	h		Pointer to a handle variable that will receive the handle 
  1495  					that contains the data in the file.
  1496  	@param	sizep	Size of the handle returned in h. 
  1497  	@return			If the file is found, readtohandle creates a Handle, reads all the data in 
  1498  					the file into it, assigns the handle to the variable hp, and returns the 
  1499  					size of the data in size. readtohandle returns 0 if the file was 
  1500  					opened and read successfully, and non-zero if there was an error.
  1501  */
  1502  short readtohandle(C74_CONST char *name, short volume, char ***h, long *sizep);
  1503  
  1504  /** Load a patcher file by name and volume reference number.
  1505  	@ingroup loading_max_files
  1506  	@param	name	Filename of the patcher file to load (C string). 
  1507  	@param	vol		Path ID specifying the location of the file.
  1508  	@return			If the file is found, fileload tries to open 
  1509  					the file, evaluate it, open a window, and bring it to the front. A pointer 
  1510  					to the newly created Patcher is returned if loading is successful, 
  1511  					otherwise, if the file is not found or there is insufficient memory, zero 
  1512  					is returned.
  1513  */
  1514  void *fileload(C74_CONST char *name, short vol);
  1515  
  1516  
  1517  /** Pass arguments to Max files when you open them.
  1518  	This function loads the specified file and returns a pointer to the 
  1519  	created object. Historically, intload() is was used to open patcher files, 
  1520  	whether they are in text or Max binary format. 
  1521  	It could also open table files whose contents begin with the word "table". 
  1522  	
  1523  	@ingroup loading_max_files
  1524  	@param	name		Name of the file to open. 
  1525  	@param	volume		Path ID specifying the location of the file. 
  1526  	@param	s			A symbol.
  1527  	@param	ac			Count of t_atoms in av. To properly open a patcher file, ac should be 9. 
  1528  	@param	av			Array of t_atoms that will replace the changeable 
  1529  						arguments 1-9. The default behavior could be to set 
  1530  						all these to t_atoms of type #A_LONG with a value of 0.
  1531  	@param	couldedit	If non-zero and the file is not a patcher file, the file is opened as a text file.
  1532  	@return				If couldedit is non-zero and the file is not a patcher file, it is made into 
  1533  						a text editor, and intoad() returns 0. If couldedit is non-zero, intload()
  1534  						will alert the user to an error and return 0. If there is no error, the 
  1535  						value returned will be a pointer to a patcher or table object. 
  1536  */
  1537  void *intload(C74_CONST char *name, short volume, t_symbol *s, short ac, t_atom *av, short couldedit);
  1538  
  1539  
  1540  /** Load a patcher file located in the Max search path by name.
  1541  	This function searches for a patcher file, opens it, 
  1542  	evaluates it as a patcher file, opens a window for the patcher and brings 
  1543  	it to the front. You need only specify a filename and Max will look 
  1544  	through its search path for the file. The search path begins with the 
  1545  	current 'default volume' that is often the volume of the last opened 
  1546  	patcher file, then the folders specified in the File Preferences dialog, 
  1547  	searched depth first, then finally the folder that contains the Max 
  1548  	application.
  1549  
  1550  	@ingroup loading_max_files
  1551  	@param	name	Filename of the patcher file to load (C string).
  1552  	@return			If stringload() returns a non-zero result, you can later 
  1553  					use freeobject() to close the patcher, or just let users do it themselves. 
  1554  					If stringload() returns zero, no file with the specified name was 
  1555  					found or there was insufficient memory to open it.
  1556  */
  1557  void *stringload(C74_CONST char *name);
  1558  
  1559  void *resource_install(char *name, long rsrc);
  1560  void *toolfile_new(const char *name, short vol, t_fourcc type);
  1561  long toolfile_fread(t_toolfile *t, char *buf, long n);
  1562  long toolfile_fwrite(t_toolfile *t, char *buf, long n);
  1563  short toolfile_getc(t_toolfile *t);
  1564  void *onecopy_fileload(C74_CONST char *s, short path);
  1565  
  1566  // preset functions
  1567  
  1568  /** Give the preset object a general message to restore the current state of your object.
  1569  	This is a general preset function for use when your object's state 
  1570  	cannot be restored with a simple int or set message. The example 
  1571  	below shows the expected format for specifying what your current 
  1572  	state is to a preset object. The first thing you supply is your object itself, 
  1573  	followed by the symbol that is the name of your object's class (which 
  1574  	you can retrieve from your object using the macro ob_sym, declared in 
  1575  	ext_mess.h). Next, supply the symbol that specifies the message you 
  1576  	want receive (a method for which had better be defined in your class), 
  1577  	followed by the arguments to this message—the current values of your 
  1578  	object's fields.
  1579  
  1580  	@ingroup presets
  1581  	@param	fmt		C string containing one or more letters corresponding 
  1582  					to the types of each element of the message. s for 
  1583  					Symbol, l for long, or f for float.
  1584  	@param	...		Elements of the message used to restore the state of 
  1585  					your object, passed directly to the function as Symbols, 
  1586  					longs, or floats. See below for an example that 
  1587  					conforms to what the preset object expects.
  1588  */
  1589  void preset_store(char *fmt, ... /*struct b100 arg1 */);
  1590  
  1591  
  1592  /** Restore the state of your object with a set message.
  1593  	This function causes a set message with the argument value to be sent 
  1594  	to your object from the preset object when the user executes a preset.
  1595  
  1596  	@ingroup presets	
  1597  	@param	obj		Your object.
  1598  	@param	val		Current value of your object.
  1599  	
  1600  */
  1601  void preset_set(t_object *obj, t_atom_long val);
  1602  
  1603  
  1604  /**	Restore the state of your object with an int message.
  1605  	This function causes an int message with the argument value to be 
  1606  	sent to your object from the preset object when the user executes a 
  1607  	preset. All of the existing user interface objects use the int message for 
  1608  	restoring their state when a preset is executed. 
  1609  
  1610  	@ingroup presets	
  1611  	@param	x	Your object.
  1612  	@param	n	Current value of your object.
  1613  */
  1614  void preset_int(t_object *x, t_atom_long n);
  1615  
  1616  
  1617  C74_DEPRECATED ( void evnum_incr(void) );
  1618  C74_DEPRECATED ( long evnum_get(void) );
  1619  
  1620  
  1621  // proxy functions
  1622  
  1623  /**
  1624  	Use proxy_new to create a new Proxy object. 
  1625  	
  1626  	@ingroup inout
  1627  	@param	x			Your object. 
  1628  	@param	id			A non-zero number to be written into your object when a message is received in this particular Proxy.
  1629  						Normally, id will be the inlet number analogous to in1, in2 etc. 
  1630  	@param	stuffloc	A pointer to a location where the id value will be written.
  1631  	@return				A pointer to the new proxy inlet.
  1632  	
  1633  	@remark		This routine creates a new Proxy object (that includes an inlet). It 
  1634  				allows you to identify messages based on an id value stored in the 
  1635  				location specified by stuffLoc. You should store the pointer 
  1636  				returned by proxy_new() because you'll need to free all Proxies in your 
  1637  				object's free function using object_free(). 
  1638  				
  1639  				After your method has finished, Proxy sets the stuffLoc location 
  1640  				back to 0, since it never sees messages coming in an object's leftmost 
  1641  				inlet. You'll know you received a message in the leftmost inlet if the 
  1642  				contents of stuffLoc is 0. As of Max 4.3, stuffLoc is not always 
  1643  				guaranteed to be a correct indicator of the inlet in which a message was 
  1644  				received. Use proxy_getinlet() to determine the inlet number. 	
  1645  */
  1646  void *proxy_new(void *x, long id, long *stuffloc);
  1647  
  1648  /**
  1649  	Use proxy_getinlet to get the inlet number in which a message was received.
  1650  	Note that the <code>owner</code> argument should point to your external object's instance, not a proxy object.
  1651  
  1652  	@ingroup inout
  1653  	@param	master	Your object. 
  1654  	@return			The index number of the inlet that received the message.
  1655  */
  1656  long proxy_getinlet(t_object *master);
  1657  
  1658  // the following functions are only used by dynamic inlet/outlet code
  1659  void *proxy_append(t_object *master, long id, long *stuffloc);
  1660  void *proxy_insert(t_object *master, long id, long *stuffloc, void *previous_proxy);
  1661  void *proxy_new_forinlet(t_object *master, long id, long *stuffloc, void *inlet); // create a new proxy for inlet
  1662  void proxy_delete(void *xx); // calls inlet_delete()
  1663  void proxy_setinletptr(void *xx, void *inlet); // associates proxy with inlet, removes any previous association
  1664  void *proxy_getinletptr(void *xx); // retrienve an associated inlet	
  1665  
  1666  //void *gwind_new(t_object *assoc, t_symbol *s, short style, short left, short top, short bottom, short right);
  1667  
  1668  
  1669  // connection functions
  1670  void *connection_client(t_object *cli, t_symbol *name, t_symbol *classname, method traverse);
  1671  void connection_server(t_object *obj, t_symbol *name);
  1672  void connection_send(t_object *server, t_symbol *name, t_symbol *mess, void *arg);
  1673  void connection_delete(t_object *ob, t_symbol *name);
  1674  
  1675  
  1676  // quittask functions
  1677  
  1678  /**
  1679  	Register a function that will be called when Max exits.
  1680  
  1681  	@ingroup misc
  1682  	@param	m	A function that will be called on Max exit.
  1683  	@param	a	Argument to be used with method m.
  1684  	
  1685  	@remark		quittask_install() provides a mechanism for your external to 
  1686  	register a routine to be called prior to Max shutdown. This is useful for 
  1687  	objects that need to provide disk-based persistance outside the 
  1688  	standard Max storage mechanisms, or need to shut down hardware or 
  1689  	their connection to system software and cannot do so in the 
  1690  	termination routine of a code fragment.
  1691  */
  1692  void quittask_install(method m, void *a);
  1693  
  1694  
  1695  /**
  1696  	Unregister a function previously registered with quittask_install().
  1697  
  1698  	@ingroup misc
  1699  	@param	m	Function to be removed as a shutdown method.
  1700  */
  1701  void quittask_remove(method m);
  1702  void quittask_remove2(method m, void *a);
  1703  
  1704  // miscellaneous functions
  1705  
  1706  /**
  1707  	Determine version information about the current Max environment.
  1708  
  1709  	This function returns the version number of Max. In Max versions 
  1710  	2.1.4 and later, this number is the version number of the Max kernel 
  1711  	application in binary-coded decimal. Thus, 2.1.4 would return 214 hex 
  1712  	or 532 decimal. Version 3.0 returns 300 hex. 
  1713  	
  1714  	Use this to check for the existence of particular function macros that are only present in more 
  1715  	recent Max versions. Versions before 2.1.4 returned 1, except for 
  1716  	versions 2.1.1 - 2.1.3 which returned 2. 
  1717  	
  1718  	Bit 14 (counting from left) will 
  1719  	be set if Max is running as a standalone application, so you should 
  1720  	mask the lower 12 bits to get the version number.
  1721  		
  1722  	@ingroup	misc
  1723  	@return		The Max environment's version number.
  1724  */
  1725  short maxversion(void);
  1726  
  1727  
  1728  C74_DEPRECATED ( long serialno(void) );
  1729  
  1730  short ispatcher(t_object *x);
  1731  short isnewex(t_object *x);
  1732  void colorinfo(void *r);
  1733  
  1734  /**
  1735  	Use open_promptset() to add a prompt message to the open file dialog displayed by open_dialog().
  1736  
  1737  	Calling this function before open_dialog() permits a string to 
  1738  	displayed in the dialog box instructing the user as to the purpose of the 
  1739  	file being opened. It will only apply to the call of open_dialog() that 
  1740  	immediately follows open_promptset().
  1741  
  1742  	@ingroup files
  1743  	@param	s		A C-string containing the prompt you wish to display in the dialog box.
  1744  	@return			Ignore.
  1745  	
  1746  	@see open_dialog()
  1747  */
  1748  void open_promptset(C74_CONST char *s);
  1749  
  1750  
  1751  /**
  1752  	Use saveas_promptset() to add a prompt message to the open file dialog displayed by saveas_dialog()
  1753  	or saveasdialog_extended().
  1754  
  1755  	Calling this function before saveasdialog_extended() permits a string to 
  1756  	displayed in the dialog box instructing the user as to the purpose of the 
  1757  	file being opened. It will only apply to the call of saveasdialog_extended() that 
  1758  	immediately follows saveas_promptset().
  1759  
  1760  	@ingroup files
  1761  	@param	s		A C-string containing the prompt you wish to display in the dialog box.
  1762  	@return			Ignore.
  1763  	
  1764  	@see open_dialog()
  1765  */
  1766  void saveas_promptset(C74_CONST char *s);
  1767  
  1768  
  1769  void dialog_setkey(t_fourcc type);
  1770  void saveasdialog_pathset(short path, short force);
  1771  void dialog_poll(short dosched, short doevent, unsigned short evtMask);
  1772  void forecolor(short index, short way);
  1773  void backcolor(short index, short way);
  1774  void *tabfromhandle(t_handle h, long n);
  1775  void stdlist(t_object *x, t_symbol *s, short ac, t_atom *av);
  1776  void assist_queue(t_object *x, method fun);
  1777  void inspector_open(t_object *x, void *p, void *b);
  1778  void *object_subpatcher(t_object *x, long *index, void *arg);
  1779  
  1780  // filewatch functions
  1781  
  1782  /**	Create a new filewatcher.
  1783  	The file will not be actively watched until filewatcher_start() is called.
  1784  	The filewatcher can be freed using object_free().
  1785  	
  1786  	@ingroup			files
  1787  	@param	owner		Your object.  
  1788  						This object will receive the message "filechanged" when the watcher sees a change in the file or folder.
  1789  	@param	path		The path in which the file being watched resides, or the path of the folder being watched.
  1790  	@param	filename	The name of the file being watched, or an empty string if you are simply watching the folder specified by path.
  1791  	@return				A pointer to the new filewatcher.
  1792  	@remark				The "filechanged" method should have the prototype:
  1793  	@code
  1794  	void myObject_filechanged(t_myObject *x, char *filename, short path);
  1795  	@endcode
  1796  	*/
  1797  void *filewatcher_new(t_object *owner, C74_CONST short path, C74_CONST char *filename);
  1798  
  1799  /**	Start watching a file using a filewatcher created with filewatcher_new().
  1800  	@param	x			A filewatcher pointer, as returned by filewatcher_new().	*/
  1801  void filewatcher_start(void *x);
  1802  
  1803  /**	Stop watching a file using a filewatcher created with filewatcher_new().
  1804  	@param	x			A filewatcher pointer, as returned by filewatcher_new().	*/
  1805  void filewatcher_stop(void *x);
  1806  
  1807  
  1808  
  1809  // fileusage functions
  1810  
  1811  /**	Add a file to a collective.
  1812  	@ingroup		files
  1813  	@param	w		Handle for the collective builder.
  1814  	@param	flags	If flags == 1, copy this file to support folder of an app instead of to the collective in an app.
  1815  	@param	name	The name of the file.
  1816  	@param	path	The path of the file to add.
  1817  */
  1818  void fileusage_addfile(void *w, long flags, C74_CONST char *name, short path);
  1819  
  1820  void fileusage_addfilename(void *w, long flags, C74_CONST char *name);
  1821  
  1822  /**	Add a package to a standalone.
  1823  	@ingroup					files
  1824  	@param	w					Handle for the standalone builder
  1825  	@param	name				The name of the package
  1826  	@param	subfoldernames		A #t_atomarray containing symbols, each of which is a foldername in the package to include.
  1827  								Pass NULL to include the entire package contents.
  1828  	@version					Introduced in Max 7.0.4
  1829   */
  1830  void fileusage_addpackage(void *w, C74_CONST char *name, t_atomarray *subfoldernames);
  1831  void fileusage_addpathname(void *w, long flags, C74_CONST char *name);
  1832  void fileusage_copyfolder(void *w, C74_CONST char *name, long recursive);
  1833  void fileusage_makefolder(void *w, C74_CONST char *name);
  1834  
  1835  /**	Add a folder to a standalone.
  1836   @ingroup					files
  1837   @param	w					Handle for the standalone builder
  1838   @param	path				Path of the folder
  1839   @param	recursive			Add the contents of the folder recursively (respected only when building standalones)
  1840   @version					Introduced in Max 8.0.2
  1841   */
  1842  void fileusage_addfolder(void *w, short path, long recursive);
  1843  
  1844  #ifdef MAC_VERSION
  1845  long fontinfo_getencoding(long id);
  1846  long fontinfo_convert(t_object *x, char *src, long srclen, long encoding, char **out);
  1847  long fontinfo_reconvert(t_object *x, char *src, long srclen, long encoding, char **out);
  1848  void fontinfo_reconverthandle(t_object *x, char **h, long encoding);
  1849  #endif
  1850  
  1851  
  1852  long fontinfo_prefcheckencoding(void);
  1853  
  1854  t_atom *atom_dynamic_start(const t_atom *static_array, long static_count, long request_count);
  1855  void atom_dynamic_end(const t_atom *static_array, t_atom *request_array);
  1856  	
  1857  short getfolder(short *vol);
  1858  	
  1859  /**
  1860   Present the user with the standard open file dialog.
  1861   This function is convenient wrapper for using Mac OS Navigation 
  1862   Services or Standard File for opening files. 
  1863   
  1864   The mapping of extensions to types is configured in the C74:/init/max-fileformats.txt file.
  1865   The standard types to use for Max files are 'maxb' for old-format binary files, 
  1866   'TEXT' for text files, and 'JSON' for newer format patchers or other .json files.
  1867   
  1868   @ingroup files
  1869   @param	name	A C-string that will receive the name of the file the user wants to open.
  1870   The C-string should be allocated with a size of at least #MAX_FILENAME_CHARS.
  1871   @param	volptr	Receives the Path ID of the file the user wants to open.
  1872   @param	typeptr	The file type of the file the user wants to open.
  1873   @param	types	A list of file types to display. This is not limited to 4 
  1874   types as in the SFGetFile() trap. Pass NULL to display all types.
  1875   @param	ntypes	The number of file types in typelist. Pass 0 to display all types.
  1876   
  1877   @return			0 if the user clicked Open in the dialog box.  
  1878   If the user cancelled, open_dialog() returns a non-zero value.
  1879   
  1880   @see saveasdialog_extended()
  1881   @see locatefile_extended()
  1882   */
  1883  short open_dialog(char *name, short *volptr, t_fourcc *typeptr, t_fourcc *types, short ntypes);
  1884  
  1885  
  1886  /**
  1887   Present the user with the standard save file dialog.
  1888   
  1889   The mapping of extensions to types is configured in the C74:/init/max-fileformats.txt file.
  1890   The standard types to use for Max files are 'maxb' for old-format binary files, 
  1891   'TEXT' for text files, and 'JSON' for newer format patchers or other .json files.
  1892   
  1893   @ingroup files
  1894   @param	filename	A C-string containing a default name for the file to save.
  1895   If the user decides to save a file, its name is returned here.
  1896   The C-string should be allocated with a size of at least #MAX_FILENAME_CHARS.
  1897   
  1898   @param	path		If the user decides to save the file, the Path ID of the location chosen is returned here.
  1899   
  1900   @param	binptr		Pass NULL for this parameter.  
  1901   This parameter was used in Max 4 to allow the choice of saving binary or text format patchers.
  1902   
  1903   @return				0 if the user choose to save the file.  
  1904   If the user cancelled, returns a non-zero value.
  1905   
  1906   @see open_dialog()
  1907   @see saveasdialog_extended()
  1908   @see locatefile_extended()
  1909   */
  1910  short saveas_dialog(char *filename, short *path, short *binptr);
  1911  
  1912  
  1913  /**
  1914   Present the user with the standard save file dialog with your own list of file types.
  1915   
  1916   saveasdialog_extended() is similar to saveas_dialog(), but allows the 
  1917   additional feature of specifying a list of possible types. These will be 
  1918   displayed in a pop-up menu. 
  1919   
  1920   File types found in the typelist argument that match known Max types 
  1921   will be displayed with descriptive text. Unmatched types will simply 
  1922   display the type name (for example, "foXx" is not a standard type so it 
  1923   would be shown in the pop-up menu as foXx) 
  1924   
  1925   Known file types include:
  1926   - TEXT: text file 
  1927   - maxb: Max binary patcher 
  1928   - maxc: Max collective 
  1929   - Midi: MIDI file 
  1930   - Sd2f: Sound Designer II audio file 
  1931   - NxTS: NeXT/Sun audio file 
  1932   - WAVE: WAVE audio file. 
  1933   - AIFF: AIFF audio file
  1934   - mP3f: Max preference file 
  1935   - PICT: PICT graphic file 
  1936   - MooV: Quicktime movie file 
  1937   - aPcs: VST plug-in 
  1938   - AFxP: VST effect patch data file 
  1939   - AFxB: VST effect bank data file 
  1940   - DATA: Raw data audio file 
  1941   - ULAW: NeXT/Sun audio file
  1942   
  1943   @ingroup files
  1944   @param	name		A C-string containing a default name for the file to save.
  1945   If the user decides to save a file, its name is returned here.
  1946   The C-string should be allocated with a size of at least #MAX_FILENAME_CHARS.
  1947   
  1948   @param	vol			If the user decides to save the file, the Path ID of the location chosen is returned here.
  1949   
  1950   @param	type		Returns the type of file chosen by the user.
  1951   @param	typelist	The list of types provided to the user. 
  1952   @param	numtypes	The number of file types in typelist.
  1953   
  1954   @return				0 if the user choose to save the file.  
  1955   If the user cancelled, returns a non-zero value.
  1956   
  1957   @see open_dialog()
  1958   @see locatefile_extended()
  1959   */
  1960  short saveasdialog_extended(char *name, short *vol, t_fourcc *type, t_fourcc *typelist, short numtypes);
  1961  
  1962  void saveas_autoextension(t_bool way);
  1963  void saveas_setselectedtype(t_fourcc type);
  1964  
  1965  short preferences_path(C74_CONST char *name, short create, short *path);
  1966  short preferences_subpath(C74_CONST char *name, short path, short create, short *subpath);
  1967  short textpreferences_read(C74_CONST char *filename, short path, short defaultid);
  1968  short textpreferences_default(short id);
  1969  void *textpreferences_open(void);
  1970  void textpreferences_addraw(void *p, C74_CONST char *fmt, ...);
  1971  void textpreferences_add(void *p, C74_CONST char *fmt, ...);
  1972  void textpreferences_addoption(void *p, C74_CONST char *fmt, ...);
  1973  void textpreferences_addrect(void *p, char *msg, short top, short left, short bottom, short right);
  1974  short textpreferences_close(void *p, C74_CONST char *filename, short path);
  1975  	
  1976  END_USING_C_LINKAGE
  1977  
  1978  #endif // _EXT_PROTO_H_
  1979