Chiuso

Sviluppare una Applicazione Mac

HI,

I need convert a DLL from Windows C++ to Mac C++

I have the source code, I write the windows version,

I need have the source code and a Mac batch to compile on Mac

The DLL use the cUrl library to call a web site and return the html

The code ha 6 files:

I will send the file by mail..

/*************************

/ MAIN FILE

/*************************

extern "C"

{

#include "mm_jsapi.h"

}

#include "global.h"

#include "WebRequest.h"

#include "MMInfo.h"

/* Every implementation of a Javascript function must have this signature */

JSBool

getServerBehaviorDefinition(JSContext *cx, JSObject *obj, unsigned int argc,

jsval *argv, jsval *rval)

{

char *m_user_name;

char *m_password;

char *m_serial;

char *m_operazione;

char *m_extension;

char *m_url;

char *m_version;

char *m_sub_type;

/* Make sure the right number of arguments were passed in */

if (argc != 8)

return JS_FALSE;

JSBool success = JS_TRUE;

m_user_name = JS_ValueToString(cx, argv[0], 0);

m_password = JS_ValueToString(cx, argv[1], 0);

m_serial = JS_ValueToString(cx, argv[2], 0);

m_operazione = JS_ValueToString(cx, argv[3], 0);

m_extension = JS_ValueToString(cx, argv[4], 0);

m_url = JS_ValueToString(cx, argv[5], 0);

m_version = JS_ValueToString(cx, argv[6], 0);

m_sub_type = JS_ValueToString(cx, argv[7], 0);

char* f_html = new char[10];

char* f_params[14] = {

"user_name", m_user_name,

"password", m_password,

"serial", m_serial,

"operazione", m_operazione,

"extension", m_extension,

"version", m_version,

"sub_type", m_sub_type};

int f_result = CallWeb(m_url, f_params, f_html);

if (f_result == 1) {

success = JS_StringToValue(cx, f_html, 0, rval);

}

else {

f_html = "error_void_response";

success = JS_StringToValue(cx, f_html, 0, rval);

}

/* Indicate success */

return success;

}

JSBool

setShowMessage(JSContext *cx, JSObject *obj, unsigned int argc,

jsval *argv, jsval *rval)

{

if (argc != 1)

return JS_FALSE;

char *m_show = JS_ValueToString(cx, argv[0], 0);

if (strcmp(m_show, "1") == 0) {

m_show_message = 1;

}

else {

m_show_message = 0;

}

return JS_TRUE;

}

JSBool

setWriteLog(JSContext *cx, JSObject *obj, unsigned int argc,

jsval *argv, jsval *rval)

{

if (argc != 1)

return JS_FALSE;

char *m_show = JS_ValueToString(cx, argv[0], 0);

if (strcmp(m_show, "1") == 0) {

m_write_log = 1;

}

else {

m_write_log = 0;

}

return JS_TRUE;

}

JSBool

setLogPath(JSContext *cx, JSObject *obj, unsigned int argc,

jsval *argv, jsval *rval)

{

if (argc != 1)

return JS_FALSE;

m_log_path = JS_ValueToString(cx, argv[0], 0);

return JS_TRUE;

}

/* MM_STATE is a macro that expands to some definitions that are

* needed in order interact with Dreamweaver. This macro must be

* defined exactly once in your library */

MM_STATE

/* Dreamweaver calls MM_Init when your library is loaded. */

void

MM_Init()

{

/* Declare the Javascript function, giving it a name that's

* likely to be unique */

JS_DefineFunction("getServerBehaviorDefinition", getServerBehaviorDefinition, 8);

JS_DefineFunction("setShowMessage", setShowMessage, 1);

JS_DefineFunction("setWriteLog", setWriteLog, 1);

JS_DefineFunction("setLogPath", setLogPath, 1);

}

/*************************

/ GLOBAL.H

/*************************

#ifndef _DWZ_GLOBAL_H_

#define _DWZ_GLOBAL_H_

#include <string.h>

#include <fstream>

#include <windows.h>

static int m_show_message = 0;

static int m_write_log = 0;

static std::string m_log_path;

void write_text_to_log_file(char *text)

{

if (m_write_log == 0 || [url removed, login to view]() == 0) {

return;

}

std::ofstream log(m_log_path, std::ios_base::app | std::ios_base::out);

log << text << "\n";

}

void ShowError(char *text)

{

if (m_show_message == 0) {

return;

}

MessageBox(0, (LPCSTR)text, (LPCSTR)("Errore"), MB_OK);

}

#endif

/*************************

/ WebRequest.h

/*************************

#include "global.h"

#include "curl/curl.h"

#include <fstream>

#include <string.h>

static std::string readBuffer;

static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)

{

((std::string*)userp)->append((char*)contents, size * nmemb);

return size * nmemb;

}

int CallWeb(char *v_url, char* v_params[], char* &res) {

int f_result = 0;

std::string f_str_params = "";

char* f_key = NULL;

char* f_value = NULL;

for (int x = 0; x < sizeof(v_params); x = x + 2) {

if (x > 0) {

f_str_params += "&";

}

f_key = v_params[x];

f_value = v_params[x + 1];

f_str_params += f_key;

f_str_params += "=";

f_str_params += f_value;

}

char *f_char_params = _strdup(f_str_params.c_str());

f_str_params += "&PAR-NAME";

f_str_params += "=";

f_str_params += "SOME-TEXT";

CURL *curl;

CURLcode response;

[url removed, login to view]();

/* In windows, this will init the winsock stuff */

curl_global_init(CURL_GLOBAL_ALL);

/* get a curl handle */

curl = curl_easy_init();

if (curl) {

/* First set the URL that is about to receive our POST. This URL can

just as well be a https:// URL if that is what should receive the

data. */

curl_easy_setopt(curl, CURLOPT_URL, v_url);

/* Now specify the POST data */

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, f_char_params);

curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);

curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

/* Perform the request, res will get the return code */

response = curl_easy_perform(curl);

/* Check for errors */

if (response != CURLE_OK) {

f_result = 0;

fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(response));

}

else {

f_result = 1;

}

/* always cleanup */

curl_easy_cleanup(curl);

}

curl_global_cleanup();

if (f_result == 1) {

res = new char[[url removed, login to view]()];

strcpy(res, readBuffer.c_str());

}

else {

//res = "ko";

}

return f_result;

}

/*************************

/ mm_jsapi_environment.h

/*************************

#ifndef _MM_JSAPI_ENVIRONMENT_H_

#define _MM_JSAPI_ENVIRONMENT_H_

/*****************************************************************************

* Private data types, macros, and globals

****************************************************************************/

#include "mm_jsclassapi.h"

typedef struct {

JSObject *libObj;

JSBool (*defineFunction)(JSObject *libObj, char *name, JSNative call, unsigned int nargs);

char *(*valueToString)(JSContext *cx, jsval v, size_t *pLength);

JSBool (*valueToInteger)(JSContext *cx, jsval v, long *lp);

JSBool (*valueToDouble)(JSContext *cx, jsval v, double *dp);

JSBool (*valueToBoolean)(JSContext *cx, jsval v, JSBool *bp);

JSBool (*valueToObject)(JSContext *cx, jsval v, JSObject **op);

JSBool (*stringToValue)(JSContext *cx, char *b, unsigned int sz, jsval *vp);

JSBool (*doubleToValue)(JSContext *cx, double dv, jsval *vp);

char *(*objectType)(JSObject *obj);

JSObject *(*newArrayObject)(JSContext *cx, unsigned int length, jsval *vp);

long (*getArrayLength)(JSContext *cx, JSObject *obj);

JSBool (*getElement)(JSContext *cx, JSObject *obj, unsigned int idx, jsval *vp);

JSBool (*setElement)(JSContext *cx, JSObject *obj, unsigned int idx, jsval *vp);

JSBool (*executeScript)(JSContext *cx, JSObject *obj, char *script,

unsigned int sz, const char *file, unsigned int lineNum, jsval *rval);

JSBool (*reportError)(JSContext *cx, char *error, unsigned int sz);

JSBool (*getJavaVM)(void **jvm, void** env); // for private internal use

jschar *(*valueToUCString)(JSContext *cx, jsval v, size_t *pLength);

JSBool (*ucstringToValue)(JSContext *cx, jschar *c, unsigned int sz, jsval *vp);

JSObject *(*getConfigFolderList)(JSContext *cx, char *fileUrl, char *constraints);

JSBool (*configFileExists)(char *fileURL);

int (*openConfigFile)(char *fileURL, char *mode);

JSBool (*getConfigFileAttributes)(char *fileUrl, unsigned long* attrs, unsigned long* filesize,

unsigned long* modtime, unsigned long* createtime);

JSBool (*setConfigFileAttributes)(char *fileURL, unsigned long attrs);

JSBool (*createConfigFolder)(char *fileURL);

JSBool (*removeConfigFolder)(char *fileURL);

JSBool (*deleteConfigFile)(char *fileURL);

JSObject *(*getUCConfigFolderList)(JSContext *cx, jschar *fileUrl, jschar *constraints);

JSBool (*ucconfigFileExists)(jschar *fileURL);

ptrdiff_t (*openUCConfigFile)(jschar *fileURL, jschar *mode);

JSBool (*getUCConfigFileAttributes)(jschar *fileUrl, unsigned long* attrs, unsigned long* filesize,

unsigned long* modtime, unsigned long* createtime);

JSBool (*setUCConfigFileAttributes)(jschar *fileURL, unsigned long attrs);

JSBool (*createUCConfigFolder)(jschar *fileURL);

JSBool (*removeUCConfigFolder)(jschar *fileURL);

JSBool (*deleteUCConfigFile)(jschar *fileURL);

JSBool (*executeUCScript)(JSContext *cx, JSObject *obj, jschar *script,

unsigned int sz, const char *file, unsigned int lineNum, jsval *rval);

JSBool (*readUCConfigFile)(JSContext *cx, jschar *fileURL, jschar *charset, jsval *vp);

JSBool (*writeUCConfigFile)(jschar *fileURL, jschar *mode, jschar *text, jschar *charset, jsval *vp);

JSBool (*resolveUCConfigFilePath)(const jschar * inFilePath, jschar* outFilePath, unsigned int outFileLength);

JSBool (*reportErrorByStringID)(JSContext *cx, const jschar *error, unsigned int sz);

JSObject *(*registerClass)(JSContext *cx, JSObject *obj, JSObject *parent_proto, JS_ClassSpec *class_spec);

JSBool (*setClassData)(JSContext *cx, JSObject *obj, void *data);

void * (*getClassData)(JSContext *cx, JSObject *obj);

} MM_Environment;

#endif /* _MM_JSAPI_ENVIRONMENT_H_ */

/*************************

/ mm_jsapi.h

/*************************

#ifndef _MM_JSAPI_H_

#define _MM_JSAPI_H_

#include <stddef.h>

/*****************************************************************************

* Public data types

****************************************************************************/

typedef struct JSContext JSContext;

typedef struct JSObject JSObject;

typedef ptrdiff_t jsval; //DW_64BIT Fix JavaScript Spider Monkey Crash on start with 64 bit.

//There was a difference in data type used in Spider Monkey Code and DW interface.

//Hence changing from long to ptrdiff_t

#ifndef CORE_INT_TYPES

#define CORE_INT_TYPES

#if __GNUC__

#include <stdint.h>

#endif

//These usigned versions are also declared in some apple headers so make sure our types match

#ifndef _UINT64

#ifdef _UINT64_T

typedef uint64_t uint64;

#else

typedef unsigned long long uint64;

#endif

#endif

#ifdef _INT64_T

typedef int64_t int64;

#else

typedef long long int64;

#endif

#ifndef _UINT32

#ifdef _UINT32_T

typedef uint32_t uint32;

#else

typedef unsigned long uint32;

#endif

#endif

#ifdef _INT32_T

typedef int32_t int32;

#else

typedef signed long int32;

#endif

#ifndef _UINT16

#ifdef _UINT16_T

typedef uint16_t uint16;

#else

typedef unsigned short uint16;

#endif

#endif

#ifdef _INT16_T

typedef int16_t int16;

#else

typedef signed short int16;

#endif

#ifndef _UINT8

#ifdef _UINT8_T

typedef uint8_t uint8;

#else

typedef unsigned char uint8;

#endif

#endif

#ifdef _INT8_T

typedef int8_t int8;

#else

typedef signed char int8;

#endif

#endif

typedef int32 jsint;

#ifndef JSBool

typedef int JSBool;

#endif

#ifndef jschar

typedef unsigned short jschar;

#endif

#ifndef NULL

#define NULL 0

#endif

typedef JSBool (*JSNative)(JSContext *cx, JSObject *obj, unsigned int argc,

jsval *argv, jsval *rval);

#ifndef jsapi_h___

/* Possible values for JSBool */

#define JS_TRUE 1

#define JS_FALSE 0

/*

* Type tags stored in the low bits of a jsval.

*/

#define JSVAL_OBJECT 0x0 /* untagged reference to object */

#define JSVAL_INT 0x1 /* tagged 31-bit integer value */

#define JSVAL_DOUBLE 0x2 /* tagged reference to double */

#define JSVAL_STRING 0x4 /* tagged reference to string */

#define JSVAL_BOOLEAN 0x6 /* tagged boolean value */

#define JSVAL_INT_POW2(n) ((jsval)1 << (n))

#define JSVAL_VOID INT_TO_JSVAL(0 - JSVAL_INT_POW2(30))

#define JSVAL_TO_INT(v) ((jsint)(v) >> 1)

#define INT_TO_JSVAL(i) (((jsval)(i) << 1) | JSVAL_INT)

#define JSVAL_IS_INT(v) (((v) & JSVAL_INT) && (v) != JSVAL_VOID)

#endif

// Attribute values Get/SetConfigFileAttributes

//

#define MM_FILEATTR_NORMAL 0x00 /* Normal file - No read/write restrictions */

#define MM_FILEATTR_RDONLY 0x01 /* Read only file */

#define MM_FILEATTR_HIDDEN 0x02 /* Hidden file */

#define MM_FILEATTR_SYSTEM 0x04 /* System file */

#define MM_FILEATTR_SUBDIR 0x10 /* Subdirectory */

/*****************************************************************************

* Public functions

****************************************************************************/

/* JSBool JS_DefineFunction(char *name, JSNative call, unsigned int nargs) */

#define JS_DefineFunction(n, c, a) \

([url removed, login to view] ? (*([url removed, login to view]))([url removed, login to view], n, c, a) \

: JS_FALSE)

/* char *JS_ValueToString(JSContext *cx, jsval v, unsigned int *pLength) */

#define JS_ValueToString(c, v, l) \

([url removed, login to view] ? (*([url removed, login to view]))(c, v, l) : (char *)0)

/* char *JS_ValueToUCString(JSContext *cx, jsval v, unsigned int *pLength) */

#define JS_ValueToUCString(c, v, l) \

([url removed, login to view] ? (*([url removed, login to view]))(c, v, l) : (jschar *)0)

/* JSBool JS_ValueToInteger(JSContext *cx, jsval v, long *lp); */

#define JS_ValueToInteger(c, v, l) \

([url removed, login to view] ? (*([url removed, login to view]))(c, v, l) : JS_FALSE)

/* JSBool JS_ValueToDouble(JSContext *cx, jsval v, double *dp); */

#define JS_ValueToDouble(c, v, d) \

([url removed, login to view] ? (*([url removed, login to view]))(c, v, d) : JS_FALSE)

/* JSBool JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp); */

#define JS_ValueToBoolean(c, v, b) \

([url removed, login to view] ? (*([url removed, login to view]))(c, v, b) : JS_FALSE)

/* JSBool JS_ValueToObject(JSContext *cx, jsval v, JSObject **op); */

#define JS_ValueToObject(c, v, o) \

([url removed, login to view] ? (*([url removed, login to view]))(c, v, o) : JS_FALSE)

/* JSBool JS_StringToValue(JSContext *cx, char *bytes, uint sz, jsval *vp); */

#define JS_StringToValue(c, b, s, v) \

([url removed, login to view] ? (*([url removed, login to view]))(c, b, s, v) : JS_FALSE)

/* JSBool JS_UCStringToValue(JSContext *cx, char *bytes, uint sz, jsval *vp); */

#define JS_UCStringToValue(c, b, s, v) \

([url removed, login to view] ? (*([url removed, login to view]))(c, b, s, v) : JS_FALSE)

/* JSBool JS_DoubleToValue(JSContext *cx, double dv, jsval *vp); */

#define JS_DoubleToValue(c, d, v) \

([url removed, login to view] ? (*([url removed, login to view]))(c, d, v) : JS_FALSE)

/* jsval JS_IntegerToValue(long lv); */

#define JS_IntegerToValue(lv) (((jsval)(lv) << 1) | 0x1)

/* jsval JS_BooleanToValue(JSBool bv); */

#define JS_BooleanToValue(bv) (((jsval)(bv) << 3) | 0x6)

/* jsval JS_ObjectToValue(JSObject *obj); */

#define JS_ObjectToValue(ov) ((jsval)(ov))

/* char *JS_ObjectType(JSObject *obj); */

#define JS_ObjectType(o) \

([url removed, login to view] ? (*([url removed, login to view]))(o) : (char *)0)

/* JSObject *JS_NewArrayObject(JSContext *cx, unsigned int length, jsval *v) */

#define JS_NewArrayObject(c, l, v) \

([url removed, login to view] ? (*([url removed, login to view]))(c, l, v) : (JSObject *)0)

/* long JS_GetArrayLength(JSContext *cx, JSObject *obj) */

#define JS_GetArrayLength(c, o) \

([url removed, login to view] ? (*([url removed, login to view]))(c, o) : -1)

/* JSBool JS_GetElement(JSContext *cx, JSObject *obj, jsint idx, jsval *vp) */

#define JS_GetElement(c, o, i, v) \

([url removed, login to view] ? (*([url removed, login to view]))(c, o, i, v) : JS_FALSE)

/* JSBool JS_SetElement(JSContext *cx, JSObject *obj, jsint idx, jsval *vp) */

#define JS_SetElement(c, o, i, v) \

([url removed, login to view] ? (*([url removed, login to view]))(c, o, i, v) : JS_FALSE)

/* JSBool JS_ExecuteScript(JSContext *cx, JSObject *obj, char *script,

* unsigned int sz, jsval *rval) */

#define JS_ExecuteScript(c, o, s, z, r) \

([url removed, login to view] ? (*([url removed, login to view]))(c, o, s, z, __FILE__, \

__LINE__, r) : JS_FALSE)

/* JSBool JS_ExecuteUCScript(JSContext *cx, JSObject *obj, char *script,

* unsigned int sz, jsval *rval) */

#define JS_ExecuteUCScript(c, o, s, z, r) \

([url removed, login to view] ? (*([url removed, login to view]))(c, o, s, z, __FILE__, \

__LINE__, r) : JS_FALSE)

/* JSBool JS_ReportError(JSContext *cx, char *error, unsigned int sz) */

#define JS_ReportError(c, e, s) \

([url removed, login to view] ? (*([url removed, login to view]))(c, e, s) : JS_FALSE)

/* JSBool JS_ReportErrorByStringID(JSContext *cx, const jschar *errorId, unsigned int sz)

* This will load the appropiate localized string and report the error

*/

#define JS_ReportErrorByStringID(c, e, s) \

([url removed, login to view] ? (*([url removed, login to view]))(c, e, s) : JS_FALSE)

/*****************************************************************************

* ConfigFile functions

* Use the following file functions in place of system calls if any of

* the file operations may act on files in the Dreamweaver configuration

* folder. On multiple user systems, such as Windows XP and Mac OSX,

* these functions will always work even if the user does not have write

* permission in the configuration folder. See Extending Dreamweaver for

* more info.

*

* Note: you can use these functions for non-configuration files as well.

****************************************************************************/

/* JSObject * MM_GetConfigFolderList (JSContext *cx, char *fileUrl, char *constraints = NULL) */

#define MM_GetConfigFolderList(c, f, cn) \

([url removed, login to view] ? (*([url removed, login to view]))(c, f, cn) : (JSObject *)0)

/* JSObject * MM_GetUCConfigFolderList (JSContext *cx, char *fileUrl, char *constraints = NULL) */

#define MM_GetUCConfigFolderList(c, f, cn) \

([url removed, login to view] ? (*([url removed, login to view]))(c, f, cn) : (JSObject *)0)

/* JSBool MM_ConfigFileExists (char *fileURL) */

#define MM_ConfigFileExists(f) \

([url removed, login to view] ? (*([url removed, login to view]))(f) : JS_FALSE)

/* JSBool MM_UCConfigFileExists (char *fileURL) */

#define MM_UCConfigFileExists(f) \

([url removed, login to view] ? (*([url removed, login to view]))(f) : JS_FALSE)

/* int MM_OpenConfigFile (char *fileURL, char *mode)

- note: mode can be "read" or "write", "write" implies create

- note: on windows, the handle you get back is a MS C Runtime file

handle opened from msvcrt.dll. This is for backwards

compatibility, as Dreamweaver no longer links against this

dll. The function MM_OpenUCConfigFile() is preferred to

get a file handle.

- note: on mac, the handle is the forkRefNum result from FSOpenFork()

with the data fork of the file*/

#define MM_OpenConfigFile(f, m) \

([url removed, login to view] ? (*([url removed, login to view]))(f, m) : JS_FALSE)

/* long MM_OpenUCConfigFile (char *fileURL, char *mode)

- note: mode can be "read" or "write", "write" implies create

- note: on windows, the handle you get back is an osfhandle

in order to use it with the MS Runtime Library use _open_osfhandle()

- note: on mac, the handle is the forkRefNum result from FSOpenFork()

with the data fork of the file*/

#define MM_OpenUCConfigFile(f, m) \

([url removed, login to view] ? (*([url removed, login to view]))(f, m) : JS_FALSE)

/* JSObject * MM_GetConfigFileAttributes (char *fileUrl, unsigned long* attrs, unsigned long* filesize, unsigned long* modtime, unsigned long* createtime)

- return string with some or all characters "DRHS", or NULL if error */

#define MM_GetConfigFileAttributes(f, a, s, m, c) \

([url removed, login to view] ? (*([url removed, login to view]))(f, a, s, m, c) : JS_FALSE)

/* JSObject * MM_GetUCConfigFileAttributes (char *fileUrl, unsigned long* attrs, unsigned long* filesize, unsigned long* modtime, unsigned long* createtime)

- return string with some or all characters "DRHS", or NULL if error */

#define MM_GetUCConfigFileAttributes(f, a, s, m, c) \

([url removed, login to view] ? (*([url removed, login to view]))(f, a, s, m, c) : JS_FALSE)

/* JSBool MM_SetConfigFileAttributes (char *fileURL, unsigned long attrs) */

#define MM_SetConfigFileAttributes(f, a) \

([url removed, login to view] ? (*([url removed, login to view]))(f, a) : JS_FALSE)

/* JSBool MM_SetUCConfigFileAttributes (char *fileURL, unsigned long attrs) */

#define MM_SetUCConfigFileAttributes(f, a) \

([url removed, login to view] ? (*([url removed, login to view]))(f, a) : JS_FALSE)

/* JSBool MM_CreateConfigFolder (char *fileURL) */

#define MM_CreateConfigFolder(f) \

([url removed, login to view] ? (*([url removed, login to view]))(f) : JS_FALSE)

/* JSBool MM_CreateUCConfigFolder (char *fileURL) */

#define MM_CreateUCConfigFolder(f) \

([url removed, login to view] ? (*([url removed, login to view]))(f) : JS_FALSE)

/* JSBool MM_RemoveConfigFolder (char *fileURL) */

#define MM_RemoveConfigFolder(f) \

([url removed, login to view] ? (*([url removed, login to view]))(f) : JS_FALSE)

/* JSBool MM_RemoveUCConfigFolder (char *fileURL) */

#define MM_RemoveUCConfigFolder(f) \

([url removed, login to view] ? (*([url removed, login to view]))(f) : JS_FALSE)

/* JSBool MM_DeleteConfigFile (char *fileURL) */

#define MM_DeleteConfigFile(f) \

([url removed, login to view] ? (*([url removed, login to view]))(f) : JS_FALSE)

/* JSBool MM_DeleteUCConfigFile (char *fileURL) */

#define MM_DeleteUCConfigFile(f) \

([url removed, login to view] ? (*([url removed, login to view]))(f) : JS_FALSE)

/* JSBool MM_ReadUCConfigFile (JSContext *cx, char *fileURL, char* charset, jsval *rval) */

#define MM_ReadUCConfigFile(cx, f, c, v) \

([url removed, login to view] ? (*([url removed, login to view]))(cx, f, c, v) : JS_FALSE)

/* JSBool MM_WriteUCConfigFile (char *fileURL, char *mode, char *text, char* charset, jsval *rval) */

#define MM_WriteUCConfigFile(f, m, t, c, v) \

([url removed, login to view] ? (*([url removed, login to view]))(f, m, t, c, v) : JS_FALSE)

/* JSBool MM_ResolveUCConfigFileURL (const jschar * inFileUrl, jschar* outFileUrl, unsigned int outFileLength) */

#define MM_ResolveUCConfigFilePath(ip, op, l) \

([url removed, login to view] ? (*([url removed, login to view]))(ip, op, l) : JS_FALSE)

/* JSObject * JS_RegisterClass (JSContext *cx, JSObject *obj, JSObject *parent_proto, MM_ClassSpec * class_spec) */

#define JS_RegisterClass(cx, obj, parent_proto, class_spec) \

([url removed, login to view] ? (*([url removed, login to view]))(cx, obj, parent_proto, class_spec) : NULL)

/* JSBool JS_SetClassData (JSContext *cx, JSObject *obj, void *data) */

#define JS_SetClassData(cx, obj, data) \

([url removed, login to view] ? (*([url removed, login to view]))(cx, obj, data) : JS_FALSE)

/* void * JS_GetClassData (JSContext *cx, JSObject *obj) */

#define JS_GetClassData(cx, obj) \

([url removed, login to view] ? (*([url removed, login to view]))(cx, obj) : NULL)

/*****************************************************************************

* Public interfaces for defining your own classes. Normally a JSExtension is

* it's own static global object so there's no instance or state information

* associated with it. These let you define your own classes that can have

* multiple instances of and a little more object oriented for the js scrippter.

****************************************************************************/

/* You need to implement this function to get your classes register. This function

* will get called during application lauch so it shouldn't do more work than just

* defining the apis you are exposing. If you aren't defining a class you can

* comment this prototype out.

*/

// Declare the external entry point and linkage

#ifdef _WIN32

__declspec( dllexport ) void MM_RegisterClasses(JSContext *cx, JSObject *obj, JSObject *parent_proto);

#else

// Codewarrior

# pragma export on

extern void MM_RegisterClasses(JSContext *cx, JSObject *obj, JSObject *parent_proto);

# pragma export off

#endif

#ifndef jsapi_h___

/*

* Add, delete, get or set a property named by iD in obj. Note the jsval iD

* type -- iD may be a string (Unicode property identifier) or an int (element

* index). The *vp out parameter, on success, is the new property value after

* an add, get, or set. After a successful delete, *vp is JSVAL_FALSE iff

* obj[iD] can't be deleted (because it's permanent).

*/

typedef JSBool(*JSPropertyOp)(JSContext *cx, JSObject *obj, jsval iD, jsval *vp);

typedef void(*JSFinalizeOp)(JSContext *cx, JSObject *obj);

/* Stub function for default implementation */

JSBool JS_PropertyStub(JSContext *cx, JSObject *obj, jsval iD, jsval *vp);

void JS_FinalizeStub(JSContext *cx, JSObject *obj);

/* Property attributes, set in JSPropertySpec and passed to API functions. */

#define JSPROP_ENUMERATE 0x01 /* property is visible to for/in loop */

#define JSPROP_READONLY 0x02 /* not settable: assignment is no-op */

#define JSPROP_PERMANENT 0x04 /* property cannot be deleted */

#define JSPROP_EXPORTED 0x08 /* property is exported from object */

#define JSPROP_GETTER 0x10 /* property holds getter function */

#define JSPROP_SETTER 0x20 /* property holds setter function */

#define JSPROP_SHARED 0x40 /* don't allocate a value slot for this

property; don't copy the property on

set of the same-named property in an

object that delegates to a prototype

containing this property */

#define JSPROP_INDEX 0x80 /* name is actually (jsint) index */

/* Function flags, set in JSFunctionSpec and passed to JS_NewFunction etc. */

#define JSFUN_LAMBDA 0x08 /* expressed, not declared, function */

#define JSFUN_GETTER JSPROP_GETTER

#define JSFUN_SETTER JSPROP_SETTER

#define JSFUN_BOUND_METHOD 0x40 /* bind this to fun->object's parent */

#define JSFUN_HEAVYWEIGHT 0x80 /* activation requires a Call object */

#define JSFUN_FLAGS_MASK 0xf8 /* overlay JSFUN_* attributes */

/* describe a property in your class */

typedef struct {

const char *name;

int8 tinyid;

uint8 flags;

JSPropertyOp getter;

JSPropertyOp setter;

}JSPropertySpec;

/* describe a function in your class */

typedef struct {

const char *name;

JSNative call;

uint8 nargs;

uint8 flags;

uint16 extra; /* number of arg slots for local GC roots */

}JSFunctionSpec;

#endif

// all the information you to to fill out to define your class is in this file

#include "mm_jsclassapi.h"

/*****************************************************************************

* Private data types, macros, and globals

****************************************************************************/

#include "mm_jsapi_environment.h"

extern MM_Environment mmEnv;

// Declare the external entry point and linkage

#ifdef _WIN32

# ifndef _MAC

// Windows

__declspec( dllexport ) void MM_InitWrapper( MM_Environment *env, unsigned int envSize );

# else

// Mac with MSVC++ Win32 portability lib

extern void MM_InitWrapper( MM_Environment *env, unsigned int envSize );

# endif

#else

// Codewarrior

# pragma export on

extern void MM_InitWrapper( MM_Environment *env, unsigned int envSize );

# pragma export off

#endif

#define MM_STATE \

/* Definitions of global variables */ \

MM_Environment mmEnv; \

\

void \

MM_InitWrapper(MM_Environment *env, unsigned int envSize) \

{ \

extern void MM_Init(); \

\

char **envPtr = (char **)env; \

char **mmPtr = (char **)(&mmEnv); \

char **envEnd = (char **)((char *)envPtr + envSize); \

char **mmEnd = (char **)((char *)mmPtr + sizeof(MM_Environment)); \

\

/* Copy fields from env to mmEnv, one pointer at a time */ \

while (mmPtr < mmEnd && envPtr < envEnd) \

*mmPtr++ = *envPtr++; \

\

/* If env doesn't define all of mmEnv's fields, set extras to NULL */ \

while (mmPtr < mmEnd) \

*mmPtr++ = (char *)0; \

\

/* Call user's MM_Init function */ \

MM_Init(); \

} \

\

\

/* Defined our stub functions */ \

JSBool JS_PropertyStub(JSContext *cx, JSObject *obj, jsval iD, jsval *vp){ \

return JS_TRUE; \

} \

\

void JS_FinalizeStub(JSContext *cx, JSObject *obj){} \

#endif /* _MM_JSAPI_H_ */

/*************************

/ mm_jsclassapi.h

/*************************

#ifndef _MM_JS_CLASS_API_H_

#define _MM_JS_CLASS_API_H_

typedef struct

{

int sizeofClassSpec; /* required - the size of this struct, used to verify it gets passed correctly from the dll to the app */

const char *name; /* required - name for your class, like foo. */

JSNative constructor; /* required - called when someone calls new on your object */

uint8 nConstructorArgs; /* required - number of required args for the constructor */

JSFinalizeOp finalize; /* called when your object is destroyed, do any local cleanup from the contructor */

JSPropertyOp addProperty; /* property operations called when a script adds, dels object instance */

JSPropertyOp delProperty;

JSPropertyOp getProperty;

JSPropertyOp setProperty;

JSPropertySpec *props; /* per instance props and funcs. */

JSFunctionSpec *funcs;

JSPropertySpec *static_props; /* static props and funcs, the kind that can get called without going var = new foo() first */

JSFunctionSpec *static_funcs;

} JS_ClassSpec;

/* default initializer

JS_ClassSpec() :

sizeofClassSpec(sizeof(JS_ClassSpec)),

name(0),

constructor(0),

nConstructorArgs(0),

finalize(JS_FinalizeStub),

addProperty(JS_PropertyStub),

delProperty(JS_PropertyStub),

getProperty(JS_PropertyStub),

setProperty(JS_PropertyStub),

props(0),

funcs(0),

static_props(0),

static_funcs(0)

{}

*/

#endif /* _MM_JS_CLASS_API_H_ */

/*************************

/ MMInfo.h

/*************************

#pragma once

//

// Copyright (c) 1998 Macromedia, inc. All Rights Reserved.

// ---------------------------------------------------------

//

// MMInfo.h

//

#ifndef _MMINFO_H_

#define _MMINFO_H_

#ifdef _WIN32 // Windows

#define MMNOTES_EXPORT __declspec( dllexport )

#define WCHAR wchar_t

#ifndef _UNICODE

#define _UNICODE

#endif

#include <tchar.h>

#else // Codewarrior/Mac

#define MMNOTES_EXPORT extern

#include "tchar_mac.h"

#define WCHAR char16_t

#define BOOL int

#ifdef TRUE

#undef TRUE

#endif

#ifdef FALSE

#undef FALSE

#endif

#define TRUE true

#define FALSE false

#ifdef __cplusplus

extern "C" {

#endif

#endif

typedef int FileHandle;

typedef char InfoKey[64];

typedef WCHAR InfoKeyW[64];

struct InfoPrefs

{

BOOL bUseDesignNotes;

BOOL bUploadDesignNotes;

};

// Declare the external entry point and linkage

MMNOTES_EXPORT FileHandle OpenNotesFile( const char* mediaFilePath, BOOL bForce=FALSE );

MMNOTES_EXPORT FileHandle OpenNotesFileWithOpenFlags( const char* mediaFilePath, BOOL bForce=FALSE, BOOL bReadOnly=FALSE );

MMNOTES_EXPORT void CloseNotesFile( FileHandle infoHandle );

MMNOTES_EXPORT BOOL SetNote( FileHandle infoHandle, const InfoKey key, const char* value );

MMNOTES_EXPORT BOOL RemoveNote( FileHandle infoHandle, const InfoKey key );

MMNOTES_EXPORT int GetNoteLength( FileHandle infoHandle, const InfoKey key );

MMNOTES_EXPORT BOOL GetNote( FileHandle infoHandle, const InfoKey key, char* valueBuf, int valueBufMaxLen );

MMNOTES_EXPORT int GetNotesKeyCount( FileHandle infoHandle );

MMNOTES_EXPORT BOOL GetNotesKeys( FileHandle infoHandle, InfoKey* keyList, int keyListMaxLen );

MMNOTES_EXPORT BOOL GetSiteRootForFile( const char* mediaFilePath, char* siteRootBuf, int siteRootBufMaxLen, InfoPrefs* prefs=NULL );

MMNOTES_EXPORT BOOL GetVersionNum( char* versionNumBuf, int versionNumBufMaxLen );

MMNOTES_EXPORT BOOL GetVersionName( char* versionNameBuf, int versionNameBufMaxLen );

MMNOTES_EXPORT BOOL FilePathToLocalURL( const char* filePath, char* localURL, int localURLMaxLen );

MMNOTES_EXPORT BOOL LocalURLToFilePath( const char* localURL, char* filePath, int filePathMaxLen );

//Wide versions of the entry points

MMNOTES_EXPORT FileHandle OpenNotesFileW( const WCHAR* mediaFilePath, BOOL bForce=FALSE );

MMNOTES_EXPORT FileHandle OpenNotesFileWithOpenFlagsW( const WCHAR* mediaFilePath, BOOL bForce=FALSE, BOOL bReadOnly=FALSE );

MMNOTES_EXPORT void CloseNotesFileW( FileHandle infoHandle );

MMNOTES_EXPORT BOOL SetNoteW( FileHandle infoHandle, const InfoKeyW key, const WCHAR* value );

MMNOTES_EXPORT BOOL RemoveNoteW( FileHandle infoHandle, const InfoKeyW key );

MMNOTES_EXPORT int GetNoteLengthW( FileHandle infoHandle, const InfoKeyW key );

MMNOTES_EXPORT BOOL GetNoteW( FileHandle infoHandle, const InfoKeyW key, WCHAR* valueBuf, int valueBufMaxLen );

MMNOTES_EXPORT int GetNotesKeyCountW( FileHandle infoHandle );

MMNOTES_EXPORT BOOL GetNotesKeysW( FileHandle infoHandle, InfoKeyW* keyList, int keyListMaxLen );

MMNOTES_EXPORT BOOL GetSiteRootForFileW( const WCHAR* mediaFilePath, WCHAR* siteRootBuf, int siteRootBufMaxLen, InfoPrefs* prefs=NULL );

MMNOTES_EXPORT BOOL GetVersionNumW( WCHAR* versionNumBuf, int versionNumBufMaxCount );

MMNOTES_EXPORT BOOL GetVersionNameW( WCHAR* versionNameBuf, int versionNameBufMaxCount );

MMNOTES_EXPORT BOOL FilePathToLocalURLW( const WCHAR* filePath, WCHAR* localURL, int localURLMaxCount );

MMNOTES_EXPORT BOOL LocalURLToFilePathW( const WCHAR* localURL, WCHAR* filePath, int filePathMaxCount );

#ifndef _WIN32

#ifdef __cplusplus

}

#endif

#endif

// Exported functions

JSBool

openInfo( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

closeInfo( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

set( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

remove( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

getLength( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

get( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

getKeyCount( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

getKeys( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

getSiteRootForFile( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

getVersionNum( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

getVersionName( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

filePathToLocalURL( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

JSBool

localURLToFilePath( JSContext* cx, JSObject* obj, unsigned int argc

, jsval* jsArgv, jsval* rval );

void

MM_Init( void );

#endif

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

// LOG

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

// 20-sep-99 hbauer Changed function names to use the word Notes

// instead of Info.

Competenze: Cacao, Mac OS, Objective C

Vedere di più: what's dp, what is dp, what is data entry 10 key, what is an unsigned integer, what is a dp, what is a 10 key data entry, web api for windows app, unsigned integer, unsigned bits, types of data entry fields, types of data entry errors, string library in c, string library c, std remove if, std library, set bits in c, prototype reference, ov r, op note, operations on bits

Sul datore di lavoro:
( 0 valutazioni ) Italy

ID Progetto: #10143909

1 freelance ha fatto un'offerta media di $222 per questo lavoro

penet2all

Familiar interface and simple algorithm encourage your application. [login to view URL] - my last huge work for Taxi/Cab app - RMS [login to view URL] I ha Più

$147 USD in 3 giorni
(3 Recensioni)
5.9
AppTricks

we can directly create project in mac and use C or C++.Please contact me to discuss in details .... Thanks

$222 USD in 3 giorni
(3 Recensioni)
3.8
$110 USD in 2 giorni
(0 Recensioni)
0.0