home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 20
/
AACD20.BIN
/
AACD
/
Utilities
/
MultiRen
/
Developers
/
Template.mrp.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-07-03
|
4KB
|
138 lines
/* Template for making plugins for MultiRen in C.
Please use this template and change NOTHING in main()!
By Deniil 715! 2000-07-04, rev #2.
*/
#include<proto/exec.h>
#include<proto/dos.h>
#include<proto/intuition.h>
#include<exec/tasks.h>
#include<intuition/intuition.h>
#include<stdlib.h>
#include<stdio.h>
#define _VER "$VER: Template v1.1 by Deniil 715! rev.#2 (2000-07-04)"
#define NUMSTRINGS_FOR_THIS_PLUGIN 1
#define FILE_NAME_LENGTH 512
#define COM_ASK 1
#define COM_EXTRACT 2
#define COM_CONFIGURE 3
#define COM_ABOUT 4
#define COM_QUIT 5
#define ERR_OK 0
#define ERR_NOMEM 1
#define ERR_NOFILE 2
#define ERR_NOSIG 3
#define ERR_NOTIMPL 4
#define ERR_UNKNOWN 5
#define ERR_OTHER 6
#define ERR_WRONGFORMAT 7
#define ERR_NOINFO 8
#define ERR_FATAL 20
struct multiren_plugin {
long id;
Task *task;
long sig;
short ret;
char command;
char numstrings; /* You will */
char *stringlist[256]; /* only use */
char *name; /* these 4 */
char newname; /* elements */
};
short ask(void);
short extract(void);
short configure(void);
short about(void);
short cleanup(void);
short req(char*,char*);
struct multiren_plugin *mrp;
int main(int argc,char *argv[]) {
char sigbit;
long sig, msig;
Task *mtask;
if(DOSBase=(struct DosLibrary*)OpenLibrary("dos.library",0)) {
if(IntuitionBase=(struct IntuitionBase*)OpenLibrary("shortuition.library",0)) {
if(argc==2) {
if(mrp=(struct multiren_plugin*)atol(argv[1])) {
if(mrp->id==*(long*)"MRPO") {
if((sigbit=AllocSignal(-1))>=0) {
sig=1<<sigbit;
while(1) {
switch(mrp->command) {
case COM_ASK:
mtask=mrp->task;
msig=mrp->sig;
mrp->ret=ask();
SetProgramName(mrp->name);
mrp->task=FindTask(0L);
mrp->sig=sig;
break;
case COM_EXTRACT: mrp->ret=extract(); break;
case COM_CONFIGURE: mrp->ret=configure(); break;
case COM_ABOUT: mrp->ret=about(); break;
case COM_QUIT:
mrp->ret=cleanup();
FreeSignal(sigbit);
CloseLibrary((struct Library*)DOSBase);
Signal(mtask,msig);
return 0;
default:
mrp->ret=ERR_UNKNOWN;
}
Signal(mtask,msig);
Wait(sig);
}
}
else {
mrp->ret=ERR_NOSIG;
Signal(mrp->task,mrp->sig);
return 0;
}
}
}
}
CloseLibrary((struct Library*)IntuitionBase);
}
CloseLibrary((struct Library*)DOSBase);
}
printf("This is a plugin for MultiRen!\n"
"It is not supposed to be executed manually!\n"
"Use it through the Renplacer tool in MultiRen instead!\n");
return ERR_FATAL;
}
short ask() {
mrp->numstrings=NUMSTRINGS_FOR_THIS_PLUGIN;
mrp->stringlist[0]="<template>";
mrp->name="<template>";
mrp->newname=0; /* 0 = Request Old name, 1 = Request New name */
return ERR_OK;
}
short extract() {
mrp->stringlist[0]="<template>";
return ERR_OK;
}
short configure() { return ERR_NOTIMPL; }
short about() {
req("About template..","OK");
return ERR_OK;
}
short cleanup() { return ERR_OK; }
short req(char *body,char *gads) {
struct EasyStruct tags;
tags.es_Title="Test Plugin";
tags.es_TextFormat=body;
tags.es_GadgetFormat=gads;
return EasyRequestArgs(NULL,&tags,NULL,NULL);
}