示例#1
0
文件: utils.c 项目: VertiPub/jsvc
/** Convert null separated double null terminated string to LPTSTR array)
 * returns array size
 */
DWORD
apxMultiSzToArrayW(APXHANDLE hPool, LPCWSTR lpString, LPWSTR **lppArray)
{
    DWORD i, n, l;
    char *buff;
    LPWSTR p;

    l = __apxGetMultiSzLengthW(lpString, &n);
    if (!n || !l)
        return 0;
    if (IS_INVALID_HANDLE(hPool))
        buff = apxPoolAlloc(hPool, (n + 2) * sizeof(LPWSTR) + (l + 1) * sizeof(WCHAR));
    else
        buff = apxAlloc((n + 2) * sizeof(LPWSTR) + (l + 1) * sizeof(WCHAR));

    *lppArray = (LPWSTR *)buff;
    p = (LPWSTR)(buff + (n + 2) * sizeof(LPWSTR));
    AplCopyMemory(p, lpString, (l + 1) * sizeof(WCHAR));
    for (i = 0; i < n; i++) {
        (*lppArray)[i] = p;
        while (*p)
            p++;
        p++;
    }
    (*lppArray)[++i] = NULL;

    return n;
}
示例#2
0
文件: utils.c 项目: VertiPub/jsvc
LPWSTR apxMultiSzCombine(APXHANDLE hPool, LPCWSTR lpStrA, LPCWSTR lpStrB,
                         LPDWORD lpdwLength)
{
    LPWSTR rv;
    DWORD  la = 0, lb = 0;
    if (!lpStrA && !lpStrB)
        return NULL;    /* Nothing to do if both are NULL */

    la = __apxGetMultiSzLengthW(lpStrA, NULL);
    lb = __apxGetMultiSzLengthW(lpStrB, NULL);

    rv = apxPoolCalloc(hPool, (la + lb + 1) * sizeof(WCHAR));
    if (la) {
        AplMoveMemory(rv, lpStrA, la * sizeof(WCHAR));
    }
    if (lb) {
        AplMoveMemory(&rv[la], lpStrB, lb * sizeof(WCHAR));
    }
    if (lpdwLength)
        *lpdwLength = (la + lb + 1) * sizeof(WCHAR);
    return rv;
}
示例#3
0
文件: utils.c 项目: VertiPub/jsvc
LPWSTR
apxMszToCRLFW(APXHANDLE hPool, LPCWSTR szStr)
{
    DWORD l, c;
    LPWSTR rv, b;
    LPCWSTR p = szStr;

    l = __apxGetMultiSzLengthW(szStr, &c);
    b = rv = apxPoolCalloc(hPool, (l + c + 2) * sizeof(WCHAR));

    while (c > 0) {
        if (*p)
            *b++ = *p;
        else {
            *b++ = L'\r';
            *b++ = L'\n';
            c--;
        }
        p++;
    }
    return rv;
}
/* ANSI version only */
DWORD
apxJavaCmdInitialize(APXHANDLE hPool, LPCWSTR szClassPath, LPCWSTR szClass,
                     LPCWSTR szOptions, DWORD dwMs, DWORD dwMx,
                     DWORD dwSs, LPCWSTR szCmdArgs, LPWSTR **lppArray)
{

    DWORD i, nJVM, nCmd, nTotal, lJVM, lCmd;
    LPWSTR p;

    /* Calculate the number of all arguments */
    nTotal = 0;
    if (szClassPath)
        ++nTotal;
    if (szClass)
        ++nTotal;
    lJVM = __apxGetMultiSzLengthW(szOptions, &nJVM);
    nTotal += nJVM;
    lCmd = __apxGetMultiSzLengthW(szCmdArgs, &nCmd);
    nTotal += nCmd;
    if (dwMs)
        ++nTotal;
    if (dwMx)
        ++nTotal;
    if (dwSs)
        ++nTotal;

    if (nTotal == 0)
        return 0;

    /* Allocate the array to store all arguments' pointers
     */
    *lppArray = (LPWSTR *)apxPoolAlloc(hPool, (nTotal + 2) * sizeof(LPWSTR));

    /* Process JVM options */
    if (nJVM && lJVM) {
        p = (LPWSTR)apxPoolAlloc(hPool, (lJVM + 1) * sizeof(WCHAR));
        AplCopyMemory(p, szOptions, (lJVM + 1) * sizeof(WCHAR) + sizeof(WCHAR));
        for (i = 0; i < nJVM; i++) {
            (*lppArray)[i] = p;
            while (*p)
                p++;
            p++;
        }
    }

    /* Process the 3 extra JVM options */
    if (dwMs) {
        p = (LPWSTR)apxPoolAlloc(hPool, 64 * sizeof(WCHAR));
        wsprintfW(p, L"-Xms%dm", dwMs);
        (*lppArray)[i++] = p;
    }
    if (dwMx) {
        p = (LPWSTR)apxPoolAlloc(hPool, 64 * sizeof(WCHAR));
        wsprintfW(p, L"-Xmx%dm", dwMx);
        (*lppArray)[i++] = p;
    }
    if (dwSs) {
        p = (LPWSTR)apxPoolAlloc(hPool, 64 * sizeof(WCHAR));
        wsprintfW(p, L"-Xss%dk", dwSs);
        (*lppArray)[i++] = p;
    }

    /* Process the classpath and class */
    if (szClassPath) {
        p = (LPWSTR)apxPoolAlloc(hPool, (lstrlenW(JAVA_CLASSPATH_W) + lstrlenW(szClassPath)) * sizeof(WCHAR));
        lstrcpyW(p, JAVA_CLASSPATH_W);
        lstrcatW(p, szClassPath);
        (*lppArray)[i++] = p;
    }
    if (szClass) {
        p = (LPWSTR)apxPoolAlloc(hPool, (lstrlenW(szClass)) * sizeof(WCHAR));
        lstrcpyW(p, szClass);
        (*lppArray)[i++] = p;
    }

    /* Process command arguments */
    if (nCmd && lCmd) {
        p = (LPWSTR)apxPoolAlloc(hPool, (lCmd + 1) * sizeof(WCHAR));
        AplCopyMemory(p, szCmdArgs, (lCmd + 1) * sizeof(WCHAR) + sizeof(WCHAR));
        for (; i < nTotal; i++) {
            (*lppArray)[i] = p;
            while (*p)
                p++;
            p++;
        }
    }

    (*lppArray)[++i] = NULL;

    return nTotal;
}