예제 #1
0
void NDAInit(int code)
{
    int i;

    if (code) {
        gCalcActive = FALSE;
        gUserId = MMStartUp();

        if (!ListStatus()) {
            LoadOneTool(0x1c, 0);
            ListStartUp();
            gListStarted = TRUE;
        }

        if (!SANEStatus()) {
            LoadOneTool(0x0a, 0);
            gSANEDirectPage = NewHandle(256, gUserId,
                                        attrBank | attrFixed | attrLocked | attrPage, NULL);
            SANEStartUp((Word) *gSANEDirectPage);
        }

        abCalcInit();

        for (i = 0; i < AB_CALC_STACK_DEPTH; i++) {
            gStackList[i].memPtr = NULL;
        }
    } else {
        if (gSANEDirectPage) {
            SANEShutDown();
            DisposeHandle(gSANEDirectPage);
            UnloadOneTool(0x0a);
            gSANEDirectPage = NULL;
        }

        if (gListStarted) {
            ListShutDown();
            UnloadOneTool(0x1c);
            gListStarted = FALSE;
        }
    }
}
예제 #2
0
파일: dtest.c 프로젝트: ksherlock/gopher
int main(int argc, char **argv)
{
  Handle dict;
  Word rv;

  dict = DictionaryCreate(MMStartUp(), 0);
  if (!dict)
  {
    fprintf(stderr, "Error: DictionaryCreate() == NULL\n");
    exit(1);
  }

  rv = DictionaryAdd(dict, "key",3,"value",5, 0);
  if (!rv)
  {
    fprintf(stderr, "Error: DictionaryAdd() == 0\n");
    DisposeHandle(dict);
    exit(1);
  }

  rv = DictionaryContains(dict, "key",3);
  if (!rv)
  {
    fprintf(stderr, "Error: DictionaryContains() == 0\n");
    DisposeHandle(dict);
    exit(1);
  }

  rv = DictionaryCount(dict);
  if (rv != 1)
  {
    fprintf(stderr, "Error: DictionaryCount() != 1\n");
    DisposeHandle(dict);
    exit(1);
  }

  rv = DictionaryAdd(dict, "key2",4, "value2", 6, false);
  if (!rv)
  {
    fprintf(stderr, "Error: DictionaryAdd() == 0\n");
    DisposeHandle(dict);
    exit(1);
  }

  {
    Word cookie = 0;
    DictionaryEnumerator e;

    while ((cookie = DictionaryEnumerate(dict, &e, cookie)) != 0)
    {
      fwrite(e.key, 1, e.keySize, stdout);
      fwrite(" -> ", 1, 4, stdout);
      fwrite(e.value, 1, e.valueSize, stdout);
      fputc('\n', stdout);
    }
  }



  DisposeHandle(dict);
  exit(0);
  return 0;
}
예제 #3
0
파일: c.port.c 프로젝트: GnoConsortium/gno
void c_port_open(void)
{
extern GSString32Ptr __C2GSMALLOC(char *);

    /* ************************************************************** *
     *  No local variables...                                         *
     * ************************************************************** */


    /* ************************************************************** *
     *  Check if we already have a file open... Apple said this should*
     *  never happen... but I really don't believe them...            *
     * ************************************************************** */

    if ((data_file_ptr != (KS_FILE_PTR) NULL) ||
        (port_status != PORT_NOT_ACTIVE))
        {
        open_count++;
        return;
        };


    /* ************************************************************** *
     *  Get the applications memory manager user ID - We'll need it   *
     *  to be able to allocate memory...                              *
     * ************************************************************** */

    ProgramID = MMStartUp();


    /* ************************************************************** *
     *  Set the size of the data buffer to 64k...                     *
     * ************************************************************** */

    KS_FILE_SET_BUFFER_SIZE((LongWord) (64*1024),
                            error);
    if (error != KS_E_SUCCESS)
        {
        error_message = BAD_BUFFER_SIZE;
        goto ERROR_BAD_BUFFER_SIZE;
        };


    /*  > Open our data file in System:filePort.data: and read it
     *
     *	The line print spool directory is hard-coded
     */

    /*	Create a spool file name, and set it up in GS/OS format for use
     *	by the KS_FILE_OPEN routine
     */

    sprintf(tmp,PATH_LPQ ":tmp.%08lX",GetTick());
    spool_directory_ptr = __C2GSMALLOC(tmp);

    /* create the spool file now */
    KS_FILE_CREATE((GSString255Ptr) spool_directory_ptr,
                   SPOOLFILE_FILETYPE,
                   SPOOLFILE_AUXTYPE,
                   error);
    if (error != KS_E_SUCCESS)
        {
        error_message = CANT_CREATE_SPOOL_FILE;
        goto ERROR_CANT_CREATE_SPOOL_FILE;
        };

    /* ************************************************************** *
     *  Open the data spool file                                      *
     * ************************************************************** */

    KS_FILE_OPEN((GSString255Ptr) spool_directory_ptr,
                 KS_FILE_WRITE_ACCESS,
                 KS_FILE_DATA_FORK,
                 KS_FILE_BUFFER_IO,
                 &data_file_ptr,
                 error);
    if (error != KS_E_SUCCESS)
        {
        error_message = CANT_OPEN_SPOOL_FILE;
        goto ERROR_CANT_OPEN_SPOOL_FILE;
        };


    /* ************************************************************** *
     *  Releasing pathname back to free memory...                     *
     *  No error checking because what would we do??                  *
     * ************************************************************** */


    KS_MEMORY_DEALLOCATE(spoolpath_handle,
                         error);


    /* ************************************************************** *
     *  Set a flag and a counter...                                   *
     * ************************************************************** */

    port_status = PORT_SPOOLING;
    open_count = 1;


    /* ************************************************************** *
     *  Everything is all set - return to our caller...               *
     * ************************************************************** */

    return;



    /* ************************************************************** *
     *  Error processing for all of the error cases of the above code *
     *                                                                *
     *  Once we clean up whatever needs to be cleaned up, then we     *
     *  will get around to putting up a dialog box for our user.      *
     * ************************************************************** */

ERROR_CANT_OPEN_SPOOL_FILE:

    KS_FILE_DELETE((GSString255Ptr) spool_directory_ptr,
                   error2);

ERROR_TOO_MANY_SPOOLFILES:

ERROR_CANT_CREATE_SPOOL_FILE:

ERROR_CANT_GET_NEXT_FILE:

ERROR_CANT_GET_ENTRY_COUNT:

    KS_FILE_CLOSE(dir_file_ptr, error2);

ERROR_CANT_OPEN_DIR:

    KS_MEMORY_DEALLOCATE(spoolpath_handle,
                         error2);

    goto ERROR_MESSAGE;

ERROR_CANT_READ_PATHNAME:

    KS_MEMORY_DEALLOCATE(spoolpath_handle,
                         error2);

ERROR_CANT_ALLOCATE_PATHNAME:

    KS_FILE_CLOSE(dir_file_ptr, error2);

ERROR_CANT_OPEN_CONFIG_FILE:

ERROR_BAD_BUFFER_SIZE:

ERROR_MESSAGE:

    port_status = PORT_ERROR;

    ERROR_DIALOG(error_message, error, button);

    return;


}   /* End of c_port_open()                                           */