• Ich habe gerade einmal https://www.codeconvert.ai/app benutzt, um mainAddressCtrl.asm nach C konvertieren zu lassen. Keine Ahnung, ob das wirklich fehlerfrei ist, aber ein wenig beeindruckend ist das schon, oder?


    /*
    (c) Copyright Geoworks 1996 -- All Rights Reserved
    GEOWORKS CONFIDENTIAL
    PROJECT: PC GEOS
    MODULE: Calendar/Main
    FILE: mainAddressCtrl.asm
    AUTHOR: Jason Ho, Dec 21, 1996
    */

    #include <stdio.h>

    // Function prototypes
    int CalendarAddressCtrlGetSelectedSMSNum();
    int CalendarAddressCtrlGetBookId();
    void CalendarAddressCtrlSetBookId(int bookId);
    void CalendarAddressCtrlContactSelected();
    void CalendarAddressCtrlMultipleContactsSelected();
    void CalendarAddressCtrlMultipleRecentNumberSelected();
    void CloseContactListShowSummary();
    void GetNumberAndNameFromContdb();
    void CalendarAddressCtrlRecentNumberSelected();
    void CalendarAddressCtrlManualDialing();
    int HandleManualNumberCommon();
    int CalendarAddressCtrlGetMiscFlags();
    void CalendarAddressCtrlCopySentToInfo();
    void CalendarAddressCtrlFetchRecipientInfo();
    void CalendarAddressCtrlFreeSelectionBlocks();

    // Constants
    #define MAX_NUMBER_FIELD_DATA_LEN 100
    #define MAX_NAME_DATA_LEN 100

    // Data structures
    typedef struct {
    char selectedSMSNum[MAX_NUMBER_FIELD_DATA_LEN+1];
    char selectedName[MAX_NAME_DATA_LEN+1];
    char recipientPasswd[MAX_NAME_DATA_LEN+1];
    int bookID;
    int miscFlags;
    int selectedContactsHandle;
    int recentContactsHandle;
    int numOfSelection;
    } CalendarAddressCtrlClass;

    // Function implementations
    int CalendarAddressCtrlGetSelectedSMSNum() {
    // Get the SMS number of selected contact
    // The buffer should be at least MAX_NUMBER_FIELD_DATA_LEN+1 / MAX_NAME_DATA_LEN+1 chars big
    CalendarAddressCtrlClass *object;
    int message;
    char *buffer;
    int length;
       
    // Get source
    if (message == MSG_CALENDAR_ADDRESS_CTRL_GET_SELECTED_SMS_NUM) {
    buffer = object->selectedSMSNum;
    } else if (message == MSG_CALENDAR_ADDRESS_CTRL_GET_SELECTED_NAME) {
    buffer = object->selectedName;
    } else if (message == MSG_CALENDAR_ADDRESS_CTRL_GET_RECIPIENT_PASSWD) {
    buffer = object->recipientPasswd;
    }
       
    // Copy string
    length = strlen(buffer);
       
    return length;
    }

    int CalendarAddressCtrlGetBookId() {
    // Get the book ID of the current booking for the particular event
    CalendarAddressCtrlClass *object;
       
    return object->bookID;
    }

    void CalendarAddressCtrlSetBookId(int bookId) {
    // Set the book ID of the current booking for the particular event
    CalendarAddressCtrlClass *object;
       
    object->bookID = bookId;
    }

    void CalendarAddressCtrlContactSelected() {
    // User pressed the "select" trigger in the address control
    // Get ready to send our message
    CalendarAddressCtrlClass *object;
       
    // We surely have matching contact
    object->miscFlags &= ~(1 << CACF_HAS_MATCHING_CONTACT);
       
    // Get number and name from contdb, and store into instance data
    GetNumberAndNameFromContdb();
       
    // Close the contact window and show the summary window
    CloseContactListShowSummary();
    }

    void CalendarAddressCtrlMultipleContactsSelected() {
    // User pressed the "select" trigger in the address control, and we are doing multiple selection
    // Get ready to send our message
    CalendarAddressCtrlClass *object;
    int handle;
    int numOfSelection;
       
    // We surely have matching contact
    object->miscFlags &= ~(1 << CACF_HAS_MATCHING_CONTACT);
       
    // Remember all the passed parameters in instance data
    object->selectedContactsHandle = handle;
    object->numOfSelection = numOfSelection;
       
    // We don't have recent contacts
    object->recentContactsHandle = 0;
       
    // If just one selection, clear the flag CACF_MULTIPLE_RECIPIENTS; else set the flag
    if (numOfSelection == 1) {
    object->miscFlags &= ~(1 << CACF_MULTIPLE_RECIPIENTS);
    } else {
    object->miscFlags |= (1 << CACF_MULTIPLE_RECIPIENTS);
    }
       
    // Close the contact window and show the summary window
    CloseContactListShowSummary();
    }

    void CalendarAddressCtrlMultipleRecentNumberSelected() {
    // Sent when the user has selected a "recent sms number" from the "recent contact" control, only this time the user selects multiple numbers
    CalendarAddressCtrlClass *object;
    int handle;
    int numOfSelection;
       
    // Remember all the passed parameters in instance data
    object->recentContactsHandle = handle;
    object->numOfSelection = numOfSelection;
       
    // We don't have regular contacts selected
    object->selectedContactsHandle = 0;
       
    // If just one selection, clear the flag CACF_MULTIPLE_RECIPIENTS
    if (numOfSelection == 1) {
    object->miscFlags &= ~(1 << CACF_MULTIPLE_RECIPIENTS);
    } else {
    object->miscFlags |= (1 << CACF_MULTIPLE_RECIPIENTS);
    }
       
    // Give a warning if we are doing reservation
    if (GetBookEventType() == BET_NORMAL_EVENT) {
    printf("Multiple recent numbers reservation warning\n");
    }
       
    // Clear the password text
    memset(object->recipientPasswd, 0, sizeof(object->recipientPasswd));
       
    // Close the contact window and show the summary window
    CloseContactListShowSummary();
    }

    void CloseContactListShowSummary() {
    // Close the contact list, and show the summary of SMS event
    printf("Close contact list and show summary\n");
    }

    void GetNumberAndNameFromContdb() {
    // Fetch the SMS number and name of a contact from the contdb
    CalendarAddressCtrlClass *object;
    int recordID;
    int fieldID;
       
    // Fetch the SMS number from contdb
    // Get record handle
    int dbHandle = ContactGetDBHandle();
    int blockHandle = FoamDBGetRecordFromID(dbHandle, recordID);
       
    // Dereference, and get field data
    char buffer[MAX_NUMBER_FIELD_DATA_LEN+1];
    FoamDBGetFieldData(blockHandle, fieldID, buffer, sizeof(buffer));
       
    // Null terminate the data string
    buffer[strlen(buffer)] = '\0';
       
    // Get the password field
    char password[MAX_NAME_DATA_LEN+1];
    FoamDBGetFieldData(blockHandle, CFT_PASSWORD, password, sizeof(password));
       
    // Null terminate the data string
    password[strlen(password)] = '\0';
       
    // Get the name field
    char name[MAX_NAME_DATA_LEN+1];
    ContactGetName(blockHandle, name);
       
    // Discard the record handle, now that we are done
    FoamDBDiscardRecord(blockHandle);
       
    // Release the database handle
    ContactReleaseDBHandle(dbHandle);
       
    // Store the fetched data into instance data
    strcpy(object->selectedSMSNum, buffer);
    strcpy(object->recipientPasswd, password);
    strcpy(object->selectedName, name);
    }

    void CalendarAddressCtrlRecentNumberSelected() {
    // Sent when the user has selected a "recent sms number" from the "recent contact" control
    CalendarAddressCtrlClass *object;
    char *recentNumber;
       
    // Consider the "recent number" as manual entered number, because there is no guarantee that the contact it specifies (RCD_contactID) exists anyway
    strcpy(object->selectedSMSNum, recentNumber);
       
    // Handle manual number
    HandleManualNumberCommon();
    }

    void CalendarAddressCtrlManualDialing() {
    // Received when the user presses the "manual dialing" trigger
    CalendarAddressCtrlClass *object;
       
    // User enters the manual dial number, and presses OK
    // Handle manual number
    HandleManualNumberCommon();
    }

    int HandleManualNumberCommon() {
    // Now that we have the manual / recent number in instance data, do name matching, fetch password if contact is found, etc.
    CalendarAddressCtrlClass *object;
       
    // Do name matching, fetch password if contact is found, etc.
    printf("Handle manual/recent number common\n");
       
    return 0;
    }

    int CalendarAddressCtrlGetMiscFlags() {
    // Get the CACI_miscFlags
    CalendarAddressCtrlClass *object;
       
    return object->miscFlags;
    }

    void CalendarAddressCtrlCopySentToInfo() {
    // From instance data, copy info to EventSentToStruct
    printf("Copy info to EventSentToStruct\n");
    }

    void CalendarAddressCtrlFetchRecipientInfo() {
    // Fetch the recipient info from contdb
    printf("Fetch recipient info from contdb\n");
    }

    void CalendarAddressCtrlFreeSelectionBlocks() {
    // Free the multiple selection mem blocks in instance
    printf("Free multiple selection mem blocks\n");
    }

    int main() {
    // Test the translation of the code
    return 0;
    }

    There are two rules in life:
    1. Never give out all of the information.

  • Was es so alles gibt. Wirklich beeindruckend. An der Funktionsfähigkeit zweifle ich zwar, z.B.

    Code
    int CalendarAddressCtrlGetMiscFlags() {
    // Get the CACI_miscFlags
    CalendarAddressCtrlClass *object;
    return object->miscFlags;
    }

    referenziert kein konkretes Objekt, glaube ich. Das müsste man noch mit Leben füllen.

    Aber vielleicht kann es einem die Standard-Aufgaben (Definition von Strukturen, Definition der Routinen usw. ) abnehmen. Compiliert es denn?

    Rainer

    Es gibt 10 Arten von Menschen - die einen wissen was binär ist, die anderen nicht.